2016-11-07 22 views
2

我的Firefox版本是46.0.1,Selenium版本是3.0.1。在执行以下代码Firefox错误:“您的连接不安全”使用Java启动Selenium 3.0.1的驱动程序

Your connection is not secure

@Test 
public void test() { 
    ProfilesIni profile = new ProfilesIni(); 
    FirefoxProfile ffProfile = profile.getProfile("newCretedProfile"); 
    ffProfile.setAcceptUntrustedCertificates(true); 
    ffProfile.setAssumeUntrustedCertificateIssuer(false); 
    System.setProperty("webdriver.gecko.driver", "D:\\SELENUIUM\\Drivers\\geckodriver.exe"); 
    FirefoxDriver driver = new FirefoxDriver(ffProfile); 
    driver.get("http://www.google.com"); 
    driver.quit(); 
} 

我已经创造了新的Firefox配置文件,并随后从该url

步骤但是它不工作,并给了我同样的错误 我收到错误而我启动任何网站。

+0

你能提供您收到一条错误消息? –

+0

嗨@ChristianGrabowski我得到这个异常:'org.openqa.selenium.WebDriverException:加载页面时出错' –

回答

0

如果你想使用Selenium 3.0设置Firefox的驱动能力“提线木偶”,以虚假的运行在Firefox测试。

@Test 
public void test() { 
    DesiredCapabilities d = new DesiredCapabilities(); 
    d.setCapability("marionette", false); 
    WebDriver driver = new FirefoxDriver(d); 
    driver.get("http://www.google.com"); 
    driver.quit(); 
} 
2

我试过这种方法,它对我很好。

按照以下步骤创建新的Firefox配置文件。

  1. 关闭所有的Firefox窗口
  2. 在运行对话框中,在类型:“firefox.exe -p”,然后点击确定。
  3. 单击“创建配置文件”
  4. 为您的新的配置文件创建一个名称(比如硒)
  5. 点击“选择文件夹”
  6. 选择位置的东西很容易找到 - 如“C:\ NewFirefoxProfile”
  7. 点击完成
  8. 现在选择新创建的配置文件后,启动Firefox。打开您获得的“安全连接问题”的特定网址,接受此配置文件的SSL证书。

enter image description here

现在使用新创建的Firefox配置文件来运行你的Selenium测试。根据您的要求修改以下代码。

System.setProperty("webdriver.firefox.marionette","D:\\SELENUIUM\\Drivers\\geckodriver.exe"); 
ProfilesIni profile = new ProfilesIni();  
FirefoxProfile myprofile = profile.getProfile("C:\\NewFirefoxProfile");//location of your new firefox profile 
WebDriver driver = new FirefoxDriver(myprofile); 
driver.get("https://cacert.org/"); 
2

下载Firefox 55 beta和设置

capabilities.setCapability("acceptInsecureCerts", true); 

这里是我的代码的Firefox 55 Beta版的工作原理:

DesiredCapabilities capabilities = new DesiredCapabilities(); 
capabilities.setBrowserName("firefox"); 
capabilities.setCapability("acceptInsecureCerts", true); 
RemoteWebDriver driver = new RemoteWebDriver(Environment.remoteWebDriverURL, capabilities); 
+0

请为代码添加一些描述。@ Sergey –

相关问题