Why won't PhantomJSDriver use the capabilities I set?

0
0

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?

  • You must to post comments
0
0

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

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website