使用 IEDriverServer 3.9.0.0 运行 selenium 时无法启动 IE 11
Unable to launch IE 11 when running selenium with IEDriverServer 3.9.0.0
当我 运行 我的 selenium 测试时,我在启动 IE 11 时遇到问题。这是我用来设置浏览器的代码
if (browser.equalsIgnoreCase("ie")) {
System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");
driver = new InternetExplorerDriver();
} else {
throw new Exception("Browser is not correct");
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.google.com/");
Dimension dimension = new Dimension(800,600);
driver.manage().window().setSize(dimension);
}
我尝试了基于此线程的其他解决方案,但仍然没有成功。 Stack Link。有什么解决方案可以使用吗?
环境:
硒版本:3.12.0
IEDriverServer版本:3.9.0.0
IE 版本:11.0.65
控制台输出:
Started InternetExplorerDriver server (64-bit)
3.9.0.0
Listening on port 10696
Only local connections are allowed
堆栈跟踪:
org.openqa.selenium.WebDriverException: java.net.SocketException:
Connection reset
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05- 08T14:04:26.12Z'
System info: host: 'DESKTOP7', ip: '', os.name: ' Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
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:543)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
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 com.dlp.tests.TestCases.Basic_Template.setup(Basic_Template.java:37)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at okio.Okio.read(Okio.java:139)
at okio.AsyncTimeout.read(AsyncTimeout.java:237)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:345)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:217)
at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:212)
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
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:105)
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:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
这个错误信息...
org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
...意味着 IEDriverServer 无法 initiate/spawn 新的 WebBrowsing Session 即 InternetExplorer 浏览器 会话。
您的主要问题是您使用的二进制文件版本之间不兼容,如下所示:
- 您的 Selenium 客户端 版本是 3.12.0 2018-05-08T14:04:26.12Z 差不多大了一岁。
- 您的 InternetExplorerDriver 版本 3.9.0.0.
因此 Selenium Client v3.12.0 和 InternetExplorerDriver v3.9.0.0 之间存在明显的不匹配。根据 best practices 作为 Selenium Client 和 InternetExplorerDriver 同步发布,您必须同时使用来自相同的主要版本。
此外 InternetExplorerDriver 服务器 v3.9.0.0 根据以下参考文献存在一个已知问题:
- Can't launch Selenium IE Driver after upgrading to version 3.9
- Selenium Java Client (v3.9.1) with IEDriverServer v3.9.0.0 (64-bit) crashes with org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:28286
此问题已通过以下提交得到解决:
解决方案
- 将 IEDriverServer 升级到当前 IEDriverServer v3.12.0 级别。
- 清理你的项目工作区通过你的IDE和重建你的项目只需要依赖。
- 使用 CCleaner 工具清除执行 测试套件 .
前后的所有 OS 琐事
- 系统重启。
- 执行你的
@Test
。
- 始终在
tearDown(){}
方法中调用 driver.quit()
以优雅地关闭和销毁 WebDriver 和 Web Client 实例.
当我 运行 我的 selenium 测试时,我在启动 IE 11 时遇到问题。这是我用来设置浏览器的代码
if (browser.equalsIgnoreCase("ie")) {
System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");
driver = new InternetExplorerDriver();
} else {
throw new Exception("Browser is not correct");
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.google.com/");
Dimension dimension = new Dimension(800,600);
driver.manage().window().setSize(dimension);
}
我尝试了基于此线程的其他解决方案,但仍然没有成功。 Stack Link。有什么解决方案可以使用吗?
环境:
硒版本:3.12.0
IEDriverServer版本:3.9.0.0
IE 版本:11.0.65
控制台输出:
Started InternetExplorerDriver server (64-bit)
3.9.0.0
Listening on port 10696
Only local connections are allowed
堆栈跟踪:
org.openqa.selenium.WebDriverException: java.net.SocketException:
Connection reset
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05- 08T14:04:26.12Z'
System info: host: 'DESKTOP7', ip: '', os.name: ' Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
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:543)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
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 com.dlp.tests.TestCases.Basic_Template.setup(Basic_Template.java:37)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at okio.Okio.read(Okio.java:139)
at okio.AsyncTimeout.read(AsyncTimeout.java:237)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:345)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:217)
at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:212)
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
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:105)
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:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
这个错误信息...
org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
...意味着 IEDriverServer 无法 initiate/spawn 新的 WebBrowsing Session 即 InternetExplorer 浏览器 会话。
您的主要问题是您使用的二进制文件版本之间不兼容,如下所示:
- 您的 Selenium 客户端 版本是 3.12.0 2018-05-08T14:04:26.12Z 差不多大了一岁。
- 您的 InternetExplorerDriver 版本 3.9.0.0.
因此 Selenium Client v3.12.0 和 InternetExplorerDriver v3.9.0.0 之间存在明显的不匹配。根据 best practices 作为 Selenium Client 和 InternetExplorerDriver 同步发布,您必须同时使用来自相同的主要版本。
此外 InternetExplorerDriver 服务器 v3.9.0.0 根据以下参考文献存在一个已知问题:
- Can't launch Selenium IE Driver after upgrading to version 3.9
- Selenium Java Client (v3.9.1) with IEDriverServer v3.9.0.0 (64-bit) crashes with org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:28286
此问题已通过以下提交得到解决:
解决方案
- 将 IEDriverServer 升级到当前 IEDriverServer v3.12.0 级别。
- 清理你的项目工作区通过你的IDE和重建你的项目只需要依赖。
- 使用 CCleaner 工具清除执行 测试套件 . 前后的所有 OS 琐事
- 系统重启。
- 执行你的
@Test
。 - 始终在
tearDown(){}
方法中调用driver.quit()
以优雅地关闭和销毁 WebDriver 和 Web Client 实例.