mgates2
mgates2

Reputation: 85

Java - PhantomJS and Selenium - Ignore SSL Errors

I am having problems with pages with SSL. I'm pretty sure this is the problem because I can go to http pages and get the full page source, but when I go to an https address, I get the following:

<html><head></head><body></body></html>

I am using:

I have tried setting --ignore-ssl-errors=true on desired capabilities, but it doesn't seem to be working.

public WebDriver createDriver(DesiredCapabilities dcaps) {
    dcaps.setCapability(
        PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
        "target/classes/phantomjs.exe");
    String [] phantomJsArgs = {"--ignore-ssl-errors=true"};
    dcaps.setCapability(
        PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS, 
        phantomJsArgs);
    return new PhantomJSDriver(dcaps);
}

I have also tried this with "PhantomJSDriverService.PHANTOMJS_CLI_ARGS" and with the cli argument "--web-security=false" added. In all cases, I can see something like the following in the console, but none seem to actually work.

DEBUG: org.apache.http.wire -  >> "{"desiredCapabilities":{
"loggingPrefs":{"driver":"FINEST"},"cssSelectorsEnabled":true,
"javascriptEnabled":true,"phantomjs.ghostdriver.cli.args":["--ignore-ssl-errors=true"],
"phantomjs.binary.path":"target/classes/phantomjs.exe",
"takesScreenshot":true}}"

Any ideas would be greatly appreciated.

Upvotes: 1

Views: 4436

Answers (1)

mgates2
mgates2

Reputation: 85

This seems to have been a bug with PhantomJS 1.9.1 and was fixed in version 1.9.8. I was able to resolve this issue by upgrading to the newer driver.

Answer found via this bug report: https://github.com/ariya/phantomjs/issues/12655

Upvotes: 1

Related Questions