Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle "Your connection is not secure" error in firefox using selenium

I am using webdriver V 3.0.1 and firefox V 46. I am facing an error as "Your connection is not secure".

enter image description here

Please help me to overcome from this issue. Below you can find my code

    System.setProperty("webdriver.gecko.driver","D:\\Software\\Webdriver\\gecko new\\geckodriver-v0.11.1-win64\\geckodriver.exe");
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("network.proxy.type", 0);
    profile.setAcceptUntrustedCertificates(true); 
    profile.setAssumeUntrustedCertificateIssuer(false);
    WebDriver driver = new FirefoxDriver(profile);
    driver.get("http://qa.applications.marykayintouch.com/Login/Login.aspx");
like image 458
Ashok Avatar asked Dec 23 '16 06:12

Ashok


People also ask

How does selenium handle this site is not secure?

Handle Untrusted Certificate Selenium Step 1-We have to create FirefoxProfile in Selenium. Step 2- We have some predefined method in Selenium called setAcceptUntrustedCertificates() which accept Boolean values(true/false)- so we will make it true. Step 3-Open Firefox browser with the above-created profile.

How do I make Firefox connection secure?

The easiest way to fix this secure connection error is to reset the Firefox settings. If that doesn't work, disable DNS over HTTPS or create a new Firefox profile. Disable the VPN client or proxy service. Your VPN and proxy service can interfere with the connection.

How do I make Firefox open insecure connection?

Look for the small gray shield icon in the extreme right-hand corner of the address bar. Click the "Load unsafe script" link. You will be taken back to the entry page of your course; navigate back to the page with the embedded video.


1 Answers

To me, the most simple and efficient solution was to do this

var options = new FirefoxOptions()
{
    AcceptInsecureCertificates = true
};

using (var driver = new FirefoxDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options))
{
    // Your code
}

I tried using Sanjay Bhimani's example but it didn't work so looked into the available constructors and ended up with the above code.

like image 54
Mathieu VIALES Avatar answered Sep 27 '22 19:09

Mathieu VIALES