Selenium WebDriver- Running test on IE Browser

In this section, you will learn how to run your Selenium Test Scripts on IE Browser.

Internet Explorer implements the WebDriver protocol using Internet Explorer Driver Server. The Internet explorer Driver Server is the link between your tests in Selenium and the Internet Explorer Browser.

Let us consider a test case in which we will try to automate the following scenarios in IE browser.

We will create our fourth test case in the same test suite (Demo_Test).

Step1. Right click on the "src" folder and create a new Class File from New > Class. Give your Class name as "Fourth" and click on "Finish" button.

Selenium WebDriver Running test on IE Browser Selenium WebDriver Running test on IE Browser

Step2. Open URL: http://selenium-release.storage.googleapis.com/index.html?path=2.48/ in your browser.

Step3. Choose the latest version and download as per the operating system you are currently working on.

For windows 64 bit, click on the "IEDriverServer x64 2.48.0 zip" download.

Selenium WebDriver Running test on IE Browser

The downloaded file would be in zipped format. Unpack the contents in a convenient directory.

Selenium WebDriver Running test on IE Browser

Step4. Set a system property "webdriver.ie.driver" to the path of your IEDriverServer.exe file and instantiate an IEDriver class.

Here is a sample code to do that.

snippet
// System Property for IEDriver 
System.setProperty("webdriver.ie.driver", "D:\\IE Driver Server\\IEDriverServer.exe");
		
     // Instantiate a IEDriver class. 	
WebDriver driver=new InternetExplorerDriver();

Step5. Now it is time to code. We have embedded comments for each block of code to explain the steps clearly.

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

public class Fourth {

	public static void main(String[] args) {
	
		    // System Property for IEDriver 
		System.setProperty("webdriver.ie.driver", "D:\\IE Driver Server\\IEDriverServer.exe");
		
	       // Instantiate a IEDriver class. 	
		WebDriver driver=new InternetExplorerDriver();
		
		   // Launch Website
		driver.navigate().to("http://www.google.com/");
		
		   //Maximize the browser
	      driver.manage().window().maximize();
	      
	       // Click on the search text box and send value
		driver.findElement(By.id("lst-ib")).sendKeys("javatpoint tutorials");
			
		   // Click on the search button
		driver.findElement(By.name("btnK")).click();
		  

	}

}

The Eclipse code window will look like this:

Selenium WebDriver Running test on IE Browser

Step6. Right click on the Eclipse code and select Run As > Java Application.

Selenium WebDriver Running test on IE Browser

Step6. The output of above test script would be displayed in Internet Explorer browser.

Selenium WebDriver Running test on IE Browser
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents