Skip to content

Commit d7155fe

Browse files
committed
Adding .NET Chrome option to enable use of W3C protocol dialect
1 parent 27bbd2c commit d7155fe

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

dotnet/src/webdriver/Chrome/ChromeOptions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ public class ChromeOptions : DriverOptions
7272
private const string MobileEmulationChromeOption = "mobileEmulation";
7373
private const string PerformanceLoggingPreferencesChromeOption = "perfLoggingPrefs";
7474
private const string WindowTypesChromeOption = "windowTypes";
75+
private const string UseSpecCompliantProtocolOption = "w3c";
7576

7677
private bool leaveBrowserRunning;
78+
private bool useSpecCompliantProtocol;
7779
private string binaryLocation;
7880
private string debuggerAddress;
7981
private string minidumpPath;
@@ -108,6 +110,7 @@ public ChromeOptions() : base()
108110
this.AddKnownCapabilityName(ChromeOptions.MobileEmulationChromeOption, "EnableMobileEmulation method");
109111
this.AddKnownCapabilityName(ChromeOptions.PerformanceLoggingPreferencesChromeOption, "PerformanceLoggingPreferences property");
110112
this.AddKnownCapabilityName(ChromeOptions.WindowTypesChromeOption, "AddWindowTypes method");
113+
this.AddKnownCapabilityName(ChromeOptions.UseSpecCompliantProtocolOption, "UseSpecCompliantProtocol property");
111114
}
112115

113116
/// <summary>
@@ -184,6 +187,17 @@ public ChromePerformanceLoggingPreferences PerformanceLoggingPreferences
184187
set { this.perfLoggingPreferences = value; }
185188
}
186189

190+
/// <summary>
191+
/// Gets or sets a value indicating whether the <see cref="ChromeDriver"/> instance
192+
/// should use the legacy OSS protocol dialect or a dialect compliant with the W3C
193+
/// WebDriver Specification.
194+
/// </summary>
195+
public bool UseSpecCompliantProtocol
196+
{
197+
get { return this.useSpecCompliantProtocol; }
198+
set { this.useSpecCompliantProtocol = value; }
199+
}
200+
187201
/// <summary>
188202
/// Adds a single argument to the list of arguments to be appended to the Chrome.exe command line.
189203
/// </summary>
@@ -596,6 +610,11 @@ private Dictionary<string, object> BuildChromeOptionsDictionary()
596610
chromeOptions[DetachChromeOption] = this.leaveBrowserRunning;
597611
}
598612

613+
if (this.useSpecCompliantProtocol)
614+
{
615+
chromeOptions[UseSpecCompliantProtocolOption] = this.useSpecCompliantProtocol;
616+
}
617+
599618
if (!string.IsNullOrEmpty(this.debuggerAddress))
600619
{
601620
chromeOptions[DebuggerAddressChromeOption] = this.debuggerAddress;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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.Chrome
8+
{
9+
public class SpecCompliantChromeDriver : ChromeDriver
10+
{
11+
public SpecCompliantChromeDriver(ChromeDriverService service) :
12+
base(service, new ChromeOptions() { UseSpecCompliantProtocol = true })
13+
{
14+
}
15+
}
16+
}

dotnet/test/common/appconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
"RemoteCapabilities": "chrome"
2020
},
2121

22+
"ChromeSpec": {
23+
"DriverTypeName": "OpenQA.Selenium.Chrome.SpecCompliantChromeDriver",
24+
"AssemblyName": "WebDriver.Chrome.Tests",
25+
"BrowserValue": "Chrome",
26+
"RemoteCapabilities": "chrome"
27+
},
28+
2229
"IE": {
2330
"DriverTypeName": "OpenQA.Selenium.IE.InternetExplorerDriver",
2431
"AssemblyName": "WebDriver",

0 commit comments

Comments
 (0)