【发布时间】:2020-09-30 19:52:27
【问题描述】:
我最近从 3.9.1 升级到 Selenium 3.14。现在每次我运行时,我都会在尝试实例化 webdriver 时遇到错误。下面是它失败并引发异常的行。
当我降级到 3.9.1 时,它工作正常。有什么我想念的吗?有人见过这个吗?
我正在使用 c# + Spec flow + BrowserStack 网格。
如果您需要更多信息,请告诉我。这是我的第一篇文章,已经通过谷歌搜索和研究,但找不到有关此错误的任何信息。
_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
【问题讨论】:
-
这很可能与您的 HTTP 请求未使用 TLS 1.2 有关。您可以明确强制您的客户端使用 TLS 1.2 并重新运行您的测试吗?您可以参考以下链接:stackoverflow.com/questions/45382254/…
-
我尝试强制使用 TLS 1.2。通过在代码中添加以下行。我仍然有同样的问题。不幸的是,我目前无法升级到 4.6 .Net 框架。我在 4.5.1 .Net Framework System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
-
由于您在升级到最新的 selenium 客户端绑定后才开始看到错误,因此客户端绑定使用的 http 库很可能没有发送使用 TLS 1.2 的请求。您可以使用诸如 wireshark 或 fiddler 之类的拦截工具来确定相同的情况,并根据您的发现在 github 或 browserstack 上使用 Selenium 打开一张票。
-
@BountyHunter - 非常感谢。我发现了导致此问题的原因。在下面发布了答案。
标签: selenium selenium-webdriver browserstack