Skip to content

Commit cde3c8a

Browse files
committed
[dotnet] implement ability to open Safari inspector
1 parent 81679ca commit cde3c8a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

dotnet/src/webdriver/Safari/SafariDriver.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace OpenQA.Selenium.Safari
6262
/// </example>
6363
public class SafariDriver : WebDriver
6464
{
65+
private const string AttachDebuggerCommand = "attachDebugger";
6566
private const string GetPermissionsCommand = "getPermissions";
6667
private const string SetPermissionsCommand = "setPermissions";
6768

@@ -144,10 +145,23 @@ public SafariDriver(SafariDriverService service, SafariOptions options)
144145
public SafariDriver(SafariDriverService service, SafariOptions options, TimeSpan commandTimeout)
145146
: base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options))
146147
{
148+
this.AddCustomSafariCommand(AttachDebuggerCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/apple/attach_debugger");
147149
this.AddCustomSafariCommand(GetPermissionsCommand, HttpCommandInfo.GetCommand, "/session/{sessionId}/apple/permissions");
148150
this.AddCustomSafariCommand(SetPermissionsCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/apple/permissions");
149151
}
150152

153+
/// <summary>
154+
/// This opens Safari's Web Inspector.
155+
/// If driver subsequently executes script of "debugger;"
156+
/// the execution will pause, no additional commands will be processed, and the code will time out.
157+
/// </summary>
158+
public void AttachDebugger()
159+
{
160+
Dictionary<string, object> parameters = new Dictionary<string, object>();
161+
parameters["attachDebugger"] = null;
162+
this.Execute(AttachDebuggerCommand, parameters);
163+
}
164+
151165
/// <summary>
152166
/// Set permission of an item on the browser. The only supported permission at this time is "getUserMedia".
153167
/// </summary>

0 commit comments

Comments
 (0)