使用 SeleniumWebDriver 在 TFS 生成期间进行 UI 测试

本文关键字:UI 测试 SeleniumWebDriver TFS 使用 | 更新日期: 2023-09-27 18:37:25

我有一组UI测试,这些测试仅从Visual Studio本地执行。决定将它们集成到 TFS 中,并在每晚生成时执行测试运行。

这是我在第一次测试中得到的例外:

OpenQA.Selenium.WebDriverException:对远程的HTTP请求 URL http://localhost:64737/session超时的 Web 驱动程序服务器 60秒后。---> System.Net.WebException:该操作具有 超时

此例外适用于其余测试:

OpenQA.Selenium.WebDriverException:意外错误。 System.Net.Web异常:无法连接到远程服务器---> System.Net.Sockets.SocketException:无法建立任何连接 因为目标计算机主动拒绝了它 127.0.0.1:64861 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, 套接字地址套接字地址) 在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& 异常)---内部异常堆栈跟踪结束--- System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command 命令执行) at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command 命令执行) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary'2 参数)

知道我做错了什么吗?

使用 SeleniumWebDriver 在 TFS 生成期间进行 UI 测试

我假设您正在使用网格来执行测试。而且,它准确地告诉你发生了什么。 System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:64861

如果没有进一步的细节,则假设您没有正确指向该网站。您的网址可能有误

您需要将 Web 应用程序部署到生成服务器。

默认情况下,Visual Studio将启动Web服务器或使用IIS(取决于您的配置方式)来动态运行您的网站。在默认情况下不部署代码的生成服务器上,情况并非如此。该网站在该端口上不存在。