4

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!

Community
  • 1
  • 1
Mister Q
  • 370
  • 6
  • 20
  • "doesn't work?" means nothing, please put the errors and log – parik Mar 03 '17 at 16:25
  • There is no error litteraly speaking because while i'm accessing to my page which is a secure page (https) I face the page "Your connection is not secure". This indicated me the certificate is not trusted/not valid – Mister Q Mar 03 '17 at 16:36

2 Answers2

2

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

Ivan Tsyng
  • 76
  • 4
1

Setting the AcceptInsecureCertificates property to true in the FirefoxOptions fixed this problem for me. Here's what my initialization looked like after this change:

        var profile = new FirefoxProfile();
        profile.DeleteAfterUse = true;
        profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", LocalURL);
        profile.SetPreference("network.automatic-ntlm-auth.allow-non-fqdn", true);
        profile.SetPreference("webdriver_accept_untrusted_certs", true);
        // Only setting this property to true did not work for me either
        profile.AcceptUntrustedCertificates = true;
        profile.AssumeUntrustedCertificateIssuer = false;

        return new FirefoxDriver(new FirefoxOptions
        {
            Profile = profile,
            // When I also added this line, it DID work
            AcceptInsecureCertificates = true
        });