I'm setting some capabilities for PhantomJsDriver
.
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("cssSelectorsEnabled", false);
caps.setCapability("applicationCacheEnabled", true);
caps.setCapability("acceptSslCerts",true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,phantomJsPath);
this.driver = new PhantomJSDriver(caps);
Then, I check what capabilities the driver is using:
System.out.println(driver.getCapabilities());
Output:
Capabilities [{
platform=XP,
acceptSslCerts=false,
javascriptEnabled=true,
browserName=phantomjs,
rotatable=false,
driverVersion=1.1.0,
locationContextEnabled=false,
version=1.9.7,
cssSelectorsEnabled=true,
databaseEnabled=false,
handlesAlerts=false,
browserConnectionEnabled=false,
proxy={proxyType=direct},
nativeEvents=true,
webStorageEnabled=false,
driverName=ghostdriver,
applicationCacheEnabled=false,
takesScreenshot=true}]
It shows:
cssSelectorsEnabled=true,
applicationCacheEnabled=false,
acceptSslCerts=false
Why is the driver running without the capabilities I set?
PhantomJS uses different mechanism in setting capabilities
static ArrayList<String> cliArgsCap = new ArrayList<String>();
capabilities = DesiredCapabilities.phantomjs();
cliArgsCap.add("--web-security=false");
cliArgsCap.add("--ssl-protocol=any");
cliArgsCap.add("--ignore-ssl-errors=true");
capabilities.setCapability("takesScreenshot", true);
capabilities.setCapability(
PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
capabilities.setCapability(
PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS,
new String[] { "--logLevel=2" });
this.driver = new PhantomJSDriver(capabilities);
For more information about its command line, you could reference http://phantomjs.org/api/command-line.html
With phantomjsdriver-1.1 I had to pass the follow arguments to get this to work.
cliArgsCap.add("--web-security=no");
cliArgsCap.add("--ignore-ssl-errors=yes");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With