HOW TO RUN SELENIUM WEBDRIVER SCRIPT IN IE BROWSER?

We can also run the Selenium Webdriver programs in Internet Explorer web browser to perform automation testing.
To run the Selenium Webdriver programs in Internet Explorer web browser we need to download IE Driver

Here is the very basic program to run Selenium Webdriver programs in Internet Explorer web browser.




Java Source code:

package com.helloselenium.selenium.test;

import java.io.File;

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

public class OpenHelloSeleniumBlogInInternetExplorer{

 public static void main(String[] args) { 

  WebDriver driver = null;

  File IEDriver = new File("path of the IEDriverServer (.exe file)");
  System.setProperty("webdriver.ie.driver", IEDriver.getAbsolutePath() );  
  driver = new InternetExplorerDriver();

  driver.get("http://helloselenium.blogspot.com");
  
  driver.quit();
 }

}

Detailed explanation for the above program is as follows:




Following code is the required package for Java File.
import java.io.File;
Following code is the required packages for Selenium Webdriver.
import org.openqa.selenium.WebDriver;
Following code is the required packages for IE driver.
import org.openqa.selenium.ie.InternetExplorerDriver;
Following code is to initialize the webdriver.
WebDriver driver = null;
Following code is to locate the ie driver executable file.
File IEDriver = new File("path of the IEDriverServer (.exe file)");
Following code is to set the ie driver with webdriver property.
System.setProperty("webdriver.ie.driver", IEDriver.getAbsolutePath() );  




Following code is to initialize the ie driver.
driver = new InternetExplorerDriver();
Following code is to open the hello selenium blog in ie browser.
driver.get("http://helloselenium.blogspot.com");
You can also use the following code is to open the hello selenium blog in browser.
driver.navigate().to("http://helloselenium.blogspot.com");
Following code is to quit the driver instance.
driver.quit();
You can also use the following code is to close the driver instance.
driver.close();



Post a Comment

0 Comments