Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ios_tests/lib/ios/specs/ios/xcuitest_gestures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def open_alert_custom
double_tap(element: element)
end

t 'touch_and_hold' do
element = button('Tinted')
touch_and_hold(element: element, duration: 4.0)
touch_and_hold(x: 100, y: 100)
end

t 'scroll' do
scroll direction: 'down'
text('Style Default').displayed?.must_equal true
Expand Down
19 changes: 19 additions & 0 deletions lib/appium_lib/ios/xcuitest_gestures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ def double_tap(x: nil, y: nil, element: nil)
execute_script 'mobile: doubleTap', args
end

# @param x [float] Screen x long tap coordinate of type float. Mandatory parameter only if element is not set
# @param y [float] Screen y long tap coordinate of type float. Mandatory parameter only if element is not set
# @param duration [Float] The float duration of press action in seconds. Mandatory parameter
# @option opts [Element] :element The internal element identifier (as hexadecimal hash string) to long tap on
#
# ```ruby
# touch_and_hold x: 100, y: 100
# touch_and_hold x: 100, y: 100, duration: 2.0
# touch_and_hold element: find_element(:accessibility_id, "some item")
# ```
def touch_and_hold(x: nil, y: nil, element: nil, duration: 1.0)
return 'require XCUITest(WDA)' unless automation_name_is_xcuitest?
return 'Set x, y or element' if (x.nil? || y.nil?) && element.nil?

args = element.nil? ? { x: x, y: y } : { element: element.ref }
args[:duration] = duration
execute_script 'mobile: touchAndHold', args
end

# @param [Element] :element Element to long tap on.
#
# ```ruby
Expand Down