运行硒测试时,我在启动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); }
我尝试了基于此线程的其他解决方案,但还是没有运气。堆栈链接。有什么我可以使用的解决方案吗?
Environmental : Selenium version: 3.12.0 Iedriverserver version: 3.9.0.0 Ie version: 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 Client v3.12.0 和 InternetExplorerDriver v3.9.0.0 之间存在明显的不匹配。根据 Selenium Client 和 InternetExplorerDriver 同步发布的 最佳实践 ,您必须使用 同一主要版本中的* 两个二进制文件。 *
根据以下参考,进一步的 InternetExplorerDriver服务器v3.9.0.0 具有一个已知问题:
通过以下提交已解决此问题:
@Test
driver.quit()
tearDown(){}