Skip to content

Commit

Permalink
[dotnet] implement ability to open Safari inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Sep 29, 2021
1 parent 81679ca commit cde3c8a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dotnet/src/webdriver/Safari/SafariDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace OpenQA.Selenium.Safari
/// </example>
public class SafariDriver : WebDriver
{
private const string AttachDebuggerCommand = "attachDebugger";
private const string GetPermissionsCommand = "getPermissions";
private const string SetPermissionsCommand = "setPermissions";

Expand Down Expand Up @@ -144,10 +145,23 @@ public SafariDriver(SafariDriverService service, SafariOptions options)
public SafariDriver(SafariDriverService service, SafariOptions options, TimeSpan commandTimeout)
: base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options))
{
this.AddCustomSafariCommand(AttachDebuggerCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/apple/attach_debugger");
this.AddCustomSafariCommand(GetPermissionsCommand, HttpCommandInfo.GetCommand, "/session/{sessionId}/apple/permissions");
this.AddCustomSafariCommand(SetPermissionsCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/apple/permissions");
}

/// <summary>
/// This opens Safari's Web Inspector.
/// If driver subsequently executes script of "debugger;"
/// the execution will pause, no additional commands will be processed, and the code will time out.
/// </summary>
public void AttachDebugger()
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters["attachDebugger"] = null;
this.Execute(AttachDebuggerCommand, parameters);
}

/// <summary>
/// Set permission of an item on the browser. The only supported permission at this time is "getUserMedia".
/// </summary>
Expand Down

0 comments on commit cde3c8a

Please sign in to comment.