How do I get past the Firefox Unsafe Connection alert page with GeckoDriver?

0

How to go through the certificate error (insecure connection) screen with the WebDriver GeckoDriver for Firefox?

I'm tapping on a URL that displays this alert.

I've already added in the browser exceptions, but the problem continues. If you uncheck the option " Query OCSP servers to confirm the current validity of the certificates " continues the problem after WebDriver starts a browser session.

I load the profile of it by system default:

private static IWebDriver GetWebDriver(string path)
{
    const string firefoxPath = @"...firefox.exe";

    var service = FirefoxDriverService.CreateDefaultService(@"...GeckoDriver\");
    service.FirefoxBinaryPath = firefoxPath;

    var options = new FirefoxOptions
    {
        Profile = GetFirefoxProfile(path),
    };

    var driver = new FirefoxDriver(service, options, TimeSpan.FromMinutes(1));

    return driver;
}

But it still does not work.

I even tried to set:

options.Profile.AcceptUntrustedCertificates = true;
options.Profile.AssumeUntrustedCertificateIssuer = true;

profile.SetPreference("acceptInsecureCerts", true);
    
asked by anonymous 16.03.2017 / 21:14

1 answer

0

I do not understand much of selenium in c# , since I'm more adept at the python version, but the idea works for both. Try to absorb the idea and figure out how to reproduce in c# .

Since adding the website to the security exceptions did not work, you can make your webdriver click the "Avançar" link and then "Continuar mesmo assim" .

But ... how to do this?

  • You need to figure out which element path on the page to tell the webdriver where it should give a .click()
  • Right-click the "Avançar" link and select "Inspecionar elemento"
  • Find out which identificador "único" you can use to show your webdriver where to find the "Next" link. This step is a matter of strategy and patience!
  • After finding a unique identifier such as id , class , name or text , for example, make your webdriver find this element and then click on it.

  • Repeat steps 2 to 4 for the "Continue anyway" link.

  • Codes:

    • Find elem: links = driver.FindElements(By.TagName("a"));
    • Click on the elem: links.First(elem => elem.Text == "Avançar").Click();

    ps: I did not test because I could not reproduce your error.

    How to find the unique identifier:

    Example using the disc drop button in SOpt.

    1st step:

    Step2:

    3rd step:

    I can use this as a unique identifier:

  • class = btn-clear discard-answer
  • a
  • text = descartar
  • Which strategy will be the most efficient? Maybe the 1st, but you can use any of the 3 strategies to find the button.

        
    16.03.2017 / 23:51