Skip to content

Commit

Permalink
Adding option to not delete anonymous Firefox profile in .NET
Browse files Browse the repository at this point in the history
This change adds an option to the .NET FirefoxProfile class so that the
driver will not delete the anonymous profile created by the driver. Since
the driver cannot and should not use an existing profile in situ because
of the multiple instance automation case, this change means that
modifications applied to the anonymous profile can be retained and
used in future anonymous profiles.The implication is that the user can
now make modifications to a profile, and retain those profile modifications
(e.g., cookies) into other future profiles, simulating persistent changes
over multiple browser launches. Fixes issue SeleniumHQ#7374.
  • Loading branch information
jimevans committed Nov 18, 2014
1 parent 9e9e5fc commit dca9ea0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dotnet/src/webdriver/Firefox/FirefoxProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class FirefoxProfile
private bool acceptUntrustedCerts;
private bool assumeUntrustedIssuer;
private bool deleteSource;
private bool deleteOnClean = true;
private Preferences profilePreferences;
private Dictionary<string, FirefoxExtension> extensions = new Dictionary<string, FirefoxExtension>();
#endregion
Expand Down Expand Up @@ -116,6 +117,16 @@ public string ProfileDirectory
get { return this.profileDir; }
}

/// <summary>
/// Gets or sets a value indicating whether to delete this profile after use with
/// the <see cref="FirefoxDriver"/>.
/// </summary>
public bool DeleteAfterUse
{
get { return this.deleteOnClean; }
set { this.deleteOnClean = value; }
}

/// <summary>
/// Gets or sets a value indicating whether native events are enabled.
/// </summary>
Expand Down Expand Up @@ -303,7 +314,7 @@ public void WriteToDisk()
/// is deleted.</remarks>
public void Clean()
{
if (!string.IsNullOrEmpty(this.profileDir) && Directory.Exists(this.profileDir))
if (this.deleteOnClean && !string.IsNullOrEmpty(this.profileDir) && Directory.Exists(this.profileDir))
{
FileUtilities.DeleteDirectory(this.profileDir);
}
Expand Down

0 comments on commit dca9ea0

Please sign in to comment.