java-使用IEDriverServer 3.9.0.0运行硒时无法启动IE 11
作者:互联网
运行硒测试时,我在启动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$2.read(Okio.java:139)
at okio.AsyncTimeout$2.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无法启动/产生新的WebBrowsing会话,即InternetExplorer浏览器会话.
您的主要问题是所使用的二进制版本之间的不兼容性,如下所示:
>您的Selenium客户端版本是2018-05-08T14:04:26.12Z的3.12.0,比现在快一年了.
>您的InternetExplorerDriver版本3.9.0.0.
因此,Selenium Client v3.12.0和InternetExplorerDriver v3.9.0.0之间显然不匹配.按照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
通过以下提交已解决此问题:
> Properly initializing JSON values in IE driver
解
>将IEDriverServer升级到当前的IEDriverServer v3.12.0级别.
>通过IDE清理项目工作区,并仅使用必需的依赖项重建项目.
>使用CCleaner工具清除测试套件执行前后的所有操作系统杂项.
>重新启动系统.
>执行您的@Test.
>始终在tearDown(){}方法中调用driver.quit()以关闭&优雅地销毁WebDriver和Web Client实例.
标签:java,selenium,selenium-webdriver,internet-explorer-11,iedriverserver 来源: https://codeday.me/bug/20191014/1911896.html