Can’t open browser with Selenium after Firefox update

As of Firefox version 47.0 (which came out a little while a go), a new driver must be used (created by mozilla instead of selenium) to connect to Firefox, because of a bug introduces in this version. As of Firefox version 48.0 the old driver will be deprecated completely and only Marionette can be used so it is better to switch now. See: Marionette Webdriver for Firefox

Download the driver (in OSX just use brew install geckodriver), rename the executable to wires.exe on windows, or wires on *nix systems, and make sure the executable is present in your system path, then use this driver in your program instead of the old driver by using the following:

When using a local webdriver:

Python:

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True

driver = webdriver.Firefox(capabilities=firefox_capabilities)

Ruby:

driver = Selenium::WebDriver.for :firefox, marionette: true

Javascript:

var capabilities = Capabilities.firefox();
capabilities.set('marionette', true);

var driver = new webdriver.Builder().withCapabilities(capabilities).build();

Java:

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
Webdriver driver = new FirefoxDriver(capabilities);

C#:

var driver = new FirefoxDriver(new FirefoxOptions());

When using selenium grid:

When using a selenium grid the driver should be present in the path for all machines in your grid.

Python:

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
driver = webdriver.Firefox(capabilities=firefox_capabilities)

Ruby:

caps = Selenium::WebDriver::Remote::Capabilities.firefox marionette: true
driver = Selenium::WebDriver.for :firefox, desired_capabilities: caps

Java:

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
// Set Marionette on so the Grid will use this instead of normal FirefoxDriver
capabilities.setCapability("marionette", true);

WebDriver driver = new RemoteWebDriver(capabilities); 

C#:

DesiredCapabilities capabilities = DesiredCapabilities.Firefox();
// Set Marionette on so the Grid will use this instead of normal FirefoxDriver
capabilities.SetCapability("marionette", true);

var driver = new RemoteWebDriver(capabilities); 

Leave a Comment