Я разработал несколько тестов Selenium для сайта AngularJS. Эти тесты работают нормально, используя Chrome Driver и Firefox Driver. Я также добавляю опцию для запуска этих тестов в Inte rnet Explorer Driver. Большую часть времени тесты работают и в Inte rnet Explorer, но я испытывал следующее исключение более пяти раз:
OpenQA.Selenium.WebDriverException: 'Было сгенерировано исключение с нулевым ответом отправка HTTP-запроса на удаленный сервер WebDriver для URL http://localhost: 53472 / session / 4a73e505-772d-4ef0-beeb-cc15e8b1e647 / elements . Состояние исключения было KeepAliveFailure, и сообщение было следующим: Основное соединение было закрыто: Соединение, которое, как ожидали, будет поддерживаться живым, было закрыто сервером. '
Внутреннее исключение
WebException : Базовое соединение было закрыто: соединение, которое, как предполагалось, будет поддерживаться в рабочем состоянии, было закрыто сервером.
При первом возникновении этого исключения тесты продолжались в течение нескольких минут; во второй раз тесты продолжались более 3 часов и были близки к завершению.
Возможно соответствующая информация:
IEDriver инициализируется следующим образом:
InternetExplorerOptions options = new InternetExplorerOptions
{
EnsureCleanSession = true,
EnableNativeEvents = true
};
InternetExplorerDriverService driverService = InternetExplorerDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
IWebDriver webDriver = new InternetExplorerDriver(driverService, options);
Строка моего кода, которая обычно вызывает исключение:
ICollection<IWebElement> webElementsIncludingDisabled = searchContext
.FindElements(pageElement.By);
где searchContext
- это драйвер, а селектор - простой CssSelector.
Соответствующая часть трассировки стека:
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)
Один случай, подобное исключение вместо этого вызвано строкой в моем коде:
webElement.SendKeys(toSend);
Соответствующая часть трассировки стека будет:
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:50818/session/72b73c2e-d7b2-4e2d-be83-54c343db4109/element/aef8dad2-4c50-41a1-aa36-34957765812a/value. 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.RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters)
...
This exception was originally thrown at this call stack:
System.Net.Sockets.NetworkStream.Read(byte[], int, int)
Inner Exception 1:
WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
Inner Exception 2:
IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Inner Exception 3:
SocketException: An existing connection was forcibly closed by the remote host
Что может быть причиной этого проблема?
Есть ли способ повлиять на тайм-аут Keep Alive, который использует сервер WebDriver?
Связано ли это с webDriver.Manage (). Timeouts (). PageLoad timeout (в настоящее время по умолчанию)?
Если вместо этого я попытаюсь использовать 64-битную версию IEDriver (версия 3.141.59), у меня возникла другая проблема: селен всегда не появляется для связи с браузером после начальной загрузки страницы. Строка, которая фактически выдает исключение в моем коде, -
WebDriver.Url = expectedURL;
, хотя из-за наблюдения две попытки SendKeys и Click уже были безуспешными.
Соответствующая часть трассировка стека:
OpenQA.Selenium.WebDriverException
HResult=0x80131500
Message=The HTTP request to the remote WebDriver server for URL http://localhost:55918/session/988d31c6-feb8-4cf0-8335-7c9eaecef6d1/url timed out after 60 seconds.
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) ...
This exception was originally thrown at this call stack:
System.Net.HttpWebRequest.GetResponse()
OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(OpenQA.Selenium.Remote.HttpCommandExecutor.HttpRequestInfo)
Inner Exception 1: WebException: The request was aborted: The operation has timed out.
Я полагаю, что эта проблема 64-битной версии та же проблема, что и драйвер Selenium IE, зависший после перехода к URL