New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to take full page screenshot #1141

Closed
foxx opened this Issue Oct 13, 2015 · 11 comments

Comments

Projects
None yet
10 participants
@foxx

foxx commented Oct 13, 2015

As a follow up from #646, it would be nice if Selenium offered support to take full page screenshots.

Currently, the only way to do this in a consistent manner is to screenshot/pagedown in a loop until page end is reached, then stitch images together. This is a lot of user work, and would be great if Selenium exposed a method which handles this for the user, in all browsers. Although this could be provided as a separate library, it seems to me like the perfect candidate for core inclusion.

Could a maintainer/contributor give their thoughts?

@jimevans

This comment has been minimized.

Show comment
Hide comment
@jimevans

jimevans Oct 13, 2015

Member

At the moment, the intended behavior of the screenshot API is to produce a so-called full page screenshot. In point of fact, the current IE and Firefox drivers do create full page screenshots. Likewise, thr PhantomJS driver also creates full page screenshots. The Chrome driver does view-port-only screenshots, mostly due to a years-old bug in the browser that shows no signs of ever being fixed. Similarly, the Safari driver has architectural limitations imposed by the browser that prevent it from yielding full page screenshots.

While this accurately describes the state of current drivers, the future behavior of drivers will be governed by a W3C specification prescribing behavior of drivers. That spec states outright that screenshots are to be of the current view port only. This decision was discussed at length by the working group responsible for the spec. Any changes in that agreed-upon behavior would need to be taken up with that group.

Moreover, driver implementations are increasingly provided by browser vendors, not the Selenium project. This has been the case for Opera and Chrome for quite some time, recently for Microsoft Edge, and soon to be for Mozilla Firefox. Even if the API provided a way to generate full page screen shots, there's no guarantee that a browser driver, provided by a browser vendor, would support such a command.

Hacks such as scrolling-and-stitching images together seem, on the surface, to be a way forward, but there are too many corner cases where something like that approach fails for a general purpose library like Selenium. A common example is the case of absolutely positioned elements, such as those that remain at the top or bottom of the view port as the user scrolls the page. This is a clear case where scrolling-and-stitching individual screenshots would fail.

Member

jimevans commented Oct 13, 2015

At the moment, the intended behavior of the screenshot API is to produce a so-called full page screenshot. In point of fact, the current IE and Firefox drivers do create full page screenshots. Likewise, thr PhantomJS driver also creates full page screenshots. The Chrome driver does view-port-only screenshots, mostly due to a years-old bug in the browser that shows no signs of ever being fixed. Similarly, the Safari driver has architectural limitations imposed by the browser that prevent it from yielding full page screenshots.

While this accurately describes the state of current drivers, the future behavior of drivers will be governed by a W3C specification prescribing behavior of drivers. That spec states outright that screenshots are to be of the current view port only. This decision was discussed at length by the working group responsible for the spec. Any changes in that agreed-upon behavior would need to be taken up with that group.

Moreover, driver implementations are increasingly provided by browser vendors, not the Selenium project. This has been the case for Opera and Chrome for quite some time, recently for Microsoft Edge, and soon to be for Mozilla Firefox. Even if the API provided a way to generate full page screen shots, there's no guarantee that a browser driver, provided by a browser vendor, would support such a command.

Hacks such as scrolling-and-stitching images together seem, on the surface, to be a way forward, but there are too many corner cases where something like that approach fails for a general purpose library like Selenium. A common example is the case of absolutely positioned elements, such as those that remain at the top or bottom of the view port as the user scrolls the page. This is a clear case where scrolling-and-stitching individual screenshots would fail.

@jimevans jimevans closed this Oct 13, 2015

@foxx

This comment has been minimized.

Show comment
Hide comment
@foxx

foxx Oct 15, 2015

Thank you for the detailed response @jimevans, much appreciated

foxx commented Oct 15, 2015

Thank you for the detailed response @jimevans, much appreciated

@Jorge2M

This comment has been minimized.

Show comment
Hide comment
@Jorge2M

Jorge2M Feb 8, 2016

Scroll in the page for capture screenshot is not a solution when the page implement a scroll functionality. The scroll for capture screenshot will affect the aspect page.

Jorge2M commented Feb 8, 2016

Scroll in the page for capture screenshot is not a solution when the page implement a scroll functionality. The scroll for capture screenshot will affect the aspect page.

@shubhanjalidubey

This comment has been minimized.

Show comment
Hide comment
@shubhanjalidubey

shubhanjalidubey Sep 1, 2016

Full Page ScreenShot seem to be broken again for latest driver for firefox which is geckoDriver.
Has anybody experienced this?

shubhanjalidubey commented Sep 1, 2016

Full Page ScreenShot seem to be broken again for latest driver for firefox which is geckoDriver.
Has anybody experienced this?

@MelindaN

This comment has been minimized.

Show comment
Hide comment
@MelindaN

MelindaN Oct 17, 2016

I have the same problem with gecko driver. Firefox was actually the only driver that I could use for taking screenshot with scroll option (had to downgrade my FF version to 47.0.1). Now I want the same feature for FF 49, and I cannot use other libraries that provide scrolling and stitching screenshots together ... So please reopen and fix this issue asap.

MelindaN commented Oct 17, 2016

I have the same problem with gecko driver. Firefox was actually the only driver that I could use for taking screenshot with scroll option (had to downgrade my FF version to 47.0.1). Now I want the same feature for FF 49, and I cannot use other libraries that provide scrolling and stitching screenshots together ... So please reopen and fix this issue asap.

@jigyasa-at-git

This comment has been minimized.

Show comment
Hide comment
@jigyasa-at-git

jigyasa-at-git Oct 17, 2016

Same here! With this latest stack:
selenium-server-standalone-3.0.0-beta4
geckodriver-v0.11.1-win64
Firefox 49.0.1

I was unable to execute even the basic code of driver.get(url), let alone take screengrab. The only thing that happened was - Firefox browser would open. I had to finally downgrade to 47 to make code work. Definitely some solution will be greatly appreciated.

Also, for the full page screenshot, it is happening only for older Firefox version. IE, Chrome and Edge take view port screengrabs only. I have provided the details on this page: http://newbieshelper.blogspot.com/p/take-screenshot.html

I have not used ‘stitching’, but will look into it and add the details on the above page.

jigyasa-at-git commented Oct 17, 2016

Same here! With this latest stack:
selenium-server-standalone-3.0.0-beta4
geckodriver-v0.11.1-win64
Firefox 49.0.1

I was unable to execute even the basic code of driver.get(url), let alone take screengrab. The only thing that happened was - Firefox browser would open. I had to finally downgrade to 47 to make code work. Definitely some solution will be greatly appreciated.

Also, for the full page screenshot, it is happening only for older Firefox version. IE, Chrome and Edge take view port screengrabs only. I have provided the details on this page: http://newbieshelper.blogspot.com/p/take-screenshot.html

I have not used ‘stitching’, but will look into it and add the details on the above page.

@MelindaN

This comment has been minimized.

Show comment
Hide comment
@MelindaN

MelindaN Oct 20, 2016

Maybe if we had a method for taking screenshot to a webpage element without cropping the whole page in order to capture the element with located position and crop with its height and width... maybe then we could consider the most external tag like <html> (or something like that) as an element from page and take screenshot to the page?

But even though the specification from webdriver (w3c) has a chapter called Take element screenshot I wasn't able to use it because I think it's not implemented yet.

e.g. For a webElement located with driver.findElement we can use File urlScreenshot = element.getScreenshotAs(OutputType.FILE) ...

MelindaN commented Oct 20, 2016

Maybe if we had a method for taking screenshot to a webpage element without cropping the whole page in order to capture the element with located position and crop with its height and width... maybe then we could consider the most external tag like <html> (or something like that) as an element from page and take screenshot to the page?

But even though the specification from webdriver (w3c) has a chapter called Take element screenshot I wasn't able to use it because I think it's not implemented yet.

e.g. For a webElement located with driver.findElement we can use File urlScreenshot = element.getScreenshotAs(OutputType.FILE) ...

@jantman

This comment has been minimized.

Show comment
Hide comment
@jantman

jantman Nov 7, 2016

Using Firefox 49.0.2 on Linux with Ruby selenium-webdriver 3.0.0 and geckodriver 0.11.1, I can launch the browser and navigate, but screenshots are exactly like they are on modern Chrome - the visible viewport only, and nothing more...

jantman commented Nov 7, 2016

Using Firefox 49.0.2 on Linux with Ruby selenium-webdriver 3.0.0 and geckodriver 0.11.1, I can launch the browser and navigate, but screenshots are exactly like they are on modern Chrome - the visible viewport only, and nothing more...

@ababushkin

This comment has been minimized.

Show comment
Hide comment
@ababushkin

ababushkin Nov 15, 2016

I'm having the same issue as @jantman

ababushkin commented Nov 15, 2016

I'm having the same issue as @jantman

@fabtho

This comment has been minimized.

Show comment
Hide comment
@fabtho

fabtho Feb 28, 2017

I do understand that the spec is screenshot = viewport size, but why not add another like get_full_screenshot_as_file or so?

fabtho commented Feb 28, 2017

I do understand that the spec is screenshot = viewport size, but why not add another like get_full_screenshot_as_file or so?

@cgoldberg

This comment has been minimized.

Show comment
Hide comment
@cgoldberg

cgoldberg Nov 26, 2017

Member

why not add another like get_full_screenshot_as_file or so?

because the underlying browsers and browser drivers don't support this.

Member

cgoldberg commented Nov 26, 2017

why not add another like get_full_screenshot_as_file or so?

because the underlying browsers and browser drivers don't support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment