Sunday, July 23, 2017

Code to open firefox with selenium 3.4 using GeckoDriver 1.8


package test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class testing {

    public static void main(String[] args) throws InterruptedException {
 // Download the geckodriver based on the firefox if it is 32 bit or 64
 // bit installed in the machine
 // Save the driver and provide path of the exe for geckodriver
 System.setProperty("webdriver.gecko.driver", "E:\\Selenium\\geckodriver-v0.18.0-win64\\geckodriver.exe");
 // define the capabilities of firefox browser with marionette set as true
 DesiredCapabilities capabilities = DesiredCapabilities.firefox();
 capabilities.setCapability("marionette", true);
 // create an instance of firefox driver
 WebDriver driver = new FirefoxDriver(capabilities);
 driver.get("http://www.rediff.com");
 driver.quit();
    }
}

No comments:

Post a Comment