Selenium WebDriver and InternetExplorer

I recently updated Selenium 2.24.1 to get Firefox 13 working. With this update, you must run an executable file similar to chromedriver.exe to send events to IE. However, I was unlucky in the fact that the tests run with IE. To do this, to work with chrome, I obviously also need to set the webdriver.chrome.driver bit, but everything works fine in it, and Firefox with the same code.

Here is my source code:

public class GoogleTest { @Test public void test() throws Exception { System.setProperty("webdriver.ie.driver", "IEDriverServer.exe"); final WebDriver driver = new InternetExplorerDriver(); driver.get("http://www.google.com"); driver.findElement(By.name("q")).sendKeys("test"); driver.findElement(By.name("q")).submit(); driver.quit(); } 

}

However, I welcome this stack trace after doing this test

 org.openqa.selenium.NoSuchElementException: Unable to find element with name == q (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 395 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_01' Driver info: driver.version: RemoteWebDriver Session ID: e20f8370-00ed-4bf6-a4fa-a0c09c2b6d8c at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242) at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:303) at org.openqa.selenium.By$ByName.findElement(By.java:291) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:234) 
+4
java internet-explorer selenium selenium-webdriver
source share
5 answers

This is probably really obvious, but since you did not mention it in your original post, and you just downloaded the driver and your internal toy application is working, you double-checked the security settings in IE, as indicated in the IEDriver code page:

In IE 7 or later, in Windows Vista or Windows 7, you must set Protected Mode to the same value for each zone. The value can be turned on or off if it is the same for each zone. To set the protected mode settings, select "Internet Options ..." in the "Tools" menu and click on the "Security" tab. For each zone, at the bottom of the tab with the inscription "Enable Protected Mode" will be checked.

If you used the previous version of Selenium before, you probably already did it, but I decided it was worth checking to be sure ...

+12
source share

Well, the error message is misleading, at least in my case. I had a system that was locked by the system administrator in Protected mode: Off. Therefore, I could not switch protected mode. Then I realized that the system has an admin user, so I logged in as admin and tried to switch to Protected mode. He was still disconnected. Then I run Selenium under the administrator account and everything works fine.

Thus, you may need to log in as an administrator in order to be able to run selenium. This trick worked for me.

+1
source share

Use the code below

 System.setProperty("webdriver.ie.driver", "E:\\Selenium\\workspace\\IEDriverServer.exe"); WebDriver driver = new InternetExplorerDriver(); 
0
source share

Check the loaded IEWebdriver server. If you are using 32-bit IE, download and use the 32-bit IEWebdriver.

Hope this helps.

0
source share

I had very similar problems. In the Internet settings, a setting has been set that must be enabled in order to make it work. Advanced> Settings> Security> Allow running active content in files on my computer.

Once I checked this box, my IE tests worked as expected, and could find elements and interact with the browser.

0
source share

All Articles