Open Bug 1493650 Opened 6 years ago Updated 1 year ago

WebDriver:TakeScreenshot captures current frame instead of top-level browsing context

Categories

(Remote Protocol :: Marionette, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: ato, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

Apparently the WebDriver:TakeScreenshot command takes a screenshot of the current frame (current browsing context) instead of the parent document (the top-level browsing context). Reported in https://github.com/mozilla/geckodriver/issues/1385.
Blocks: webdriver
Priority: -- → P3
Severity: normal → S3
Product: Testing → Remote Protocol

The problem those days can be seen here:
https://searchfox.org/mozilla-central/rev/065102493dfc49234120c37fc6a334a5b1d86d9e/remote/marionette/driver.sys.mjs#2459,2473

We basically need to use the top-level browsing context when getting the actor (as we also initially assert for).

What's interesting that the test_no_browsing_context test is not failing given that the current frame has been removed. See also another related GitHub issue.

Lets discuss the priority of this in a triage meeting.

Severity: S3 → --
Type: enhancement → defect
Priority: P3 → --
Mentor: hskupin
Severity: -- → S3
Priority: -- → P3
Whiteboard: [lang=js]

So there can also be a security security error if the screenshot is taken from the iframe:
https://github.com/mozilla/geckodriver/issues/2068

A testcase for that can be found at: https://github.com/nightwatchjs/nightwatch/issues/3512

Hi Victoria, as we spoke on Matrix I wonder if you would still be interested on this bug. Or given that it includes Python additions / changes you would like to have a JS only one? Thanks for letting me know.

Flags: needinfo?(victoria.o.ajala)

Hello @whimboo, sorry fro the delay. I'm still working on this issue and I would be attaching a patch soon.

Flags: needinfo?(victoria.o.ajala)

As discussed with Victoria, she is working on a different bug now. So this one is free again for pickup. Also adding lang=py given that the required tests need to be written in Python.

Whiteboard: [lang=js] → [lang=js][lang=py]

Hii, I am working on this.

Hi,
So, while running some initial tests with selenium and geckodriver from the latest build of Mozilla, the screenshot command seems to be functioning correctly,

My system specs are:

  1. OS: Windows 10 - version 10.0.19045 Build 19045
  2. Firefox Version: 118.0a1 (2023-08-26)
  3. Geckodriver Version: 0.33.0
  4. Selenium Version: 4.11.2

Even after switching frame to an iframe component (current context), the save_screenshot() returned an image of complete web page (the top context)

Also, while taking a screen shot of an element from the url https://the-internet.herokuapp.com/nested_frames , the program didn't return any security errors. (reference to : https://github.com/mozilla/geckodriver/issues/2068 )

Hello I can contribute for this.,,😉

Flags: needinfo?(hskupin)

Sorry, but I forgot to remove the mentored flag after Mitesh commented recently. There is most likely no further work needed here and I have to verify that.

Daniel, if you want to contribute maybe you could take bug 1838152? If you are interested please let Sasha know over on that mentioned bug. Thanks!

Mentor: hskupin
Whiteboard: [lang=js][lang=py]
You need to log in before you can comment on or make changes to this bug.