How do I go through the Firefox Insecure Connection alert page with Geckodriver?

Asked

Viewed 418 times

1

How to pass certificate error screen (insecure connection) with Geckodriver Firefox Webdriver?

I’m hitting a URL that displays this alert.

I already added in the browser exceptions, but the problem remains.
Uncheck the option to "Consult OCSP servers to confirm the current validity of certificates" continues the problem after Webdriver starts a browser session.

I load its profile 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 doesn’t work.

I even tried to set:

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

profile.SetPreference("acceptInsecureCerts", true);
  • Post a photo of the page.... maybe if you click "Advanced" at the bottom of the page, and then "Continue anyway", you can access the page.

  • @dot. Py hello, this is the type of page that appears. But how to do this with the Webdriver? In exceptions of the browser is already. Thank you!

  • I found this solution for python to look in the code to see if you find something like this: profile = webdriver.Firefoxprofile() profile.accept_untrusted_certs = True

  • I momentarily solved the problem by fixing the version of Firefox on 47.0.2

1 answer

1

I don’t know much about Selenium in C#, because I’m more adept at the version for the Python, but the idea serves both. Try to absorb the idea and figure out how to reproduce in C#.

How to add the website to the security exceptions didn’t work, you can do your WebDriver click on the link "Avançar" and then in "Continuar mesmo assim".

But... how to do this?

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

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


Codes:

  • Find them: 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 discard post button in Sopt.

first stage:

inserir a descrição da imagem aqui


second stage:

inserir a descrição da imagem aqui


3rd stage:

I can use as unique identifier:

  1. class = btn-clear discard-answer
  2. a
  3. text = descartar

Which strategy will be the most efficient? Maybe the first, but you can use any of the 3 strategies to find the button.

  • Thanks for the details. In Firefox is a window itself, like an Alert. I’ve seen something about selecting a specific Alert button, but I couldn’t find anything about windows other than Alert. Still looking for it. Thank you!

  • 1

    @Jamestk veja that answer and just below it. Selenium has an 'Alert Handler', that is, it can manipulate browser Alerts! However, when Alert is from the operating system, this is not possible (such as the boxes that appear when using a digital certificate).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.