How to run Selenium tests on Internet Explorer browser?

SeleniumAutomation TestingTesting Tools

We can run Selenium tests on the Internet Explorer browser with the help of the Selenium IE driver. It is an independent server that works on the protocols of the webdriver and serves as a communication between the Internet Explorer browser and the Selenium code.

First, we have to download the IEDriverServer.exe file from the following link − https://www.selenium.dev/downloads/.

Then click on the download link (32 or 64 bit) based on our local operating system.

Once the download is completed, a zip file gets saved. It needs to be extracted and stored in a location. After extracting it, the executable file - IEDriverServer.exe file is to be kept at a desired location.

We have to configure the path of the IEDriverServer.exe file using the System.setProperty method along with creating an object of the InternetExplorerDriver class.

Syntax

System.setProperty("webdriver.ie.driver",
"C:\\Users\\ghs6kor\\Desktop\\Java\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();

Example

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class IEBrwserLaunch{
   public static void main(String[] args) {
      //configure path of IEDriverServer.exe path
      System.setProperty("webdriver.ie.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\IEDriverServer.exe");
      //object of InternetExplorerDriver
      WebDriver driver = new InternetExplorerDriver();
      //URL launch
      driver.get("https://www.yahoo.com/");
   }
}

Output

raja
Published on 06-Apr-2021 10:31:42
Advertisements