|
22 | 22 | using System; |
23 | 23 | using System.Collections.Generic; |
24 | 24 | using System.Diagnostics.CodeAnalysis; |
25 | | -using System.Globalization; |
26 | 25 |
|
27 | 26 | namespace OpenQA.Selenium; |
28 | 27 |
|
@@ -115,23 +114,6 @@ public abstract class DriverOptions |
115 | 114 | { |
116 | 115 | private readonly Dictionary<string, object> additionalCapabilities = new Dictionary<string, object>(); |
117 | 116 | 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 | | - } |
135 | 117 |
|
136 | 118 | /// <summary> |
137 | 119 | /// Gets or sets the name of the browser. |
@@ -361,71 +343,6 @@ protected void ValidateCapabilityName([NotNull] string? capabilityName) |
361 | 343 | { |
362 | 344 | throw new ArgumentException("Capability name may not be null an empty string.", nameof(capabilityName)); |
363 | 345 | } |
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]; |
429 | 346 | } |
430 | 347 |
|
431 | 348 | /// <summary> |
|
0 commit comments