2017-05-09 58 views
0

禁用SSL/web安全試過:C#,硒,PhantomJS添加CLI args作爲與RemoteWebDriver

1.

capabilities.SetCapability("phantomjs.cli.args", "[\"--web-security=false\"]"); 

2.

capabilities.SetCapability("phantomjs.cli.args", 
       "['--ssl-protocol=tlsv1','--ignore-ssl-errors=true', '--web-security=false']"); 

而且有逃脫\"代替'

現在,我期待到使用此服務的事情,但我不知道如何將它傳遞給RemoteWebDriver構造函數(如你在Firefox」的情況下做capabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, profile);

FirefoxOptions x = new FirefoxOptions(); 
x.ToCapabilities() 

因此,這是我在哪裏:

PhantomJSDriverService service = PhantomJSDriverService.CreateDefaultService(); 
service.IgnoreSslErrors = true; 

回答

0

最簡單的方法來消滅一切大驚小怪的使用方法:

capabilities.SetCapability("phantomjs.cli.args", 
       new String[] { "--web-security=no", "--ssl-protocol=tlsv1", "--ignore-ssl-errors=true" }); 

這解決了它,現在PhantomJS繞過了錯誤的證書。