App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Get Started free
Home Guide How to run Selenium tests on IE using IE Driver?

How to run Selenium tests on IE using IE Driver?

By Jash Unadkat, Community Contributor -

Chrome is undoubtedly the most widely used browser in the world. However, certain users prefer surfing the internet solely through Internet Explorer. As per a report by netshare, 7% of total desktop browser users worldwide still use IE. These users might have been using IE for years, and prefer sticking to what is familiar to them.

Bear in mind that Internet Explorer also has significant brand recognition as it is one of the oldest browsers in existence. Therefore, it becomes integral for QAs to test and optimize their websites for flawless functioning on Internet Explorer.

This article aims to explain how QAs can automate tests for their web applications on the IE browser using the IE driver for Selenium tests.

First, let’s quickly understand what Selenium Internet Explorer Driver is and its role in test automation.

What is Selenium IE Driver?

The Selenium IE Driver (also known as Selenium Internet Explorer Driver) is a stand-alone server that implements the WebDriver protocol. This server acts as a link between Selenium scripts and Internet Explorer.

Note: It is important for QAs to download the IE driver compatible with their working environment (32 bit or 64 bit).

Steps to Configure the IE Driver

  1. Download the zip file of the InternetExplorerDriver from the official site. Make sure the downloaded version is compatible with the working environment.
  2. Unzip the file and copy it to a specific location.
  3. Download and install the IDE of your choice. Also, import all the Selenium dependencies.
  4. Define the IE Driver along with its path using the setProperty method and instantiate the IE Driver class.
    Refer to the sample code snippet below:
// Defining System Property for the IEDriver 
System.setProperty("webdriver.ie.driver", "D:IE Driver ServerIEDriverServer.exe"); 

// Instantiate a IEDriver class. 
WebDriver driver=new InternetExplorerDriver();

How to launch the IE Driver in Selenium?

At this point, you have completed configuring your IE Driver. Now let’s take a simple scenario that will explain how to launch the IE browser in Selenium and navigate to a specific website. In this scenario, we will automate three simple steps:

  1. Open the Internet Explorer browser
  2. Navigate to the Google website (www.google.com)
  3. Enter BrowserStack in the search box.

Note: For automating specific test scenarios, one needs to interact with several web-elements like text boxes, buttons, etc. To do so, one must know how to locate these elements. To understand how to locate elements in Selenium Webdriver, refer to this guide on Locators in Selenium.

Now let’s code the above scenario.

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.ie.InternetExplorerDriver;


public class IEexample {
public static void main(String[] args) {

//Setting system properties of InternetExplorerDriver
System.setProperty("webdriver.ie.driver", "D:IE Driver ServerIEDriverServer.exe"); 

//Creating an object of InternetExplorerDriver
WebDriver driver=new InternetExplorerDriver();
driver.manage().window().maximize();

//Deleting all the cookies
driver.manage().deleteAllCookies();

//Specifiying pageLoadTimeout and Implicit wait
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

//launching the specified URL
driver.get("https://www.google.com/");

//Locating the elements using name locator for the text box
driver.findElement(By.name("q")).sendKeys("BrowserStack");

//name locator for google search button
WebElement searchIcon = driver.findElement(By.name("btnK"));
searchIcon.click();
}
}

When the above script is executed, the InternetExplorerDriver launches the IE browser, navigates to the Google website, and enters “BrowserStack” as the search query in the search box.

Although the market share of Internet Explorer might make it seem like one can avoid testing web-apps on IE, that’s not the case. As a business owner, one must leave no stone unturned to cater to potential customers. Optimizing web-applications for IE ensures that businesses are going the extra mile to provide a truly inclusive experience. This helps organizations establish their credibility and increase revenue flow.

To do so, teams can use platforms like BrowserStack that enables them to test their web-applications on multiple version of the IE browser on real devices. One can simply download the Test IE extension available for the Chrome browser and get started instantly. This extension allows QAs to locally test their web-apps for IE versions 6-11 and Edge directly from Chrome. The image below gives a glimpse of the extension.

Selenium tests using IE driver
Besides testing on IE, QAs can also leverage BrowserStack’s real device cloud to run their web-apps for browser compatibility testing. They can test their web-applications across thousands of real browsers and browser versions like Safari, Chrome, Edge, Firefox, etc. on real desktop and mobile devices, thus providing a single platform for QAs to instantly test their web-apps in real user conditions.

Try BrowserStack Now

Tags
Automation Testing Cross browser testing Selenium Selenium Webdriver

Featured Articles

How to test on older browser versions easily

GeckoDriver vs. Marionette: Differences

App & Browser Testing Made Easy

Seamlessly test across 20,000+ real devices with BrowserStack