ChromeDriver在启动时失败

时间:2016-11-02 14:08:15

标签: selenium selenium-chromedriver

当我尝试启动Selenium测试时,我收到了失败和以下错误消息。

OpenQA.Selenium.WebDriverException was unhandled by user code
HResult=-2146233088
Message=A exception with a null response was thrown sending an HTTP        
request to the remote WebDriver server for URL http://localhost:55754 
/session. The status of the exception was ReceiveFailure, and the message  
was: The underlying connection was closed: An unexpected error occurred   
on a receive.
Source=WebDriver

 InnerException: 
   HResult=-2146233079
   Message=The underlying connection was closed: An unexpected error occurred on a receive.
   Source=System
   StackTrace:
        at System.Net.HttpWebRequest.GetResponse()
        at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
   InnerException: 
        HResult=-2146232800
        Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
        Source=System
        StackTrace:
             at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
             at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
             at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
        InnerException: 
             ErrorCode=10054
             HResult=-2147467259
             Message=An existing connection was forcibly closed by the remote host
             NativeErrorCode=10054
             Source=System
             StackTrace:
                  at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
                  at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
             InnerException: 

这是失败的代码,它已经好几个月了。

ChromeOptions选项=新的ChromeOptions();             // ChromeDriver驱动程序=新的C​​hromeDriver(@“C:\ Program Files(x86)\ SeleniumDrivers”,选项);             //// Driver = new ChromeDriver(选项);
            options.AddArgument( “ - 禁用扩展”);             Driver = new ChromeDriver(选项);

1 个答案:

答案 0 :(得分:0)

卸载ChromeDriver和WebDriver nuget软件包,然后重新安装。