Ashok
Ashok

Reputation: 115

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");

Upvotes: 8

Views: 6520

Answers (3)

Mathieu VIALES
Mathieu VIALES

Reputation: 4772

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.

Upvotes: 1

Mahima
Mahima

Reputation: 26

For handling SSL certificate error in Firefox, we need to use desired capabilities of Selenium Webdriver and follow the following steps:

ProfilesIni allProfiles = new ProfilesIni();
System.setProperty("webdriver.firefox.profile","your custom firefox profile name");
String browserProfile = stem.getProperty("webdriver.firefox.profile");
FirefoxProfile profile = allProfiles.getProfile(browserProfile); 
profile.setAcceptUntrustedCertificates (true); 
webdriver = new FirefoxDriver(profile); 

You can refer the following for reference: Handling UntrustedSSLcertificates using WebDriver

Upvotes: 0

Sanjay Bhimani
Sanjay Bhimani

Reputation: 1603

It seems SSLCertificates error Just try with editing capabilities

ProfilesIni profiles = new ProfilesIni();
System.setProperty("webdriver.firefox.profile","custom firefox profile name");
String browser_profile = System.getProperty("webdriver.firefox.profile");
FirefoxProfile profile = profiles.getProfile(browser_profile); 
profile.setAcceptUntrustedCertificates (true); 
webdriver = new FirefoxDriver(profile); 

or

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new FirefoxDriver(capabilities);

or

DesiredCapabilities capabilities = new DesiredCapabilities();
ProfilesIni profiles = new ProfilesIni();
System.setProperty("webdriver.firefox.profile","custom firefox profile name");
String browser_profile = System.getProperty("webdriver.firefox.profile");
FirefoxProfile profile = profiles.getProfile(browser_profile); 
profile.setAcceptUntrustedCertificates(true); 
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
webdriver = new FirefoxDriver(capabilities); 

Hope it works.

Upvotes: 0

Related Questions