Java Code Examples for org.openqa.selenium.firefox.FirefoxProfile#setAcceptUntrustedCertificates()

The following examples show how to use org.openqa.selenium.firefox.FirefoxProfile#setAcceptUntrustedCertificates() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FirefoxFrozenPreferences.java    From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License 6 votes vote down vote up
public static void main(String... args) {

        System.setProperty("webdriver.gecko.driver",
                "./src/test/resources/drivers/geckodriver 2");

        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("browser.shell.checkDefaultBrowser", true);
        profile.setAssumeUntrustedCertificateIssuer(false);
        profile.setAcceptUntrustedCertificates(false);

        FirefoxOptions firefoxOptions = new FirefoxOptions();
        firefoxOptions.setProfile(profile);

        FirefoxDriver driver = new FirefoxDriver(firefoxOptions);
        driver.get("http://facebook.com");
    }
 
Example 2
Source File: FireFoxCaps.java    From teasy with MIT License 5 votes vote down vote up
private FirefoxProfile createFirefoxProfile() {
    FirefoxProfile profile = new FirefoxProfile();

    profile.setPreference("dom.max_chrome_script_run_time", 999);
    profile.setPreference("dom.max_script_run_time", 999);

    //Disable plugin container. fix problem with 'FF plugin-container has stopped working'.
    profile.setPreference("dom.ipc.plugins.enabled", false);
    profile.setPreference("dom.ipc.plugins.enabled.npctrl.dll", false);
    profile.setPreference("dom.ipc.plugins.enabled.npqtplugin.dll", false);
    profile.setPreference("dom.ipc.plugins.enabled.npswf32.dll", false);
    profile.setPreference("dom.ipc.plugins.enabled.nptest.dll", false);
    profile.setPreference("dom.ipc.plugins.timeoutSecs", -1);
    //Add this to avoid JAVA plugin certificate warnings
    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(true);
    profile.setPreference("plugin.state.java", 2);

    //TODO VE NT check if this is still actual
    //disable  Advocacy/heartbeat in Firefox 37
    //http://selenium2.ru/news/131-rekomenduetsya-otklyuchit-advocacy-heartbeat-v-firefox-37.html
    profile.setPreference("browser.selfsupport.url", "");

    //for sso auth
    profile.setPreference("network.http.phishy-userpass-length", 255);
    profile.setPreference("network.automatic-ntlm-auth.trusted-uris", "http://,https://");

    return profile;
}
 
Example 3
Source File: FirefoxBrowser.java    From SeleniumCucumber with GNU General Public License v3.0 5 votes vote down vote up
public Capabilities getFirefoxCapabilities() {
	DesiredCapabilities firefox = DesiredCapabilities.firefox();
	FirefoxProfile profile = new FirefoxProfile();
	profile.setAcceptUntrustedCertificates(true);
	profile.setAssumeUntrustedCertificateIssuer(true);
	firefox.setCapability(FirefoxDriver.PROFILE, profile);
	firefox.setCapability("marionette", true);
	return firefox;
}
 
Example 4
Source File: FirefoxCapabilitiesFactory.java    From seleniumtestsframework with Apache License 2.0 5 votes vote down vote up
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());
    }

    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.setPreference("dom.max_chrome_script_run_time", 0);
    profile.setPreference("dom.max_script_run_time", 0);
}
 
Example 5
Source File: TestBrowserFactory.java    From webtester-core with Apache License 2.0 5 votes vote down vote up
@Override
public Browser createBrowser() {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setAcceptUntrustedCertificates(true);
    profile.setEnableNativeEvents(false);
    return createBrowser(new FirefoxDriver(profile));
}
 
Example 6
Source File: WebDriverCapabilities.java    From QVisual with Apache License 2.0 4 votes vote down vote up
private void setupFirefox() {
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    firefoxProfile.setPreference("dom.webnotifications.enabled", false);
    firefoxProfile.setAcceptUntrustedCertificates(true);
    firefoxProfile.setPreference("app.update.enabled", false);
    firefoxProfile.setPreference("devtools.devedition.promo.url", "");
    firefoxProfile.setPreference("xpinstall.signatures.required", false);
    firefoxProfile.setPreference("browser.startup.homepage;about:home", "about:blank");
    firefoxProfile.setPreference("browser.startup.homepage_override.mstone", "ignore");
    firefoxProfile.setPreference("browser.usedOnWindows10", false);
    firefoxProfile.setPreference("browser.usedOnWindows10.introURL", "about:blank");
    firefoxProfile.setPreference("startup.homepage_welcome_url", "about:blank");
    firefoxProfile.setPreference("startup.homepage_welcome_url.additional", "about:blank");
    firefoxProfile.setPreference("browser.helperApps.alwaysAsk.force", false);
    firefoxProfile.setPreference("browser.download.folderList", 2);
    firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
    firefoxProfile.setPreference("browser.download.manager.useWindow", false);
    firefoxProfile.setPreference("browser.download.manager.alertOnEXEOpen", false);
    firefoxProfile.setPreference("browser.download.dir", DOWNLOAD_DIRECTORY);
    firefoxProfile.setPreference("browser.download.manager.focusWhenStarting", false);
    firefoxProfile.setPreference("browser.download.useDownloadDir", true);
    firefoxProfile.setPreference("browser.download.manager.closeWhenDone", true);
    firefoxProfile.setPreference("browser.download.manager.showAlertOnComplete", false);
    firefoxProfile.setPreference("browser.download.panel.shown", false);
    firefoxProfile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
    firefoxProfile.setPreference("pdfjs.disabled", true);
    firefoxProfile.setPreference("plugin.scan.Acrobat", "99.0");
    firefoxProfile.setPreference("plugin.scan.plid.all", false);
    firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-msdownload," +
            "application/AppleLink," +
            "application/x-newton-compatible-pkg," +
            "image/png," +
            "application/ris," +
            "text/csv," +
            "text/xml," +
            "text/html," +
            "text/plain," +
            "application/xml," +
            "application/zip," +
            "application/x-zip," +
            "application/x-zip-compressed," +
            "application/download," +
            "application/octet-stream," +
            "application/excel," +
            "application/vnd.ms-excel," +
            "application/x-excel," +
            "application/x-msexcel," +
            "application/vnd.openxmlformats-officedocument.spreadsheetml.template," +
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet," +
            "application/msword," +
            "application/csv," +
            "application/pdf," +
            "application/vnd.openxmlformats-officedocument.wordprocessingml.document," +
            "application/vnd.openxmlformats-officedocument.wordprocessingml.template");

    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setProfile(firefoxProfile);
    firefoxOptions.setHeadless(BROWSER_HEADLESS);

    capabilities.merge(firefoxOptions);
}
 
Example 7
Source File: BrowserDriver.java    From SWET with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
private static DesiredCapabilities capabilitiesFirefox() {

	final String geckoDriverPath = (applicationGeckoDriverPath == null)
			? osName.toLowerCase().startsWith("windows")
					? "c:/java/selenium/geckodriver.exe" : "/var/run/geckodriver"
			: applicationGeckoDriverPath;
	// firefox.browser.path
	final String firefoxBrowserPath = (applicationFirefoxBrowserPath == null)
			? osName.toLowerCase().startsWith("windows")
					? "c:/Program Files (x86)/Mozilla Firefox/firefox.exe"
					: osName.toLowerCase().startsWith("mac")
							? "/Applications/Firefox.app/Contents/MacOS/firefox.bin"
							: "/usr/bin/firefox/firefox"
			: applicationFirefoxBrowserPath;
	System.setProperty("webdriver.gecko.driver",
			new File(geckoDriverPath).getAbsolutePath());
	System.setProperty("webdriver.firefox.bin",
			new File(firefoxBrowserPath).getAbsolutePath());
	System.setProperty("webdriver.reap_profile", "false");
	DesiredCapabilities capabilities = DesiredCapabilities.firefox();

	// TODO: switch to Selenium 3.X+
	/*
	FirefoxOptions firefoxOptions = new FirefoxOptions();
	firefoxOptions.setBinary(new File(firefoxBrowserPath).getAbsolutePath());
	
	capabilities.setCapability("moz:firefoxOptions", firefoxOptions);
	*/
	capabilities.setCapability("firefox_binary",
			new File(firefoxBrowserPath).getAbsolutePath());

	capabilities.setCapability("marionette", false);
	FirefoxProfile profile = new FirefoxProfile();
	// no longer exists in Selenium
	// profile.setEnableNativeEvents(true);
	profile.setAcceptUntrustedCertificates(true);
	profile.setAssumeUntrustedCertificateIssuer(false);

	// Disable Firefox Auto-Updating
	profile.setPreference("app.update.auto", false);
	profile.setPreference("app.update.enabled", false);

	capabilities.setCapability(FirefoxDriver.PROFILE, profile);
	capabilities.setCapability("elementScrollBehavior", 1);
	capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
	return capabilities;
}
 
Example 8
Source File: AbstractCapabilities.java    From carina with Apache License 2.0 4 votes vote down vote up
/**
 * Generate default default Carina FirefoxProfile.
 *
 * @return Firefox profile.
 */
// keep it public to be bale to get default and override on client layerI
public FirefoxProfile getDefaultFirefoxProfile() {
    FirefoxProfile profile = new FirefoxProfile();

    // update browser language
    String browserLang = Configuration.get(Parameter.BROWSER_LANGUAGE);
    if (!browserLang.isEmpty()) {
        LOGGER.info("Set Firefox lanaguage to: " + browserLang);
        profile.setPreference("intl.accept_languages", browserLang);
    }

    boolean generated = false;
    int newPort = 7055;
    int i = 100;
    while (!generated && (--i > 0)) {
        newPort = PortProber.findFreePort();
        generated = firefoxPorts.add(newPort);
    }
    if (!generated) {
        newPort = 7055;
    }
    if (firefoxPorts.size() > 20) {
        firefoxPorts.remove(0);
    }

    profile.setPreference(FirefoxProfile.PORT_PREFERENCE, newPort);
    LOGGER.debug("FireFox profile will use '" + newPort + "' port number.");

    profile.setPreference("dom.max_chrome_script_run_time", 0);
    profile.setPreference("dom.max_script_run_time", 0);

    if (Configuration.getBoolean(Configuration.Parameter.AUTO_DOWNLOAD) && !(Configuration.isNull(Configuration.Parameter.AUTO_DOWNLOAD_APPS)
            || "".equals(Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS)))) {
        profile.setPreference("browser.download.folderList", 2);
        profile.setPreference("browser.download.dir", getAutoDownloadFolderPath());
        profile.setPreference("browser.helperApps.neverAsk.saveToDisk", Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS));
        profile.setPreference("browser.download.manager.showWhenStarting", false);
        profile.setPreference("browser.download.saveLinkAsFilenameTimeout", 1);
        profile.setPreference("pdfjs.disabled", true);
        profile.setPreference("plugin.scan.plid.all", false);
        profile.setPreference("plugin.scan.Acrobat", "99.0");
    } else if (Configuration.getBoolean(Configuration.Parameter.AUTO_DOWNLOAD) && Configuration.isNull(Configuration.Parameter.AUTO_DOWNLOAD_APPS)
            || "".equals(Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS))) {
        LOGGER.warn(
                "If you want to enable auto-download for FF please specify '" + Configuration.Parameter.AUTO_DOWNLOAD_APPS.getKey() + "' param");
    }

    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(true);

    // TODO: implement support of custom args if any
    return profile;
}