Unable to find element on closed window on IE 11 with Selenium
Asked Answered
P

7

15

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.

Partheniaparthenocarpy answered 30/6, 2015 at 9:26 Comment(13)
did the script opened the IE browser?Mcculley
Yes, the script opens the IE browser, the exception is when it has to find the element q (the search textbox)Partheniaparthenocarpy
I tried it on Selenium Build #2.44 and it worked fine. Please downgrade your selenium versionBliss
Do you mean the IE webdriver version o Selenium version?Partheniaparthenocarpy
Sorry for ambiguous statement. I reffered to IE webdriver versionBliss
Thank you for your answer, but is the same, the exception is still appearing.Partheniaparthenocarpy
did you set registry entry?Eschatology
Yes, I did, I created the FEATURE_BFCACHE and inside I created a DWORD value named iexplorer.exe with value 0x0000000 (0)Partheniaparthenocarpy
The IEDriver is opening.Is it not even navigating to the url or not finding the elements onlySulphonate
It does navigate to the URL, but it doesn't find the element.Partheniaparthenocarpy
Same problem. Browser opens, loads the page, but then throws when trying to find an element on Windows 10, IE11 (with Dart language Selenium client)Quartziferous
What solution you found @Partheniaparthenocarpy I am having same issue.Compensable
Someone has found the solution, I have exactly the same issue. I open the IE11 Driver, it navigate to the URL. I have use the same configuration Windows 10, IE11, Selenium 3.0.1 and IEBrowserDriver 3.0.0. There is no one 3.0.1 versionSuperjacent
R
33

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

enter image description here

Ropy answered 17/9, 2015 at 7:0 Comment(1)
Does somebody know WHY this is?Suggestive
C
8

There are 2 ways:

Way 1: Setting INITIAL_BROWSER_URL:

File ieFile = new File("D:\\IEDriverServer_x64_2.53.0\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", ieFile.getAbsolutePath());
DesiredCapabilities ieCaps = DesiredCapabilities.internetExplorer();
ieCaps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "http://www.bing.com/");
driver = new InternetExplorerDriver(ieCaps);
//some operations on that site
driver.findElement(By.id("sb_form_q")).clear();
driver.findElement(By.id("sb_form_q")).sendKeys("Ripon Al Wasim");
driver.findElement(By.id("sb_form_go")).click();

Way 2: To set a registry entry on the target computer:
For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates.

For 32-bit Windows: The key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

For 64-bit Windows: The key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.

For more details you can visit: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration

Choline answered 25/4, 2016 at 9:5 Comment(1)
This is the main focus: ieCaps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "bing.com/");Choline
R
3

I faced the same issue after going through every possible solution finally I got the answer.Try this it will definitely solve your problem as well.

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();

capabilities.setCapability(CapabilityType.BROWSER_NAME, "IE");

capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);

System.setProperty("webdriver.ie.driver","C://MavenTest//driver//IEDriverServer.exe");

driver = new InternetExplorerDriver();
Rewarding answered 27/10, 2016 at 10:23 Comment(0)
S
1

For 32-bit Windows: The key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

For 64-bit Windows: The key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.

Screenshot

Saponify answered 5/10, 2016 at 10:7 Comment(0)
C
0

I had faced the similar issue. I faced while I was running my code in the Maven build. Here in the POM XML file, I had a different version whereas actual selenium installed is another version. So just changed the version so that it matches with the installed version. And Now everything working fine

Capitoline answered 13/12, 2016 at 16:34 Comment(0)
C
0

Ripon Al Wasim posted this url, which is a key to IE11 working with Selenium. https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration

I had this setup:

  • Windows 7 Pro 64 bit
  • IE11 64 bit, latest I found
  • Selenium remote server 2.53.1 64 bit
  • IEDriverServer 2.53.1 64 bit
  • selenium 2.53.1 module installed on 64 bit linux machine used with 64 bit python

downloaded from here: http://selenium-release.storage.googleapis.com/index.html?path=2.53/

I had to follow the guide and to:

  • Set Enhanced Protected Mode to disabled in all security zones which is a requirement for IE10 and IE11.
  • Add the FEATURE_BFCACHE key and it's iexplore.exe DWORD into registry
  • I made all used software to be 64 bit.
  • Check that zoom in IE is set to 100%.
  • Check if size of text is 100% in Windows display settings.

Additionaly:

  • I had to disable proxy settings in IE, because it prevented Selenium remote server to communicate with IEDriverServer.
  • I am running webdriver with requireWindowFocus set to true, because key typing with 64 bit selenium was slow due some timeout issue (Selenium WebDriver typing very slow in text field on IE browser)

And it worked. I divert from the guide when I specify a path to IEDriverServer.exe when I run standalone server, so it doesn't necessary have to be in the PATH.

Castora answered 8/10, 2018 at 21:17 Comment(0)
P
0

Same exception, but in Python. This worked for me:

delay = 30
driver.implicitly_wait(delay)
Polity answered 30/12, 2020 at 1:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.