Skip to content

Commit db1e959

Browse files
committed
Removing legacy WebDriver extension when using Geckodriver in .NET
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 #6043.
1 parent 04afbc4 commit db1e959

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

dotnet/src/webdriver/Firefox/FirefoxOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ private Dictionary<string, object> GenerateFirefoxOptionsDictionary()
354354

355355
if (this.profile != null)
356356
{
357+
// Using Marionette/Geckodriver, so the legacy WebDriver extension
358+
// is not required.
359+
this.profile.RemoveWebDriverExtension();
357360
firefoxOptions[FirefoxProfileCapability] = this.profile.ToBase64String();
358361
}
359362

dotnet/src/webdriver/Firefox/FirefoxProfile.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,18 @@ internal void AddWebDriverExtension()
327327
}
328328
}
329329

330+
/// <summary>
331+
/// Removes the WebDriver extension for Firefox to the profile, for use with non-legacy
332+
/// FirefoxDriver instances that use geckodriver.
333+
/// </summary>
334+
internal void RemoveWebDriverExtension()
335+
{
336+
if (this.extensions.ContainsKey("webdriver"))
337+
{
338+
this.extensions.Remove("webdriver");
339+
}
340+
}
341+
330342
/// <summary>
331343
/// Internal implementation to set proxy preferences for this profile.
332344
/// </summary>

0 commit comments

Comments
 (0)