3 Replies Latest reply on Nov 19, 2018 7:16 AM by davinator

    Turn off SSL validation in phantomjs

    m83379y8

      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?

        • 1. Re: Turn off SSL validation in phantomjs
          lfryc

          Nice catch Carl,

           

          could you please create an issue against Drone extension?

           

          The Drone needs be able to handle coercion of types to the expected value.

           

          https://issues.jboss.org/browse/ARQ

          Component: Extension - Drone

           

          The workaround is using a custom hook to setup capabilities correctly, for that you will need an Arquillian extension:

          https://github.com/aslakknutsen/arquillian.github.com/blob/e2fc397f166a8dbca2a45ccea5c509c617abe524/guides/getting_started_spi.textile

           

          You can observe to this event: DroneConfigured

           

          From configuration, you should be able to setup capabilities.

          • 2. Re: Turn off SSL validation in phantomjs
            lfryc

            I would also suggest these two improvements:

             

            • moved DroneConfigured from implementation to SPI
            • expose DroneConfigured and DroneReady events to user hooks (similarly to @BeforeClass/@Before)
            • 3. Re: Turn off SSL validation in phantomjs
              davinator

              I know this thread is 5 years old but the question is still unanswered and the issue still exists.

              I'm facing the same problem and I'm not aware if someone really created an issue for this.

              If i don't get to run my tests with phantomjs I'm gonna have to delete all the arquillian tests in our project because they can not be executed on our clients Jenkins without Docker and without phantomjs.

               

              So i will try to implement the workaround you described.

              I think with the getting started guide you provided i will be able to implement an Extension to observe the DroneConfigured-Event.

              But I'm not sure what you mean with "setup capabilities correctly". What exactly is a capability and how do you set it up? Can you provide more detail and Code snippets what i would have to to turn off SSL validation?

               

              Thanks a lot!