From 6103798b5f7148df80b329acc6c4397393f2a76a Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Tue, 20 Mar 2018 14:04:36 -0700 Subject: [PATCH] Updating .NET to not propagate non-W3C compliant capability names Fixes issue #5646. --- dotnet/src/webdriver/DriverOptions.cs | 5 +++++ dotnet/src/webdriver/Remote/CapabilityType.cs | 22 +++++++++++++++++++ .../src/webdriver/Remote/RemoteWebDriver.cs | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/DriverOptions.cs b/dotnet/src/webdriver/DriverOptions.cs index 8d5adc4254e25..4de820689fd2f 100644 --- a/dotnet/src/webdriver/DriverOptions.cs +++ b/dotnet/src/webdriver/DriverOptions.cs @@ -333,6 +333,11 @@ protected DesiredCapabilities GenerateDesiredCapabilities(bool isSpecificationCo if (this.Proxy != null) { Dictionary proxyCapability = this.Proxy.ToCapability(); + if (!isSpecificationCompliant) + { + proxyCapability = this.Proxy.ToLegacyCapability(); + } + if (proxyCapability != null) { capabilities.SetCapability(CapabilityType.Proxy, proxyCapability); diff --git a/dotnet/src/webdriver/Remote/CapabilityType.cs b/dotnet/src/webdriver/Remote/CapabilityType.cs index 87e08845994d1..7d0447a7f1eaf 100644 --- a/dotnet/src/webdriver/Remote/CapabilityType.cs +++ b/dotnet/src/webdriver/Remote/CapabilityType.cs @@ -16,6 +16,8 @@ // limitations under the License. // +using System.Collections.Generic; + namespace OpenQA.Selenium.Remote { /// @@ -137,5 +139,25 @@ public static class CapabilityType /// Capability name used to indicate whether the driver supports web storage. /// public static readonly string SupportsWebStorage = "webStorageEnabled"; + + private static readonly List KnownSpecCompliantCapabilityNames = new List() { + BrowserName, + BrowserVersion, + PlatformName, + AcceptInsecureCertificates, + PageLoadStrategy, + Proxy, + UnhandledPromptBehavior + }; + + public static bool IsSpecCompliantCapabilityName(string capabilityName) + { + if (KnownSpecCompliantCapabilityNames.Contains(capabilityName) || capabilityName.Contains(":")) + { + return true; + } + + return false; + } } } diff --git a/dotnet/src/webdriver/Remote/RemoteWebDriver.cs b/dotnet/src/webdriver/Remote/RemoteWebDriver.cs index 91e6dc685576c..dcc962a54f5bc 100644 --- a/dotnet/src/webdriver/Remote/RemoteWebDriver.cs +++ b/dotnet/src/webdriver/Remote/RemoteWebDriver.cs @@ -1158,7 +1158,7 @@ protected virtual Dictionary GetCapabilitiesDictionary(ICapabili DesiredCapabilities capabilitiesObject = capabilitiesToConvert as DesiredCapabilities; foreach (KeyValuePair entry in capabilitiesObject.CapabilitiesDictionary) { - if (entry.Key != CapabilityType.Version && entry.Key != CapabilityType.Platform) + if (CapabilityType.IsSpecCompliantCapabilityName(entry.Key)) { capabilitiesDictionary.Add(entry.Key, entry.Value); }