Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
122 views
in Technique[技术] by (71.8m points)

java - Unable to find element on closed window on IE 11 with Selenium

I'm trying to run tests on Internet Explorer 11 working with Selenium WebDriver. The code is:

System.setProperty("webdriver.ie.driver", "Path/to//IEDriverServer.exe");
        WebDriver driver = new InternetExplorerDriver();
driver.get("www.google.com");
driver.findElement(By.name("q"));

And I get this error:

Started InternetExplorerDriver server (64-bit) 2.46.0.0 Listening on port 43760 Exception in thread "main" org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 15 milliseconds Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50' System info: host: 'user1-PC', ip: '10.0.23.71', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_45' Driver info: 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, ie.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) at sun.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) at org.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)

I tried to follow the configure tutorial on https://code.google.com/p/selenium/wiki/InternetExplorerDriver but is still not working. And this code works on Firefox and Chrome.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try going to Internet Options --> Security --> "Enable Protected Mode" on ALL zones should either be checked or ALL unchecked.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...