I am trying to take a screenshot using Selenium with Python 3.9 but suddenly I've got the error as:
Message: SecurityError: Permission denied to access property "pageXOffset" on cross-origin object
I've tried to use:
profile.setPreference("privacy.trackingprotection.enabled", false)
But it does not work. How to fix it?
Tracking protection is a technology that helps us to block HTTP loads at the network level based on the Safe Browsing technology which empowers us to fight against against phishing attempts and malwares.
This functionality was a part of the Polaris initiative and included some of tracking protection settings:
browser.contentblocking.enabled
: master switch for all content blocking features (includes tracking protection, but excludes tracking annotations).privacy.trackingprotection.annotate_channels
: flag network channels loading resources on the tracking list.privacy.trackingprotection.enabled
: to enable Tracking Protection globally.privacy.trackingprotection.lower_network_priority
: lower the priority of channels loading tracking resources.privacy.trackingprotection.pbmode.enabled
: to enable Tracking Protection in Private Browsing mode (not needed if the global pref is enabled)privacy.trackingprotection.introCount
privacy.trackingprotection.introURL
: URL that kicks off the UI tour (target of the "See how this works" button in about:privatebrowsing).This error message...
Message: SecurityError: Permission denied to access property "pageXOffset" on cross-origin object
...implies that permission denied when the browsing engine tried to access the property pageXOffset
due to cross-origin policy
Lower the security level by removing the tracking protection preferances including:
profile.setPreference("privacy.trackingprotection.enabled", false)
and execute your test.
You can find a couple of relevant detailed discussions in: