简体   繁体   中英

How can i resolve insecure connection on mozilla firefox 54 in selenium

I have used Selenium 3.4 along with Geckodriver v0.18.0.

To handle the SSL certificates in Firefox I used capabilities of Selenium Webdriver:

ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("default");
myprofile.setAcceptUntrustedCertificates(true);
myprofile.setAssumeUntrustedCertificateIssuer(false);
driver = new FirefoxDriver(myprofile);

But still it is showing an insecure connection after firefox launch

Here is the Answer to your Question:

As per the question without any reference to the url where the SSL certificates are blocking, here is the minimum code block to bypass the SSL Certificate . In this code block we will use the DesiredCapabilities Class to set the CapabilityType of ACCEPT_SSL_CERTS to true as follows:

package certificateIssue;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

public class CertificateIssue_Firefox 
{

    @Test
    public void handleCertificate()
    {
        System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");

        DesiredCapabilities cap= new DesiredCapabilities();
        cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

        WebDriver driver = new FirefoxDriver(cap);
        driver.get("http://www.cacert.org/");

    }
}

Let me know if this Answers your Question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM