升级到版本3.9

时间:2018-02-20 23:31:25

标签: c# unit-testing selenium webdriver iedriverserver

here更新到IEDriverServer 3.9 for 64-bit后,我在尝试使用IE运行任何测试时遇到以下异常(版本:11.0.9600.17842,Win8.1)。有谁知道怎么解决这个问题,还是应该降级回3.8?

  

OpenQA.Selenium.WebDriverException:具有空响应的异常   被抛出向远程WebDriver服务器发送HTTP请求   网址http://localhost:53379/session

     

例外的状态是   ReceiveFailure,消息是:底层连接是   已关闭:接收时发生意外错误。 ---->

     

System.Net.WebException:底层连接已关闭:An   接收时发生意外错误。 ----> System.IO.IOException   :无法从传输连接中读取数据:现有数据   连接被远程主机强行关闭。 ---->   System.Net.Sockets.SocketException:现有连接是   被远程主机TearDown强行关闭:   System.NullReferenceException:对象引用未设置为   对象的实例。

堆栈跟踪如下:

  

结果StackTrace:at   OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo   requestInfo)at   OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(命令   commandToExecute)at   OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(命令   commandToExecute)at   OpenQA.Selenium.Remote.RemoteWebDriver.Execute(字符串   driverCommandToExecute,Dictionary`2参数)at   OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities   desiredCapabilities)   OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor   commandExecutor,ICapabilities desiredCapabilities)at   OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService   服务,InternetExplorerOptions选项)   OpenQA.Selenium.IE.InternetExplorerDriver..ctor()   OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo)上的System.Net.HttpWebRequest.GetResponse()的WebException   requestInfo)   System.Net.Sockets.NetworkStream.Read上的--IOException(Byte []缓冲区,Int32偏移量,Int32大小)at   System.Net.PooledStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)   在System.Net.Connection.SyncRead(HttpWebRequest请求,布尔值   userRetrievedStream,Boolean probeRead)   System.SNet.Sockets.Socket.Receive(Byte []缓冲区,Int32偏移量,Int32大小,SocketFlags socketFlags)处于--SocketException   System.Net.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,   Int32尺寸)

1 个答案:

答案 0 :(得分:0)

使用 IEDriverServer 3.9.0.0 http://selenium-release.storage.googleapis.com获取 Windows 64位我能够使用 IEDriverServer_x64_3.9.0 。

错误堆栈跟踪:

Started InternetExplorerDriver server (64-bit)
3.9.0.0
Listening on port 28286
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:28286
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
System info: host: 'ATECHM-03', ip: '192.168.1.35', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.8.0_144'
Driver info: driver.version: InternetExplorerDriver
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
    at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:223)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:215)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:152)
    at demo.A_IE_simple.main(A_IE_simple.java:13)
Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:28286
    at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:240)
    at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158)
    at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
    at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
    at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
    at okhttp3.RealCall.execute(RealCall.java:77)
    at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:104)
    at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:54)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:138)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    ... 6 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at okhttp3.internal.platform.Platform.connectSocket(Platform.java:125)
    at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:238)
    ... 29 more

虽然IEDriverServer_Win32_3.9.0的快速测试没有显示任何错误。 虽然 IEDriverServer_Win32_3.9.0 IEDriverServer_x64_3.9.0 已经提出,但从未明确推送 / 已发布以便可用Download页面的seleniumhq.org标签。

IEDriverServer.exe CHANGELOG明确提到以下免责声明:

The "major" and "minor" fields are synchronized to releases of the Selenium
project. Changes in the "build" field indicate interim releases made publicly
available via the project downloads page. Changes in "revision" field indicate
private releases checked into the prebuilts directory of the source tree, but
not made generally available on the downloads page.

此外, IEDriverServer.exe v3.9.0.1 CHANGELOG提到以下免责声明:

Finally, there is every chance that, despite all efforts to the contrary,
it's possible that there are new regressions introduced by this change.
Multiple test suites have been run using this change, and none have
failed thus far due to the changes herein. Claims that this change is
causing a specific failure should be accompanied by a full test case, or
issues reported against this change will be summarily closed.

解决方案

简单的解决方案是:

  • 在32位和64位平台上使用 IEDriverServer_Win32_3.9.0
  • 还原为 IEDriverServer_x64_3.8.0