我似乎遇到了一组测试问题,只有在远程运行时才试图与特定元素交互。我正在通过VSTS来构建和运行它。仅在远程运行时通过Selenium测试中途抛出WebDriverException
错误:
OpenQA.Selenium.WebDriverException: A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL (URL redacted, is a localhost URL). 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
为我想输入一个数字元素(我们使用淘汰赛)的HTML:
<input type="number" min="0" max="999" data-bind="value: redacted).extend({ min: 0, required: { message: 'redacted' } }), disable: redacted" name="redacted" id="redacted" title="redacted" required="required" class="">
不介意redacted
。我想留下那里的所有属性来显示为元素设置了哪些属性,但是实际值被编辑了。
这是我使用的输入值到元素的代码:
IWebElement element = driver.FindElement(By.Id(elementID));
element.Clear();
element.SendKeys(value);
这与ChromeDriver运行。还有其他几个数字字段,我可以在没有问题的情况下成功填充数据。
任何想法这里可能会出错,以及如何解决它?
你是什么意思远程运行?在机器中调用/运行测试,但测试是在远程机器上执行还是在同一个远程机器上调用/运行并执行测试?如果您在本地机器上运行测试,结果如何?特定元素的细节是什么? –
@ starain-MSFT它在VSTS中调用,并在远程构建服务器上运行。在本地运行时,我从未遇到过这个问题。我不确定“什么是特定元素的细节”是什么意思,我已经在这里展示了这个元素的HTML。 – tnw
关于特定的元素,你的意思是它适用于其他元素吗?构建代理是否以交互模式运行?另一方面,它在本地运行时工作正常,如果您手动在该构建服务器上运行它,结果如何? –