繁体   English   中英

我如何解决硒中Mozilla Firefox 54上的不安全连接

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

我已经将Selenium 3.4和Geckodriver v0.18.0一起使用了。

为了处理Firefox中的SSL证书,我使用了Selenium Webdriver的功能:

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

但是在启动Firefox后仍然显示不安全的连接

这是您的问题的答案:

根据没有参考SSL证书被阻止的url的问题,这是绕过SSL Certificate的最小代码块。 在此代码块中,我们将使用DesiredCapabilities类将ACCEPT_SSL_CERTSCapabilityType设置为true ,如下所示:

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

    }
}

让我知道这是否回答了您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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