What are the different methods APIs provided by Selenium Webdriver to take screenshot of a webpage

0 votes
What are the different methods (APIs) provided by Selenium Webdriver to take screenshot of a webpage?
Jul 22, 2019 in Selenium by Hemant
3,276 views

1 answer to this question.

0 votes

Hey Hemant, Selenium Webdriver provides 3 different APIs to capture screenshot of a webpage. These are:

  1. save_screenshot()
  2. get_screenshot_as_file()
  3. get_screenshot_as_png()

To understand all three methods, checkout this script:

driver = webdriver.Firefox();

driver.get("https://www.facebook.com/");

driver.save_screenshot('screenshot_1.png');

driver.get_screenshot_as_file('screenshot_2.png');

screenshot = driver.get_screenshot_as_png();    
screenshot_size = (20, 10, 480, 600);

image = Image.open (StringIO.StringIO(screen));
region = image.crop(screenshot_size);
region.save('screenshot_3.jpg', 'JPEG', optimize=True);
answered Jul 22, 2019 by Abha
• 28,140 points

Related Questions In Selenium

0 votes
3 answers

What are the different ways to select an option from a dropdown using Selenium Webdriver?

So follow this steps for solution: First click ...READ MORE

answered Dec 16, 2020 in Selenium by Roshni
• 10,480 points
52,206 views
0 votes
1 answer

How to take screenshot of a frame using Selenium WebDriver?

you can use the below code: import java.awt.image.BufferedImage; import ...READ MORE

answered Jun 20, 2018 in Selenium by Meci Matt
• 9,460 points
3,504 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,764 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,184 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,258 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,896 views
0 votes
1 answer
0 votes
1 answer

How to capture screenshot of a webpage using Selenium Webdriver?

Hi Bindiya, you can use TakesScreenshot interface to capture the ...READ MORE

answered Jul 8, 2019 in Selenium by Abha
• 28,140 points
1,696 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP