Skip to content

Commit

Permalink
Updating .NET to not propagate non-W3C compliant capability names
Browse files Browse the repository at this point in the history
Fixes issue #5646.
  • Loading branch information
jimevans committed Mar 20, 2018
1 parent 74e584d commit 6103798
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dotnet/src/webdriver/DriverOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ protected DesiredCapabilities GenerateDesiredCapabilities(bool isSpecificationCo
if (this.Proxy != null)
{
Dictionary<string, object> proxyCapability = this.Proxy.ToCapability();
if (!isSpecificationCompliant)
{
proxyCapability = this.Proxy.ToLegacyCapability();
}

if (proxyCapability != null)
{
capabilities.SetCapability(CapabilityType.Proxy, proxyCapability);
Expand Down
22 changes: 22 additions & 0 deletions dotnet/src/webdriver/Remote/CapabilityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// limitations under the License.
// </copyright>

using System.Collections.Generic;

namespace OpenQA.Selenium.Remote
{
/// <summary>
Expand Down Expand Up @@ -137,5 +139,25 @@ public static class CapabilityType
/// Capability name used to indicate whether the driver supports web storage.
/// </summary>
public static readonly string SupportsWebStorage = "webStorageEnabled";

private static readonly List<string> KnownSpecCompliantCapabilityNames = new List<string>() {
BrowserName,
BrowserVersion,
PlatformName,
AcceptInsecureCertificates,
PageLoadStrategy,
Proxy,
UnhandledPromptBehavior
};

public static bool IsSpecCompliantCapabilityName(string capabilityName)
{
if (KnownSpecCompliantCapabilityNames.Contains(capabilityName) || capabilityName.Contains(":"))
{
return true;
}

return false;
}
}
}
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/Remote/RemoteWebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ protected virtual Dictionary<string, object> GetCapabilitiesDictionary(ICapabili
DesiredCapabilities capabilitiesObject = capabilitiesToConvert as DesiredCapabilities;
foreach (KeyValuePair<string, object> entry in capabilitiesObject.CapabilitiesDictionary)
{
if (entry.Key != CapabilityType.Version && entry.Key != CapabilityType.Platform)
if (CapabilityType.IsSpecCompliantCapabilityName(entry.Key))
{
capabilitiesDictionary.Add(entry.Key, entry.Value);
}
Expand Down

0 comments on commit 6103798

Please sign in to comment.