Skip to content

Commit 0cf2e24

Browse files
committed
Add attach debugger command to Safari
Copies Python bindings command added in 1cb3f69
1 parent f6f0064 commit 0cf2e24

4 files changed

Lines changed: 48 additions & 1 deletion

File tree

rb/lib/selenium/webdriver/common.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
require 'selenium/webdriver/common/driver_extensions/has_network_conditions'
5858
require 'selenium/webdriver/common/driver_extensions/has_network_conditions'
5959
require 'selenium/webdriver/common/driver_extensions/has_permissions'
60+
require 'selenium/webdriver/common/driver_extensions/has_debugger'
6061
require 'selenium/webdriver/common/driver_extensions/uploads_files'
6162
require 'selenium/webdriver/common/driver_extensions/has_addons'
6263
require 'selenium/webdriver/common/interactions/interactions'
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
module Selenium
19+
module WebDriver
20+
module DriverExtensions
21+
module HasDebugger
22+
23+
#
24+
# Attaches debugger to session.
25+
#
26+
# @example
27+
# driver.attach_debugger
28+
# driver.execute_script('debugger')
29+
#
30+
# @return [Hash]
31+
#
32+
33+
def attach_debugger
34+
@bridge.attach_debugger
35+
end
36+
37+
end # HasDebugger
38+
end # DriverExtensions
39+
end # WebDriver
40+
end # Selenium

rb/lib/selenium/webdriver/safari/bridge.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module Bridge
2323
# https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/WebDriverEndpointDoc/Commands/Commands.html
2424
COMMANDS = {
2525
get_permissions: [:get, '/session/:session_id/apple/permissions'.freeze],
26-
set_permissions: [:post, '/session/:session_id/apple/permissions'.freeze]
26+
set_permissions: [:post, '/session/:session_id/apple/permissions'.freeze],
27+
attach_debugger: [:post, '/session/:session_id/apple/attach_debugger'.freeze]
2728
}.freeze
2829

2930
def commands(command)
@@ -38,6 +39,10 @@ def permissions=(permissions)
3839
execute :set_permissions, {}, {permissions: permissions}
3940
end
4041

42+
def attach_debugger
43+
execute :attach_debugger, {}, {}
44+
end
45+
4146
end # Bridge
4247
end # Safari
4348
end # WebDriver

rb/lib/selenium/webdriver/safari/driver.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module Safari
2525
#
2626

2727
class Driver < WebDriver::Driver
28+
include DriverExtensions::HasDebugger
2829
include DriverExtensions::HasPermissions
2930
include DriverExtensions::TakesScreenshot
3031

0 commit comments

Comments
 (0)