Getting IllegalStateException when starting Firefox 46.0.1 using Selenium 3.0

I have version Selenium version 3.0.1 and Firefox version 46.0.1. In selenium 3.0.1 changelog mentions that:

Geckodriver is now the default mechanism for automating Firefox. This is the implementation of the Mozilla driver for this browser and is required to automate versions of Firefox version 48 and higher.

Although I get the error message:

java.lang.IllegalStateException: the path to the driver executable file must be set using the webdriver.gecko.driver property; for more information see https://github.com/mozilla/geckodriver . The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases

when executing the code below:

@Test public void test() { WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com"); driver.quit(); } 

Why am I getting this error, however, am I using a version of Firefox <48.0? Is it mandatory to use Geckodriver with Selenium 3.0.1?

The code works fine if I make the following changes:

 System.setProperty("webdriver.gecko.driver","path to geckodriver"); WebDriver driver = new FirefoxDriver(); 
+1
source share
2 answers

You must set the following property for all Firefox browsers, regardless of the version from selenium 3.0 onwards:

 System.setProperty("webdriver.gecko.driver","path to geckodriver"); 

Geckodriver is now the default mechanism for automating Firefox. This is the Mozilla version for the driver for this browser and is required to automate versions of Firefox version 48 and higher.

Setting the path is required.

If you want to run tests in Firefox 47 or earlier, set the puppet parameter of the Firefox driver to false.

 DesiredCapabilities d = new DesiredCapabilities(); d.setCapability("marionette", false); // to disable marionette. WebDriver driver = new FirefoxDriver(d); 
+1
source

The link you provided is for dotnet. Here is Changelog for Java

  • Firefox is fully supported only in version 47.0.1 or earlier. Support for later versions of firefox is provided by geckodriver, which is based on the evolving W3C WebDriver specification and uses the wire protocol in this specification, which is subject to change without notice.
  • You can choose an ESR release such as 45.4.0esr or earlier.
  • Firefox 47.0.0 is not supported at all.
0
source

Source: https://habr.com/ru/post/1259916/


All Articles