I\'m using Firefox 47.0 with Selenium 2.53. Recently they have been a bug between Selenium and Firefox which make code not working. One of the solution is to use the Marion
You can handle the Firefox driver automatically using WebDriverManager.
This library downloads the proper binary (geckodriver) for your platform (Mac, Windows, Linux) and then exports the proper value of the required Java environment variable (webdriver.gecko.driver).
Take a look at a complete example as a JUnit test case:
public class FirefoxTest {
private WebDriver driver;
@BeforeClass
public static void setupClass() {
WebDriverManager.firefoxdriver().setup();
}
@Before
public void setupTest() {
driver = new FirefoxDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
// Your test code here
}
}
If you are using Maven you have to put at your pom.xml
:
io.github.bonigarcia
webdrivermanager
4.2.2
WebDriverManager does magic for you:
So far, WebDriverManager supports Chrome
, Opera
, Internet Explorer
, Microsoft Edge
, PhantomJS
, and Firefox
.