Home >Java >javaTutorial >Why Does Selenium 2.53.0 Encounter a Connection Error When Using Firefox 47?

Why Does Selenium 2.53.0 Encounter a Connection Error When Using Firefox 47?

Susan Sarandon
Susan SarandonOriginal
2024-11-11 10:10:03522browse

Why Does Selenium 2.53.0 Encounter a Connection Error When Using Firefox 47?

Selenium 2.53 Incompatibility with Firefox 47

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:

  • Firefox Version: 47.0
  • Selenium Version: 2.53.0
  • Operating System: Windows 10, 64-bit

Resolution

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn