Example usage for org.openqa.selenium.firefox FirefoxProfile setAssumeUntrustedCertificateIssuer

List of usage examples for org.openqa.selenium.firefox FirefoxProfile setAssumeUntrustedCertificateIssuer

Introduction

In this page you can find the example usage for org.openqa.selenium.firefox FirefoxProfile setAssumeUntrustedCertificateIssuer.

Prototype

public void setAssumeUntrustedCertificateIssuer(boolean untrustedIssuer) 

Source Link

Document

By default, when accepting untrusted SSL certificates, assume that these certificates will come from an untrusted issuer or will be self signed.

Usage

From source file:NumOfWHGamesTest.java

@Before
public void setup() throws MalformedURLException, UnknownHostException {

    ProfilesIni allProfiles = new ProfilesIni();
    FirefoxProfile myProfile = allProfiles.getProfile("SimBin");
    myProfile.setAcceptUntrustedCertificates(true);
    myProfile.setAssumeUntrustedCertificateIssuer(false);
    driver2 = new FirefoxDriver(myProfile);

    WebDriverWait wait = new WebDriverWait(driver2, 15);
    driver2.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    driver2.navigate().to(urlWHGames);/*from w ww .j  a  v  a 2 s .  co m*/
    driver2.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver2.navigate().to(urlWHGamesAZ);

    wait.until(ExpectedConditions.urlMatches(urlWHGamesAZ));

    wait = new WebDriverWait(driver2, 30);
    driver2.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

From source file:LoginWHTest.java

@Before
public void setup() throws MalformedURLException, UnknownHostException {

    ProfilesIni allProfiles = new ProfilesIni();
    FirefoxProfile myProfile = allProfiles.getProfile("SimBin");
    myProfile.setAcceptUntrustedCertificates(true);
    myProfile.setAssumeUntrustedCertificateIssuer(false);
    driver2 = new FirefoxDriver(myProfile);

    WebDriverWait wait = new WebDriverWait(driver2, 15);
    driver2.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    driver2.navigate().to(urlWHGames);/* w  w  w.j  av a 2 s  .  c om*/
    driver2.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

/**
 * This method build a webDriver based on the passed in browser request
 *
 * @param browser/*  w w  w .  j  a v a  2 s.co  m*/
 * @return WebDriver
 * @throws MalformedURLException
 */
private static WebDriver buildWebDriver(String browserName) {
    DesiredCapabilities capability = null;
    BrowserType browserType = BrowserType.getBrowserTypeFromString(browserName);
    switch (browserType) {
    case MARIONETTE:
        FirefoxProfile ffProfile = null;
        ffProfile = new FirefoxProfile();
        ffProfile.setAcceptUntrustedCertificates(true);
        ffProfile.setAssumeUntrustedCertificateIssuer(false);
        DesiredCapabilities cap = DesiredCapabilities.firefox();
        cap.setCapability("marionette", true);
        cap.setCapability("firefox_profile", ffProfile);
        cap.setCapability("handlesAlerts", true);
        sysEnv = System.getenv("webdriver.firefox.marionette");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "geckodriver.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.firefox.marionette in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.firefox.marionette", sysEnv);
            }
        }
        return new MarionetteDriver(capability);
    case FIREFOX_DRIVER:
        capability = DesiredCapabilities.firefox();
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.setAcceptUntrustedCertificates(true);
        firefoxProfile.setEnableNativeEvents(true);
        firefoxProfile.setAssumeUntrustedCertificateIssuer(true);
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
        return new FirefoxDriver(capability);
    case CHROME_DRIVER:
        sysEnv = System.getenv("webdriver.chrome.driver");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "chromedriver.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.chrome.driver in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.chrome.driver", sysEnv);
            }
        }
        capability = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments(new String[] { "--allow-running-insecure-content" });
        options.addArguments(new String[] { "--ignore-certificate-errors" });
        options.addArguments(new String[] { "--enable-npapi" });
        options.addArguments(new String[] { "--disable-extensions" });
        options.addArguments(new String[] { "--start-maximized" });
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability(ChromeOptions.CAPABILITY, options);
        return new ChromeDriver(capability);
    case INTERNET_EXPLORER:
        sysEnv = System.getenv("webdriver.ie.driver");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "IEDriverServer.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.ie.driver in system environment variables and restart the PC");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.ie.driver", sysEnv);
            }
        }
        capability = DesiredCapabilities.internetExplorer();
        capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        capability.setCapability("ignoreProtectedModeSettings", true);
        capability.setCapability("acceptSslCerts", true);
        capability.setCapability("ignoreZoomSetting", true);
        capability.setCapability("nativeEvents", true);
        capability.setCapability("ie.ensureCleanSession", true);
        return new InternetExplorerDriver(capability);
    case SAFARI:
        capability = DesiredCapabilities.safari();
        capability.setCapability("acceptSslCerts", true);
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability("ensureCleanSession", true);
        capability.setJavascriptEnabled(true);
        return new SafariDriver(capability);
    /*        case OPERA_DRIVER:
    capability = DesiredCapabilities.opera();
    capability.setCapability("opera.host", "127.0.0.1");
    return new OperaDriver();
     */
    case EDGE:
        capability = DesiredCapabilities.edge();
        EdgeOptions option = new EdgeOptions();
        capability.setCapability("edgeOptions", option);
        return new EdgeDriver(capability);
    default:
        log.info(
                "Currenty support is there for Chrome, Firefox, Firefox Marionette, Internet Explorer, Edge, Safari & Opera. Support is not there for "
                        + browserName);
        capability = DesiredCapabilities.firefox();
        FirefoxProfile firefoxProf = new FirefoxProfile();
        firefoxProf.setAcceptUntrustedCertificates(true);
        firefoxProf.setEnableNativeEvents(true);
        firefoxProf.setAssumeUntrustedCertificateIssuer(true);
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProf);
        return new FirefoxDriver(capability);
    }
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

/**
 * This method build a RemoteWebDriver based on the passed in browser request
 *
 * @param browser// ww  w  . j  a va  2  s  . c o  m
 * @return RemoteWebDriver
 *
 */
private static RemoteWebDriver buildRemoteWebDriver(String browserName) {
    DesiredCapabilities capability = null;
    BrowserType browserType = BrowserType.getBrowserTypeFromString(browserName);
    switch (browserType) {
    case MARIONETTE:
        FirefoxProfile ffProfile = null;
        ffProfile = new FirefoxProfile();
        ffProfile.setAcceptUntrustedCertificates(true);
        ffProfile.setAssumeUntrustedCertificateIssuer(false);
        DesiredCapabilities cap = DesiredCapabilities.firefox();
        cap.setCapability("marionette", true);
        cap.setCapability("firefox_profile", ffProfile);
        cap.setCapability("handlesAlerts", true);
        sysEnv = System.getenv("webdriver.firefox.marionette");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "geckodriver.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.firefox.marionette in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.firefox.marionette", sysEnv);
            }
        }
        return new MarionetteDriver(capability);
    case FIREFOX_DRIVER:
        capability = DesiredCapabilities.firefox();
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.setAcceptUntrustedCertificates(true);
        firefoxProfile.setEnableNativeEvents(true);
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
        capability.setPlatform(capability.getPlatform());
        capability.setVersion(capability.getVersion());
        return new FirefoxDriver(capability);
    case CHROME_DRIVER:
        sysEnv = System.getenv("webdriver.chrome.driver");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "chromedriver.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.chrome.driver in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.chrome.driver", sysEnv);
            }
        }
        capability = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments(new String[] { "--allow-running-insecure-content" });
        options.addArguments(new String[] { "--ignore-certificate-errors" });
        options.addArguments(new String[] { "--enable-npapi" });
        options.addArguments(new String[] { "--disable-extensions" });
        options.addArguments(new String[] { "--start-maximized" });
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability(ChromeOptions.CAPABILITY, options);
        capability.setPlatform(capability.getPlatform());
        capability.setVersion(capability.getVersion());
        return new ChromeDriver(capability);
    case INTERNET_EXPLORER:
        sysEnv = System.getenv("webdriver.ie.driver");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "IEDriverServer.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.ie.driver in system environment variables and restart the PC");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.ie.driver", sysEnv);
            }
        }
        capability = DesiredCapabilities.internetExplorer();
        capability.setCapability("ignoreProtectedModeSettings", true);
        String browserVersion = capability.getVersion();
        if (browserVersion != null && browserVersion.equals("10")) {
            capability.setPlatform(Platform.WINDOWS);
            capability.setVersion(browserVersion);
        } else if (browserVersion != null && browserVersion.equals("11")) {
            capability.setPlatform(Platform.WIN8_1);
            capability.setVersion(browserVersion);
        }
        capability.setBrowserName("internet explorer");
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        return new InternetExplorerDriver(capability);
    case SAFARI:
        capability = DesiredCapabilities.safari();
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability("ensureCleanSession", true);
        capability.setPlatform(capability.getPlatform());
        capability.setVersion(null);
        return new SafariDriver(capability);
    /*         case OPERA_DRIVER:
    capability = DesiredCapabilities.opera();
    capability.setCapability("opera.profile", "/test");
    return new OperaDriver();
    */
    case EDGE:
        capability = DesiredCapabilities.edge();
        EdgeOptions option = new EdgeOptions();
        capability.setCapability("edgeOptions", option);
        return new EdgeDriver(capability);
    default:
        log.info(
                "Currenty support is there for Chrome, Firefox, Firefox Marionette, Internet Explorer, Edge, Safari & Opera. Support is not there for "
                        + browserName);
        capability = DesiredCapabilities.firefox();
        firefoxProfile = new FirefoxProfile();
        firefoxProfile.setAcceptUntrustedCertificates(true);
        firefoxProfile.setEnableNativeEvents(true);
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
        capability.setPlatform(capability.getPlatform());
        capability.setVersion(capability.getVersion());
        return new FirefoxDriver(capability);
    }
}

From source file:com.cognifide.aet.worker.drivers.FirefoxWebDriverFactory.java

License:Apache License

@Override
public WebCommunicationWrapper createWebDriver(ProxyServerWrapper proxyServer) throws WorkerException {
    try {//from  ww  w .j  ava2 s.c  o m
        Proxy proxy = proxyServer.seleniumProxy();
        proxyServer.setCaptureContent(true);
        proxyServer.setCaptureHeaders(true);

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.PROXY, proxy);
        capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

        FirefoxProfile fp = getFirefoxProfile();
        fp.setAcceptUntrustedCertificates(true);
        fp.setAssumeUntrustedCertificateIssuer(false);
        capabilities.setCapability(AetFirefoxDriver.PROFILE, fp);

        return new WebCommunicationWrapperImpl(getFirefoxDriver(fp, capabilities), proxyServer,
                builderFactory.createInstance());
    } catch (Exception e) {
        throw new WorkerException(e.getMessage(), e);
    }
}

From source file:com.consol.citrus.selenium.client.WebClient.java

License:Apache License

private FirefoxProfile createFireFoxProfile() {
    FirefoxProfile fp = new FirefoxProfile();

    fp.setAcceptUntrustedCertificates(true);
    fp.setAssumeUntrustedCertificateIssuer(false);

    /* set custom download folder */
    fp.setPreference("browser.download.dir", temporaryStorage.toFile().getAbsolutePath());

    /* default download folder, set to 2 to use custom download folder */
    fp.setPreference("browser.download.folderList", 2);

    /* comma separated list if MIME types to save without asking */
    fp.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/plain");

    /* do not show download manager */
    fp.setPreference("browser.download.manager.showWhenStarting", false);

    fp.setEnableNativeEvents(true);/*from ww  w .jav a2 s. co  m*/

    return fp;
}

From source file:com.elastica.browserfactory.FirefoxCapabilitiesFactory.java

License:Apache License

protected void configProfile(final FirefoxProfile profile, final DriverConfig webDriverConfig) {
    profile.setAcceptUntrustedCertificates(webDriverConfig.isSetAcceptUntrustedCertificates());
    profile.setAssumeUntrustedCertificateIssuer(webDriverConfig.isSetAssumeUntrustedCertificateIssuer());

    if (webDriverConfig.getFirefoxBinPath() != null) {
        System.setProperty("webdriver.firefox.bin", webDriverConfig.getFirefoxBinPath());
    }/*w  w w . j a v  a2s. c om*/

    if (webDriverConfig.getUserAgentOverride() != null) {
        profile.setPreference("general.useragent.override", webDriverConfig.getUserAgentOverride());
    }

    if (webDriverConfig.getNtlmAuthTrustedUris() != null) {
        profile.setPreference("network.automatic-ntlm-auth.trusted-uris",
                webDriverConfig.getNtlmAuthTrustedUris());
    }

    if (webDriverConfig.getBrowserDownloadDir() != null) {
        profile.setPreference("browser.download.dir", webDriverConfig.getBrowserDownloadDir());
        profile.setPreference("browser.download.folderList", 2);
        profile.setPreference("browser.download.manager.showWhenStarting", false);
        profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
                "application/octet-stream,text/plain,application/pdf,application/zip,text/csv,text/html");
    }

    if (!webDriverConfig.isEnableJavascript()) {
        profile.setPreference("javascript.enabled", false);
    } else {

        // Add Firefox extension to collect JS Error
        if (webDriverConfig.isAddJSErrorCollectorExtension()) {
            try {
                JavaScriptError.addExtension(profile);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    // fix permission denied issues
    profile.setPreference("capability.policy.default.Window.QueryInterface", "allAccess");
    profile.setPreference("capability.policy.default.Window.frameElement.get", "allAccess");
    profile.setPreference("capability.policy.default.HTMLDocument.compatMode.get", "allAccess");
    profile.setPreference("capability.policy.default.Document.compatMode.get", "allAccess");
    profile.setEnableNativeEvents(false);
    profile.setPreference("dom.max_chrome_script_run_time", 0);
    profile.setPreference("dom.max_script_run_time", 0);
}

From source file:com.ggasoftware.uitest.utils.WebDriverWrapper.java

License:Open Source License

/**
 * initialization FirefoxDriver/* w  ww.jav a 2  s. c  o m*/
 */
public static void initFirefoxDriver() {
    ReporterNGExt.logTechnical("Initialization Firefox Driver");
    FirefoxProfile profile = new FirefoxProfile();
    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(true);
    profile.setEnableNativeEvents(true);
    profile.setPreference("javascript.enabled", true);
    profile.setPreference("dom.max_script_run_time", 0);
    profile.setPreference("dom.max_chrome_script_run_time", 0);
    setWebDriver(new FirefoxDriver(profile));
    setTimeout(TIMEOUT);
    getDriver().manage().window().maximize();
}

From source file:com.seleniumtests.browserfactory.MarionetteCapabilitiesFactory.java

License:Apache License

protected void configProfile(final FirefoxProfile profile, final DriverConfig webDriverConfig) {
    profile.setAcceptUntrustedCertificates(webDriverConfig.isSetAcceptUntrustedCertificates());
    profile.setAssumeUntrustedCertificateIssuer(webDriverConfig.isSetAssumeUntrustedCertificateIssuer());

    if (webDriverConfig.getFirefoxBinPath() != null) {
        System.setProperty("webdriver.firefox.bin", webDriverConfig.getFirefoxBinPath());
    }//from w  ww .  j  av  a 2  s.  c o m

    if (webDriverConfig.getUserAgentOverride() != null) {
        profile.setPreference("general.useragent.override", webDriverConfig.getUserAgentOverride());
    }

    if (webDriverConfig.getNtlmAuthTrustedUris() != null) {
        profile.setPreference("network.automatic-ntlm-auth.trusted-uris",
                webDriverConfig.getNtlmAuthTrustedUris());
    }

    if (webDriverConfig.getBrowserDownloadDir() != null) {
        profile.setPreference("browser.download.dir", webDriverConfig.getBrowserDownloadDir());
        profile.setPreference("browser.download.folderList", 2);
        profile.setPreference("browser.download.manager.showWhenStarting", false);
        profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
                "application/octet-stream,text/plain,application/pdf,application/zip,text/csv,text/html");
    }

    if (!webDriverConfig.isEnableJavascript()) {
        profile.setPreference("javascript.enabled", false);
    }

    // fix permission denied issues
    profile.setPreference("capability.policy.default.Window.QueryInterface", "allAccess");
    profile.setPreference("capability.policy.default.Window.frameElement.get", "allAccess");
    profile.setPreference("capability.policy.default.HTMLDocument.compatMode.get", "allAccess");
    profile.setPreference("capability.policy.default.Document.compatMode.get", "allAccess");
    profile.setEnableNativeEvents(false);
    profile.setPreference("dom.max_chrome_script_run_time", 0);
    profile.setPreference("dom.max_script_run_time", 0);
}

From source file:com.tascape.qa.th.webui.comm.Firefox.java

License:Apache License

public Firefox(boolean enableFirebug) throws Exception {
    FirefoxProfile profile;

    ProfilesIni profileIni = new ProfilesIni();
    String profileName = sysConfig.getProperty(SYSPROP_FF_PROFILE_NAME);
    if (profileName != null) {
        LOG.debug("Load Firefox profile named as {}", profileName);
        profile = profileIni.getProfile(profileName);
    } else {//ww  w  .ja  v a2  s  . c o m
        LOG.debug("Load Firefox profile named as {}", DEFAULT_FF_PROFILE_NAME);
        profile = profileIni.getProfile(DEFAULT_FF_PROFILE_NAME);
    }
    if (profile == null) {
        throw new Exception("Cannot find Firefox profile");
    }

    profile.setPreference("app.update.enabled", false);
    profile.setEnableNativeEvents(false);
    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(false);
    profile.setPreference("dom.max_chrome_script_run_time", 0);
    profile.setPreference("dom.max_script_run_time", 0);
    if (enableFirebug) {
        this.firebug = new Firebug();
        this.firebug.updateProfile(profile);
    }
    long end = System.currentTimeMillis() + 180000;
    while (System.currentTimeMillis() < end) {
        try {
            super.setWebDriver(new FirefoxDriver(profile));
            break;
        } catch (org.openqa.selenium.WebDriverException ex) {
            String msg = ex.getMessage();
            LOG.warn(msg);
            if (!msg.contains("Unable to bind to locking port 7054 within 45000 ms")) {
                throw ex;
            }
        }
    }
}