Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
439 views
in Technique[技术] by (71.8m points)

python - 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:pathoIEDriverServer.exe')
browser.get('http://google.com/')
browser.quit()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...