@@ -15,14 +15,13 @@ def teardown
15
15
@@core . quit_driver
16
16
end
17
17
18
- def test_tap
18
+ def test_tap_scroll
19
19
skip if @driver . dialect == :oss
20
20
21
21
el = @@core . wait { @driver . find_element ( :accessibility_id , 'Views' ) }
22
22
@driver . action . click ( el ) . perform
23
23
24
24
el = @@core . wait { @driver . find_element ( :accessibility_id , 'Custom' ) }
25
- # same as @driver.action.click_and_hold(el).move_to_location(0, 700).release.perform
26
25
27
26
rect1 = el . rect . dup
28
27
@driver
@@ -39,15 +38,81 @@ def test_tap
39
38
. action
40
39
. move_to_location ( rect2 . x , rect2 . y )
41
40
. pointer_down ( :left )
42
- . move_to_location ( 0 , rect2 . y - rect2 . height * 2 )
41
+ . move_to_location ( 0 , rect2 . y - rect2 . height * 3 ) # gone the element
43
42
. release
44
43
. perform
45
- assert rect2 . y > el . rect . y
44
+
45
+ @driver . manage . timeouts . implicit_wait = 3
46
+ assert_raises ::Selenium ::WebDriver ::Error ::NoSuchElementError do
47
+ @driver . find_element ( :accessibility_id , 'Custom' )
48
+ end
49
+ @driver . manage . timeouts . implicit_wait = @@core . default_wait
46
50
47
51
el = @@core . wait { @driver . find_element ( :accessibility_id , 'ImageButton' ) }
48
52
assert_equal 'ImageButton' , el . text
49
53
end
50
54
55
+ def test_double_tap
56
+ skip if @driver . dialect == :oss
57
+
58
+ el = @@core . wait { @driver . find_element ( :accessibility_id , 'Views' ) }
59
+ @driver . action . click ( el ) . perform
60
+
61
+ el = @@core . wait { @driver . find_element ( :accessibility_id , 'Buttons' ) }
62
+ @driver . action . click ( el ) . perform
63
+
64
+ el = @driver . find_element ( :id , 'io.appium.android.apis:id/button_toggle' )
65
+ assert_equal 'OFF' , el . text
66
+ @driver . action . click ( el ) . perform
67
+
68
+ assert_equal 'ON' , el . text
69
+
70
+ # double tap action with pause
71
+ action_builder = @driver . action
72
+ input = action_builder . pointer_inputs [ 0 ]
73
+ action_builder
74
+ . move_to ( el )
75
+ . pointer_down ( :left )
76
+ . pause ( input , 0.05 ) # seconds
77
+ . pointer_up ( :left )
78
+ . pause ( input , 0.05 ) # seconds
79
+ . pointer_down ( :left )
80
+ . pause ( input , 0.05 ) # seconds
81
+ . pointer_up ( :left )
82
+ . perform
83
+ assert_equal 'ON' , el . text
84
+
85
+ error = assert_raises ::Selenium ::WebDriver ::Error ::UnknownError do
86
+ @driver . action . double_click ( el ) . perform
87
+ end
88
+ assert error . message . include? ( 'You cannot perform' )
89
+ end
90
+
91
+ def test_actions_with_many_down_up
92
+ skip if @driver . dialect == :oss
93
+
94
+ el = @@core . wait { @driver . find_element ( :accessibility_id , 'Views' ) }
95
+ @driver . action . click_and_hold ( el ) . release . perform
96
+
97
+ el = @@core . wait { @driver . find_element ( :accessibility_id , 'Custom' ) }
98
+
99
+ rect1 = el . rect . dup
100
+
101
+ error = assert_raises ::Selenium ::WebDriver ::Error ::UnknownError do
102
+ @driver
103
+ . action
104
+ . move_to ( el )
105
+ . pointer_down ( :left ) # should insert pause
106
+ . pointer_down ( :left )
107
+ . pointer_down ( :left )
108
+ . move_to_location ( 0 , rect1 . y - rect1 . height )
109
+ . release
110
+ . release
111
+ . perform
112
+ end
113
+ assert error . message . include? ( 'You cannot perform' )
114
+ end
115
+
51
116
# Note: Works with Espresso Driver
52
117
def test_multiple_actions
53
118
f1 = @driver . action . add_pointer_input ( :touch , 'finger1' )
0 commit comments