Skip to content

Commit

Permalink
[dotnet] Add Bidi-compliant webSocketUrl capability
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Sep 28, 2021
1 parent 1dacd21 commit fe91134
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
9 changes: 8 additions & 1 deletion dotnet/src/webdriver/CapabilityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ public static class CapabilityType
/// </summary>
public static readonly string UseStrictFileInteractability = "strictFileInteractability";

/// <summary>
/// Capability name used to get a value indicating whether to request URL of a WebSocket
/// connection for bidirectional communication with a driver.
/// </summary>
public static readonly string WebSocketUrl = "webSocketUrl";

private static readonly List<string> KnownSpecCompliantCapabilityNames = new List<string>() {
BrowserName,
BrowserVersion,
Expand All @@ -165,7 +171,8 @@ public static class CapabilityType
SetWindowRect,
Timeouts,
UnhandledPromptBehavior,
UseStrictFileInteractability
UseStrictFileInteractability,
WebSocketUrl
};

/// <summary>
Expand Down
17 changes: 17 additions & 0 deletions dotnet/src/webdriver/DriverOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public abstract class DriverOptions
private string platformName;
private Proxy proxy;
private bool? acceptInsecureCertificates;
private bool? useWebSocketUrl;
private bool useStrictFileInteractability;
private UnhandledPromptBehavior unhandledPromptBehavior = UnhandledPromptBehavior.Default;
private PageLoadStrategy pageLoadStrategy = PageLoadStrategy.Default;
Expand All @@ -118,6 +119,7 @@ protected DriverOptions()
this.AddKnownCapabilityName(CapabilityType.UnhandledPromptBehavior, "UnhandledPromptBehavior property");
this.AddKnownCapabilityName(CapabilityType.PageLoadStrategy, "PageLoadStrategy property");
this.AddKnownCapabilityName(CapabilityType.UseStrictFileInteractability, "UseStrictFileInteractability property");
this.AddKnownCapabilityName(CapabilityType.WebSocketUrl, "UseWebSocketUrl property");
}

/// <summary>
Expand Down Expand Up @@ -157,6 +159,16 @@ public bool? AcceptInsecureCertificates
set { this.acceptInsecureCertificates = value; }
}

/// <summary>
/// Gets or sets a value indicating whether the driver should request a URL to
/// a WebSocket to be used for bidirectional communication.
/// </summary>
public bool? UseWebSocketUrl
{
get { return this.useWebSocketUrl; }
set { this.useWebSocketUrl = value; }
}

/// <summary>
/// Gets or sets the value for describing how unexpected alerts are to be handled in the browser.
/// Defaults to <see cref="UnhandledPromptBehavior.Default"/>.
Expand Down Expand Up @@ -450,6 +462,11 @@ protected IWritableCapabilities GenerateDesiredCapabilities(bool isSpecification
capabilities.SetCapability(CapabilityType.AcceptInsecureCertificates, this.acceptInsecureCertificates);
}

if (this.useWebSocketUrl.HasValue)
{
capabilities.SetCapability(CapabilityType.WebSocketUrl, this.useWebSocketUrl);
}

if (this.useStrictFileInteractability)
{
capabilities.SetCapability(CapabilityType.UseStrictFileInteractability, true);
Expand Down
1 change: 0 additions & 1 deletion dotnet/src/webdriver/Remote/DesiredCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace OpenQA.Selenium.Remote
/// <summary>
/// Internal class to specify the requested capabilities of the browser for <see cref="IWebDriver"/>.
/// </summary>
[Obsolete("Use of DesiredCapabilities has been deprecated in favor of browser-specific Options classes")]
internal class DesiredCapabilities : IWritableCapabilities, IHasCapabilitiesDictionary
{
private readonly Dictionary<string, object> capabilities = new Dictionary<string, object>();
Expand Down

0 comments on commit fe91134

Please sign in to comment.