@@ -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