Sunday, 23 October 2016

Step 1: Download MicrosoftWebDriver.exe from "https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ "

Below is the sample code to launch edge browser using Microsoft driver

package com.Sample;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.testng.annotations.Test;
public class EdgeBrowserTest {
String driverPath = "Path Microsoft edge driver"; // D:\\microsoftdriver\\
public WebDriver driver;
@Test(priority=0)
public void launchEdgeBrowser() {
System.out.println("===== Microsoft Edge browser =======");
System.setProperty("webdriver.edge.driver", driverPath+"MicrosoftWebDriver.exe");
driver = new EdgeDriver();
}
@Test(priority=1)
public void openEdgeBrowser() {
driver.navigate().to("http://seleniummansion.blogspot.com/");
}
@Test(priority=2)
public void closeDriver() {
if(driver!=null) {
driver.close();
}
} }
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();
}
}
}
Step 1: Download the geckodriver from ' https://github.com/mozilla/geckodriver/releases '
Step 2: Now you need to specify the system property with the path

                     System.setProperty("webdriver.gecko.driver","path of geckodriver.exe");
                     WebDriver driver = new FirefoxDriver();
Your done...