对于管理面板上的一些常规工作,我们有一个自动的硒解决方案.它一直在工作,直到昨天突然破裂.导航很好:
driver.Navigate().GoToUrl(url); // this works just fine
但是,此行中断:
var inputs = driver.FindElements(By.CssSelector("input"));
异常消息是:
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:2110
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)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
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.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByCssSelector(String cssSelector)
at OpenQA.Selenium.By.<>c__displayClass1e.<CssSelector>b__1c(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
我不知道这个问题的原因是什么.由于Chrome的63版本强制执行HSTS,因此我认为chromedriver.exe可能存在问题,因为Chrome 63发生了巨大变化.请提供帮助.
解决方法:
西服的评论似乎是正确的(谢谢).我安装了最新的WebDriver nuget软件包,但没有最新的chromedriver.exe.版本2.34已修复它.