Selenium 2.53.1 不适用于 FireFox 48

Selenium 2.53.1 does not work on FireFox 48

我正在使用 selenium 来测试我们的网站。当我构建项目时,出现异常:-

OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000 milliseconds. Attempted to connect to the following addresses: 127.0.0.1:7055 and the problem is from the code

IWebDriver driver = new FirefoxDriver();

有人知道如何解决这个问题吗?

就像其他浏览器供应商提供的可用于 Selenium 的其他驱动程序一样,Mozilla 已经发布了一个可执行文件,它将 运行 与浏览器一起使用。

您可以从 here

下载最新的可执行 geckodriver

将下载的可执行 geckodriver 添加到系统路径

Selenium 客户端绑定将尝试从系统路径中找到 geckodriver(或 wire)可执行文件。您需要将包含可执行文件的目录添加到系统路径。

  • 在 Unix 系统上,如果您使用 bash-compatible shell,您可以执行以下操作将其附加到系统的搜索路径中:

    export PATH=$PATH:/path/to/directory/of/executable/downloaded/in/previous/step
    
  • 在 Windows 上,您需要更新 Path 系统变量以将完整目录路径添加到可执行 geckodriver。原理与Unix相同

完成上述所有内容后,您需要如下初始化 FireFoxDriver :-

var driver = new FirefoxDriver(new FirefoxOptions());

注意 :- 用其他编程语言解决这个问题。

这个答案对我不起作用。 运行 selenium 2.53.6 和 firefox 47 n 48。

我建议下载 firefox 46,它似乎最适合 selenium 2。53.x。

https://ftp.mozilla.org/pub/firefox/releases/46.0.1/win64/en-US/

一旦我降级到 firefox 46.0.1,一切都按预期工作。