问题
I'm having issues launching IE 11 when I run my selenium tests. Here is the code I am using to setup my browser
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);
}
I tried the other solutions base off this thread but still no luck. Stack Link. Is there any solutions I can use?
Environment:
Selenium version: 3.12.0
IEDriverServer version: 3.9.0.0
IE Version: 11.0.65
Console output:
Started InternetExplorerDriver server (64-bit)
3.9.0.0
Listening on port 10696
Only local connections are allowed
stack trace:
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)
回答1:
This error message...
org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
...implies that the IEDriverServer was unable to initiate/spawn a new WebBrowsing Session i.e. InternetExplorer Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- Your Selenium Client version is 3.12.0 of 2018-05-08T14:04:26.12Z which is almost an year older.
- Your InternetExplorerDriver version 3.9.0.0.
So there is a clear mismatch between the Selenium Client v3.12.0 and InternetExplorerDriver v3.9.0.0. As per best practices as Selenium Client and InternetExplorerDriver are released in sync you must use both the binaries from the same major release.
Further InternetExplorerDriver server v3.9.0.0 had a known issue as per the following references:
- 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
This issue have been addressed through the following commit:
- Properly initializing JSON values in IE driver
Solution
- Upgrade IEDriverServer to current IEDriverServer v3.12.0 level.
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
- Take a System Reboot.
- Execute your
@Test
. - Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.
来源:https://stackoverflow.com/questions/50729991/unable-to-launch-ie-11-when-running-selenium-with-iedriverserver-3-9-0-0