SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.24k stars 8.12k forks source link

Selenium Grid cannot launch IE11 and report IE driver cannot bypass insecure SSL certificate #4704

Closed jared-ziqxu closed 7 years ago

jared-ziqxu commented 7 years ago

Meta -

OS: Windows7

Selenium Version: 3.5.3

Browser: IE 11

Browser Version: 11

Expected Behavior -

IE should open a url.

Actual Behavior -

IE cannot open the url, and the node reports: 16:26:13.815 INFO - Found handler: org.openqa.selenium.remote.server.BeginSessio n@e2e2c07 16:26:13.815 INFO - /session: Executing POST on /session (handler: BeginSession)

16:26:13.815 INFO - Mismatched capabilities. Creating a synthetic w3c capability . 16:26:13.815 INFO - Capabilities are: Capabilities {ensureCleanSession=true, acc eptSslCerts=true, acceptInsecureCerts=true, browserName=internet explorer, platf ormName=WINDOWS, version=11, platform=WINDOWS, } 16:26:13.815 INFO - Capabilities {ensureCleanSession=true, acceptSslCerts=true, acceptInsecureCerts=true, browserName=internet explorer, platformName=WINDOWS, v ersion=11, platform=WINDOWS, } matched class org.openqa.selenium.remote.server.S ervicedSession$Factory (provider: org.openqa.selenium.ie.InternetExplorerDriverS ervice) 16:26:13.815 INFO - Capabilities {ensureCleanSession=true, acceptSslCerts=true, acceptInsecureCerts=true, browserName=internet explorer, platformName=WINDOWS, v ersion=11, platform=WINDOWS, } matched class org.openqa.selenium.remote.server.S ervicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService ) Started InternetExplorerDriver server (64-bit) 3.5.1.0 Listening on port 22044 Only local connections are allowed

The Java code reports: Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to match capability set 0: acceptInsecureCerts was 'true', but the IE driver does not allow bypassing insecure (self-signed) SSL certificates Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z' System info: host: 'SELENIUM-WIN7-B', ip: '192.168.0.164', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144' Driver info: driver.version: unknown remote stacktrace: Command duration or timeout: 606 milliseconds at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167) at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53) at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:359) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:362) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:255) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:237) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:138) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:175) at main.java.test.main(test.java:42)

Steps to reproduce -

  1. launch selenium grid hub in one machine with java -jar selenium-server-standalone-3.5.3.jar -role hub
  2. launch selenium grid node in another machine: java -jar -Dwebdriver.ie.driver=PATH_to_IEDriver.exe -DacceptsSslCerts=true -jar selenium-server-standalone.3.5.3.jar -role node -hub http://Hub_Machine_IP:4444/grid/register -browser browserName="internet explorer",version=11,platform=WINDOWS
  3. I followed this link https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver to configure the IE settings.
  4. run following java code:

    DesiredCapabilities capabilities =  DesiredCapabilities.internetExplorer();
    capabilities.setBrowserName("internet explorer");
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setVersion("11");
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    capabilities.setCapability("acceptInsecureCerts", true);
    capabilities.setCapability("acceptSslCerts",true);
    capabilities.setAcceptInsecureCerts(true);
    capabilities.acceptInsecureCerts();
    
    WebDriver driver = new RemoteWebDriver(new URL("http://Hub_Machine_IP/wd/hub"), capabilities);
     capabilities);

    driver.navigate().to("https://www.google.com/");

It works fine in a chrome in the same Windows 7 platform.

jimevans commented 7 years ago

The error message is telling you exactly what the issue is. The IE driver does not allow you to accept self-signed certificates. In truth, it never has been able to do so. What has changed is that the driver now implements the W3C WebDriver specification that dictates that an error be thrown if capabilities cannot be matched. You specifically requested a browser with the capability that could accept self-signed certificates, but there is no matching browser for that set of capabilities (because the IE driver does not).

jared-ziqxu commented 7 years ago

In this case, how can I use IE to open a HTTPS or HTTP web page? Because I cannot open either while Chrome all works fine.

jimevans commented 7 years ago

The same way you've always done so, just don't specify the capabilities for IE.

jared-ziqxu commented 7 years ago

It really helps! Thank you so much!