[selenium-users] How to capture entire page screenshot

7,329 views
Skip to first unread message

ankit shah

unread,
Dec 20, 2016, 11:58:51 PM12/20/16
to Selenium Users
Hi,

I want to capture the entire page screenshot using chrome/Firefox browser.
I found in the latest version of Firefox , it won't working so as in Chrome.

Please help me out of this.

Note: I am able to capture the visible part of screen.

Regards,
Ankit

Ripon Al Wasim

unread,
Dec 21, 2016, 12:25:40 AM12/21/16
to seleniu...@googlegroups.com
What's the error in Chrome?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPS9dcazpQW2e3bqtRD%3DaMjS42yb6SdkU5h45bsfuuHAdpkS-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

ankit shah

unread,
Dec 21, 2016, 12:29:25 AM12/21/16
to Selenium Users
There is no any error. But it only captures the visible part.
Consider an example there is website called "http://www.bbc.com/" so once i open this and capture it's screenshot. It will capture only the above part of screen.
I want the complete page screenshot.

On Wed, Dec 21, 2016 at 10:55 AM, Ripon Al Wasim <ripona...@gmail.com> wrote:
What's the error in Chrome?
On Tue, Dec 20, 2016 at 8:58 PM, ankit shah <shahan...@gmail.com> wrote:
Hi,

I want to capture the entire page screenshot using chrome/Firefox browser.
I found in the latest version of Firefox , it won't working so as in Chrome.

Please help me out of this.

Note: I am able to capture the visible part of screen.

Regards,
Ankit

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

Nimesh.T.Prajapati

unread,
Dec 21, 2016, 4:54:29 AM12/21/16
to Selenium
Hello,

You may need to scroll page so a single page may have multiple screenshots. 
WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,250)", "");
I did the same for one task-working model.
This is one of the solution but not the final.


Nimesh T. Prajapati
Automation Engineer | Manual Testing
"Quality does matter..."

WebDriver+Testng+Maven+Ant+Sikuli

On Wed, Dec 21, 2016 at 10:59 AM, ankit shah <shahan...@gmail.com> wrote:
There is no any error. But it only captures the visible part.
Consider an example there is website called "http://www.bbc.com/" so once i open this and capture it's screenshot. It will capture only the above part of screen.
I want the complete page screenshot.
On Wed, Dec 21, 2016 at 10:55 AM, Ripon Al Wasim <ripona...@gmail.com> wrote:
What's the error in Chrome?

On Tue, Dec 20, 2016 at 8:58 PM, ankit shah <shahan...@gmail.com> wrote:
Hi,

I want to capture the entire page screenshot using chrome/Firefox browser.
I found in the latest version of Firefox , it won't working so as in Chrome.

Please help me out of this.

Note: I am able to capture the visible part of screen.

Regards,
Ankit

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPS9dcazpQW2e3bqtRD%3DaMjS42yb6SdkU5h45bsfuuHAdpkS-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

ankit shah

unread,
Dec 21, 2016, 6:54:11 AM12/21/16
to Selenium Users
How to decide how many times scrolls is needed. Because every result page is dynamic.
And after capturing screenshot needed to be merged properly so that only one consolidated image should appear in the result

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

Nimesh.T.Prajapati

unread,
Jan 9, 2017, 4:15:32 AM1/9/17
to Selenium
Hi Ankit,

My suggestion would be:
1) Have loop for 10 times, which will try to scroll 10 times or less, screenshots will be managed in one folder or per case.
2) Try to invoke third party events (tool), like [capture and screenshots/FireShot]-You may use AutoIT script.

--
Thanks

Nimesh T. Prajapati
Automation Engineer | Manual Testing
"Quality does matter..."

WebDriver+Testng+Maven+Ant+Sikuli

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

Anand Somani

unread,
Jan 9, 2017, 7:01:41 AM1/9/17
to seleniu...@googlegroups.com
I will suggest, change resolution of screen before taking screenshot and reset back after taking screenshot. or use browser zoom in and zoom out. 

Thanks & Regards,
Anand Somani |
Skype ID: anand.somani
LinkedIn Profile : https://www.linkedin.com/in/somanianands
Visit Blogs: http://seleniumtestingguide.blogspot.in/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

Swati W.

unread,
Jan 11, 2017, 11:19:53 PM1/11/17
to Selenium Users
Hi Ankit,

To capture full Screen shot in Chrome you can try below addon to your chrome browser.

=> Add "full page screen capture chrome" Add-on in your chrome browser.

Hope it may work.

or check below links also :-

http://www.seleniumeasy.com/comment/6280#comment-6280

http://www.myyesm.com/how-to-capture-screenshot-using-selenium-webdriver/

Thanks,
Swati W.

pelto...@yahoo.com

unread,
Jan 12, 2017, 2:49:57 AM1/12/17
to seleniu...@googlegroups.com

--------------------------------------------
On Thu, 1/12/17, Swati W. <swati.w...@gmail.com> wrote:

Subject: Re: [selenium-users] How to capture entire page screenshot
To: "Selenium Users" <seleniu...@googlegroups.com>
Date: Thursday, January 12, 2017, 6:19 AM
--

You received this message because you are subscribed to the
Google Groups "Selenium Users" group.

To unsubscribe from this group and stop receiving emails
from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/4b81efc2-259b-44e0-88fa-8fa37f061249%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
a ia68 de loturi in folosinta Pentru clacasi obligatiile acestora cel putin in

harshal shewale

unread,
Jan 12, 2017, 6:20:57 AM1/12/17
to Selenium Users
Hi,

Use Java code instead Selenium

BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "png", new File(Filename));

Visit http://www.seleniumpoint.com for more details also watch video for the same https://www.youtube.com/watch?v=em4SMVbidX4

ankit shah

unread,
Jan 12, 2017, 6:56:05 AM1/12/17
to Selenium Users
Hello Harshal,

Thank you for reply, I have tried with the method provided by you bt It won't capture the complete page ( user needs to scroll for seeing the below part of page)

Have you tried with latest chrome and Firefox?

Thanks,
Ankit

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7015dd36-20e0-463e-9716-a0c629ed50b1%40googlegroups.com.

ankit shah

unread,
Jan 12, 2017, 6:56:53 AM1/12/17
to Selenium Users
Hello Swati,

Thank you for reply, I have tried with the method provided in the links earlier.
I can try with chrome add on.
But can you suggest how to automate the extension using java or C# code.

Thanks,
Ankit

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

Kendall Schmidt

unread,
Jan 13, 2017, 3:06:59 PM1/13/17
to Selenium Users
I do this successfully in Firefox, Chrome, IE with the following Java code:

Rectangle captureSize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
Robot robot = new Robot();
BufferedImage bufferedImage = robot.createScreenCapture(captureSize);

This form of screen capture produces a screen capture of the entire display containing the browser. It is similar to performing a Print Screen.

To capture just the content of the browser, I use the following in Java:

WebDriver webDriver = keywordDriverManager.getWebDriver();

// As of Selenium v2.40 only need to augment HtmlUnitDriver as it yet implements TakesScreenshot
if (webDriver instanceof HtmlUnitDriver) {
 webDriver
= new Augmenter().augment(keywordDriverManager.getWebDriver());
}

File screenShot = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE);

This form of screen capture attempts to make a best effort, depending on the browser, to return the following in order of preference:
  • Entire page
  • Current window
  • Visible portion of the current frame
  • The screenshot of the entire display containing the browser
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Nimesh.T.Prajapati

unread,
Jan 24, 2017, 8:54:56 AM1/24/17
to Selenium
Hi,

I would like to suggest jar. Kindly go through the link.


WebDriver Screenshot utility

  • Takes a screenshot of the WebElement on different platforms (i.e. desktop browsers, iOS Simulator Mobile Safari, Android Emulator Browser)
  • Decorates screenshots
  • Provides flexible screenshot comparison
WebElement view

aShot takes a screenshot in three simple steps:

  • Capture the entire page screenshot
  • Find element's size and position
  • Crop the original screenshot



Nimesh T. Prajapati
Automation Engineer | Manual Testing
"Quality does matter..."

WebDriver+Testng+Maven+Ant+Sikuli

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/489895fa-ec67-4cf6-adff-0a85035d289a%40googlegroups.com.

Serhii Mozghovyi

unread,
Sep 16, 2017, 2:04:58 AM9/16/17
to Selenium Users
I've just found a decent way to do entire-page screenshots with Selenium. Couldn't find this method among the answers here, so sharing it with you: there's an element screenshot command. So you just find the root <html> element (by get_element_with_tag_name), and then using this command to take its screenshot. It will be an entire capture of the webpage.

VIGNESH R

unread,
Oct 27, 2017, 9:02:28 AM10/27/17
to Selenium Users
Hi ankit shah,

                      can u share me code of the entire page screenshot using firefox browser? thanks

Abanoub M Erian

unread,
Mar 17, 2019, 3:22:50 AM3/17/19
to Selenium Users
Hi Nimesh ,
Thanks for your suggestion but actually the ashot is now buggy as it's not working correctly with the IE11 and safari specially the latest version,so please advice if there anyway we can use to take screenshot using java, java-script or selenium as they are more stable and reliable

Regards

Karthik Deepan

unread,
Mar 17, 2019, 3:59:41 AM3/17/19
to seleniu...@googlegroups.com
It will be very easy if you are good to use Third Party Tools like ShutterBug - 

Maven Dependency - 
<dependency>
    <groupId>com.assertthat</groupId>
    <artifactId>selenium-shutterbug</artifactId>
    <version>0.9</version>
</dependency>

Gradle Dependency - 
compile group: 'com.assertthat', name: 'selenium-shutterbug', version: '0.9'


Then use the below code and it will save the Full page Screenshot under screenshot folder under current Project Directory

 Shutterbug.shootPage(driver,ScrollStrategy.BOTH_DIRECTIONS,500,true).withName("FullPageScreenshot").save();

Also, you can screenshot specific element also by - 

Shutterbug.shootElement(driver,logo).withName("LogoElementScreenshot").save();  

(where logo is the WebElement)


Let me know if you have any questions


Hanumantha Reddy

unread,
Apr 12, 2020, 2:28:43 PM4/12/20
to Selenium Users
You can capture entire page screenshot by using Noksa.WebDriver.ScreenshotsExtensions nuget package if you are using c#.


The program is as below,

[TestMethod]
public void FullWebPageScreenShotCapture()
{
 
IWebDriver driver = new ChromeDriver();
        driver
.Manage().Window.Maximize();

 driver
.Url = "
https://www.selenium.dev/";

 
// ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile("oldFirefox.png");

 
VerticalCombineDecorator vcd = new VerticalCombineDecorator(new ScreenshotMaker().RemoveScrollBarsWhileShooting());
        driver
.TakeScreenshot(vcd).ToMagickImage().ToBitmap().Save("newChrome.png");

 driver
.Quit();
}


You can watch the video on the same, use the following link.

Adrian

unread,
Apr 14, 2020, 6:00:09 PM4/14/20
to Selenium Users
Hi, 
Try answer number 9 in this link https://stackoverflow.com/questions/16795458/selenium-webdriver-c-sharp-full-website-screenshots-with-chromedriver-and-firefo
The Graphics component needs a bit work as it has changed since this post.

Cheers,
Adrian.
Reply all
Reply to author
Forward
0 new messages