首页 > 解决方案 > 无法通过 Jenkins 执行 NUnit Selenium 测试 - 目标机器主动拒绝连接

问题描述

我正在尝试通过 Jenkins 使用 NUnit 执行用 C#.NET 编写的 Selenium 测试,但显示以下错误消息:

-> error: Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:13748 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

我在 Jenkins 中的构建配置如下: 在此处输入图像描述

该解决方案似乎构建成功,但同样,在执行测试时,我收到上述错误消息。

注意:我检查了我的防火墙设置,并且允许 Jenkins 通过防火墙。

任何反馈将不胜感激。

标签: c#.netseleniumjenkins

解决方案


Selenium 在测试运行 (BeforeTestRun) 之前被实例化。这意味着在第一个测试之后执行的任何后续测试都不会引用 WebDriver 的实例,因为它没有在场景开始时重新实例化。


推荐阅读