1

I created a MavenTestProject in Eclipse with these dependencies:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>
</dependencies>

In MyTest01.java I tried to instantiate the FirefoxDriver:

WebDriver driver = new FirefoxDriver();

and I got this error:

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property;...

I tried this code, but it didn't work also:

System.setProperty("webdriver.gecko.driver", "selenium-firefox-driver-3.141.59.jar");
WebDriver driver = new FirefoxDriver();

I got this error:

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\Users\ofiman\eclipse-workspace\MavenTestProject\selenium-firefox-driver-3.141.59.jar

What can I do to get an instance of my FireFoxDriver?

Thanks in advance.

ofiman
  • 21
  • 2
  • Do you have gecko driver installed? is it in your path? – Gus Nov 15 '18 at 15:55
  • The Maven Dependencies contain the selenium-firefox-driver and some other drivers for browsers. – ofiman Nov 15 '18 at 15:59
  • Check this one - https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr?rq=1 – Dhamo Nov 15 '18 at 16:00

2 Answers2

1
System.setProperty("webdriver.gecko.driver", "path where your gecko driver is in your local");
WebDriver driver = new FirefoxDriver();

Let me know if this does'nt work

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Prp
  • 51
  • 5
0

webdriver.gecko.driver needs to be a path to geckodriver.

elken
  • 556
  • 4
  • 11
  • What's the difference between geckodriver and selenium-firefox-driver? – ofiman Nov 15 '18 at 16:00
  • 1
    @ofiman https://stackoverflow.com/questions/52197632/what-is-the-difference-between-webdriver-firefox-and-webdriver-firefoxpath-t – Manoj Kengudelu Nov 15 '18 at 16:10
  • @ofiman Gecko driver is the current most updated driver for newer versions of Firefox – Gus Nov 15 '18 at 17:31
  • @ofiman selenium-firefox-driver is the library that uses geckodriver. Geckodriver is essentially Firefox without the GUI. – elken Nov 16 '18 at 08:20