pythonselenium-webdriverfirefoxgeckodrivercross-origin-read-blocking

SecurityError: Permission denied to access property "pageXOffset" on cross-origin object


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?


Solution

  • Security/Tracking Protection

    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:


    This usecase

    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


    Solution

    Lower the security level by removing the tracking protection preferances including:

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

    and execute your test.


    References

    You can find a couple of relevant detailed discussions in: