2017-07-28 44 views
0

我已经使用Selenium 3.4以及Geckodriver v0.18.0。我如何解决硒在Mozilla Firefox 54上的不安全连接

要处理Firefox中的SSL证书,我用硒webdriver的能力:

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

但它毕竟是显示Firefox的推出后不安全的连接

+0

你能给我们提供一些关于正在使用的URL的线索吗?更重要的是,我还没有看到您使用Selenium Webdriver的功能。谢谢 – DebanjanB

回答

0

这里是回答你的问题:

根据没有提及SSL证书阻塞的URL的问题,下面是用于绕过SSL Certificate的最小代码块。在此代码块中,我们将使用DesiredCapabilities类设置的CapabilityTypeACCEPT_SSL_CERTStrue如下:

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

    } 
} 

让我知道如果这个回答你的问题。