/// <summary> /// Gets a <see cref="FirefoxProfile"/> with a given name. /// </summary> /// <param name="profileName">The name of the profile to get.</param> /// <returns>A <see cref="FirefoxProfile"/> with a given name. /// Returns <see langword="null"/> if no profile with the given name exists.</returns> public FirefoxProfile GetProfile(string profileName) { FirefoxProfile profile = null; if (!string.IsNullOrEmpty(profileName)) { if (this.profiles.ContainsKey(profileName)) { profile = new FirefoxProfile(this.profiles[profileName]); if (profile.Port == 0) { profile.Port = FirefoxDriver.DefaultPort; } } } return(profile); }
private static ICommandExecutor CreateExtensionConnection(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout) { FirefoxProfile profileToUse = profile; string suggestedProfile = Environment.GetEnvironmentVariable("webdriver.firefox.profile"); if (profileToUse == null && suggestedProfile != null) { profileToUse = new FirefoxProfileManager().GetProfile(suggestedProfile); } else if (profileToUse == null) { profileToUse = new FirefoxProfile(); } FirefoxDriverCommandExecutor executor = new FirefoxDriverCommandExecutor(binary, profileToUse, "localhost", commandTimeout); return(executor); }
private void ModifyLinkLibraryPath(FirefoxProfile profile) { // Extract x_ignore_nofocus.so from x86, amd64 directories inside // the jar into a real place in the filesystem and change LD_LIBRARY_PATH // to reflect that. string existingLdLibPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH"); // The returned new ld lib path is terminated with ':' string newLdLibPath = ExtractAndCheck(profile, NoFocusLibraryName, "x86", "amd64"); if (!string.IsNullOrEmpty(existingLdLibPath)) { newLdLibPath += existingLdLibPath; } this.SetEnvironmentProperty("LD_LIBRARY_PATH", newLdLibPath); // Set LD_PRELOAD to x_ignore_nofocus.so - this will be taken automagically // from the LD_LIBRARY_PATH this.SetEnvironmentProperty("LD_PRELOAD", NoFocusLibraryName); }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriverServer"/> class. /// </summary> /// <param name="binary">The <see cref="FirefoxBinary"/> on which to make the connection.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> creating the connection.</param> /// <param name="host">The name of the host on which to connect to the Firefox extension (usually "localhost").</param> public FirefoxDriverServer(FirefoxBinary binary, FirefoxProfile profile, string host) { this.host = host; if (profile == null) { this.profile = new FirefoxProfile(); } else { this.profile = profile; } if (binary == null) { this.process = new FirefoxBinary(); } else { this.process = binary; } }
private FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, ICapabilities capabilities, TimeSpan commandTimeout) : base(CreateExtensionConnection(binary, profile, commandTimeout), RemoveUnneededCapabilities(capabilities)) { this.binary = binary; this.profile = profile; }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriver"/> class for a given profile, binary environment, and timeout value. /// </summary> /// <param name="binary">A <see cref="FirefoxBinary"/> object representing the operating system /// environmental settings used when running Firefox.</param> /// <param name="profile">A <see cref="FirefoxProfile"/> object representing the profile settings /// to be used in starting Firefox.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout) : this(binary, profile, DesiredCapabilities.Firefox(), commandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriver"/> class for a given profile and binary environment. /// </summary> /// <param name="binary">A <see cref="FirefoxBinary"/> object representing the operating system /// environmental settings used when running Firefox.</param> /// <param name="profile">A <see cref="FirefoxProfile"/> object representing the profile settings /// to be used in starting Firefox.</param> public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile) : this(binary, profile, RemoteWebDriver.DefaultCommandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriver"/> class for a given profile. /// </summary> /// <param name="profile">A <see cref="FirefoxProfile"/> object representing the profile settings /// to be used in starting Firefox.</param> public FirefoxDriver(FirefoxProfile profile) : this(new FirefoxBinary(), profile) { }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriverCommandExecutor"/> class. /// </summary> /// <param name="binary">The <see cref="FirefoxBinary"/> on which to make the connection.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> creating the connection.</param> /// <param name="host">The name of the host on which to connect to the Firefox extension (usually "localhost").</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public FirefoxDriverCommandExecutor(FirefoxBinary binary, FirefoxProfile profile, string host, TimeSpan commandTimeout) { this.server = new FirefoxDriverServer(binary, profile, host); this.commandTimeout = commandTimeout; }