private FirefoxOptions transferFirefoxProfileFromSystemProperties(FirefoxOptions currentFirefoxOptions) { String prefix = "firefoxprofile."; FirefoxProfile profile = Optional.ofNullable(currentFirefoxOptions.getProfile()) .orElseGet(FirefoxProfile::new); for (String key : System.getProperties().stringPropertyNames()) { if (key.startsWith(prefix)) { String capability = key.substring(prefix.length()); String value = System.getProperties().getProperty(key); log.config("Use " + key + "=" + value); if (value.equals("true") || value.equals("false")) { profile.setPreference(capability, Boolean.valueOf(value)); } else if (value.matches("^-?\\d+$")) { //if integer profile.setPreference(capability, Integer.parseInt(value)); } else { profile.setPreference(capability, value); } } } return currentFirefoxOptions.setProfile(profile); } }
@BeforeEach public void setup(@TempDirectory.TempDir Path folder) throws IOException { Assumptions.assumeTrue(Boolean.getBoolean("smoke.test"), "Smoke tests disabled (set System property 'smoke.test')"); this.downloadDir = folder.toFile(); FirefoxProfile fxProfile = new FirefoxProfile(); fxProfile.setPreference("browser.download.folderList", 2); fxProfile.setPreference("browser.download.manager.showWhenStarting", false); fxProfile.setPreference("browser.download.dir", this.downloadDir.getAbsolutePath()); fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip,application/x-compress,application/octet-stream"); FirefoxOptions options = new FirefoxOptions().setProfile(fxProfile); this.driver = new FirefoxDriver(options); ((JavascriptExecutor) this.driver).executeScript("window.focus();"); Actions actions = new Actions(this.driver); this.enterAction = actions.sendKeys(Keys.ENTER).build(); }
profile.setPreference("browser.download.dir", System.getProperty("java.io.tmpdir")); FirefoxOptions options = new FirefoxOptions().setProfile(profile); return new FirefoxDriver(options);
/** * Sets specific {@link FirefoxProfile} to be used in the {@link FirefoxDriver}. * * @param firefoxProfile Profile to be used. * @return A self reference, allowing further configuration. * @since 0.9.0 */ public FirefoxDriverBuilder withProfile(FirefoxProfile firefoxProfile) { getInitializedFirefoxOptions().setProfile(firefoxProfile); return this; }
/** * Sets specific {@link FirefoxProfile} to be used in the {@link FirefoxDriver}. * * @param firefoxProfile Profile to be used. * @return A self reference, allowing further configuration. * @since 0.9.0 */ public FirefoxDriverBuilder withProfile(FirefoxProfile firefoxProfile) { getInitializedFirefoxOptions().setProfile(firefoxProfile); return this; }
@Override public WebDriver createDriver() { Class<?> driverClass = getDriverClass(); try { Object driver; if ("firefoxdriver".equalsIgnoreCase(driverClass.getSimpleName())) { FirefoxProfile fxProfile = getFirefoxProfile(profile); FirefoxOptions options = new FirefoxOptions().setProfile(fxProfile); driver = new FirefoxDriver(options); } else if ("chromedriver".equalsIgnoreCase(driverClass.getSimpleName())) { DesiredCapabilities capabilities = getChromeMobileCapabilities(profile); driver = new ChromeDriver(capabilities); } else if ("internetexplorerdriver".equalsIgnoreCase(driverClass.getSimpleName())) { InternetExplorerOptions ieOptions = getInternetExplorerOptions(profile); driver = new InternetExplorerDriver(ieOptions); } else { driver = driverClass.newInstance(); } return (WebDriver) driver; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
public FirefoxOptions() { // Read system properties and use those if they are set, allowing users to override them later // should they want to. String binary = System.getProperty(FirefoxDriver.SystemProperty.BROWSER_BINARY); if (binary != null) { setBinary(binary); } String profileName = System.getProperty(FirefoxDriver.SystemProperty.BROWSER_PROFILE); if (profileName != null) { FirefoxProfile profile = new ProfilesIni().getProfile(profileName); if (profile == null) { throw new WebDriverException(String.format( "Firefox profile '%s' named in system property '%s' not found", profileName, FirefoxDriver.SystemProperty.BROWSER_PROFILE)); } setProfile(profile); } String forceMarionette = System.getProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE); if (forceMarionette != null) { setLegacy(!Boolean.getBoolean(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE)); } setCapability(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX); setAcceptInsecureCerts(true); }
if (that.binary != null) { setCapability(BINARY, that.binary.asCapability()); } if (that.profile != null) { setProfile(that.profile); } } else if (raw instanceof Map) { Map<?, ?> that = (Map<?, ?>) raw; if (value instanceof String) { try { setProfile(FirefoxProfile.fromJson((String) value)); } catch (IOException e) { throw new WebDriverException(e); setProfile((FirefoxProfile) value); } else { throw new WebDriverException(
private static FirefoxDriver constructFirefoxDriver(final GeckoDriverService.Builder firefoxBuilder, FirefoxProfile profile) { if (profile == null) { profile = new FirefoxProfile(); } try { JavaScriptError.addExtension(profile); } catch (IOException e) { log.error("Failed to add JavaScriptError extension to profile", e); } FirefoxOptions options = new FirefoxOptions(); //options.setLogLevel(FirefoxDriverLogLevel.TRACE); options.setProfile(profile); showEnv(); return new FirefoxDriver(firefoxBuilder.build(), options); }
@Override public WebDriver getDriver() { FirefoxProfile profile = getFirefoxProfile(Locale.GERMANY); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setProfile(profile); LogManager.getLogger().info("is headless: {}", isHeadless()); firefoxOptions.setHeadless(isHeadless()); FirefoxDriver firefoxDriver = new FirefoxDriver(firefoxOptions); firefoxDriver.manage().window().setSize(new Dimension(dimX, dimY)); firefoxDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); return firefoxDriver; }
File profileDir = new File(profilePath); FirefoxProfile profile = new FirefoxProfile(profileDir); options.setProfile(profile);
firefoxOptions.setHeadless(isHeadless()); if (isProfilePathSet()) { firefoxOptions.setProfile(new FirefoxProfile(new File(profilePath)));
FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.addExtension(getExtension(extension)); firefoxOptions.setProfile(firefoxProfile);
profile.setAssumeUntrustedCertificateIssuer(firefoxProperties.shouldUntrustedCertIssuer()); return new FirefoxOptions().setProfile(profile);
@Override public WebDriver newInstance(DriverOptions driverOptions) { GeckoDriverService service = setupBuilder(new GeckoDriverService.Builder(), driverOptions, GECKODRIVER).build(); FirefoxOptions firefoxOptions = newFirefoxOptions(driverOptions); String firefoxBin = getFirefoxBinary(driverOptions); if (firefoxBin != null) firefoxOptions.setBinary(firefoxBin); if (driverOptions.has(CLI_ARGS)) firefoxOptions.addArguments(driverOptions.getCliArgs()); FirefoxProfile profile = getFirefoxProfile(driverOptions); if (profile != null) firefoxOptions.setProfile(profile); firefoxOptions.merge(driverOptions.getCapabilities()); FirefoxDriver driver = new FirefoxDriver(service, firefoxOptions); setInitialWindowSize(driver, driverOptions); return driver; }
firefoxOptions.setProfile(firefoxProfile);
firefoxOptions.setProfile(firefoxProfile);
firefoxOptions.setProfile(firefoxProfile); if (browser.isHeadless()) { firefoxOptions.addArguments("-headless");
WebDriverManager.firefoxdriver().setup(); FirefoxOptions options = new FirefoxOptions(); options.setProfile(getFirefoxProfileWithDisabledAnimatedGifs()); options.addArguments(runStepConfig.getFirefoxParameters()); if (jobConfig.browser.isHeadless()) {
firefoxOptions.setProfile(firefoxProfile); firefoxOptions.setHeadless(BROWSER_HEADLESS);