Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

getscreenshot returns different results for firefox and chrome (e.g., for elements with position fixed). #5670

Open
lukeis opened this issue Mar 4, 2016 · 10 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 5670

Webdriver's getscreenshot implementations for Firefox and Chrome differ in several places,
two of which are the elements with position fixed, and the scroll bars.
Both show (as expected) the entire webpage (not just what's viewed in via the viewport),
however, Firefox show the fixed elements as seen by the viewport, while Chrome "assumes"
the viewport is as the size of the document (see linked images).

What steps will reproduce the problem?
1. Start a FirefoxDriver.
1. Load Soasta's demo page: http://www.soasta.com/cloudtest/demos/
2. Save the screenshot.
3. Repeat (1) and (2) for both Chrome.

What is the expected output? What do you see instead?
Firefox: http://i.imgur.com/CR6NtTG.png
Chrome: http://i.imgur.com/tuj8d1P.png

Selenium version:
OS:
Browser:
Browser version:

Please provide any additional information below.
Note that both Chrome and Firefox render/show the page similarly (e.g., when a regular
user browses), they just differ when asked via the Webdriver API (which renders/show
the entire page, and not just the viewport.
The second issue is the scroll bars, which are missing in Firefox.

Reported by shexMan on 2013-05-18 08:16:20

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I am aware that this is not technically a Selenium issue, but since this is the API
Selenium exposes I prefer people affiliated with Selenium will contact both companies
and try to find mutual understanding.

Reported by shexMan on 2013-05-18 08:21:07

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Hi!

Firefox driver uses canvas to copy into content of page w/o real changes of browser
width/height so fixed element is shown in the middle.
IE and (i suppose) Chrome drivers changes browser width/height before screenshot 
so fixed element is shown at the end.

From my point of view it works as intended.

Reported by a.u.savchuk on 2013-05-20 09:19:21

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Aloha, and thanks for the quick response!

I guessed this was the case, however, Firefox's implementation seems more like a bug
than something intended, and their screenshot is misleading.
Since WebDriver (http://www.w3.org/TR/webdriver) is a W3C proposal, which I hope all
parties (including IE) will want to conform to one day, I simply hope it will be sooner
than later.
Quoting from the spec: "One way to think of capturing the entire DOM is that the user
has an infinitely large monitor and has resized the window to allow all content to
be visible"

Cheers,
Oren

p.s. On the other hand, if Chrome changes the document's width/height why are there
scroll-bars (again, from the spec: " must be captured without additional chrome such
as scrollbars")

Reported by shexMan on 2013-05-20 09:45:15

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2013-05-21 08:58:44

  • Labels added: Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

It would appear that Chrome is the doing the unintended thing here so changing this
for Chrome. 

@Ken can you have a look please?

Reported by david.burns@theautomatedtester.co.uk on 2013-05-22 11:45:06

  • Labels added: Browser-Chrome
  • Labels removed: Status-Untriaged, Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Hi guys,

Intuitively, looking at the two image and reading the spec, Chrome's behavior seems
correct (regarding fixed elements, not the scroll bars).
Can you please supply more information why this isn't correct.

Cheers,
Oren Rubin

p.s. I've opened a ticket in the Firefox's bug tracker (https://bugzilla.mozilla.org/show_bug.cgi?id=874404)

Reported by shexMan on 2013-05-22 12:08:23

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2013-05-22 21:46:27

  • Labels added: Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I agree that Chrome's behavior is more correct here than Firefox.

Also, Chrome does *not* resize the browser window for the screenshot.  It just adjusts
the internal buffer/canvas the document is rendered to for the screenshot so everything
can be captured.

Reported by jmleyba on 2013-05-23 02:47:02

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2013-11-02 13:06:23

  • Labels removed: Browser-Chrome

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 17:45:12

  • Labels added: Restrict-AddIssueComment-Commit

@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant