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

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.

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

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

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();

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.

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

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.

Same exception, but in Python. This worked for me:
delay = 30
driver.implicitly_wait(delay)

Related

Selenium UnreachableBrowserException - Java

System.setProperty("webdriver.chrome.driver","D:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://link");
driver.findElement(By.cssSelector("#username")).sendKeys("id");
driver.findElement(By.cssSelector("#password")).sendKeys("pass");
driver.findElement(By.cssSelector("#clientName")).sendKeys("name");
driver.findElement(By.cssSelector("#submitButton")).click();
System.out.println("Okay !");
I set property for Chrome Driver. When I run it gives an error. (Below) I searched a lot but didn't found any solution.
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 10589
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z'
System info: host: 'DESKTOP-9HVORCR', ip: '192.168.1.24', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:564)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at zaaa.main.main(main.java:11)
Caused by: java.lang.IllegalArgumentException: Unexpected char 0x131 at 23 in User-Agent value: selenium/3.12.0 (java wındows)
at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:338)
at okhttp3.Headers$Builder.add(Headers.java:288)
at okhttp3.Request$Builder.addHeader(Request.java:177)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:85)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
... 6 more
I have tried these:
32/64 bit drivers.
Run it as administrator.
Creating a Try/Catch block.
Other drivers. (Like Operadriver.exe) (Result: Same error)
I think your windows is not english. I am having the same problem. When I tried the same in an english version windows 10 the code works without any problem.
Locale.setDefault(new Locale("en", "EN"));
you can also try this. it worked for me.
Add these lines before instantiating "WebDriver driver = new ChromeDriver();"
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
Then add the argument where you have declared Webdriver as shown below:-
WebDriver driver = new ChromeDriver(chromeOptions);
I hope it will help you.
Here you are using
selenium version : 3.12.0
chromedriver version : 2.40
When i tried to run with these configurations (they are latest at present)
I am able to launch the application without any exception and in the logs getting :
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 35584
Only local connections are allowed.
Jun 21, 2018 2:42:51 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Okay !
which is same as your starting logs.
My chrome browser version is :
Version 67.0.3396.87 (Official Build) (64-bit)
I think you should check your .m2 folder and delete
.m2\repository\org\seleniumhq\selenium
folder from there and then again try to download the dependencies.
Also update to latest chrome browser version.
Hope it helps.
This is a problem of Turkish Windows. As it is indicated in exception message the 'ı' character in user agent value "selenium/3.12.0 (java wındows)" is the cause of the exception.
The problem is the string "WINDOWS" is changed to lower case and it results "wındows" because of TR locale. I found that it is generated in class org.openqa.selenium.remote.http.HttpClientand added Locale.US like this.
String USER_AGENT = String.format(
"selenium/%s (java %s)",
new BuildInfo().getReleaseLabel(),
(Platform.getCurrent().family() == null ?
Platform.getCurrent().toString().toLowerCase(Locale.US) :
Platform.getCurrent().family().toString().toLowerCase(Locale.US)));
I compiled the library with my changes and it works now. I also opened a pull request on github.
You can also find my edited fork here.

How to find an element within a frame in IE?

Code trials:
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[contains(#src,'path')]")));
driver.findElement(By.id());
Switching to Frame is may be successful but it didn't throw any NoSuchFrameException.
The same is working in Chrome and FireFox. But the same is not Working in IE (tried in IE9 and IE11).
WebDriver Used: IEDriverServer Ver: 3.12.0.0
Is it because of the Document mode? or due to any Page rendering issue?
In What Case will this happen?
HTML Source Code Link: Source Code
Tried to Find the id MF:txtentdon
I don't know if this is important or not, but It also throws HTTP Status: '404' -> incorrect JSON status mapping for 'stale element reference' (400 expected)
Error Stack Trace:
org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == #MF\:txtentdon
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'N9776', ip: '172.29.18.139', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{proxy=Proxy(), acceptInsecureCerts=false, browserVersion=9, se:ieOptions={nativeEvents=true, browserAttachTimeout=0.0, ie.ensureCleanSession=false, elementScrollBehavior=0.0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:6017/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000.0, ignoreProtectedModeSettings=false}, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, browserName=internet explorer, pageLoadStrategy=normal, javascriptEnabled=true, platformName=windows, setWindowRect=true, platform=ANY}]
Session ID: 48da0488-5d2e-46db-996e-77f27f26ff28
*** Element info: {Using=id, value=MF:txtentdon}
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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:150)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:115)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:410)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:453)
at org.openqa.selenium.By$ById.findElement(By.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:402)
This error message...
org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == #MF\:txtentdon
...implies that the InternetExplorerDriver server was unable to locate the desired element.
Your main issue seems to be the incompatibility between the version of the binaries you are using as follows:
You are using Selenium Java Client v3.4.0
You are using IEDriverServer v3.12.0.0
You are using JDK v1.8.0_131
So there is a clear mismatch between JDK v1.8.0-131, Selenium Client v3.4.0 and IEDriverServer v3.12.0.0.
Solution
While you work with Selenium Java Client, InternetExplorerDriver and Internet Explorer Browser ensure that:
You have fulfilled the Required Configuration as well as the additional considerations for Native Events and Browser Focus as per the documentation of InternetExplorerDriver.
You have upgraded JDK to recent levels JDK 8u171.
You have upgraded Selenium to current levels Version 3.12.0.
You have upgraded InternetExplorerDriver to current IEDriverServer v3.12.0 level.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
Take a System Reboot.
Execute your #Test.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
A couple of additional facts you need to consider while switching frame to locate element:
Always induce WebDriverwait while switching to desired frame.
Once you switch to the desired frame induce WebDriverwait while you look out for the desired element.
As your desired element is having the attribute readOnly="readonly" so you need to use the ExpectedConditions as visibilityOfElementLocated() as follows:
So your effective code block will be:
new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[contains(#src,'path')]")));
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[#class='inputfld' and #id='MF:txtentdon']")));
You can try with this code :
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[contains(#src,'path')]")));
System.err.println("inside frame");
WebElement element = new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.id("MF:txtentdon")));
Or
WebElement element = new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.name("MF:txtentdon")));

Selenium WebDriver upgrade results in UnreachableBrowserException

I recently found that my Selenium Java libraries were not working. Version 2.48.2 would open a Firefox window and then "stall" with no error within Netbeans nor Firefox itself before returning from new FirefoxDriver(). I figured that this version of Selenium might be broken so I found the latest Java libraries (Version 2.53.1) and have been trying to get them to work.
My issue now is almost the same but with two errors. The first is thrown by Netbeans when trying to execute new FirefoxDriver().
Exception in thread "AWT-EventQueue-0" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'MrComputer', ip: '192.168.0.101', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
...
The second is from Firefox itself. The window opens but instantly encounters the error.
Problem signature:
Problem Event Name: APPCRASH
Application Name: firefox.exe
Application Version: 47.0.0.5999
...
The code I am using is quite simple. Just the line
WebDriver driver = new FirefoxDriver();
I am by no means an extremely knowledgeable Selenium user so I am not sure what other information I could provide that might be of help.
EDIT: It seems that my Firefox version was not high enough to use the 2.53.1 Selenium libraries. My version of 47.0.0.5999 needed to be at least 47.0.1.
Prior to this, version 2.53.0 did need to make use of the MarionetteDriver as per this SO answer.
Unfortunately Selenium WebDriver 2.53.0 is not compatible with Firefox
47.0. The WebDriver component which handles Firefox browsers (FirefoxDriver) will be discontinued. As of version 3.0, Selenium
WebDriver will have MarionetteDriver as the default running
implementation for Firefox tests.
...
UPDATE
Selenium WebDriver 2.53.1 has been released on 30th June 2016.
FirefoxDriver is working again with Firefox 47.0.1 as browser.
For Selenium 2.53.1 the Firefox version needs to be at least 47.0.1. Updating my Firefox did the trick.
EDIT: It also seems that version 47.+ was not released to the Ubuntu archives for a few weeks after the Windows version.

Selenium - NoSuchWindowException in IE 11

I am trying to automate a webpage using selenium in IE11. I have set the protected mode settings to same level and zoom level is 100%. While running the test it opens the website however gives the exception just after. Below is the code used.
File file = new File("C:\\Users\\Desktop\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath() );
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true);
WebDriver driver = new InternetExplorerDriver(capabilities);
driver.get("http://www.google.com");
And the exception stacktrace
Started InternetExplorerDriver server (32-bit)
2.39.0.0
Listening on port 38122
Jul 11, 2014 1:50:02 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: recv failed
Jul 11, 2014 1:50:02 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
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: 18 milliseconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'Neeraj', ip: '10.136.180.161', os.name: 'Windows 7', s.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_60' Session ID: ab6edd65-8a66-41fa-be46-56fba7dbdfc9
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false, enablePersistentHover=true, ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss, version=11, ie.usePerProcessProxy=false, cssSelectorsEnabled=true, ignoreProtectedModeSettings=true, requireWindowFocus=false, handlesAlerts=true, initialBrowserUrl=http://localhost:38122/, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=, takesScreenshot=true}]
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:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:348)
at org.openqa.selenium.By$ById.findElement(By.java:220)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at Test1.main(Test1.java:27)
Any suggestions on how to resolve this.
First of all, don't use
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
as you have already set Protected mode settings. For the issue you are seeing, it should be because of the missing registry settings that is added as a prerequisite for running tests in IE11:
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration
I am using IE 11 - 64 bit windows machine. This point worked for me.
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 installations, 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 installations, 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.
The solution suggested by #David Kemp is not working for the ie 11 of windows 10 - 64 bit . I have added the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet explorer\Main\FeatureControl\FEATURE_BFCACHE according to the steps mentioned For IE 11 only following https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration but after opening the https certificate page (url https://my-page:9443) it is unable to execute driver.navigate().to("javascript:document.getElementById('overridelink').click()"); throwing NoSuchWindowException
However same works fine for ie 11 of windows 7-64 bit and able to execute the scripts .
The work around to make ie 11 work for win 10 is by setting initialBrowserUrl capabilities to https://my-page:9443 like below
capabilities.setCapability("initialBrowserUrl", "https://my-page:9443");
but I am still confused why for ie11 / windows 10 it's different ?
Below solution also works if from current page you navigate on next page on some action/event and selenium driver doesnt recognise window :-
For 64-bit Windows installations, the key is:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet explorer\Main\FeatureControl\FEATURE_BFCACHE
Inside this create a DWORD value named iexplore.exe with the value of 0.
I found that, if the launched browser is kept on focus, you will get that exception. As soon as you launch the webdriver, open any other window, for example, you can open eclipse as soon as the script launches IE Driver. Script execution starts, and then you can open you IE Driver.. to handle it through scripts, you add the below code:
public WebDriver driver, driver1;
System.setProperty("webdriver.ie.driver", System.getProperty(
"webdriver.ie.driver", "./BrowserDrivers/IEDriverServer.exe"));
driver = new InternetExplorerDriver(cap);
this.driver.manage().deleteAllCookies();
this.driver.manage().timeouts().implicitlyWait(WaitTimeConstants.WAIT_TIME_LONG, TimeUnit.SECONDS);
this.driver.get("yourApplication.com");
this.driver.manage().window().maximize();
public WebDriver driver, driver1;
System.setProperty("webdriver.ie.driver", System.getProperty(
"webdriver.ie.driver", "./BrowserDrivers/IEDriverServer.exe"));
driver1 = new InternetExplorerDriver(cap);
this.driver1.manage().deleteAllCookies();
this.driver1.get("http://www.google.com");
this.driver1.manage().window().maximize();
Added domain of AUT to list of "Trusted Sites" for i.e. in "Internet Options". Solved the problem.
IE Options --> Security Tab -> Uncheck "Enable Protected Mode" worked for me.
Add http://localhost/ to your trusted sites in IE11. This worked for me,after trying everything else without results.
Ignore above all... i have tried below line in my desired capabilities for IE driver then its worked .. :)
ieCapabilities.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL,false);
You can follow a few options from below:
Use relative paths in the project, later you can choose to get its absolute path.
Setting the Protected mode setting for all, to either enabled or disabled.
Try understanding what really this exception mean "org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 18 milliseconds"
This states that whatever being done by your code (the web driver) is not able to identify the window of IE.
The possible causes can be:
a. Multiple driver instances are already running which were instantiated by older runs and could not have been terminated by quite().
b. The sometimes when you use close() on a driver it will not terminate the IE Driver, so use quite() after closing inside a finally block.
Yes, add some Exception handling to avoid the above issue.
Exception "org.openqa.selenium.NoSuchWindowException" also suggests that web driver instance is not able to get the handle of IE's window tab. I faced this issue when accidentally, the browser was closed and the code was still trying to locate and do some action on a web element. In this case, the driver throws this exception to tell that there is no IE browser opened at all.
Having a check on the opening of browser can also help, I usually keep some piece of code that gives logs of used Driver object and the port where it is trying to connect and to which browser to.
For me, point 4 & 5 worked. but you might wanna just change the web driver's service i.e. browser. IE is just too slow sometimes to honour the selenium API calls :(

Running Selenium 2.12 fails on Internet Explorer with Java

I have just installed the latest version of Selenium 2.12.
I am trying to run the following java program using Selenium on IE. But unfortunately it's not working.
sample program
Here is the error message.
May 24, 2012 7:12:50 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 849 milliseconds
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_04'
Driver info: driver.version: InternetExplorerDriver
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:175)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:134)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:459)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:140)
at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:113)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:66)
at ExampleProgram.main(ExampleProgram.java:13)
This is launching the IE 8 with the URL "http://localhost:15194/" and showing the content - This is the initial start page for the WebDriver server.
Please help me with what I'm doing wrong here. I have done the basic setup as mentioned in wiki
Just a small correction, the latest version is 2.21 and not 2.12.
Start your scripts with this
driver = Selenium::WebDriver.for :ie, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate]
Open your browser as an Admin, and change settings in Internet Options to allow popups and also keep "Protected Mode"disabled.
Apart from that, I guess the modal message could also be because there might be some insecure content that is being displayed on a https site.
So to avoid that the message from being displayed, also perform the following steps
IE-> Open as Admin
Go to Internet Options
Go to Security tab
Click on Custom Level button
Under Miscellaneous - Enable Mixed content
if this does not solve the issue, please share the exact message that is displayed on the modal popup.
Hope this helps
This worked for me after installing the new IE version - 9.
You have to download "IEDriverServer_Win32_2.29.0.zip". Extract it to a target folder and instantiate the Internet Explorer browser as below:
File file = new File("E:\\Global Blue\\globalblue-selenium-test\\gb-selenium-test\\lib\\IEDriverServer_Win32_2.29.0\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver oWebDriver = new InternetExplorerDriver();
Try using:
Thread.sleep(3000);
It worked for me.

Categories