2

IE忽略缩放设置不起作用,我的代码如下,为什么它不起作用?我收到错误消息(selenium.common.exceptions.SessionNotCreatedException:消息:启动 Internet Explorer 时出现意外错误。浏览器缩放级别设置为 125%。它应该设置为 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)
4

2 回答 2

2

,在使用InternetExplorerDriver时,您不应忽略浏览器缩放设置。

根据InternetExplorerDriver的官方文档,Required Configuration提到以下有关浏览器缩放级别

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

由于浏览器缩放级别设置为125% ,因此您会看到错误。作为解决方案,您必须将浏览器缩放级别设置回100%


更新

虽然您没有回复/评论我的答案,该答案是根据您的问题构建的,但我可以从您的问题更新中观察到您正在尝试将属性ignore_protected_mode_settings设置为True。为此,您需要使用DesiredCapabilities()类的实例并配置WebDriver实例,如下所示:

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()
于 2018-04-12T06:06:01.833 回答
1

我遇到了同样的问题。该选项ignore_zoom_level解决了它。

from selenium import webdriver
from selenium.webdriver.ie.options import Options


ie_options = Options()
ie_options.ignore_zoom_level = True
ie_driver = webdriver.Ie(options=ie_options)

另请参阅:https ://www.selenium.dev/documentation/en/driver_idiosyncrasies/driver_specific_capabilities/#internet-explorer

于 2021-07-14T20:30:13.707 回答