Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear friends,

I got a problem with webdriver on MAC OS, can not open firefox.
Here below is my code. Firefox version is 45.01 esr.
can anyone help?
Thanks for advance :)

Java
public static void main(String[] args){
    WebDriver driver = null;
    String routerURL = "https://www.google.com/";

    System.setProperty("webdriver.firefox.bin", "/Applications/Firefox.app/Contents/MacOS/firefox-bin");

    System.out.println("ready to open firefox");
    try{
        driver = new FirefoxDriver();
        driver.get(routerURL);
    }catch(Exception e){
        System.out.println("can not open firefox");
        e.printStackTrace();
        driver.close();
    }
    System.out.println("open firefox");
}


Here is the log:
ready to open firefox
can not open firefox
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:199)
	at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
	at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
	at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:91)
	at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
	at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:245)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
	at com.router.crack.routerCrack.main(routerCrack.java:23)
Exception in thread "main" java.lang.NullPointerException
	at com.router.crack.routerCrack.main(routerCrack.java:28)


What I have tried:

I tried to use System.setProperty(), and change firefox version from 48 to 45 esr, but still can not work.
Posted
Comments
David_Wimbley 28-Aug-16 16:27pm    
The exception tells you what to do, you should visit those links and see what they say as to what your problem is.

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

1 solution

1. download the geckodriver package from github
[^]
2. expand the tar file in your path

3. set the geckodriver like this
System.setProperty("webdriver.firefox.marionette", "path/geckodriver");
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900