Thursday 4 February 2016

How to run webdriver in IE browser:

How to run web driver in IE browser?:
==============================

To run selenium webdriver in IE browser, we need InternetExplorerDriver.
Download latest version of IEDriver server for webdriver from seleniumhq.org.

In order to launch IE we need to set the 2 attributes see the synatx.
syntax:
=======


System.setProperty("webdriver.ie.driver", "path of IEDriverServer.exe");

Example IE:
=========

package blog;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class IeDemo {

WebDriver webDriver;

@BeforeSuite
public void launchingIEBrowser() {

System.setProperty("webdriver.ie.driver", "D:\\Ramesh\\IEDriverServer.exe");
   webDriver = new InternetExplorerDriver();
webDriver.manage().window().maximize();
webDriver.manage().deleteAllCookies();
webDriver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);

}

@Test
public void testScript() {
webDriver.get("https://google.com");
webDriver.findElement(By.name("q")).sendKeys("selenium by ramesh");
webDriver.findElement(By.name("btNg")).click();

}

@AfterSuite
public void closeBrowser() {
webDriver.quit();

}


}

No comments:

Post a Comment