diff --git a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs index fb2d91b08e9c4..0f8b126f73e47 100644 --- a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs +++ b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs @@ -50,6 +50,7 @@ public abstract class ChromiumDriver : WebDriver, ISupportsLogs, IDevTools private const string SendChromeCommand = "sendChromeCommand"; private const string SendChromeCommandWithResult = "sendChromeCommandWithResult"; private const string LaunchAppCommand = "launchAppCommand"; + private const string SetPermissionCommand = "setPermission"; private readonly string optionsCapabilityName; private DevToolsSession devToolsSession; @@ -83,6 +84,7 @@ public ChromiumDriver(ChromiumDriverService service, ChromiumOptions options, Ti this.AddCustomChromeCommand(SendChromeCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/chromium/send_command"); this.AddCustomChromeCommand(SendChromeCommandWithResult, HttpCommandInfo.PostCommand, "/session/{sessionId}/chromium/send_command_and_get_result"); this.AddCustomChromeCommand(LaunchAppCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/chromium/launch_app"); + this.AddCustomChromeCommand(SetPermissionCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/permissions"); } /// @@ -151,6 +153,31 @@ public void LaunchApp(string id) this.Execute(LaunchAppCommand, parameters); } + /// + /// Set supported permission on browser. + /// + /// Name of item to set the permission on. + /// Value to set the permission to. + public void SetPermission(string permissionName, string permissionValue) + { + if (permissionName == null) + { + throw new ArgumentNullException("permissionName", "name must not be null"); + } + + if (permissionValue == null) + { + throw new ArgumentNullException("permissionValue", "value must not be null"); + } + + Dictionary nameParameter = new Dictionary(); + nameParameter["name"] = permissionName; + Dictionary parameters = new Dictionary(); + parameters["descriptor"] = nameParameter; + parameters["state"] = permissionValue; + this.Execute(SetPermissionCommand, parameters); + } + /// /// Executes a custom Chrome Dev Tools Protocol Command. ///