Skip to content

Commit 7909daa

Browse files
Rename press_for_duration to long_press
1 parent d63a58f commit 7909daa

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

ios_tests/lib/ios/specs/device/device.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def before_first
5555

5656
t 'app_strings' do
5757
app_strings.must_include "SearchBarExplain"
58+
app_strings('en').must_include "SearchBarExplain"
5859
end
5960

6061
t 'action_chain' do

ios_tests/lib/ios/specs/device/touch_actions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# todo: write tests
55
=begin
66
move_to
7-
press_for_duration
7+
long_press
88
press
99
release
1010
tap

lib/appium_lib/device/touch_actions.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Appium
99
# action = TouchAction.new.press(x: 45, y: 100).wait(5).release
1010
# action.perform
1111
class TouchAction
12-
ACTIONS = [:move_to, :press_for_duration, :press, :release, :tap, :wait, :perform]
12+
ACTIONS = [:move_to, :long_press, :press, :release, :tap, :wait, :perform]
1313
COMPLEX_ACTIONS = [:swipe]
1414

1515
class << self
@@ -40,13 +40,14 @@ def move_to(opts)
4040
end
4141

4242
# Press down for a specific duration.
43-
# @param element [WebDriver::Element] the element to press.
44-
# @param x [integer] x co-ordinate to press on.
45-
# @param y [integer] y co-ordinate to press on.
46-
# @param duration [integer] Number of seconds to press.
47-
def press_for_duration(element, x, y, duration)
48-
@actions << {element: element.ref, x: x, y: y, duration: duration}
49-
chain_method(:longPress, args)
43+
# @option element [WebDriver::Element] the element to press.
44+
# @option x [integer] x co-ordinate to press on.
45+
# @option y [integer] y co-ordinate to press on.
46+
# @option duration [integer] Number of milliseconds to press.
47+
def long_press(opts)
48+
args = opts.select {|k, v| [:element, :x, :y, :duration].include? k}
49+
args = args_with_ele_ref(args)
50+
chain_method(:longPress, args) # longPress is what the appium server expects
5051
end
5152

5253
# Press a finger onto the screen. Finger will stay down until you call
@@ -84,10 +85,10 @@ def tap(opts)
8485
chain_method(:tap, args)
8586
end
8687

87-
# Pause for a number of seconds before the next action
88-
# @param seconds [integer] Number of seconds to pause for
89-
def wait(seconds)
90-
args = {ms: seconds}
88+
# Pause for a number of milliseconds before the next action
89+
# @param milliseconds [integer] Number of milliseconds to pause for
90+
def wait(milliseconds)
91+
args = {ms: milliseconds}
9192
chain_method(:wait, args)
9293
end
9394

@@ -96,7 +97,7 @@ def wait(seconds)
9697
# @option opts [int] :start_y Where to start swiping, on the y axis. Default 0.
9798
# @option opts [int] :end_x Where to end swiping, on the x axis. Default 0.
9899
# @option opts [int] :end_y Where to end swiping, on the y axis. Default 0.
99-
# @option opts [int] :duration How long the actual swipe takes to complete.
100+
# @option opts [int] :duration How long the actual swipe takes to complete in milliseconds.
100101
def swipe(opts)
101102
start_x = opts.fetch :start_x, 0
102103
start_y = opts.fetch :start_y, 0

0 commit comments

Comments
 (0)