OS: Ubuntu 16.04
Selenium Version: 3.0.1
Browser: Firefox
Browser Version: 45.0.2
When call new FirefoxDriver(firefoxBinary, firefoxProfile, capabilities) new driver is opened
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.
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
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);
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: