Open In App

How to Run Internet Explorer Driver in Selenium Using Java?

Selenium is a well-known software used for software testing purposes. Selenium consists of three parts. One is Selenium IDE, one is Selenium Webdriver & the last one is Selenium Grid. Among these Selenium Webdriver is the most important one. Using Webdriver online website testing can be done. There are three main Webdrivers present. For the Chrome browser, ChromeDriver is present. For the Firefox browser, Gecko Driver is applicable. And for Microsoft Edge, there will be MSEdgeDriver present. Excluding these, many more drivers are present for other browsers. In this article, the process of running InternetExplorerWebdriver is implemented. This simple Java program can be run.

Pre-Requisites

Approach

Note: In this case, InternetExplorerDriver.exe is stored in Eclipse, so maybe the location seems different. But also, a complete File Explorer path can also be passed.



Below is the complete implementation of the above approach:




// Importing All Necessary Items
import java.io.*;
import java.lang.Thread;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
 
public class GoogleHomePage {
    public static void main(String[] args)
    {
        // Try-Catch Block For Implementing Sleep Method
        try {
            // String Where Home Page URL Is Stored
            String baseUrl = "https://www.google.com/";
           
            // Implementation of SetProperty Method
            System.setProperty("webdriver.ie.driver","test/resources/IEDriverServer.exe");
           
            // Creating New Object driver Of Webdriver
            WebDriver driver = new InternetExplorerDriver();
           
            // Calling the Home Page
            // By Using Get() Method
            driver.get(baseUrl);
           
            // Delaying The Output
            Thread.sleep(2000);
           
            // Closing The Opened Window
            driver.quit();
        }
        catch (Exception e) {
            // Catching The Exception
            System.out.println(e);
        }
    }
}

Output:



If the above code is run, then a new Internet Explorer Window will be opened.

 


Article Tags :