2017-05-02 46 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); 
    } 
} 

即使使用我尝试了来自不同网站的其他示例代码。今天升级所有软件并运行代码后,它为我工作。