java为什么PhantomJSDriver不使用我设置的功能?
我正在为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);
然后,我检查驱动程序使用的功能:
System.out.println(driver.getCapabilities());
输出:
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}]
它显示:
cssSelectorsEnabled=true,
applicationCacheEnabled=false,
acceptSslCerts=false
为什么驱动程序在没有我设置的功能的情况下运行
# 1 楼答案
对于phantomjsdriver-1.1,我必须传递以下参数才能使其正常工作
# 2 楼答案
PhantomJS在设置功能时使用不同的机制
有关其命令行的更多信息,可以参考http://phantomjs.org/api/command-line.html