Internet Explorer Driver Server

Introduction

We have seen how to run Selenium Tests in IE browser by using the driver. Alternatively, we can also start the Internet Explorer driver server locally and communicate to IE browser through it. In this tutorial, we will learn to execute the Selenium tests through the IE driver server.

About IE Driver Server

Internet Explorer does not have a native implementation in Selenium Webdriver. So, Selenium WebDriver project created the IE driver server.  Hence, this server implements the WebDriver protocol and communicates with the IE browser. In other words, the IE driver server is nothing but a small application server used to form an interface between Selenium Tests and IE browser. In short, it receives commands from Selenium code and relays them to IE browser for action.

Pre-requisites

The pre-requisites to perform the steps demonstrated in this tutorial are:

In case, you have missed any of the above steps, you will not be able to create your script and execute it. Please refer to the individual tutorials available in our course for completing the above steps before you go with the below steps.

Download IE Driver server 

  1. First, check the version of the IE browser installed in your machine. Go to Settings > About InternetExplorer and click. It will show the current version installed.

2. Next step is, to download the IE browser driver. For that, go to the download section of the Selenium official site https://docs.seleniumhq.org/download/ and click on the appropriate link as per the Windows configuration.

3. It will download a zip file IEDriverServer_xnn_n.n.n where n stands for version information. Next, save this zip file at an appropriate location in the system.

4. Extract the content of the saved zip file in a folder and you will get IE driver server executable.

We have downloaded the IE driver server executable successfully. Now, let us see how we can start the server and run the script using it.

Start the server

  1. Goto the folder location where you have saved the driver server executable and copy the file path. Now, open the command prompt and input following commands:
  • cd c:\file location: This command will move the control to the directory where the server executable is located.
  • dir: It lists the contents of the directory or folder.
  • IEDriverServer.exe -help: It will list all the options available to use with IEDriverServer.exe. Hence, we can select as per our needs.

2. To start the server using the command prompt, input the following command in the command prompt and press Enter Key.

IEDriverServer.exe /log-file=C:\\test\\IELog.txt /port=8099 /log-level=DEBUG 

  • IEDriverServer.exe: It will start the IE driver server.
  • /log-file=<file>: It specifies the full path and file name of the log file used by
    the server.
  • /port=<nnnn>: It specifies the port on which the server will listen for
    commands.
  • /log-level=DEBUG: It specifies the log level used by the server.

That is how we can start IE server from the command prompt. It lists the details of the port, IP address, and log file.

Code changes

Let us see how we can connect to IE server programmatically. In other words, the Selenium automation script needs to connect the IE driver server to communicate through it.  For that, we write in the code to provide the details of the IE server.

package seleniumAutomationTests;

import java.io.File;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerDriverLogLevel;
import org.openqa.selenium.ie.InternetExplorerDriverService;

public class MyFirstTest {

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    
    //location of the IE driver server exe
    String driverPath = "C:\\softwares\\drivers\\IEDriverServer.exe";
    
    InternetExplorerDriverService.Builder newService = new InternetExplorerDriverService.Builder();
    
    newService.usingPort(8099); //provide port 
    
    newService.usingDriverExecutable(new File(driverPath)); //provide ie driver path
    
    newService.withHost("localhost"); //provide ip details
    newService.withLogFile(new File("C:\\test\\IELog.txt")); //provide log file location 
    newService.withLogLevel(InternetExplorerDriverLogLevel.DEBUG); //provide log level
    
    InternetExplorerDriverService service = newService.build();
    
    InternetExplorerDriver driver = new InternetExplorerDriver(service);
        
    //load the webpage of application under test
    driver.get("https://www.google.com/");
        
    //get the title of the page in a string variable
    String pageTitle = driver.getTitle();
    
    //print the page title on console
    System.out.println(pageTitle);
    
    //close the browser
    driver.close();

  }

}

Therefore, we provide the details of port, ie server executable location and IP details in the Selenium code. Then, Internet driver service is built with the using the details provided and the server is connected to receive the commands from the script.

Execution

Execute the code by right-clicking on the Class Name > Run As > Java Application. It will

  • The script will connect to the IE driver server.
  • IE driver server will start the IE browser.
  • Launch the application under test on the browser.
  • Fetch the value of the page title of the web page and store it in a string.
  • Print the page title on the console
  • Close the web page and finish the execution of the script.

You will see the server logs being collected in the log file.

If we don’t specify the log file, we will get the logs in Console instead of the log file as below.

Conclusion

In this tutorial, we learned about Internet Explorer driver server and its usage in automating actions with IE browser. Additionally, we saw how we can programmatically connect to the IE server and execute the Selenium commands.

Translate »