2016-06-14 58 views
0

正如標題所說,我在處理Chrome,IE和Opera瀏覽器中的SSL證書方面很苦惱。 我在做什麼:在Chrome,IE和Opera上處理SSL證書的問題

ChromeOptions opt = new ChromeOptions(); 
opt.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true); 

IWebDriver driver = new ChromeDriver(opt); 
driver.Navigate().GoToUrl("https://localhost"); 

什麼我越來越:

Result StackTrace: 
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) 
    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) 
    at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) 
    at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) 
    at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options) 
    at ... (project name and path here) 
Result Message: Initialization method <Project and test method name here> threw exception. System.InvalidOperationException: System.InvalidOperationException: unknown error: cannot parse capability: chromeOptions 
from unknown error: unrecognized chrome option: acceptSslCerts 
    (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64). 

同樣,我用OperaOptionsOperaDriver類爲獲得Opera瀏覽器同樣的事情:

System.InvalidOperationException: unknown error: cannot parse capability: operaOptions 
from unknown error: unrecognized chrome option: acceptSslCerts 

而對於Internet Explorer瀏覽器,通過使用InternetExplorerOptionsInternetExplorerDriver類,我沒有收到任何錯誤,但SSL證書證書處理不當。

任何幫助表示讚賞。

回答

0

我假設你已經設置了chromedriver可執行屬性的一些事情。我建議你試試看如下:

DesiredCapabilities capability = DesiredCapabilities.chrome(); 
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); 
driver = new ChromeDriver(capability);