Skip to content

Commit b754461

Browse files
committed
[dotnet] Update Chromium-based browsers to correclty inherit Options
1 parent 70af0d6 commit b754461

File tree

5 files changed

+62
-25
lines changed

5 files changed

+62
-25
lines changed

dotnet/src/webdriver/Chrome/ChromeOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class ChromeOptions : ChromiumOptions
5858
/// <summary>
5959
/// Initializes a new instance of the <see cref="ChromeOptions"/> class.
6060
/// </summary>
61-
public ChromeOptions()
61+
public ChromeOptions() : base()
6262
{
6363
this.BrowserName = BrowserNameValue;
6464
}

dotnet/src/webdriver/Edge/EdgeDriver.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -104,30 +104,8 @@ public EdgeDriver(EdgeDriverService service, EdgeOptions options)
104104
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param>
105105
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
106106
public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
107-
: base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options, service.UsingChromium))
107+
: base(service, options, commandTimeout)
108108
{
109109
}
110-
111-
private static ICapabilities ConvertOptionsToCapabilities(EdgeOptions options, bool serviceUsingChromium)
112-
{
113-
if (options == null)
114-
{
115-
throw new ArgumentNullException("options", "options must not be null");
116-
}
117-
118-
if (serviceUsingChromium != options.UseChromium)
119-
{
120-
if (serviceUsingChromium)
121-
{
122-
throw new WebDriverException("options.UseChromium must be set to true when using an Edge Chromium driver service.");
123-
}
124-
else
125-
{
126-
throw new WebDriverException("options.UseChromium must be set to false when using an Edge Legacy driver service.");
127-
}
128-
}
129-
130-
return options.ToCapabilities();
131-
}
132110
}
133111
}

dotnet/src/webdriver/Edge/EdgeOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class EdgeOptions : ChromiumOptions
6969
/// <summary>
7070
/// Initializes a new instance of the <see cref="EdgeOptions"/> class.
7171
/// </summary>
72-
public EdgeOptions()
72+
public EdgeOptions() : base()
7373
{
7474
this.BrowserName = DefaultBrowserNameValue;
7575
this.AddKnownCapabilityName(UseChromiumCapability, "UseChromium property");
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace OpenQA.Selenium.Edge
8+
{
9+
public class StableChannelEdgeDriver : EdgeDriver
10+
{
11+
private static string servicePath = string.Empty;
12+
13+
public StableChannelEdgeDriver()
14+
: this(DefaultService, DefaultOptions)
15+
{
16+
}
17+
18+
public StableChannelEdgeDriver(EdgeDriverService service, EdgeOptions options)
19+
: base(service, options)
20+
{
21+
}
22+
23+
public static EdgeOptions DefaultOptions
24+
{
25+
get {
26+
// The below path to the Edge Developer Channel executable is obviously hard-coded.
27+
// On non-Windows OSes, and for custom install locations, you will need to add a
28+
// property to the below options: BinaryLocation = <path to MSEdge.exe>
29+
return new EdgeOptions()
30+
{
31+
UseChromium = true,
32+
BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
33+
};
34+
}
35+
}
36+
37+
public static EdgeDriverService DefaultService
38+
{
39+
get
40+
{
41+
EdgeDriverService service = EdgeDriverService.CreateChromiumService(ServicePath);
42+
return service;
43+
}
44+
}
45+
46+
public static string ServicePath
47+
{
48+
get { return servicePath; }
49+
set { servicePath = value; }
50+
}
51+
}
52+
}

dotnet/test/common/appconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
},
4747

4848
"Edge": {
49+
"DriverTypeName": "OpenQA.Selenium.Edge.StableChannelEdgeDriver",
50+
"AssemblyName": "WebDriver.Common.Tests",
51+
"BrowserValue": "Edge",
52+
"RemoteCapabilities": "MicrosoftEdge"
53+
},
54+
55+
"EdgeDev": {
4956
"DriverTypeName": "OpenQA.Selenium.Edge.DevChannelEdgeDriver",
5057
"AssemblyName": "WebDriver.Common.Tests",
5158
"BrowserValue": "Edge",

0 commit comments

Comments
 (0)