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

have to do login to an application with two different browsers (IE & FF) and hence I tried to do cross browser test. When the URL gets passed to IE, I am getting link as "Continue to this website not recommended", whereas the same link will not be displayed in FF. To click on "Continue to this website not recommended" link am using this script "driver.findElement(By.id("overridelink")).click();". but when the script runs for firefox its failing because FF could not able to locate the element. Help me in this how to write script for specific browser.

In simple words, this line " driver.findElement(By.id("overridelink")).click();" should get execute only for IE and not on FF.

I have to download IE driver server for ubuntu.I did't find it in selenium easy.will you please help me.

*******************
launching chrome browser
Sep 07, 2016 11:24:56 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
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: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700'
System info: host: 'AASHI', ip: '192.168.1.6', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
Driver info: driver.version: InternetExplorerDriver

Hi,

My website is running on a Wildfly server when authentification is done by SNPEGO. Roughly it uses Microsoft authentification (kerberos) to identify user. When I am testing my site with InternetExplorerDriver, I get error 401 (not authorrized).
The web site is working when I do not use InternetExplorerDriver. Does InternetExplorerDriver support Kerberos?

Thanks for your help.

S.

its showing error"Listening on port 42903
Only local connections are allowed
Exception in thread "main" 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). pls provide solution

Hi,

I am able to launch all browsers without setting system property and .exe path, but I just copied paste all .exe in my src folder?
Will it affect my project in any way?
Please clarify the functionality of system.setProperty?
Thanks,
Ishan Tyagi

Even though you have copied all driver executables '.exe' in my src folder, you have to set the path.

Hi,

I have seen some wired behavior in IE, when my test case is executing in IE, if I minimize the the browser, execution is failing at the next step leaving element not found exception, and it executes successfully if i keep IE browser open(active).
Is there any limitation from selenium that IE browser should be active or it should be on focus while execution?

Thanks in Advance.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.