Selenium: FirefoxDriver fails to construct with existing FirefoxBinary

Created on 24 Jan 2017  路  1Comment  路  Source: SeleniumHQ/selenium

Meta

OS: Ubuntu 16.04

Selenium Version: 3.0.1

Browser: Firefox

Browser Version: 45.0.2

Expected Behavior

When call new FirefoxDriver(firefoxBinary, firefoxProfile, capabilities) new driver is opened

Actual Behavior

Although the firefoxBinary actually exists (i.e. it's not null), FirefoxDriver fails to construct with error message java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property.

Imo, the problem is here org.openqa.selenium.firefox.GeckoDriverService.Builder#Builder(org.openqa.selenium.firefox.FirefoxBinary). This constructor sets the binary field, but doesn't set its' super field org.openqa.selenium.remote.service.DriverService.Builder#exe. Thus call to org.openqa.selenium.remote.service.DriverService.Builder#build fails.

Steps to reproduce

String path = "/usr/bin/firefox";
String display = ":0";

FirefoxProfile profile = new FirefoxProfile(); // here was createDefaultFirefoxProfile();
FirefoxBinary binary = new FirefoxBinary(new File(path));

binary.setEnvironmentProperty("DISPLAY", display);
WebDriver driver = new FirefoxDriver(binary, profile, cap);

This code works perfectly in Selenium 2.53.1

Most helpful comment

Fixed in 3.3.1

Please note that we've changed driver construction API, it's recommented to init the driver with the brand-new constructor:

FirefoxOptions options = new FirefoxOptions()
        .setBinary(new FirefoxBinary(path));
WebDriver driver = new FirefoxDriver(options);

>All comments

Fixed in 3.3.1

Please note that we've changed driver construction API, it's recommented to init the driver with the brand-new constructor:

FirefoxOptions options = new FirefoxOptions()
        .setBinary(new FirefoxBinary(path));
WebDriver driver = new FirefoxDriver(options);
Was this page helpful?
0 / 5 - 0 ratings