Search code examples
pythonseleniumselenium-webdriverselenium-iedriveriedriverserver

How to ignore zoom setting


IE ignore zoom setting doesn't work, my code as below, why it doesn't work? I got the error message (selenium.common.exceptions.SessionNotCreatedException: Message: Unexpected error launching Internet Explorer. Browser zoom level was set to 125%. It should be set to 100%)

from selenium.webdriver import Ie
from selenium.webdriver.ie.options import Options
opts = Options()
opts.ignore_protected_mode_settings = True
driver = Ie(options=opts)

Solution

  • No, while working with InternetExplorerDriver you shouldn't ignore the browser zoom settings.

    As per the Official Documentation of InternetExplorerDriver the Required Configuration mentions the following about Browser Zoom Level

    The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
    

    As the browser zoom level is set to 125% hence you see the error. As a solution you must set the browser zoom level back to 100%.


    Update

    Though you havn't replied/commented to my Answer which was constructed as per your question I can observe from your question update that you are trying to set the property ignore_protected_mode_settings to True. To achieve that you need to use an instance of DesiredCapabilities() Class and configure the WebDriver instance as follows :

    from selenium import webdriver
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    
    cap = DesiredCapabilities().INTERNETEXPLORER
    cap['ignoreZoomSetting'] = True
    browser = webdriver.Ie(capabilities=cap, executable_path=r'C:\path\to\IEDriverServer.exe')
    browser.get('http://google.com/')
    browser.quit()