Cha*_*how 4 java selenium automation selenium-webdriver selenium-iedriver
我正在尝试使用以下代码在本地计算机上启动 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();
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,它会打开带有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
Run Code Online (Sandbox Code Playgroud)
我手动尝试将浏览器缩放级别设置为 100%。即使这样,错误也会出现。
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
aDriver = new InternetExplorerDriver(caps);
Run Code Online (Sandbox Code Playgroud)
修复了问题。
小智 5
这对我来说很好用。Ingore 缩放级别。
private static InternetExplorerOptions IeSettings()
{
var options = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;
return options;
}
public static IWebDriver ieDriver = new InternetExplorerDriver(IeSettings());
Run Code Online (Sandbox Code Playgroud)
它可能会解决您的问题,但从长远来看这可能会给您带来麻烦。否则,您可能会遇到本机鼠标事件无法正确识别坐标的问题。
解决此问题的最佳方法是实际转到 IE 浏览器,然后通过“设置”->“缩放”将缩放级别设置为默认值 100%。
如果您愿意,还请确保:
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.exe0
您可以在 IE 驱动程序github 项目页面上找到更多详细信息。
| 归档时间: |
|
| 查看次数: |
17556 次 |
| 最近记录: |