Sunday, 23 October 2016

Below is the sample code to launch web browser in Firefox using selenium 3.0

package com.sample;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class SampleTest {
String driverPath = "<path to gecko driver executable>"; // D:\\geckofolder\\
public WebDriver driver;
@Test
public void launchBrowser() {
System.out.println("===== launching firefox browser ==== ");
System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
driver = new FirefoxDriver();
}
@Test
public void openApplication() {
driver.navigate().to("http://seleniummansion.blogspot.com");
}
@Test
public void closeDriver() {
if(driver!=null) {
driver.close();
driver.quit();
}
}
}

0 comments:

Post a Comment