How to ignore zoom setting

China☆狼群 提交于 2019-12-18 09:28:23

问题


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)

回答1:


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()


来源:https://stackoverflow.com/questions/49788994/how-to-ignore-zoom-setting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!