@Test public void should_contain_user_preferences_set() throws IOException { List<String> prefsFile = Files.readAllLines(Paths.get("src", "test", "resources", "prefs.js")); List<String> expLines = prefsFile.stream() .filter(line -> line.startsWith("user_pref")) .collect(Collectors.toList()); Path userPrefFile = Paths.get((String) driver.getCapabilities().getCapability("moz:profile"), "user.js"); assertThat(Files.readAllLines(userPrefFile)).containsAll(expLines); }
public Capabilities getCapabilities(WebDriverConfiguration configuration, boolean performValidations) { DesiredCapabilities capabilities = new DesiredCapabilities(configuration.getCapabilities()); String binary = (String) capabilities.getCapability(FirefoxDriver.BINARY); if (Validate.nonEmpty(binary) && performValidations) { Validate.isExecutable(binary, "Firefox binary does not point to a valid executable, " + binary); } new FirefoxDriverBinaryHandler(capabilities).checkAndSetBinary(performValidations); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities); CapabilitiesOptionsMapper.mapCapabilities(firefoxOptions, capabilities, BROWSER_CAPABILITIES); FirefoxProfile firefoxProfile = getFirefoxProfile(capabilities, performValidations); if (firefoxProfile != null) { firefoxOptions.setProfile(firefoxProfile); } addUserPreferencesFromFile(capabilities, firefoxOptions); return firefoxOptions; }
FirefoxDriverFactory extends AbstractWebDriverFactory<FirefoxDriver> implements
    Configurator<FirefoxDriver, WebDriverConfiguration>, Instantiator<FirefoxDriver, WebDriverConfiguration>,
    Destructor<FirefoxDriver> { public Capabilities getCapabilities(WebDriverConfiguration configuration, boolean performValidations) { DesiredCapabilities capabilities = new DesiredCapabilities(configuration.getCapabilities()); String binary = (String) capabilities.getCapability(FirefoxDriver.BINARY); if (Validate.nonEmpty(binary) && performValidations) { Validate.isExecutable(binary, "Firefox binary does not point to a valid executable, " + binary); } new FirefoxDriverBinaryHandler(capabilities).checkAndSetBinary(performValidations); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities); CapabilitiesOptionsMapper.mapCapabilities(firefoxOptions, capabilities, BROWSER_CAPABILITIES); FirefoxProfile firefoxProfile = getFirefoxProfile(capabilities, performValidations); if (firefoxProfile != null) { firefoxOptions.setProfile(firefoxProfile); } addUserPreferencesFromFile(capabilities, firefoxOptions); return firefoxOptions; } }
FirefoxDriverFactory extends AbstractWebDriverFactory<FirefoxDriver> implements
    Configurator<FirefoxDriver, WebDriverConfiguration>, Instantiator<FirefoxDriver, WebDriverConfiguration>,
    Destructor<FirefoxDriver> { public Capabilities getCapabilities(WebDriverConfiguration configuration, boolean performValidations) { DesiredCapabilities capabilities = new DesiredCapabilities(configuration.getCapabilities()); String binary = (String) capabilities.getCapability(FirefoxDriver.BINARY); if (Validate.nonEmpty(binary) && performValidations) { Validate.isExecutable(binary, "Firefox binary does not point to a valid executable, " + binary); } new FirefoxDriverBinaryHandler(capabilities).checkAndSetBinary(performValidations); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities); CapabilitiesOptionsMapper.mapCapabilities(firefoxOptions, capabilities, BROWSER_CAPABILITIES); FirefoxProfile firefoxProfile = getFirefoxProfile(capabilities, performValidations); if (firefoxProfile != null) { firefoxOptions.setProfile(firefoxProfile); } addUserPreferencesFromFile(capabilities, firefoxOptions); return firefoxOptions; }  }
FirefoxDriverFactory extends AbstractWebDriverFactory<FirefoxDriver> implements
    Configurator<FirefoxDriver, WebDriverConfiguration>, Instantiator<FirefoxDriver, WebDriverConfiguration>,
    Destructor<FirefoxDriver> { public Capabilities getCapabilities(WebDriverConfiguration configuration, boolean performValidations) { DesiredCapabilities capabilities = new DesiredCapabilities(configuration.getCapabilities()); String binary = (String) capabilities.getCapability(FirefoxDriver.BINARY); if (Validate.nonEmpty(binary) && performValidations) { Validate.isExecutable(binary, "Firefox binary does not point to a valid executable, " + binary); } new FirefoxDriverBinaryHandler(capabilities).checkAndSetBinary(performValidations); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities); CapabilitiesOptionsMapper.mapCapabilities(firefoxOptions, capabilities, BROWSER_CAPABILITIES); FirefoxProfile firefoxProfile = getFirefoxProfile(capabilities, performValidations); if (firefoxProfile != null) { firefoxOptions.setProfile(firefoxProfile); } addUserPreferencesFromFile(capabilities, firefoxOptions); return firefoxOptions; }  @Override int getPrecedence(); @Override void destroyInstance(FirefoxDriver instance); @Override FirefoxDriver createInstance(WebDriverConfiguration configuration); Capabilities getCapabilities(WebDriverConfiguration configuration, boolean performValidations); }
FirefoxDriverFactory extends AbstractWebDriverFactory<FirefoxDriver> implements
    Configurator<FirefoxDriver, WebDriverConfiguration>, Instantiator<FirefoxDriver, WebDriverConfiguration>,
    Destructor<FirefoxDriver> { public Capabilities getCapabilities(WebDriverConfiguration configuration, boolean performValidations) { DesiredCapabilities capabilities = new DesiredCapabilities(configuration.getCapabilities()); String binary = (String) capabilities.getCapability(FirefoxDriver.BINARY); if (Validate.nonEmpty(binary) && performValidations) { Validate.isExecutable(binary, "Firefox binary does not point to a valid executable, " + binary); } new FirefoxDriverBinaryHandler(capabilities).checkAndSetBinary(performValidations); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities); CapabilitiesOptionsMapper.mapCapabilities(firefoxOptions, capabilities, BROWSER_CAPABILITIES); FirefoxProfile firefoxProfile = getFirefoxProfile(capabilities, performValidations); if (firefoxProfile != null) { firefoxOptions.setProfile(firefoxProfile); } addUserPreferencesFromFile(capabilities, firefoxOptions); return firefoxOptions; }  @Override int getPrecedence(); @Override void destroyInstance(FirefoxDriver instance); @Override FirefoxDriver createInstance(WebDriverConfiguration configuration); Capabilities getCapabilities(WebDriverConfiguration configuration, boolean performValidations);  }