正如标题所说,我正在努力处理 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).
同样,我通过使用OperaOptions
和OperaDriver
类为 Opera 浏览器得到同样的结果:
System.InvalidOperationException: unknown error: cannot parse capability: operaOptions
from unknown error: unrecognized chrome option: acceptSslCerts
对于 Internet Explorer 浏览器,通过使用InternetExplorerOptions
和InternetExplorerDriver
类,我没有收到任何错误,但 SSL 证书未正确处理。
任何帮助表示赞赏。