对远程 WebDriver 服务器的 URL http://localhost:6444/session 的 HTTP 请求在 60 秒后超时

对远程 WebDriver 服务器的 URL http://localhost:6444/session 的 HTTP 请求在 60 秒后超时

问题描述:

我目前在使用 selenium 初始化 Firefox 时遇到问题.这个问题似乎只发生在我的 Windows Server 2012 r2 上,因为我在我的本地机器(Windows 10)上尝试了相同的配置并且它没有问题.

I am currently facing a problem in initializing Firefox in selenium. This issue seems to be only happening to me on Windows Server 2012 r2 as I have tried the same configuration on my local machine (windows 10) and it worked without a problem.

我目前正在使用此代码 (C#):

I am currently using this code (C#):

 FirefoxDriverService service = FirefoxDriverService.CreateDefaultService("Path to Drivers folder", "geckodriver.exe");
                    service.Port = 6444;
                    service.FirefoxBinaryPath = "Firefox installation path";
                    ffDriver = new FirefoxDriver(service);

但是,它返回此错误:

OpenQA.Selenium.WebDriverException:对远程的 HTTP 请求URL http://localhost:6444/session 的 WebDriver 服务器超时后60 秒.---> System.Net.WebException: 操作已超时

OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:6444/session timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out

正在使用的当前版本:

  • Firefox 56.0 64 位
  • 硒 3.5.1
  • Geckodriver v0.19.0 64 位

有人可以指导我解决这个问题吗?

Can someone please guide me through this issue?

在启动 FirefoxDriver 的代码中添加这个

Add this in code on Launching FirefoxDriver

通过引用这个 答案

  ffDriver=   new FirefoxDriver(new FirefoxBinary(),new FirefoxProfile(),TimeSpan.FromSeconds(120));