c# - Selenium 3.14.0 + BrowserStack - Webdriver 异常 - 接收失败和实例化失败

c# - Selenium 3.14.0 + BrowserStack - Webdriver exception - Receive failure and instantiation fails

我最近从 3.9.1 升级到 Selenium 3.14。现在每次 运行,我都会在尝试实例化 webdriver 时遇到错误。下面是它失败并抛出异常的行。

当我降级到 3.9.1 时它工作正常。有什么我想念的吗?有人以前看过这个吗?

我正在使用 c# + Spec flow + BrowserStack 网格。

如果您需要更多信息,请告诉我。这是我第一次 post 搜索和研究但找不到有关此错误的任何信息。

_driver = new RemoteWebDriver(new Uri("http://" + browserStackConfig["BSserver"] + "/wd/hub/"), capability,  new TimeSpan(0,0,30));


Result Message: 
OneTimeSetUp: OpenQA.Selenium.WebDriverException : A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://hub-cloud.browserstack.com/wd/hub/session. The status of the exception was ReceiveFailure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.
  ----> System.Net.WebException : The underlying connection was closed: An unexpected error occurred on a receive.
  ----> System.IO.IOException : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
  ----> System.Net.Sockets.SocketException : An existing connection was forcibly closed by the remote host

Selenium 在 7 月 25 日进行了更改,以从 HttpCommandExecutor class 公开 Proxy 属性(下面是 link)。您会期望如果没有传递代理,那么 Selenium 将使用默认 Web 代理。不是这种情况。代理被设置为空,这将导致执行程序在实例化驱动程序时失败。

https://github.com/SeleniumHQ/selenium/commit/52969e49a16efee7efb52893addde19605162a66#diff-bc8a75c5cb22ca86093a1bbced41a6ee

修复: 我对代码进行了简单更改以传递默认 Web 代理。下面是代码片段。这解决了我的问题。

 var executor = new HttpCommandExecutor(new Uri("http://" + browserStackConfig["BSserver"] + "/wd/hub/"), new TimeSpan(0, 0, 0, 30));
 executor.Proxy = WebRequest.DefaultWebProxy;
 _driver = new RemoteWebDriver(executor, capability);