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:
io.github.bonigarcia webdrivermanager 5.1.0
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.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3