1.在启动ie浏览器前先加入属性设置一项:
DesiredCapabilities ie = DesiredCapabilities.internetExplorer(); ie.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); System.setProperty("webdriver.ie.driver", "e:/IEDriverServer.exe"); driver = new InternetExplorerDriver(ie);
2.如果加入属性项返回“This is the initial start page for the WebDriver server.” 则说明你浏览器进行了缩放,具体如报错:
Exception in thread "main" 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)
解决方案:将IE浏览器缩放比例设置成100% 页面→缩放,选择100%,再次运行即可。
时间: 2024-12-28 20:13:43