c# - Selenium :意外错误。 System.Net.WebException:无法连接到远程服务器

标签 c# asp.net selenium iis

我有一个网络 API 应用程序。应用程序的某些方法运行 chromedriver 并进行一些操作(例如点击和截屏)

在 Visual Studio 下应用程序运行良好。 但是当我将我的应用程序发布到 IIS 时,应用程序抛出异常

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:51149 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)

如何解决?

我在 StackOverflow 上看到了一些熟悉的问题,但没有找到答案。

最佳答案

我遇到这个问题是因为驱动程序 .quit 在最后一个方法调用之前执行的方法中。通过从现有页面对象方法中删除 driver.quit 并将其放在测试方法的末尾来修复。完美开始工作

关于c# - Selenium :意外错误。 System.Net.WebException:无法连接到远程服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46647306/

相关文章:

selenium - Behat 我按 "Button"不工作

Java + Selenium : How to know if WebElement is clickable in a way other than isDisplayed, isEnabled 和 findElement?

c# - Aero Glass 按钮像 Windows Media Player?

c# - 这种聚合设计模式有名称吗?

c# - 显示名称为 'VJSharpCodeProvider' 的程序集加载失败

asp.net - 如何让 jqGrid 在后端使用 ASP.NET + JSON 工作?

c# - 如何获取要在 MVC 2 中显示的位图图像

c# - 为什么在资源字符串中放入\t​​ 不起作用

asp.net - ASP.NET 中的数据访问 : In-memory collection vs database

java - 等待结果并不总是一样