我已经为AngularJS网站开发了一些Selenium测试。使用Chrome驱动程序和Firefox驱动程序,这些测试可以正常工作。我还在添加选项以在Internet Explorer驱动程序中运行这些测试。大多数时候,测试也可以在Internet Explorer中运行,但是我两次遇到以下异常:
OpenQA.Selenium.WebDriverException:'引发了具有空响应的异常,该异常将HTTP请求发送到URL http://localhost:53472/session/4a73e505-772d-4ef0-beeb-cc15e8b1e647/elements的远程WebDriver服务器。异常的状态为KeepAliveFailure,并且消息为:基础连接已关闭:服务器关闭了预期保持活动状态的连接。'
内部异常
WebException:基础连接已关闭:预期会保持活动状态的连接已被服务器关闭。
第一次发生此异常,测试已经进行了几分钟;第二次,测试已经运行了3个多小时,并且接近完成。
可能相关的信息:
IE版本:11.778.18362.0
Selenium Version:3.141.0
Selenium IE驱动程序(32位)版本:3.150.1
在最近一次运行中导致异常的代码行是:
ICollection<IWebElement> webElementsIncludingDisabled = searchContext
.FindElements(pageElement.By);
其中searchContext
是驱动程序,选择器是简单的CssSelector。
IEDriver的初始化如下:
InternetExplorerOptions options = new InternetExplorerOptions
{
EnsureCleanSession = true,
EnableNativeEvents = true
};
InternetExplorerDriverService driverService = InternetExplorerDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
IWebDriver webDriver = new InternetExplorerDriver(driverService, options);
stacktrace的相关部分是:
OpenQA.Selenium.WebDriverException
HResult=0x80131500
Message=A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:53472/session/4a73e505-772d-4ef0-beeb-cc15e8b1e647/elements. The status of the exception was KeepAliveFailure, and the message was: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
Source=WebDriver
StackTrace:
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElements(String mechanism, String value)
什么可能导致此问题?
有没有一种方法可以影响WebDriver服务器使用的Keep Alive超时?
这与webDriver.Manage()。Timeouts()。PageLoad超时有关(当前为默认值)吗?>>
我已经为AngularJS网站开发了一些Selenium测试。使用Chrome驱动程序和Firefox驱动程序,这些测试可以正常工作。我还在添加选项以在...
在一个旧线程中,我发现如果您尝试减小轮询间隔,则可以解决此问题。