简体   繁体   中英

C# - Selenium - firefox driver fails to capture and apply AcceptInsecureCerts (2018/02/08 Latest Releases)

Hello (first time posting here),

I am having trouble getting geckodriver to bypass certificate errors. I've done a lot of research and made sure that I have the latest versions of all components. Reason I stress that is because a lot of the past questions that exist on this site discuss obsolete methods such as using DesiredCapabilities.

This is my code:

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
FirefoxProfile profile = new FirefoxProfile("QA"){
    AcceptUntrustedCertificates = true
};
FirefoxOptions options = new FirefoxOptions(){
    Profile = profile
};
var driver = new FirefoxDriver(options);
driver.Navigate().GoToUrl("https://google.ca");

The code above fails and I still get certificate errors on Firefox. One thing I noticed when debugging it is that the driver still sees the capability "acceptInsecureCerts" as "false". Screenshot below.

在此输入图像描述

Am I doing something wrong? Please advise.

I am currently using:

  • Selenium V3.9 (latest)
  • Mozilla Firefox Nightly 60.0a (latest)
  • geckodriver 19.1 (latest)

Aah! Found it: Firefox Options has an "addcapabilities" function that fixes it.

options.AddAdditionalCapability("acceptInsecureCerts", true, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM