How to run webdriver in IE browser?

To run selenium webdriver in IE browser, we need InternetExplorerDriver which is a standalone server which implements WebDriver's wire protocol.

First of all, download latest version of IEDriver server for webdriver. You can download latest version server from Download InternetExplorerEDriver

Note: Choose the IEdriver server based on your working environment as there are two different zip files for both 32 and 64 bit IE . Recommended 32bit IEDriver which is less prone to errors when compared with 64bit driver.

Save the downloaded file to your local machine.

In you code you need to set the system property for IE driver as

System.setProperty("webdriver.ie.driver", "pathofchromedriver\\IEDriverServer.exe");

Please find the below example program for running webdriver in IE browser. It has a test method which will validate google home page title once when the browser is opened.

package com.test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class TestIEBrowser {
	
	static String driverPath = "IE driver path";
	public WebDriver driver;
	
	@BeforeClass
	public void setUp() {
		System.out.println("*******************");
		System.out.println("launching IE browser");
		System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe");
		driver = new InternetExplorerDriver();
		driver.manage().window().maximize();
	}
	
	@Test
	public void testGooglePageTitleInIEBrowser() {
		driver.navigate().to("http://www.google.com");
		String strPageTitle = driver.getTitle();
		System.out.println("Page title: - "+strPageTitle);
		Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match");
	}

	@AfterClass
	public void tearDown() {
		if(driver!=null) {
			System.out.println("Closing IE browser");
			driver.quit();
		}
	}
}

As we all know, InternetExplorerDriver works only with Windows system and the execution speed is slow Comparatively to other browsers.

Most of the time when working with Internet explorer, we may end up seeing issues such as 'NoSuchElementFound' exception because of Synchronization

However when working with InternetExplorerDriver there are some issues with mouse events when the browser window does not have focus, and attempting to hover over elements.

Your test scripts may work fine with Firefox and Chrome browsers which are intelligent enough find the elements in the DOM, but Internet Explorer is slow because of which you will end up with an exception.

To avoid issues when executing scripts with Internet explorer, try to use 'Css selectors' which will minimize your issues.

When ever working with Internet explorer browser for Selenium webdriver, the below are the common issues that you may come across.

1. If see issue some thing like 'Unexpected error launching Internet Explorer' below, You have to set 'Enable protected mode' option in all levels with same value.

org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 516 milliseconds

Please follow below steps to set:

1. Open Internet Explorer browser--> Select Internet Options from Tools menu
2. Select Security Tab --> Select Enable Protected Mode option -- > Check the default Zone level for 'Internet'. If you look at the screen shot below, security level for this zone is selected as 'Allowed level for this zone : Medium to High.' and 'Enable Protected Mode' option is Checked.

Zone level settings for IE driver

Now you need to make sure that, for the other Zones, such as 'Local Internet' and 'Trusted sites' is also selected as ABOVE. You may don't need to do anything with 'Restricted Site' option. We can leave the option as is and by default 'Enable Protected Mode' option will be Checked.

Now after changing the settings, please click on 'Apply' and 'Ok' button.

There is also an other alternative for setting the protected mode using desired capabilities as below: -

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

But how ever, the first option is advised and it is not that hard to set internet explorer browser settings.

You can checkout for the required configuration options which are defined IE required configuration for Selenium Webdriver

2. Make sure that the IE browser zoom level is set to 100% so that the native mouse events can be set to the correct coordinates.

3. It may be silly one, But make sure you provide correct path when setting the property of Internet explorer driver.

Hope you will Run your scripts in IE browser without any issues.

As said above If you are still facing any problem running your scripts in Internet Explorer, please refer InternetExplorerDriver Required_Configuration

Selenium Tutorials: 

Comments

When we try the above and get the below exception

org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)

Follow the steps below:

1. Open the internet browser, go to tools> Internet Options> Security and check the option(Enabled Protected Mode) for all the zones(Internet, Local Intranet, Trusted Sites, Restricted Sites), apply the changes and click ok.

2. Go to option 'View' and set the browser zoom to 100%.

Now run the code again and there you go.

Happy Testing :-)

Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Unable to use CreateProcess() API. To use CreateProcess() with Internet Explorer 8 or higher, the value of registry setting in HEKY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0'. (WARNING: The server did not provide any stacktrace information)

Thanks for sharing. How do I run this code and where do I do that?
I have a browser and selenium IDE installed. What I don't understand is what command to execute in CMD so that my script recorded in Firefox will run in IE or Chrome. Can you help?

Selenium IDE works only with Firefox . For multiple browser use Seleniumwebdriver

How to avoid following exception:
selenium.common.exceptions.WebDriverException: Message: Unexpected error launching Internet Explorer. Could not get document from window handle

I am trying to execute simple program through IE and getting below error as :

xception in thread "main" java.lang.IllegalStateException: The driver executable is a directory: C:\Program Files\Internet Explorer
at com.google.common.base.Preconditions.checkState(Preconditions.java:197)

In my system exe is not present. I am running this through webtop directly application of IE.

Please let me know how to resolve this query ?

Very useful information.Thanks . Keep up he good work

Qu: I am trying to open IE browser in private mode getting exception:

DesiredCapabilities capabilities1 = DesiredCapabilities.internetExplorer();
capabilities1.setCapability("ignoreZoomSetting", true);
capabilities1.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities1.setJavascriptEnabled(true);
capabilities1.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
capabilities1.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
driver= new InternetExplorerDriver(capabilities1);

Exception:

Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Unable to use CreateProcess() API. To use CreateProcess() with Internet Explorer 8 or higher, the value of registry setting in HEKY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0'. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.24 seconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'GLCT4BS', ip: '172.16.2.2', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_73'
Driver info: org.openqa.selenium.ie.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:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:151)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:225)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:181)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:173)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:150)
at testfirst1.test.main(test.java:35)

Hello,
I am getting this error on IE "This page can’t be displayed", when running my code for selenium automation,plz resolev

how to do loacte elements in pop ups in IE browser? as after coming alertbox developer tool is not launching..
please suggest me solution.

Add new comment

Image CAPTCHA