无法在带有硒的IE 11上关闭的窗口中找到元素
我正在尝试使用Selenium WebDriver在Internet Explorer 11上运行测试。代码是:
System.setProperty("webdriver.ie.driver", "Path/to//IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("www.google.com");
driver.findElement(By.name("q"));
我得到这个错误:
已启动 InternetExplorerDriver 服务器(64 位) 2.46.0.0 侦听端口 43760 中的异常 org.openqa.selenium.NoSuchWindowException:无法在关闭的窗口中找到元素(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:15 毫秒 构建信息:版本:'2.46.0',修订版:'61506a4624b13675f24581e453592342b7485d71',时间:'2015-06-04 10:22:50' 系统信息:主机:'user1-PC',ip:'10.0.23.71',os.name:'Windows 7',os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_45' 驱动程序信息: org.openqa.selenium.ie.InternetExplorerDriver Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, i.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false,browserName=Internet Explorer, initialBrowserUrl=http://localhost:43760/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}] Session ID: 8a5b7ab5-862a-462d-ab4b-929d4ed5b71a *** Element info: {Using=name, value=q} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) atsun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.delegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605) atorg.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:358) at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:431) at org.openqa.selenium.By$ByName.findElement(By.java:300) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:350) at MySel20Proj.MySel20Proj.App.main(App.java:42)
我试图按照 https://code.google.com/p/selenium/wiki/InternetExplorerDriver 的配置教程进行操作,但仍然无法正常工作。这段代码适用于Firefox和Chrome。