While utilizing Selenium WebDriver 2.53.0, an error is encountered:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
Relevant System Information:
Selenium WebDriver 2.53.0 is incompatible with Firefox 47.0. As of version 3.0, Selenium WebDriver relies on the geckodriver binary for managing Firefox browsers.
To resolve the issue, download the Firefox driver (geckodriver). Set the system property "webdriver.gecko.driver" to the absolute path of the geckodriver binary in your Java code:
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");
Utilize the WebDriverManager library to automate this process:
<dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>5.1.0</version> </dependency>
WebDriverManager.firefoxdriver().setup();
Complete Example:
public class FirefoxTest { protected 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() { // Test code goes here } }
Note: Marionette is the recommended option for Firefox versions 48 and Selenium WebDriver 3 .
Update:
Selenium WebDriver version 2.53.1 has been released, restoring compatibility with Firefox 47.0.1.
The above is the detailed content of Why Does Selenium 2.53.0 Encounter a Connection Error When Using Firefox 47?. For more information, please follow other related articles on the PHP Chinese website!