@@ -7,19 +7,12 @@ module Appium
7
7
#
8
8
# ```ruby
9
9
# action = TouchAction.new.press(x: 45, y: 100).wait(5).release
10
+ # action.perform
10
11
class TouchAction
11
- ACTIONS = [ :moveTo , :longPress , :press , :release , :tap , :wait , :perform ]
12
+ ACTIONS = [ :move_to , :press_for_duration , :press , :release , :tap , :wait , :perform ]
12
13
COMPLEX_ACTIONS = [ :swipe ]
13
14
14
15
class << self
15
- ACTIONS . each do |action |
16
- define_method ( action ) do |*args |
17
- ta = TouchAction . new
18
- ta . send ( action , args )
19
- ta . perform
20
- end
21
- end
22
-
23
16
COMPLEX_ACTIONS . each do |action |
24
17
define_method ( action ) do |opts |
25
18
auto_perform = opts . delete ( :auto_perform ) { |k | true }
@@ -41,7 +34,7 @@ def initialize
41
34
# @option opts (integer) :x x co-ordinate to move to.
42
35
# @option opts (integer) :y y co-ordinate to move to.
43
36
# @option opts (WebDriver::Element) Element to scope this move within.
44
- def moveTo ( opts )
37
+ def move_to ( opts )
45
38
opts = args_with_ele_ref ( opts )
46
39
chain_method ( :moveTo , opts )
47
40
end
@@ -112,7 +105,7 @@ def swipe(opts)
112
105
113
106
self . press x : start_x , y : start_y
114
107
self . wait ( duration ) if duration
115
- self . moveTo x : end_x , y : end_y
108
+ self . move_to x : end_x , y : end_y
116
109
self . release
117
110
self
118
111
end
0 commit comments