Rumah  >  Artikel  >  Java  >  Mengapa Selenium 2.53.0 Menghadapi "NotConnectedException" dengan Firefox 47.0?

Mengapa Selenium 2.53.0 Menghadapi "NotConnectedException" dengan Firefox 47.0?

Mary-Kate Olsen
Mary-Kate Olsenasal
2024-11-14 11:06:02340semak imbas

Why Does Selenium 2.53.0 Encounter a

FirefoxDriver Compatibility with Selenium 2.53

When using Selenium WebDriver 2.53.0 with Firefox 47.0, an error like the following may occur:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms.

This issue arises due to the incompatibility of Selenium WebDriver 2.53.0 with Firefox 47.0. The discontinued FirefoxDriver component, which handled Firefox browsing, has been replaced with the need for the geckodriver binary to manage Firefox browsers in Selenium WebDriver 3.0 and later.

Solution:

To address this problem, follow these steps:

  1. Download GeckoDriver: Get the Firefox driver binary (geckodriver) compatible with your system from here.
  2. Set System Property: Export the absolute path to the geckodriver binary as a system property named "webdriver.gecko.driver":
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");

Alternatively, you can use the WebDriverManager library to simplify the process:

  1. Add Dependency: Include the following dependency in your project's pom.xml file:
<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>5.1.0</version>
</dependency>
  1. Setup GeckoDriver: Execute the following line before using WebDriver:
WebDriverManager.firefoxdriver().setup();

Note:

  • Marionette will eventually become the sole option for browser management in future releases of Selenium WebDriver and Firefox.
  • Selenium WebDriver 2.53.1, released on June 30, 2016, resolved the issue, allowing FirefoxDriver to work again with Firefox 47.0.1.

Atas ialah kandungan terperinci Mengapa Selenium 2.53.0 Menghadapi "NotConnectedException" dengan Firefox 47.0?. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn