1

使用 Selenium 2.53.1 版和 Firefox 浏览器 35 版以及此脚本:

package no.mine;

import java.net.MalformedURLException;
import org.junit.Assert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.remote.*;

import java.util.concurrent.TimeUnit;

public class SeleniumAdmin {

private static WebDriver driver = null;

public static void main(String[] args) {

    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile ffProfile = profile.getProfile("MagnusQA");

    ffProfile.setAcceptUntrustedCertificates(true);
    ffProfile.setAssumeUntrustedCertificateIssuer(false);
    ffProfile.setPreference("extensions.shownSelectionUI", true);


    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    capabilities.setCapability(FirefoxDriver.PROFILE, ffProfile);

    driver = new FirefoxDriver(ffProfile);

    driver.get("https://my_url/");
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.close();

    System.exit(0);
}}

我看到浏览器已启动,并出现如附件所示的对话框。

在此处输入图像描述

我以为我的代码:

ffProfile.setAcceptUntrustedCertificates(true);

会确保对话会得到处理(如“按确定”)?

我如何告诉浏览器“始终接受”Firefox 配置文件中的证书?

4

0 回答 0