Search code examples
c#seleniumfirefoxselenium-webdrivergeckodriver

Selenium Why setting acceptuntrustedcertificates to true for firefox driver doesn't work?


I'm developping some selenium tests and I face an important issue because I didn't found a "real" solution when I test my site with secure connection (HTTPS). All solutions I found on stackoverflow are out of date or doesn't work:

  1. I am writing a Selenium script in Firefox but I am getting "Untrusted Certificate"
  2. How to disable Firefox's untrusted connection warning using Selenium?
  3. Handling UntrustedSSLcertificates using WebDriver

The only workaround I have is to use the nightly mozilla release as indicated on github: https://github.com/mozilla/geckodriver/issues/420

        private IWebDriver driver;
        private string baseURL;
        private FirefoxOptions ffOptions;
        private IWait<IWebDriver> wait;

        [SetUp]
        public void SetupTest()
        {
            ffOptions = new FirefoxOptions();
            ffOptions.BrowserExecutableLocation = @"D:\AppData\Local\Nightly\firefox.exe";
            FirefoxProfile profile = new FirefoxProfile();
            profile.AssumeUntrustedCertificateIssuer = false;
            profile.AcceptUntrustedCertificates = true;
            ffOptions.Profile = profile;            
            ffOptions.LogLevel = FirefoxDriverLogLevel.Info;
            driver = new FirefoxDriver(FirefoxDriverService.CreateDefaultService(), ffOptions, TimeSpan.FromSeconds(30));

            //[...]           
        }

Configuration:

  • Firefox v47.0.1, v49.0.2, v51.0.1, v52.0b9 (i tried these differents versions)
  • geckodriver 0.14
  • selenium 3.1.0

Does anyone have a solution to avoid using nightly release ?

For information I have access only to stackoverflow and github due to my internet policy, and please don't suggest me to use chrome!

Thank for your help!


Solution

  • Yeah, it's a bug on the geckodriver. You can find it here!