c# - Selenium 3.14.0 + 浏览器堆栈 - Web 驱动程序异常 - 接收失败和实例化失败



我最近从3.9.1升级到Selenium 3.14。现在每次我运行时,我都会在尝试实例化网络驱动程序的地方出现以下错误。下面是它失败并抛出 expection 的行。

当我降级到 3.9.1 时,它工作正常。我错过了什么吗?以前有人见过这个吗?

我正在使用 c# + 规范流 + 浏览器堆栈网格。

如果您需要更多信息,请告诉我。这是我的第一篇文章,已经用谷歌搜索和研究了,但找不到有关此错误的任何信息。

_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 类的代理属性(下面是链接(。你会期望,如果没有通过代理,那么Selenium将使用默认Web代理。事实并非如此。代理设置为 null,这将导致执行程序在实例化驱动程序时失败。

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);

相关内容

  • 没有找到相关文章

最新更新