Search code examples
c#seleniumfirefoxgeckodriver

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.

enter image description here

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)

Solution

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

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