如何添加PhantomJSDriver命令行参数

时间:2015-07-30 10:37:13

标签: java selenium phantomjs

如何为Java PhantomJSDriver指定命令行参数?例如,我想在我运行的脚本上设置--ignore-ssl-errors=yes

1 个答案:

答案 0 :(得分:5)

只需添加到phantomJS的默认所需功能,如下所示:

DesiredCapabilities desiredCapabilities = DesiredCapabilities.phantomjs();
desiredCapabilities.setCapability("phantomjs.cli.args", Collections.singletonList("--ignore-ssl-errors=yes"));

PhantomJSDriver driver = new PhantomJSDriver(desiredCapabilities);