4

In Firefox version 97 and 98 when I am switching inside iframe and taking screenshot I am getting exception: org.openqa.selenium.WebDriverException: SecurityError: Permission denied to access property pageXOffset" on cross-origin object.

Exception is coming in method: org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs

I am able to do perform click, getText and all other operations inside iFrame. Only exception is coming while taking screeshot

No such issue is coming in Chrome 99.

I tried setting preferences:

profile.setPreference("browser.tabs.remote.useCrossOriginEmbedderPolicy", false);
            profile.setPreference("security.csp.enable", false);
            profile.setPreference("security.external_protocol_requires_permission", false);
            profile.setPreference("security.fileuri.strict_origin_policy", false);
            profile.setPreference("browser.tabs.remote.useCrossOriginOpenerPolicy", false);
            profile.setPreference("network.http.referer.disallowCrossSiteRelaxingDefault.pbmode", false);
            profile.setPreference("dom.block_external_protocol_in_iframes", false);
            profile.setPreference("dom.block_download_in_sandboxed_iframes", false);
            profile.setPreference("dom.delay.block_external_protocol_in_iframes.enabled", false);
            profile.setPreference("dom.block_download_in_sandboxed_iframes", false);

It didn't work.

However, when I am switching to main content and taking screenshot no exception comes but my whole webpage is inside iFrame and hence I have to switch inside iFrame and take multiple screenshots of full page. Has anyone faced this issue recently in Firefox. Please help.

I am using Selenium version: 3.14.0 and using WebdriverManager for auto driver downloads.

Let me know if any more information I can add.

1 Answers1

-1

I had the same issue while taking a screenshot. I managed to fix it by disabling tracking protection. I added the preference to the options, and screenshots now work as they should.

profile.setPreference("privacy.trackingprotection.enabled", false)