FirefoxOptions createFirefoxOptions(Config config, Proxy proxy) { FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setHeadless(config.headless()); if (!config.browserBinary().isEmpty()) { log.info("Using browser binary: " + config.browserBinary()); firefoxOptions.setBinary(config.browserBinary()); } firefoxOptions.addPreference("network.automatic-ntlm-auth.trusted-uris", "http://,https://"); firefoxOptions.addPreference("network.automatic-ntlm-auth.allow-non-fqdn", true); firefoxOptions.addPreference("network.negotiate-auth.delegation-uris", "http://,https://"); firefoxOptions.addPreference("network.negotiate-auth.trusted-uris", "http://,https://"); firefoxOptions.addPreference("network.http.phishy-userpass-length", 255); firefoxOptions.addPreference("security.csp.enable", false); firefoxOptions.addPreference("network.proxy.no_proxies_on", ""); firefoxOptions.merge(createCommonCapabilities(config, proxy)); firefoxOptions = transferFirefoxProfileFromSystemProperties(firefoxOptions); return firefoxOptions; }
@Override public FirefoxOptions getDefaultOptions() { FirefoxOptions opt = new FirefoxOptions(); opt.addPreference("browser.startup.homepage", "about:blank"); opt.addPreference("startup.homepage_welcome_url", "about:blank"); opt.addPreference("startup.homepage_welcome_url.additional", "about:blank"); return opt; }
private void addUserPreferencesFromFile(DesiredCapabilities capabilities, FirefoxOptions firefoxOptions) { final String userPreferences = (String) capabilities.getCapability("firefoxUserPreferences"); if (Validate.nonEmpty(userPreferences)) { Validate.isValidPath(userPreferences, "User preferences does not point to a valid path " + userPreferences); // we need to manually parse preferences, as Selenium provides no way to set these value for (Map.Entry<String, Object> preference : FirefoxPrefsReader.getPreferences(new File(userPreferences)) .entrySet()) { String key = preference.getKey(); Object value = preference.getValue(); if (value instanceof Boolean) { firefoxOptions.addPreference(key, (Boolean) value); } else if (value instanceof Integer) { firefoxOptions.addPreference(key, (Integer) value); } else if (value instanceof String) { firefoxOptions.addPreference(key, (String) value); } } } }
private void addUserPreferencesFromFile(DesiredCapabilities capabilities, FirefoxOptions firefoxOptions) { final String userPreferences = (String) capabilities.getCapability("firefoxUserPreferences"); if (Validate.nonEmpty(userPreferences)) { Validate.isValidPath(userPreferences, "User preferences does not point to a valid path " + userPreferences); // we need to manually parse preferences, as Selenium provides no way to set these value for (Map.Entry<String, Object> preference : FirefoxPrefsReader.getPreferences(new File(userPreferences)) .entrySet()) { String key = preference.getKey(); Object value = preference.getValue(); if (value instanceof Boolean) { firefoxOptions.addPreference(key, (Boolean) value); } else if (value instanceof Integer) { firefoxOptions.addPreference(key, (Integer) value); } else if (value instanceof String) { firefoxOptions.addPreference(key, (String) value); } } } }
private void managePreferences(Parameter parameter, FirefoxOptions firefoxOptions) { Preferences preferences = parameter.getAnnotation(Preferences.class); if (preferences != null) { for (String preference : preferences.value()) { Optional<List<Object>> keyValue = annotationsReader .getKeyValue(preference); if (!keyValue.isPresent()) { continue; } String name = keyValue.get().get(0).toString(); String value = keyValue.get().get(1).toString(); if (annotationsReader.isBoolean(value)) { firefoxOptions.addPreference(name, valueOf(value)); } else if (annotationsReader.isNumeric(value)) { firefoxOptions.addPreference(name, parseInt(value)); } else { firefoxOptions.addPreference(name, value); } } } }
firefoxOptions.addPreference("media.navigator.permission.disabled", true); firefoxOptions.addPreference("media.navigator.streams.fake", true);
firefoxOptions.addPreference("media.navigator.permission.disabled", true); firefoxOptions.addPreference("media.navigator.streams.fake", true);
firefoxOptions.addPreference("network.proxy.type", 1); firefoxOptions.addPreference("network.proxy.http", proxyAddress); firefoxOptions.addPreference("network.proxy.http_port", proxyPort); firefoxOptions.addPreference("network.proxy.ssl", proxyAddress); firefoxOptions.addPreference("network.proxy.ssl_port", proxyPort); firefoxOptions.addPreference("network.proxy.share_proxy_settings", true); firefoxOptions.addPreference("network.proxy.no_proxies_on", "");
case "firefox": FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.addPreference(LANGUAGE_SELECTOR, "en"); firefoxOptions.addPreference(DOM_MAX_SCRIPT_RUN_TIME, (int)getElasticTime().seconds(600)); firefoxOptions.addPreference(DOM_MAX_CHROME_SCRIPT_RUN_TIME, (int)getElasticTime().seconds(600)); setDriverProperty("geckodriver", GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY); return new FirefoxDriver(firefoxOptions);
options.addPreference("download.prompt_for_download", drPromptForDl); options.addPreference("download.default_directory", driverDlPath); options.addPreference("profile.default_content_settings.popups", 0); options.setCapability(CapabilityType.LOGGING_PREFS, getLoggingPrefs());