diff --git a/dotnet/src/webdriver/Chrome/ChromeDriver.cs b/dotnet/src/webdriver/Chrome/ChromeDriver.cs
index 9f9e96c2c3948..8beea124c455e 100644
--- a/dotnet/src/webdriver/Chrome/ChromeDriver.cs
+++ b/dotnet/src/webdriver/Chrome/ChromeDriver.cs
@@ -139,6 +139,11 @@ public ChromeDriver(ChromeDriverService service, ChromeOptions options, TimeSpan
: base(service, options, commandTimeout)
{
this.AddCustomChromeCommand(ExecuteCdp, HttpCommandInfo.PostCommand, "/session/{sessionId}/goog/cdp/execute");
+ this.AddCustomChromeCommand(GetCastSinksCommand, HttpCommandInfo.GetCommand, "/session/{sessionId}/goog/cast/get_sinks");
+ this.AddCustomChromeCommand(SelectCastSinkCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/goog/cast/set_sink_to_use");
+ this.AddCustomChromeCommand(StartCastTabMirroringCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/goog/cast/start_tab_mirroring");
+ this.AddCustomChromeCommand(GetCastIssueMessageCommand, HttpCommandInfo.GetCommand, "/session/{sessionId}/goog/cast/get_issue_message");
+ this.AddCustomChromeCommand(StopCastingCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/goog/cast/stop_casting");
}
}
diff --git a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs
index 957bc94dcfe47..de483cb492f57 100644
--- a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs
+++ b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs
@@ -38,12 +38,17 @@ public abstract class ChromiumDriver : WebDriver, ISupportsLogs, IDevTools
///
public static readonly bool AcceptUntrustedCertificates = true;
+ protected const string ExecuteCdp = "executeCdpCommand";
+ protected const string GetCastSinksCommand = "getCastSinks";
+ protected const string SelectCastSinkCommand = "selectCastSink";
+ protected const string StartCastTabMirroringCommand = "startCastTabMirroring";
+ protected const string GetCastIssueMessageCommand = "getCastIssueMessage";
+ protected const string StopCastingCommand = "stopCasting";
private const string GetNetworkConditionsCommand = "getNetworkConditions";
private const string SetNetworkConditionsCommand = "setNetworkConditions";
private const string DeleteNetworkConditionsCommand = "deleteNetworkConditions";
private const string SendChromeCommand = "sendChromeCommand";
private const string SendChromeCommandWithResult = "sendChromeCommandWithResult";
- protected const string ExecuteCdp = "executeCdpCommand";
private readonly string optionsCapabilityName;
private DevToolsSession devToolsSession;
@@ -234,6 +239,74 @@ public void CloseDevToolsSession()
}
}
+ ///
+ /// Returns the list of cast sinks (Cast devices) available to the Chrome media router.
+ ///
+ /// An object representing the list of available sinks.
+ public object GetCastSinks()
+ {
+ Response response = this.Execute(GetCastSinksCommand, null);
+ return response.Value;
+ }
+
+ ///
+ /// Selects a cast sink (Cast device) as the recipient of media router intents (connect or play).
+ ///
+ /// Name of the target sink (device).
+ public void SelectCastSink(string deviceName)
+ {
+ if (deviceName == null)
+ {
+ throw new ArgumentNullException("deviceName", "deviceName must not be null");
+ }
+
+ Dictionary parameters = new Dictionary();
+ parameters["sinkName"] = deviceName;
+ this.Execute(SelectCastSinkCommand, parameters);
+ }
+
+ ///
+ /// Initiates tab mirroring for the current browser tab on the specified device.
+ ///
+ /// Name of the target sink (device).
+ public void StartTabMirroring(string deviceName)
+ {
+ if (deviceName == null)
+ {
+ throw new ArgumentNullException("deviceName", "deviceName must not be null");
+ }
+
+ Dictionary parameters = new Dictionary();
+ parameters["sinkName"] = deviceName;
+ this.Execute(StartCastTabMirroringCommand, parameters);
+ }
+
+ ///
+ /// Returns the error message if there is any issue in a Cast session.
+ ///
+ /// An error message.
+ public String GetCastIssueMessage()
+ {
+ Response response = this.Execute(GetCastIssueMessageCommand, null);
+ return (string)response.Value;
+ }
+
+ ///
+ /// Stops casting from media router to the specified device, if connected.
+ ///
+ /// Name of the target sink (device).
+ public void StopCasting(string deviceName)
+ {
+ if (deviceName == null)
+ {
+ throw new ArgumentNullException("deviceName", "deviceName must not be null");
+ }
+
+ Dictionary parameters = new Dictionary();
+ parameters["sinkName"] = deviceName;
+ this.Execute(StopCastingCommand, parameters);
+ }
+
protected override void Dispose(bool disposing)
{
if (disposing)
diff --git a/dotnet/src/webdriver/Edge/EdgeDriver.cs b/dotnet/src/webdriver/Edge/EdgeDriver.cs
index 4e95fd96bfb01..d2ce25cbc7e19 100644
--- a/dotnet/src/webdriver/Edge/EdgeDriver.cs
+++ b/dotnet/src/webdriver/Edge/EdgeDriver.cs
@@ -107,6 +107,11 @@ public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan comma
: base(service, options, commandTimeout)
{
this.AddCustomChromeCommand(ExecuteCdp, HttpCommandInfo.PostCommand, "/session/{sessionId}/ms/cdp/execute");
+ this.AddCustomChromeCommand(GetCastSinksCommand, HttpCommandInfo.GetCommand, "/session/{sessionId}/ms/cast/get_sinks");
+ this.AddCustomChromeCommand(SelectCastSinkCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/ms/cast/set_sink_to_use");
+ this.AddCustomChromeCommand(StartCastTabMirroringCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/ms/cast/start_tab_mirroring");
+ this.AddCustomChromeCommand(GetCastIssueMessageCommand, HttpCommandInfo.GetCommand, "/session/{sessionId}/ms/cast/get_issue_message");
+ this.AddCustomChromeCommand(StopCastingCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/ms/cast/stop_casting");
}
}
}