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); } }
File xpi = File.createTempFile(extension.keySet().iterator().next(), ".xpi"); FileUtils.copyInputStreamToFile(is, xpi); firefoxOptions.getProfile().addExtension(xpi); } catch (Throwable t) { log.error("Error loading Firefox extension {} ({} : {})", extension, t.getClass(),
File xpi = File.createTempFile(extension.keySet().iterator().next(), ".xpi"); FileUtils.copyInputStreamToFile(is, xpi); firefoxOptions.getProfile().addExtension(xpi); } catch (Throwable t) { log.error("Error loading Firefox extension {} ({} : {})", extension, t.getClass(),
() -> (FirefoxProfile) caps.getCapability(FirefoxDriver.PROFILE), () -> FirefoxProfile.fromJson((String) caps.getCapability(FirefoxDriver.PROFILE)), () -> ((FirefoxOptions) caps).getProfile(), () -> (FirefoxProfile) ((Map<String, Object>) caps.getCapability(FIREFOX_OPTIONS)).get("profile"), () -> FirefoxProfile.fromJson((String) ((Map<String, Object>) caps.getCapability(FIREFOX_OPTIONS)).get("profile")),
private static CommandExecutor toExecutor(FirefoxOptions options) { Objects.requireNonNull(options, "No options to construct executor from"); DriverService.Builder<?, ?> builder; if (! Boolean.parseBoolean(System.getProperty(SystemProperty.DRIVER_USE_MARIONETTE, "true")) || options.isLegacy()) { FirefoxProfile profile = options.getProfile(); if (profile == null) { profile = new FirefoxProfile(); options.setCapability(FirefoxDriver.PROFILE, profile); } builder = XpiDriverService.builder() .withBinary(options.getBinary()) .withProfile(profile); } else { builder = new GeckoDriverService.Builder() .usingFirefoxBinary(options.getBinary()); } return new FirefoxDriverCommandExecutor(builder.build()); }