2017-07-28 50 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/"); 

    } 
} 

讓我知道如果這個回答你的問題。