Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
197 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...