How to capture full webpage screenshot using selenium c# for chrome browser

3,372 views
Skip to first unread message

Abhijit Biradar

unread,
Oct 10, 2016, 6:51:57 AM10/10/16
to Selenium Users
Hi,

I am using selenium c# for chrome for automation.I want to capture full webpage screenshot when i tried below code i got only desktop snapshot & not full web page.
Any idea how to capture it.


public static void CaptureScreenshot()
        {
            try
            {
                string fileName = TestInfoHelper.currentDirectory + TestInfoHelper.ScreenshotFileName + "_" + TestInfoHelper.screeshotCoutner + TestSettings.DefaultScreenshotFileFormat;

                Screenshot ss = ((ITakesScreenshot)SeleniumDriver.Instance).GetScreenshot();
                ss.SaveAsFile(fileName, System.Drawing.Imaging.ImageFormat.Png);

                TestInfoHelper.screeshotCoutner++;
            }
            catch (NullReferenceException)
            {
                log.Error("Test failed ");
            }
           
        }


Regards,
Abhijit

Ripon Al Wasim

unread,
Oct 10, 2016, 7:02:14 AM10/10/16
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/773c55c0-4953-477e-9ec2-33877511b198%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhijit Biradar

unread,
Oct 12, 2016, 1:19:51 AM10/12/16
to Selenium Users
Hi Wasim, 

I have tried your code but it is not capturing full webpage screen shot.

Regards,
Abhijit

Abhijit Biradar

unread,
Oct 13, 2016, 1:26:28 AM10/13/16
to Selenium Users
Hi,

Can any one please help me on this.

Regards,
Abhijit



On Monday, October 10, 2016 at 4:21:57 PM UTC+5:30, Abhijit Biradar wrote:

Jim Evans

unread,
Oct 13, 2016, 2:11:29 AM10/13/16
to Selenium Users
The short answer is, with Chrome, you don't take full page screenshots.

The slightly longer answer is, you don't take full page screenshots with Chrome, and get used to it, because all drivers will work that way soon.

The fully detailed answer is what follows. The Chrome driver only takes screenshots of the currently visible view port. This is by design, as the driver is implemented by the developers of the Chromium project (the open-source project on which the Chrome browser is based), and a bug in Chrome prevented them from doing full page screenshots. Furthermore, all drivers will eventually *only* support creating screenshots of the current fire port, as that is the only type of screenshot supported by the W3C WebDriver specification. In other words, if a driver takes a "full page" screenshot, it is not compliant with the spec.

Abhijit Biradar

unread,
Oct 21, 2016, 5:03:19 AM10/21/16
to seleniu...@googlegroups.com

Understood. Thanks for your reply


--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/ERamyF1PoTI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-users+unsubscribe@googlegroups.com.

To post to this group, send email to selenium-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages