As announced some time ago, FirefoxDriver will no longer work after Firefox 47 has been released. There are 2 options;
- Downgrade Firefox (version < 47)
- Implement Marionette Driver. (Marionette WebDriver)
This blogpost will cover the implementation of Marionette Driver. Luckily it’s not too hard to switch to Following these steps:MarionetteDriver
.
- Download Marionette Driver
- Extract the file
- Set the
webdriver.gecko.driver
property to the location path of Marionette driver - Adjust the code, to something like this:
@BeforeClass public void startFirefox() { System.setProperty("webdriver.gecko.driver", "path/to/geckodriver"); final WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com"); }
Alternatively, we can implement a method to find the file on path:
private static String findFileOnPath(final String fileName) { return MarionetteDriverTest.class.getClassLoader().getResource(fileName).getPath(); }
MarionetteDriverTest
is the classname.
And use it like this:
@BeforeClass public void startFirefox() { System.setProperty("webdriver.gecko.driver", findFileOnPath("geckodriver")); //assuming the file is located in the resources folder final WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com"); }
I use the WebDriverManager https://github.com/bonigarcia/webdrivermanager
It makes the setup platform and device independent.