1

am unable to open browser using geckodriver 3.8.1 and selenium oxygen and firefox 57.0.4(32 bit) version

package Selenium_JavaFundamentals;

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

public class opengmail {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        WebDriver driver = new FirefoxDriver();

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

I am getting following 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:754) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124) at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41) at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:141) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339) at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:158) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:98) at Selenium_JavaFundamentals.opengmail.main(opengmail.java:10)

Please note that I have loaded the gecko driver.

Paul Karam
  • 4,052
  • 8
  • 30
  • 53
john dst
  • 11
  • 3

4 Answers4

0

You need to explicitly tell it where the WebDriver is. Like this:

package Selenium_JavaFundamentals;

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



    public class opengmail {

        public static void main(String[] args) {
            // TODO Auto-generated method stub
            WebDriver driver = new FirefoxDriver();
            System.setProperty("webdriver.gecko.driver", "/path/to/geckoDriver.exe");"
            driver.get("https://www.google.com");
        }    
}
0

From some research, I came across that

WebDriver uses native browser approach. Selenium offers inbuilt driver for Firefox but not for other browsers. All drivers (Chrome Driver, IE driver, etc.) are built based on the special JS Engine used by each browser.

So I suppose

System.setProperty("webdriver.gecko.driver","/path/to/geckoDriver.exe");"

isn't required for Firefox after all.

What seems to be the issue here is broken Firefox installation in your machine. Scrub your current installation completely and do a fresh install of the compatible Firefox. (Optional- Also you can put the Firefox.exe path in your PATH in Environment Variables.)

hiren
  • 1,067
  • 1
  • 9
  • 16
  • 1
    Your research is no longer correct. At some point in the past a separate driver was introduced and is now required even from Firefox. – SiKing Jan 11 '18 at 16:02
0

For this issue, i simply downgraded my firefox browser version- 43 this issue got resolved after downgrading the browser

Yogeshk
  • 1
  • 3
0

Set the geckodriver.exe location first before initializing the FirefoxDriver.

For selenium 3.x with Firefox

System.setProperty("webdriver.gecko.driver", "path.to.geckodriver.exe");  
WebDriver driver = new FirefoxDriver();
Beam
  • 68
  • 9