Skip to content

Commit

Permalink
Removing legacy WebDriver extension when using Geckodriver in .NET
Browse files Browse the repository at this point in the history
When a `FirefoxProfile` object is created in the .NET bindings, the legacy
WebDriver extension is included in that profile by default. This includes
the case where the user is using Geckodriver. When using Geckodriver, the
legacy extension is doing nothing more than taking up space. This commit
adds an internal method to detect when a `FirefoxProfile` object is being
used with geckodriver, and removes the extension from the list of
extensions in the profile before the profile is serialized to disk, and
subsequently to a base64-encoded string for transmission over the wire to
geckodriver. Fixes issue SeleniumHQ#6043.
  • Loading branch information
jimevans committed Jun 23, 2018
1 parent 04afbc4 commit db1e959
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/Firefox/FirefoxOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ public override ICapabilities ToCapabilities()

if (this.profile != null)
{
// Using Marionette/Geckodriver, so the legacy WebDriver extension
// is not required.
this.profile.RemoveWebDriverExtension();
firefoxOptions[FirefoxProfileCapability] = this.profile.ToBase64String();
}

Expand Down
12 changes: 12 additions & 0 deletions dotnet/src/webdriver/Firefox/FirefoxProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,18 @@ internal void AddWebDriverExtension()
}
}

/// <summary>
/// Removes the WebDriver extension for Firefox to the profile, for use with non-legacy
/// FirefoxDriver instances that use geckodriver.
/// </summary>
internal void RemoveWebDriverExtension()
{
if (this.extensions.ContainsKey("webdriver"))
{
this.extensions.Remove("webdriver");
}
}

/// <summary>
/// Internal implementation to set proxy preferences for this profile.
/// </summary>
Expand Down

0 comments on commit db1e959

Please sign in to comment.