public ProfilesIni() { File appData = locateAppDataDirectory(Platform.getCurrent()); profiles = readProfiles(appData); }
private static FirefoxProfile getFirefoxProfile(DriverOptions driverOptions) { if (!driverOptions.has(PROFILE) && !driverOptions.has(PROFILE_DIR)) return null; FirefoxProfile profile; // Create FirefoxProfile and set to DesiredCapabilities. // (FirefoxProfile object can work with both local and remote FirefoxDriver // see: https://code.google.com/p/selenium/wiki/DesiredCapabilities#Firefox_specific) String profileName = driverOptions.get(PROFILE); String profileDir = driverOptions.get(PROFILE_DIR); if (profileName != null) { if (profileDir != null) throw new IllegalArgumentException("Can't specify both '--profile' and '--profile-dir' at once"); // see http://code.google.com/p/selenium/wiki/TipsAndTricks ProfilesIni allProfiles = new ProfilesIni(); profile = allProfiles.getProfile(profileName); if (profile == null) throw new IllegalArgumentException("Profile '" + profile + "' does not exist."); log.info("Firefox profile: {}", profileName); } else { File dir = new File(profileDir); if (!dir.isDirectory()) throw new IllegalArgumentException("Missing profile directory: " + profileDir); profile = new FirefoxProfile(dir); log.info("Firefox profile directory: {}", profileDir); } return profile; }
File profile = newProfile(name, appData, path, isRelative); if (profile != null) toReturn.put(name, profile); try { if (reader != null) { File profile = newProfile(name, appData, path, isRelative); if (profile != null) toReturn.put(name, profile);
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); }