Selenium:启动 IE 时出现意外错误。浏览器缩放级别设置为 122%。它应该设置为 100%
Selenium: Unexpected error launching IE. Browser zoom level was set to 122%. It should be set to 100%
我正在尝试使用以下代码在我的本地计算机上启动 IE11 浏览器。
try{System.setProperty("webdriver.ie.driver", "src/main/resources/bin/IEDriverServer.exe");
}
catch (Exception ex){
Reporter.log("\nException in getting and setting the webdriver IE driver: "+ ex.getMessage() + ex.getClass(),true);
ex.printStackTrace();
}
WebDriverManager.browser = browser;
driver = new EventFiringWebDriver(new InternetExplorerDriver());
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
当我 运行 代码时,它会使用 http://localhost:22414/ 启动浏览器,但之后无法加载。附上下面的日志。
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Browser zoom level was set to 125%. It should be set to 100% (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.16 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'AAAAAA', ip: '123.123.123.123', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_79'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
我手动尝试将浏览器缩放级别设置为 100%。即使这样,错误也会出现。
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
aDriver = new InternetExplorerDriver(caps);
已解决问题。
它可能会解决您的问题,但是从长远来看,这可能会给您带来麻烦 运行。否则,您可能会遇到无法正确识别坐标的本机鼠标事件问题。
解决此问题的最佳方法是实际转到 IE 浏览器并将缩放级别设置为默认值 100%,方法是转到“设置”->“缩放”。
如果你在做,还要确保:
- 在 Windows Vista 或 Windows 7 上的 IE 7 或更高版本上,您必须设置
每个区域的保护模式设置为相同的值。价值
可以打开或关闭,只要每个区域都相同即可。设置
保护模式设置,从中选择 "Internet Options..."
工具菜单,然后单击安全选项卡。对于每个区域,将有
是标记为“启用受保护的”选项卡底部的复选框
模式”。
- 此外,必须为 IE 10 禁用 "Enhanced Protected Mode"
和更高。这个选项可以在 Internet 的高级选项卡中找到
选项对话框。浏览器缩放级别必须设置为 100%,以便
本机鼠标事件可以设置为正确的坐标。
- 仅适用于 IE 11,您需要在目标上设置注册表项
计算机,以便驱动程序可以保持与实例的连接
它创建的 Internet Explorer。对于 32 位 Windows 安装,
您必须在注册表编辑器中检查的密钥是
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_BFCACHE
。对于 64 位 Windows
安装,关键是
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_BFCACHE
。请注意,
FEATURE_BFCACHE
子项可能存在也可能不存在,应该是
如果不存在则创建。重要提示:在此密钥中,创建一个
DWORD
名为 iexplore.exe
的值,值为 0
。
您可以在 IE 驱动程序上找到更多详细信息 github project page。
System.setProperty("webdriver.ie.driver",".\browserDrivers\IEDriverServer.exe");
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability.setCapability("ignoreZoomSetting", true);
capability.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "");
driver = new InternetExplorerDriver(capability);
这对我来说很好用。忽略那个缩放级别。
private static InternetExplorerOptions IeSettings()
{
var options = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;
return options;
}
public static IWebDriver ieDriver = new InternetExplorerDriver(IeSettings());
DesiredCapabilities 已被弃用。现在执行此操作的官方方法是使用 InternetExplorerOptions。添加这两行时,请确保在实例化驱动程序时将其作为参数传递。
InternetExplorerOptions capabilities = new InternetExplorerOptions();
capabilities.ignoreZoomSettings();
driver = new InternetExplorerDriver(capabilities);
我正在尝试使用以下代码在我的本地计算机上启动 IE11 浏览器。
try{System.setProperty("webdriver.ie.driver", "src/main/resources/bin/IEDriverServer.exe");
}
catch (Exception ex){
Reporter.log("\nException in getting and setting the webdriver IE driver: "+ ex.getMessage() + ex.getClass(),true);
ex.printStackTrace();
}
WebDriverManager.browser = browser;
driver = new EventFiringWebDriver(new InternetExplorerDriver());
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
当我 运行 代码时,它会使用 http://localhost:22414/ 启动浏览器,但之后无法加载。附上下面的日志。
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Browser zoom level was set to 125%. It should be set to 100% (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.16 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'AAAAAA', ip: '123.123.123.123', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_79'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
我手动尝试将浏览器缩放级别设置为 100%。即使这样,错误也会出现。
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
aDriver = new InternetExplorerDriver(caps);
已解决问题。
它可能会解决您的问题,但是从长远来看,这可能会给您带来麻烦 运行。否则,您可能会遇到无法正确识别坐标的本机鼠标事件问题。
解决此问题的最佳方法是实际转到 IE 浏览器并将缩放级别设置为默认值 100%,方法是转到“设置”->“缩放”。
如果你在做,还要确保:
- 在 Windows Vista 或 Windows 7 上的 IE 7 或更高版本上,您必须设置 每个区域的保护模式设置为相同的值。价值 可以打开或关闭,只要每个区域都相同即可。设置 保护模式设置,从中选择 "Internet Options..." 工具菜单,然后单击安全选项卡。对于每个区域,将有 是标记为“启用受保护的”选项卡底部的复选框 模式”。
- 此外,必须为 IE 10 禁用 "Enhanced Protected Mode" 和更高。这个选项可以在 Internet 的高级选项卡中找到 选项对话框。浏览器缩放级别必须设置为 100%,以便 本机鼠标事件可以设置为正确的坐标。
- 仅适用于 IE 11,您需要在目标上设置注册表项
计算机,以便驱动程序可以保持与实例的连接
它创建的 Internet Explorer。对于 32 位 Windows 安装,
您必须在注册表编辑器中检查的密钥是
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
。对于 64 位 Windows
安装,关键是
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_BFCACHE
。请注意,
FEATURE_BFCACHE
子项可能存在也可能不存在,应该是
如果不存在则创建。重要提示:在此密钥中,创建一个
DWORD
名为 iexplore.exe
的值,值为 0
。
您可以在 IE 驱动程序上找到更多详细信息 github project page。
System.setProperty("webdriver.ie.driver",".\browserDrivers\IEDriverServer.exe");
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability.setCapability("ignoreZoomSetting", true);
capability.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "");
driver = new InternetExplorerDriver(capability);
这对我来说很好用。忽略那个缩放级别。
private static InternetExplorerOptions IeSettings()
{
var options = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;
return options;
}
public static IWebDriver ieDriver = new InternetExplorerDriver(IeSettings());
DesiredCapabilities 已被弃用。现在执行此操作的官方方法是使用 InternetExplorerOptions。添加这两行时,请确保在实例化驱动程序时将其作为参数传递。
InternetExplorerOptions capabilities = new InternetExplorerOptions();
capabilities.ignoreZoomSettings();
driver = new InternetExplorerDriver(capabilities);