2 Replies Latest reply on Jul 16, 2013 9:33 AM by Lukáš Fryč

    Turn off SSL validation in phantomjs

    Carl S Newbie

      I'm trying to use the phantomjs together with Drone and Graphene. I need to turn off SSL validation when I test against sites with self signed certs.

       

      My first approach was to set acceptSslCerts=true:

       

      <extension qualifier="webdriver">

              <property name="browserCapabilities">phantomjs</property>

              <property name="acceptSslCerts">true</property>

              <property name="phantomjs.binary.path">/Tools/phantomjs-1.9.1-linux-x86_64/bin/phantomjs</property>

      </extension>

       

      but after negotiation it still is false:

      [INFO  - 2013-07-15T08:59:01.554Z] Session [cb0ce4e0-ed2c-11e2-9014-3b55ccbe24f6] - CONSTRUCTOR - Desired Capabilities: {"acceptSslCerts":true,"phantomjs.binary.path":"/Tools/phantomjs-1.9.1-linux-x86_64/bin/phantomjs"}

      [INFO  - 2013-07-15T08:59:01.554Z] Session [cb0ce4e0-ed2c-11e2-9014-3b55ccbe24f6] - CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.1","driverName":"ghostdriver","driverVersion":"1.0.3","platform":"linux-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}

       

      From what I can gather regarding ghostdriver, acceptSslCerts doesn't seem to be implemented (please correct me if I'm wrong). There is a command line parameter, --ignore-ssl-errors=true, that can be used instead (https://github.com/ariya/phantomjs/wiki/API-Reference).

       

      I tried to use phantomjs.cli.args in arquillian.xml but the parameter is supposed to be an array so this results in ClassCastException:

       

      <extension qualifier="webdriver">
               <property name="browserCapabilities">phantomjs</property>
               <property name="phantomjs.cli.args">--ignore-ssl-errors=true</property>
               <property name="phantomjs.binary.path">/Tools/phantomjs-1.9.1-linux-x86_64/bin/phantomjs</property>
      </extension>

       

      Unable to instantiate Drone via org.openqa.selenium.phantomjs.PhantomJSDriver(Capabilities): java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;

      Is there a way to pass --ignore-ssl-errors to phantomjs or any other way to turn off SSL validation?