This question already has answers here:
Why won't PhantomJSDriver use the capabilities I set?
                                
                                    (2个答案)
                                
                        
                                4年前关闭。
            
                    
如何为Java PhantomJSDriver指定命令行参数?例如,我想在运行的脚本上设置--ignore-ssl-errors=yes

最佳答案

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

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

PhantomJSDriver driver = new PhantomJSDriver(desiredCapabilities);

10-07 13:41