Running Webdriver script for Internet Explorer & Chrome is not as same as working with Firefox browser. Following are the steps to Run:
Step 1: In order to run, we need to download IE Driver & Chrome Driver and we can download from https://code.google.com/p/selenium/downloads/detail?name=IEDriverServer_Win32_2.31.0.zip
https://code.google.com/p/chromedriver/downloads/list
Step 2: Include the respective drivers in to the Path
Step 3: Set the System property using the following Command which takes two parameters Driver and location of the driver.
System.setProperty("webdriver.ie.driver", "Drivers\\IEDriverServer.exe");
Step 4: Now create an Driver Object for IE using the following command
driver = new InternetExplorerDriver();
Once we start running the script Internet Explorer will open and execute script.
Following is the sample code for IE and kept commented code for Google Chrome
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class DriversExample{
private static InternetExplorerDriver driver;
//private static ChromeDriver driver;
@BeforeClass
public void beforeClass()
{
System.setProperty("webdriver.ie.driver", "Drivers\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
// System.setProperty("webdriver.chrome.driver", "Drivers\\chromedriver.exe");
// driver = new ChromeDriver();
}
@Test
public void testDrivers() throws Exception
{
driver.get("http://www.google.com");
Thread.sleep(3000);
}
@AfterClass
public void afterClass()
{
driver.close();
}
}
Step 1: In order to run, we need to download IE Driver & Chrome Driver and we can download from https://code.google.com/p/selenium/downloads/detail?name=IEDriverServer_Win32_2.31.0.zip
https://code.google.com/p/chromedriver/downloads/list
Step 2: Include the respective drivers in to the Path
Step 3: Set the System property using the following Command which takes two parameters Driver and location of the driver.
System.setProperty("webdriver.ie.driver", "Drivers\\IEDriverServer.exe");
Step 4: Now create an Driver Object for IE using the following command
driver = new InternetExplorerDriver();
Once we start running the script Internet Explorer will open and execute script.
Following is the sample code for IE and kept commented code for Google Chrome
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class DriversExample{
private static InternetExplorerDriver driver;
//private static ChromeDriver driver;
@BeforeClass
public void beforeClass()
{
System.setProperty("webdriver.ie.driver", "Drivers\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
// System.setProperty("webdriver.chrome.driver", "Drivers\\chromedriver.exe");
// driver = new ChromeDriver();
}
@Test
public void testDrivers() throws Exception
{
driver.get("http://www.google.com");
Thread.sleep(3000);
}
@AfterClass
public void afterClass()
{
driver.close();
}
}