Monday, October 21, 2013

Codeception: Phantomjs setup for WebDriver when using self-signed SSL certificate

When using phantomjs as browser for acceptance tests with WebDriver in Codeception - if the targeted site is using self-signed SSL certificate tests will fail. To avoid that - phantomjs must be started with --ignore-ssl-errors=true command line option. Here is an example acceptance.suite.yml configuration:

# Codeception Test Suite Configuration
# suite for acceptance tests.
# perform tests in browser using the Selenium-like tools.
# powered by Mink (http://mink.behat.org).
# (tip: that's what your customer will see).
# (tip: test your ajax and javascript by one of Mink drivers).

# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.

class_name: WebGuy
modules:
    enabled: [WebDriver, WebHelper]
    config:
        WebDriver:
            url: 'https://example.com/'
            browser: phantomjs
            capabilities:
                phantomjs.cli.args: ['--ignore-ssl-errors=true']
Another alternative is to use method from Ghostdriver documentation - Register GhostDriver with a Selenium Grid hub