Skip to content

Commit

Permalink
[dotnet] Remove Edge Legacy options.
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Evans <james.h.evans.jr@gmail.com>
  • Loading branch information
bwalderman authored and jimevans committed Oct 12, 2021
1 parent 9b1d5f2 commit d3b35ef
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 442 deletions.
6 changes: 3 additions & 3 deletions dotnet/src/webdriver/Edge/EdgeDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public EdgeDriver()
/// </summary>
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param>
public EdgeDriver(EdgeOptions options)
: this(EdgeDriverService.CreateDefaultServiceFromOptions(options), options)
: this(EdgeDriverService.CreateDefaultService(), options)
{
}

Expand All @@ -49,7 +49,7 @@ public EdgeDriver(EdgeOptions options)
/// </summary>
/// <param name="service">The <see cref="EdgeDriverService"/> used to initialize the driver.</param>
public EdgeDriver(EdgeDriverService service)
: this(service, new EdgeOptions() { UseChromium = service.UsingChromium })
: this(service, new EdgeOptions())
{
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public EdgeDriver(string edgeDriverDirectory, EdgeOptions options)
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param>
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
public EdgeDriver(string edgeDriverDirectory, EdgeOptions options, TimeSpan commandTimeout)
: this(EdgeDriverService.CreateDefaultServiceFromOptions(edgeDriverDirectory, options), options, commandTimeout)
: this(EdgeDriverService.CreateDefaultService(edgeDriverDirectory), options, commandTimeout)
{
}

Expand Down
273 changes: 12 additions & 261 deletions dotnet/src/webdriver/Edge/EdgeDriverService.cs

Large diffs are not rendered by default.

135 changes: 0 additions & 135 deletions dotnet/src/webdriver/Edge/EdgeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,44 +47,14 @@ public class EdgeOptions : ChromiumOptions
{
private const string DefaultBrowserNameValue = "MicrosoftEdge";
private const string WebViewBrowserNameValue = "webview2";

// Engine switching
private const string UseChromiumCapability = "ms:edgeChromium";
private bool useChromium = true;

private const string EdgeOptionsCapabilityName = "edgeOptions";

// Edge Legacy options
private const string UseInPrivateBrowsingCapability = "ms:inPrivate";
private const string ExtensionPathsCapability = "ms:extensionPaths";
private const string StartPageCapability = "ms:startPage";

private bool useInPrivateBrowsing;
private string startPage;
private List<string> extensionPaths = new List<string>();

// Additional Edge-specific Chromium options
private bool useWebView;

/// <summary>
/// Initializes a new instance of the <see cref="EdgeOptions"/> class.
/// </summary>
public EdgeOptions() : base()
{
this.BrowserName = DefaultBrowserNameValue;
this.AddKnownCapabilityName(UseChromiumCapability, "UseChromium property");
this.AddKnownCapabilityName(UseInPrivateBrowsingCapability, "UseInPrivateBrowsing property");
this.AddKnownCapabilityName(StartPageCapability, "StartPage property");
this.AddKnownCapabilityName(ExtensionPathsCapability, "AddExtensionPaths method");
}

/// <summary>
/// Gets or sets a value indicating whether to launch Edge Chromium. Defaults to using Edge Legacy.
/// </summary>
public bool UseChromium
{
get { return this.useChromium; }
set { this.useChromium = value; }
}

/// <summary>
Expand Down Expand Up @@ -112,110 +82,5 @@ public bool UseWebView
get { return this.BrowserName == WebViewBrowserNameValue; }
set { this.BrowserName = value ? WebViewBrowserNameValue : DefaultBrowserNameValue; }
}


/// <summary>
/// Gets or sets a value indicating whether the browser should be launched using
/// InPrivate browsing.
/// </summary>
public bool UseInPrivateBrowsing
{
get { return this.useInPrivateBrowsing; }
set { this.useInPrivateBrowsing = value; }
}

/// <summary>
/// Gets or sets the URL of the page with which the browser will be navigated to on launch.
/// </summary>
public string StartPage
{
get { return this.startPage; }
set { this.startPage = value; }
}

/// <summary>
/// Adds a path to an extension that is to be used with the Edge Legacy driver.
/// </summary>
/// <param name="extensionPath">The full path and file name of the extension.</param>
public void AddExtensionPath(string extensionPath)
{
if (string.IsNullOrEmpty(extensionPath))
{
throw new ArgumentException("extensionPath must not be null or empty", "extensionPath");
}

this.AddExtensionPaths(extensionPath);
}

/// <summary>
/// Adds a list of paths to an extensions that are to be used with the Edge Legacy driver.
/// </summary>
/// <param name="extensionPathsToAdd">An array of full paths with file names of extensions to add.</param>
public void AddExtensionPaths(params string[] extensionPathsToAdd)
{
this.AddExtensionPaths(new List<string>(extensionPathsToAdd));
}

/// <summary>
/// Adds a list of paths to an extensions that are to be used with the Edge Legacy driver.
/// </summary>
/// <param name="extensionPathsToAdd">An <see cref="IEnumerable{T}"/> of full paths with file names of extensions to add.</param>
public void AddExtensionPaths(IEnumerable<string> extensionPathsToAdd)
{
if (extensionPathsToAdd == null)
{
throw new ArgumentNullException("extensionPathsToAdd", "extensionPathsToAdd must not be null");
}

this.extensionPaths.AddRange(extensionPathsToAdd);
}

/// <summary>
/// Returns DesiredCapabilities for Edge with these options included as
/// capabilities. This copies the options. Further changes will not be
/// reflected in the returned capabilities.
/// </summary>
/// <returns>The DesiredCapabilities for Edge with these options.</returns>
public override ICapabilities ToCapabilities()
{
return this.useChromium ? ToChromiumCapabilities() : ToLegacyCapabilities();
}

/// <summary>
/// Adds vendor-specific capabilities for Chromium-based browsers.
/// </summary>
/// <param name="capabilities">The capabilities to add.</param>
protected override void AddVendorSpecificChromiumCapabilities(IWritableCapabilities capabilities)
{
capabilities.SetCapability(EdgeOptions.UseChromiumCapability, this.useChromium);
}

private ICapabilities ToChromiumCapabilities()
{
return base.ToCapabilities();
}

private ICapabilities ToLegacyCapabilities()
{
IWritableCapabilities capabilities = this.GenerateDesiredCapabilities(true);
capabilities.SetCapability(EdgeOptions.UseChromiumCapability, this.useChromium);

if (this.useInPrivateBrowsing)
{
capabilities.SetCapability(UseInPrivateBrowsingCapability, true);
}

if (!string.IsNullOrEmpty(this.startPage))
{
capabilities.SetCapability(StartPageCapability, this.startPage);
}

if (this.extensionPaths.Count > 0)
{
capabilities.SetCapability(ExtensionPathsCapability, this.extensionPaths);
}

return capabilities.AsReadOnly();
}
}
}
1 change: 0 additions & 1 deletion dotnet/test/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ SUPPORTED_BROWSERS = [
("firefoxnightly", "FirefoxNightly"),
("ie", "IE"),
("edge", "Edge"),
("edgelegacy", "EdgeLegacy"),
("safari", "Safari"),
("safaritechpreview", "SafariTechPreview"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public static EdgeOptions DefaultOptions
// property to the below options: BinaryLocation = <path to MSEdge.exe>
return new EdgeOptions()
{
UseChromium = true,
BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe"
};
}
Expand All @@ -38,7 +37,7 @@ public static EdgeDriverService DefaultService
{
get
{
EdgeDriverService service = EdgeDriverService.CreateChromiumService(ServicePath);
EdgeDriverService service = EdgeDriverService.CreateDefaultService(ServicePath);
return service;
}
}
Expand Down
31 changes: 0 additions & 31 deletions dotnet/test/common/CustomDriverConfigs/LegacyEdgeDriver.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public static EdgeOptions DefaultOptions
// property to the below options: BinaryLocation = <path to MSEdge.exe>
return new EdgeOptions()
{
UseChromium = true,
BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
};
}
Expand All @@ -38,7 +37,7 @@ public static EdgeDriverService DefaultService
{
get
{
EdgeDriverService service = EdgeDriverService.CreateChromiumService(ServicePath);
EdgeDriverService service = EdgeDriverService.CreateDefaultService(ServicePath);
return service;
}
}
Expand Down
7 changes: 0 additions & 7 deletions dotnet/test/common/appconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@
"RemoteCapabilities": "MicrosoftEdge"
},

"EdgeLegacy": {
"DriverTypeName": "OpenQA.Selenium.Edge.LegacyEdgeDriver",
"AssemblyName": "WebDriver.Common.Tests",
"BrowserValue": "EdgeLegacy",
"RemoteCapabilities": "MicrosoftEdge"
},

"Firefox": {
"DriverTypeName": "OpenQA.Selenium.Firefox.StableChannelFirefoxDriver",
"AssemblyName": "WebDriver.Common.Tests",
Expand Down

0 comments on commit d3b35ef

Please sign in to comment.