Table of Contents
Enroll in Selenium Training

Internet Explorer browser is still chosen by a section of people for internet browsing. These users are mainly the ones who have been using the IE browser for a long time and want to continue using it as they are habituated to it. Also, it must be remembered that IE is one of the earliest brands established in the market. Since Selenium gives the option of running our tests in multiple browsers, Selenium with IE browser blending can be used to test any application. IE has a driver, which creates a connection between Selenium WebDriver and IE. and then executes the Selenium tests on Internet Explorer. Let us explore How to run Selenium Tests on Internet Explorer by discussing the below topics:

  • What is Selenium IE Driver?
    • What are the pre-conditions for Selenium IE Driver?
  • How to install IE Driver on Windows?
    • How to download IE Driver on Windows?
    • Also, how to configure IE Driver on Windows?
    • How to run Selenium tests on Internet Explorer browser?
  • How to download IE Driver on Mac OS?

What is Selenium Internet Explorer Driver or IE Driver?

IE Driver is the connection that enables the users to execute Selenium test cases on the IE browser. It is an independent server that administers the open-source Selenium WebDriver Protocol. The Selenium tests communicate with the IE Driver via the JsonWireProtocol, which converts the commands in Selenium into actions on the IE browser.

Run Selenium tests on Internet Explorer: Selenium IE Driver communication

The main objective of the IE Driver is to communicate with Internet Explorer. It is not feasible to execute Selenium test cases on IE without it. An IE Driver can be used by instantiating an object of the IE Driver and assigning it to the WebDriver object. Then utilizing it for browser actions.

What are the pre-conditions for Selenium Internet Explorer Driver or IE Driver?

Before we can begin creating tests in Selenium or configuring the IE Driver so as we can run Selenium tests on Internet Explorer, we should take care of a few pre-conditions on our system:

  • Java JDK - We need the JDK or Java Development Kit for the Java programs. It has the JRE and multiple development tools like the debugger and compiler.
  • Java IDE - Integrated Development Environment(IDE) assists in writing the Java programs.  It has multiple features for end-user programming. Here, we will be using the Eclipse IDE. Any other alternative Java IDE can also be used.
  • Selenium WebDriver - To build the Selenium tests, we require Selenium WebDriver. You can download it from the official Selenium site. For more details, you can refer to the topic: Configure Selenium WebDriver.

For this tutorial, we can use either the Selenium 3 or Selenium 4 version.

How to install IE Driver on Windows?

Let's proceed further and discuss how to set up the IE Driver with your Selenium Java project and run test cases on IE. Initially, we will download the IE Driver. Let's investigate how we can carry it out on Windows operating system?

How to download IE Driver on Windows?

Prior to download the IE Driver, we will note the version of the IE browser on our system. IE Driver version that we need to download has to be compatible with the IE browser version. Follow the steps listed below, to check the browser version:

  1. Firstly, to know the IE browser version on your machine, click on Help in the menu.

IE Help menu

  1. Secondly, click on About Internet Explorer in the sub-menu.

IE About Internet Explorer sub menu

  1. After clicking the About Internet Explorer option, the following pop-up will open. Therefore, we will get the IE version information as shown in the image below:

Run Selenium tests on Internet Explorer: Check IE version

Now, as we have the version of the IE browser,  we can proceed further. Configure the IE Driver with the steps mentioned below:

  1. First, go to the link. In the below image,  we have seen both the 32 bit Windows IE and 64 bit Windows IE available for Windows. You can download the zip file of the IE Driver which is compatible with your operating system and the browser.

Run Selenium tests on Internet Explorer: Select compatible Selenium IE Driver

  1. Then, as the download is successful, unzip the zip file and keep it in a particular location.

IE Driver zip file

  1. Create a Java project after opening Eclipse. Incorporate all the project dependencies. To know how to create a Java project with Selenium WebDriver in Eclipse, go through the complete tutorial at Configure Selenium WebDriver.

  2. As the following step, we require to make this IE Driver accessible to the Selenium tests.

Let's discuss how to configure IE Driver so that it can be utilized in the Selenium scripts.

How to configure IE Driver on Windows?

To configure IE Driver with Selenium, so as we can run Selenium tests on Internet Explorer, the IE Driver executable file should be made available to the test scripts. Selenium test cases can approach the IE Driver by following any one of the ways:

  1. Setting up the IE Driver via System Properties in Environment Variables.

  2. Setting up the IE Driver via System Properties in the script.

Let's understand all these and make an attempt to execute our code with Selenium 3 or Selenium 4.

How to configure IE Driver via System Properties in Environment Variables?

We can define system-level variables via Environment Variables. Moreover, users have the option to declare either system variables or user-level variables. Besides, the variables declared here can be utilized by every program executing on the system.

Additionally, we can take the help of environment variables to set the IE Driver path. As we have an instance of the WebDriver, it will by default identify the IE Driver path from the system variables. Subsequently,  let’s explore the steps by which we can achieve that.

  1. Firstly, we open the Environment Variables pop-up. For that, click on the search box and type env. Consequently, it will show Edit the system environment variables as displayed in the below image. Click on it.

Search System variables

  1. Secondly, the System Properties pop-up will come up. Go to the Advanced tab inside the pop-up. Next, in the Advanced tab, click on Environment Variables.

Run Selenium tests on Internet Explorer: Environment variables on Windows

  1. Thirdly, it will open the Environment Variables pop-up. Within the System variables section, search for the Path variable as highlighted in the image below. Then, select it. Finally, after selection, click on Edit as highlighted in the image.

EnvironmentVariablesPth

  1. Fourthly, as the Edit environment variable pop-up opens up, click on New.

Run Selenium tests on Internet Explorer: Edit Environment variable

  1. Finally, add the location of the IE Driver folder path. We have kept our driver in the location C:\Selenium\iedriver, hence we have added that in the path variable. Then click on OK.

Run Selenium tests on Internet Explorer: Add path of IE Driver folder

How to run Selenium tests on Internet Explorer browser?

So, now let's see how we can run Selenium tests on Internet Explorer. Consequently, we can initialize the WebDriver instance with the help of IE Driver, as described below:

package demoPackageIE;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

 
public class IEDriverDemo {
    public static void main(String[] args) throws InterruptedException{
 
        System.out.println("Setting IE Driver Path in System Variables");    
        WebDriver driver=new InternetExplorerDriver();  
      	driver.get("https://google.com");
        Thread.sleep(3000);
        driver.quit();
         System.out.println("Execution done"); 
 
    }
}

On running the above code, the output shall be:

IE Driver path set in System Variables

From the console output, it is obvious that there is no WebDriver issue, indicating it's set up is accurate. Also, we can find the print statement at the start and end of execution.

How to initialize IE Driver via System Properties in the script?

We can initialize IE Driver by directly specifying the path in the script. In simpler terms, we have to add the following line of code to set up the system properties for the IE Driver, as given below:

System.setProperty("webdriver.ie.driver", "<Path of the IE Driver Executable>");

Let us update the code we have used above and confirm that we can launch the IE browser accurately. The updated code should be similar to this:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

 
public class DemoIE {
    public static void main(String[] args) throws InterruptedException{
 
        System.out.println("IE Driver execution on Windows!!");
        System.setProperty("webdriver.ie.driver", "E:\\IEDriver\\IEDriverServer.exe");
        WebDriver driver=new InternetExplorerDriver();  
      	driver.get("https://google.com");
        Thread.sleep(3000);
        Capabilities c = ((RemoteWebDriver) driver).getCapabilities();
        // get the browser name, version and platform with Capabilities object and getCapability() method
        System.out.println("Current browser Name is : " +c.getBrowserName());
        System.out.println("Current browser Version is : " +c.getVersion());
        System.out.println("Current platform is : " +c.getPlatform().toString());
        driver.quit();
 
    }
}

You will find that google.com opens in the IE browser without any issue and exception.

IE Browser launch

So, in this way, you can execute your Selenium tests on a particular version of IE by mentioning the direct path of the IE Driver within the setProperty() method. Additionally, the logs point to the fact that our WebDriver session began with the print statement and confirms that tests are executed in IE version 11 in Windows.

How to download IE Driver on Mac OS?

The macOS does not back IE. But if we have to execute our Selenium tests in IE, there are multiple ways that can be done:

  1. Oracle VM Virtual Box - To verify IE on macOS, we can install VM Virtual Box on our system.
  2. Cross Browser Testing on Cloud - This is one of the popular ways to do cross-browser testing. LambdaTest is one of the testing platforms to perform a cross-browser check.

Key Takeaways

  • IE has deprecated, but we still use it for cross-browser testing.
  • Additionally, make sure to set the browser zoom level 100% for IE before execution.
Run Selenium tests on Chrome
Run Selenium tests on Chrome
Previous Article
Run Selenium tests on Edge
Run Selenium tests on Edge
Next Article

Similar Articles

Feedback