Selenium, GhostDriver / PhantomJS and self-signed certificates

If you’re using self-signed HTTPS certificates and find your Selenium + GhostDriver (PhantomJS) scripts failing with a blank HTML page, you might need to tell PhantomJS to ignore SSL errors:-

DesiredCapabilities dCaps = new DesiredCapabilities();
dCaps.setJavascriptEnabled(true);
dCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[]{"--web-security=no", "--ignore-ssl-errors=yes"});
dCaps.setJavascriptEnabled(true);
driver = new PhantomJSDriver(dCaps);

Credit to pavelpp in this thread.

This is my personal blog - all views are my own.

Tagged with: , , , , ,