Skip to content

Commit 49e4944

Browse files
committed
Remove client side validation what API user may use correctly
1 parent 8cf788f commit 49e4944

File tree

5 files changed

+1
-140
lines changed

5 files changed

+1
-140
lines changed

dotnet/src/webdriver/Chromium/ChromiumOptions.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,6 @@ public abstract class ChromiumOptions : DriverOptions
5555
private string? mobileEmulationDeviceName;
5656
private ChromiumMobileEmulationDeviceSettings? mobileEmulationDeviceSettings;
5757

58-
/// <summary>
59-
/// Initializes a new instance of the <see cref="ChromiumOptions"/> class.
60-
/// </summary>
61-
public ChromiumOptions() : base()
62-
{
63-
this.AddKnownCapabilityName(this.CapabilityName, "current ChromiumOptions class instance");
64-
this.AddKnownCapabilityName(CapabilityType.LoggingPreferences, "SetLoggingPreference method");
65-
this.AddKnownCapabilityName(this.LoggingPreferencesChromeOption, "SetLoggingPreference method");
66-
this.AddKnownCapabilityName(ChromiumOptions.ArgumentsChromeOption, "AddArguments method");
67-
this.AddKnownCapabilityName(ChromiumOptions.BinaryChromeOption, "BinaryLocation property");
68-
this.AddKnownCapabilityName(ChromiumOptions.ExtensionsChromeOption, "AddExtensions method");
69-
this.AddKnownCapabilityName(ChromiumOptions.LocalStateChromeOption, "AddLocalStatePreference method");
70-
this.AddKnownCapabilityName(ChromiumOptions.PreferencesChromeOption, "AddUserProfilePreference method");
71-
this.AddKnownCapabilityName(ChromiumOptions.DetachChromeOption, "LeaveBrowserRunning property");
72-
this.AddKnownCapabilityName(ChromiumOptions.DebuggerAddressChromeOption, "DebuggerAddress property");
73-
this.AddKnownCapabilityName(ChromiumOptions.ExcludeSwitchesChromeOption, "AddExcludedArgument property");
74-
this.AddKnownCapabilityName(ChromiumOptions.MinidumpPathChromeOption, "MinidumpPath property");
75-
this.AddKnownCapabilityName(ChromiumOptions.MobileEmulationChromeOption, "EnableMobileEmulation method");
76-
this.AddKnownCapabilityName(ChromiumOptions.PerformanceLoggingPreferencesChromeOption, "PerformanceLoggingPreferences property");
77-
this.AddKnownCapabilityName(ChromiumOptions.WindowTypesChromeOption, "AddWindowTypes method");
78-
this.AddKnownCapabilityName(ChromiumOptions.UseSpecCompliantProtocolOption, "UseSpecCompliantProtocol property");
79-
}
80-
8158
/// <summary>
8259
/// Gets the vendor prefix to apply to Chromium-specific capability names.
8360
/// </summary>

dotnet/src/webdriver/DriverOptions.cs

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
using System;
2323
using System.Collections.Generic;
2424
using System.Diagnostics.CodeAnalysis;
25-
using System.Globalization;
2625

2726
namespace OpenQA.Selenium;
2827

@@ -115,23 +114,6 @@ public abstract class DriverOptions
115114
{
116115
private readonly Dictionary<string, object> additionalCapabilities = new Dictionary<string, object>();
117116
private readonly Dictionary<string, LogLevel> loggingPreferences = new Dictionary<string, LogLevel>();
118-
private readonly Dictionary<string, string> knownCapabilityNames = new Dictionary<string, string>();
119-
120-
/// <summary>
121-
/// Initializes a new instance of the <see cref="DriverOptions"/> class.
122-
/// </summary>
123-
protected DriverOptions()
124-
{
125-
this.AddKnownCapabilityName(CapabilityType.BrowserName, "BrowserName property");
126-
this.AddKnownCapabilityName(CapabilityType.BrowserVersion, "BrowserVersion property");
127-
this.AddKnownCapabilityName(CapabilityType.PlatformName, "PlatformName property");
128-
this.AddKnownCapabilityName(CapabilityType.Proxy, "Proxy property");
129-
this.AddKnownCapabilityName(CapabilityType.UnhandledPromptBehavior, "UnhandledPromptBehavior property");
130-
this.AddKnownCapabilityName(CapabilityType.PageLoadStrategy, "PageLoadStrategy property");
131-
this.AddKnownCapabilityName(CapabilityType.UseStrictFileInteractability, "UseStrictFileInteractability property");
132-
this.AddKnownCapabilityName(CapabilityType.WebSocketUrl, "UseWebSocketUrl property");
133-
this.AddKnownCapabilityName(CapabilityType.EnableDownloads, "EnableDownloads property");
134-
}
135117

136118
/// <summary>
137119
/// Gets or sets the name of the browser.
@@ -361,71 +343,6 @@ protected void ValidateCapabilityName([NotNull] string? capabilityName)
361343
{
362344
throw new ArgumentException("Capability name may not be null an empty string.", nameof(capabilityName));
363345
}
364-
365-
if (this.TryGetKnownCapability(capabilityName!, out string? typeSafeOptionName))
366-
{
367-
string message = string.Format(CultureInfo.InvariantCulture, "There is already an option for the {0} capability. Please use the {1} instead.", capabilityName, typeSafeOptionName);
368-
throw new ArgumentException(message, nameof(capabilityName));
369-
}
370-
}
371-
372-
/// <summary>
373-
/// Adds a known capability to the list of known capabilities and associates it
374-
/// with the type-safe property name of the options class to be used instead.
375-
/// </summary>
376-
/// <param name="capabilityName">The name of the capability.</param>
377-
/// <param name="typeSafeOptionName">The name of the option property or method to be used instead.</param>
378-
protected void AddKnownCapabilityName(string capabilityName, string typeSafeOptionName)
379-
{
380-
this.knownCapabilityNames[capabilityName] = typeSafeOptionName;
381-
}
382-
383-
/// <summary>
384-
/// Remove a capability from the list of known capabilities
385-
/// </summary>
386-
/// <param name="capabilityName">The name of the capability to be removed.</param>
387-
protected void RemoveKnownCapabilityName(string? capabilityName)
388-
{
389-
if (capabilityName is not null)
390-
{
391-
this.knownCapabilityNames.Remove(capabilityName);
392-
}
393-
}
394-
395-
/// <summary>
396-
/// Gets a value indicating whether the specified capability name is a known capability name which has a type-safe option.
397-
/// </summary>
398-
/// <param name="capabilityName">The name of the capability to check.</param>
399-
/// <returns><see langword="true"/> if the capability name is known; otherwise <see langword="false"/>.</returns>
400-
protected bool IsKnownCapabilityName(string capabilityName)
401-
{
402-
return this.knownCapabilityNames.ContainsKey(capabilityName);
403-
}
404-
405-
/// <summary>
406-
/// Gets a value indicating whether the specified capability name is a known capability name which has a type-safe option.
407-
/// </summary>
408-
/// <param name="capabilityName">The name of the capability to check.</param>
409-
/// <param name="typeSafeOptionName">The name of the type-safe option for the given capability name, or <see langword="null"/> if not found.</param>
410-
/// <returns><see langword="true"/> if the capability name is known; otherwise <see langword="false"/>.</returns>
411-
protected bool TryGetKnownCapability(string capabilityName, [NotNullWhen(true)] out string? typeSafeOptionName)
412-
{
413-
return this.knownCapabilityNames.TryGetValue(capabilityName, out typeSafeOptionName);
414-
}
415-
416-
/// <summary>
417-
/// Gets the name of the type-safe option for a given capability name.
418-
/// </summary>
419-
/// <param name="capabilityName">The name of the capability to check.</param>
420-
/// <returns>The name of the type-safe option for the given capability name.</returns>
421-
protected string GetTypeSafeOptionName(string capabilityName)
422-
{
423-
if (!this.IsKnownCapabilityName(capabilityName))
424-
{
425-
return string.Empty;
426-
}
427-
428-
return this.knownCapabilityNames[capabilityName];
429346
}
430347

431348
/// <summary>

dotnet/src/webdriver/Firefox/FirefoxOptions.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,7 @@ public FirefoxOptions()
7272
: base()
7373
{
7474
this.BrowserName = BrowserNameValue;
75-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxOptionsCapability, "current FirefoxOptions class instance");
76-
this.AddKnownCapabilityName(FirefoxOptions.IsMarionetteCapability, "UseLegacyImplementation property");
77-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxProfileCapability, "Profile property");
78-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxBinaryCapability, "BrowserExecutableLocation property");
79-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxArgumentsCapability, "AddArguments method");
80-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxPrefsCapability, "SetPreference method");
81-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxEnvCapability, "SetEnvironmentVariable method");
82-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxLogCapability, "LogLevel property");
83-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxLegacyProfileCapability, "Profile property");
84-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxLegacyBinaryCapability, "BrowserExecutableLocation property");
85-
this.AddKnownCapabilityName(FirefoxOptions.FirefoxEnableDevToolsProtocolCapability, "EnableDevToolsProtocol property");
75+
8676
// https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
8777
// Enable BiDi only
8878
this.SetPreference("remote.active-protocols", 1);

dotnet/src/webdriver/IE/InternetExplorerOptions.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,6 @@ public InternetExplorerOptions() : base()
102102
{
103103
this.BrowserName = BrowserNameValue;
104104
this.PlatformName = "windows";
105-
this.AddKnownCapabilityName(Capability, "current InterentExplorerOptions class instance");
106-
this.AddKnownCapabilityName(IgnoreProtectedModeSettingsCapability, "IntroduceInstabilityByIgnoringProtectedModeSettings property");
107-
this.AddKnownCapabilityName(IgnoreZoomSettingCapability, "IgnoreZoomLevel property");
108-
this.AddKnownCapabilityName(CapabilityType.HasNativeEvents, "EnableNativeEvents property");
109-
this.AddKnownCapabilityName(InitialBrowserUrlCapability, "InitialBrowserUrl property");
110-
this.AddKnownCapabilityName(ElementScrollBehaviorCapability, "ElementScrollBehavior property");
111-
this.AddKnownCapabilityName(CapabilityType.UnexpectedAlertBehavior, "UnhandledPromptBehavior property");
112-
this.AddKnownCapabilityName(EnablePersistentHoverCapability, "EnablePersistentHover property");
113-
this.AddKnownCapabilityName(RequireWindowFocusCapability, "RequireWindowFocus property");
114-
this.AddKnownCapabilityName(BrowserAttachTimeoutCapability, "BrowserAttachTimeout property");
115-
this.AddKnownCapabilityName(ForceCreateProcessApiCapability, "ForceCreateProcessApi property");
116-
this.AddKnownCapabilityName(ForceShellWindowsApiCapability, "ForceShellWindowsApi property");
117-
this.AddKnownCapabilityName(BrowserCommandLineSwitchesCapability, "BrowserComaandLineArguments property");
118-
this.AddKnownCapabilityName(UsePerProcessProxyCapability, "UsePerProcessProxy property");
119-
this.AddKnownCapabilityName(EnsureCleanSessionCapability, "EnsureCleanSession property");
120-
this.AddKnownCapabilityName(FileUploadDialogTimeoutCapability, "FileUploadDialogTimeout property");
121-
this.AddKnownCapabilityName(EnableFullPageScreenshotCapability, "EnableFullPageScreenshot property");
122-
this.AddKnownCapabilityName(LegacyFileUploadDialogHandlingCapability, "LegacyFileUploadDialogHanlding property");
123-
this.AddKnownCapabilityName(AttachToEdgeChromeCapability, "AttachToEdgeChrome property");
124-
this.AddKnownCapabilityName(EdgeExecutablePathCapability, "EdgeExecutablePath property");
125-
this.AddKnownCapabilityName(IgnoreProcessMatchCapability, "IgnoreProcessMatch property");
126105
}
127106

128107
/// <summary>

dotnet/src/webdriver/Safari/SafariOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public SafariOptions() : base()
5353
{
5454
this.BrowserName = BrowserNameValue;
5555
this.TechnologyPreview = false;
56-
this.AddKnownCapabilityName(SafariOptions.EnableAutomaticInspectionSafariOption, "EnableAutomaticInspection property");
57-
this.AddKnownCapabilityName(SafariOptions.EnableAutomaticProfilingSafariOption, "EnableAutomaticProfiling property");
5856
}
5957

6058
/// <summary>

0 commit comments

Comments
 (0)