@@ -50,6 +50,7 @@ public abstract class ChromiumDriver : WebDriver, ISupportsLogs, IDevTools
50
50
private const string SendChromeCommand = "sendChromeCommand" ;
51
51
private const string SendChromeCommandWithResult = "sendChromeCommandWithResult" ;
52
52
private const string LaunchAppCommand = "launchAppCommand" ;
53
+ private const string SetPermissionCommand = "setPermission" ;
53
54
54
55
private readonly string optionsCapabilityName ;
55
56
private DevToolsSession devToolsSession ;
@@ -83,6 +84,7 @@ public ChromiumDriver(ChromiumDriverService service, ChromiumOptions options, Ti
83
84
this . AddCustomChromeCommand ( SendChromeCommand , HttpCommandInfo . PostCommand , "/session/{sessionId}/chromium/send_command" ) ;
84
85
this . AddCustomChromeCommand ( SendChromeCommandWithResult , HttpCommandInfo . PostCommand , "/session/{sessionId}/chromium/send_command_and_get_result" ) ;
85
86
this . AddCustomChromeCommand ( LaunchAppCommand , HttpCommandInfo . PostCommand , "/session/{sessionId}/chromium/launch_app" ) ;
87
+ this . AddCustomChromeCommand ( SetPermissionCommand , HttpCommandInfo . PostCommand , "/session/{sessionId}/permissions" ) ;
86
88
}
87
89
88
90
/// <summary>
@@ -151,6 +153,31 @@ public void LaunchApp(string id)
151
153
this . Execute ( LaunchAppCommand , parameters ) ;
152
154
}
153
155
156
+ /// <summary>
157
+ /// Set supported permission on browser.
158
+ /// </summary>
159
+ /// <param name="permissionName">Name of item to set the permission on.</param>
160
+ /// <param name="permissionValue">Value to set the permission to.</param>
161
+ public void SetPermission ( string permissionName , string permissionValue )
162
+ {
163
+ if ( permissionName == null )
164
+ {
165
+ throw new ArgumentNullException ( "permissionName" , "name must not be null" ) ;
166
+ }
167
+
168
+ if ( permissionValue == null )
169
+ {
170
+ throw new ArgumentNullException ( "permissionValue" , "value must not be null" ) ;
171
+ }
172
+
173
+ Dictionary < string , object > nameParameter = new Dictionary < string , object > ( ) ;
174
+ nameParameter [ "name" ] = permissionName ;
175
+ Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
176
+ parameters [ "descriptor" ] = nameParameter ;
177
+ parameters [ "state" ] = permissionValue ;
178
+ this . Execute ( SetPermissionCommand , parameters ) ;
179
+ }
180
+
154
181
/// <summary>
155
182
/// Executes a custom Chrome Dev Tools Protocol Command.
156
183
/// </summary>
0 commit comments