-3

Prog

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


public class login {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.setProperty("webdriver.gecko.driver","C:\\Users\\Vishal\\Downloads\\geckodriver.exe");
       WebDriver driver=new FirefoxDriver();

  driver.get("https://www.facebook.com");

    }

}

Error

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
    at com.google.common.base.Preconditions.checkState(Preconditions.java:847)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:125)
    at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:43)
    at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:168)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:346)
    at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:168)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
    at login.main(login.java:8)
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
chandru
  • 1
  • 2

1 Answers1

0

If you are using the latest version of Gecko and a recent version of Firefox, your answer might be here.

To resume, try something like this (if the path to GeckoDriver is correct) :

public static void main(String[] args) throws InterruptedException {
    System.setProperty("webdriver.gecko.driver", "yourGeckoPath");
    FirefoxOptions capabilities = new FirefoxOptions();
    capabilities.setCapability("marionette", true);
    WebDriver driver = new FirefoxDriver(capabilities);
    driver.get("http://www.facebook.com");

    Thread.sleep(5000);
    driver.quit();
}
Azrix
  • 99
  • 1
  • 10