2017-05-02 44 views
0

我使用硒3.4.0,firefox版本53.0和gecko驅動程序0.16.1,java編譯器1.7。不安全連接錯誤Firefox v 53.0

對於某些網站顯示不安全的連接錯誤。

我已經使用Firefox的配置對象遵循但它仍然不是解決:

 FirefoxProfile profile = new FirefoxProfile(); 
     profile.setAcceptUntrustedCertificates(true); 
     profile.setAssumeUntrustedCertificateIssuer(false); 
     profile.setPreference("network.proxy.type", 1); 
     profile.setPreference("network.proxy.http", "localhost"); 
     profile.setPreference("network.proxy.http_port", 3128); 


     WebDriver driver = new FirefoxDriver(profile); 
     driver.manage().window().maximize(); 

回答

0

要與硒3.4.0你需要從here下載最新geckodriver Mozilla Firefox瀏覽器53.x工作。將它保存在你的機器上&提供了geckodriver的絕對路徑。

以名稱debanjan手動創建一個新的Firefox配置文件並使用AcceptUntrustedCertificates & setAssumeUntrustedCertificateIssuer選項。

這段代碼執行得很好,對你自己的代碼做了一些簡單的調整。

System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe"); 
    ProfilesIni profile = new ProfilesIni(); 
    FirefoxProfile testprofile = profile.getProfile("debanjan"); 
    testprofile.setAcceptUntrustedCertificates(true); 
    testprofile.setAssumeUntrustedCertificateIssuer(true); 
    testprofile.setPreference("network.proxy.type", 1); 
    testprofile.setPreference("network.proxy.http", "localhost"); 
    testprofile.setPreference("network.proxy.http_port", 3128); 
    DesiredCapabilities dc = DesiredCapabilities.firefox(); 
    dc.setCapability(FirefoxDriver.PROFILE, testprofile); 
    dc.setCapability("marionette", true); 
    WebDriver driver = new FirefoxDriver(dc); 

讓我知道這是否對你有幫助。

0

嘗試使用下面的48版本的Firefox。你不會遇到任何問題或包括下面的代碼在現有的代碼:

System.setProperty("webdriver.firefox.bin" ,"C:/Users/siddhesh.kalgaonkar/AppData/Local/Mozilla Firefox/firefox.exe"); 

應該解決您的問題,因爲這是我使用當前版本的Firefox。

0

使用Firefox 54.0 64位,硒v3.4.0,jcommender V1.7,TestNG的v6.9.9,Java的V8.0,蛤蚧司機v0.17.0

下面代碼 -

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

public class AppUrl { 
public static WebDriver driver; 
public static final String url = "https://10.10.1.1"; 

@BeforeTest 

public void setup() throws Exception { 
    System.setProperty("webdriver.gecko.driver","C:/Users/Downloads/geckodriver.exe"); 
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); 
    desiredCapabilities.setAcceptInsecureCerts(true); 
    driver = new FirefoxDriver(desiredCapabilities); 
    driver.get(url); 
    } 
} 

即使使用我嘗試了來自不同網站的其他示例代碼。今天升級所有軟件並運行代碼後,它爲我工作。