@@ -55,7 +55,7 @@ def test_close_and_launch_app
55
55
end
56
56
else
57
57
@driver . close_app
58
- assert ( @@core . wait { @driver . app_state ( 'io.appium.android.apis' ) != :running_in_foreground } )
58
+ assert ( @driver . wait_until { | d | d . app_state ( 'io.appium.android.apis' ) != :running_in_foreground } )
59
59
end
60
60
61
61
if @@core . automation_name == :espresso
@@ -64,7 +64,7 @@ def test_close_and_launch_app
64
64
end
65
65
else
66
66
@driver . launch_app
67
- e = @@core . wait { @driver . find_element :accessibility_id , 'App' }
67
+ e = @driver . wait_until { | d | d . find_element :accessibility_id , 'App' }
68
68
assert_equal 'App' , e . text
69
69
end
70
70
end
@@ -74,13 +74,13 @@ def test_lock_unlock
74
74
assert @driver . device_locked?
75
75
76
76
@driver . unlock
77
- @@core . wait { assert !@driver . device_locked? }
77
+ @driver . wait_until { | d | assert !d . device_locked? }
78
78
end
79
79
80
80
def test_background_reset
81
81
@driver . background_app 3
82
82
83
- e = @@core . wait { @driver . find_element :accessibility_id , 'App' }
83
+ e = @driver . wait_until { | d | d . find_element :accessibility_id , 'App' }
84
84
assert_equal 'App' , e . text
85
85
86
86
@driver . background_app ( -1 )
@@ -90,7 +90,7 @@ def test_background_reset
90
90
# Instrumentation process will crash in Espresso
91
91
if @@core . automation_name == :espresso
92
92
@driver . activate_app ( 'io.appium.android.apis' )
93
- @@core . wait { assert @driver . app_state ( 'io.appium.android.apis' ) == :running_in_foreground }
93
+ @driver . wait_until { | d | assert d . app_state ( 'io.appium.android.apis' ) == :running_in_foreground }
94
94
else
95
95
error = assert_raises ::Selenium ::WebDriver ::Error ::WebDriverError do
96
96
@driver . find_element :accessibility_id , 'App'
@@ -100,7 +100,7 @@ def test_background_reset
100
100
@driver . reset
101
101
end
102
102
103
- e = @@core . wait ( timeout : 60 ) { @driver . find_element :accessibility_id , 'App' }
103
+ e = @driver . wait ( timeout : 60 ) { | d | d . find_element :accessibility_id , 'App' }
104
104
assert_equal 'App' , e . text
105
105
end
106
106
@@ -126,12 +126,12 @@ def test_context_related
126
126
webview_context = contexts . detect { |e | e . start_with? ( 'WEBVIEW' ) }
127
127
128
128
@driver . set_context webview_context
129
- @@core . wait { assert @driver . current_context . start_with? 'WEBVIEW' }
129
+ @driver . wait { | d | assert d . current_context . start_with? 'WEBVIEW' }
130
130
131
131
webview_page = @driver . page_source
132
132
133
133
@driver . switch_to_default_context
134
- @@core . wait { assert_equal 'NATIVE_APP' , @driver . current_context }
134
+ @driver . wait { | d | assert_equal 'NATIVE_APP' , d . current_context }
135
135
assert native_page != webview_page
136
136
end
137
137
@@ -159,35 +159,35 @@ def test_app_management
159
159
# Instrumentation process will crash in Espresso
160
160
unless @@core . automation_name == :espresso
161
161
assert @driver . terminate_app ( 'io.appium.android.apis' )
162
- @@core . wait { assert @driver . app_state ( 'io.appium.android.apis' ) == :not_running }
162
+ @driver . wait_until { | d | assert d . app_state ( 'io.appium.android.apis' ) == :not_running }
163
163
end
164
164
165
165
assert @driver . activate_app ( 'io.appium.android.apis' ) . nil?
166
- @@core . wait { assert @driver . app_state ( 'io.appium.android.apis' ) == :running_in_foreground }
166
+ @driver . wait_until { assert @driver . app_state ( 'io.appium.android.apis' ) == :running_in_foreground }
167
167
end
168
168
169
169
def test_start_activity
170
- e = @@core . wait { @ driver. current_activity }
170
+ e = @driver . wait_until ( & : current_activity)
171
171
assert_equal '.ApiDemos' , e
172
172
173
173
@driver . start_activity app_package : 'io.appium.android.apis' ,
174
174
app_activity : '.accessibility.AccessibilityNodeProviderActivity'
175
- e = @@core . wait { @ driver. current_activity }
175
+ e = @driver . wait_until ( & : current_activity)
176
176
assert true , e . include? ( 'Node' )
177
177
178
178
# Espresso cannot launch my root launched activity: https://github.com/appium/appium-espresso-driver/pull/378#discussion_r250034209
179
179
return if @@core . automation_name == :espresso
180
180
181
181
@driver . start_activity app_package : 'com.android.settings' , app_activity : '.Settings' ,
182
182
app_wait_package : 'com.android.settings' , app_wait_activity : '.Settings'
183
- e = @@core . wait { @ driver. current_activity }
183
+ e = @driver . wait_until ( & : current_activity)
184
184
assert true , e . include? ( 'Settings' )
185
185
186
186
@driver . start_activity app_package : 'io.appium.android.apis' , app_activity : '.ApiDemos'
187
187
end
188
188
189
189
def test_current_package
190
- e = @@core . wait { @ driver. current_package }
190
+ e = @driver . wait_until ( & : current_package)
191
191
assert_equal 'io.appium.android.apis' , e
192
192
end
193
193
@@ -197,21 +197,21 @@ def test_touch_actions
197
197
. release
198
198
. perform
199
199
200
- @@core . wait { @driver . find_element :accessibility_id , 'Action Bar' }
200
+ @driver . wait_until { | d | d . find_element :accessibility_id , 'Action Bar' }
201
201
@driver . back
202
202
end
203
203
204
204
def test_swipe
205
- @@core . wait { @driver . find_element :accessibility_id , 'App' } . click
205
+ @driver . wait_until { | d | d . find_element :accessibility_id , 'App' } . click
206
206
207
- el = @@core . wait { @driver . find_element :accessibility_id , 'Fragment' }
207
+ el = @driver . wait_until { | d | d . find_element :accessibility_id , 'Fragment' }
208
208
rect = el . rect
209
209
210
210
Appium ::Core ::TouchAction . new ( @driver )
211
211
. swipe ( start_x : 75 , start_y : 500 , end_x : 75 , end_y : 500 , duration : 500 )
212
212
. perform
213
213
@driver . back # The above command become "tap" action since it doesn't move.
214
- el = @@core . wait { @driver . find_element :accessibility_id , 'Fragment' }
214
+ el = @driver . wait_until { | d | d . find_element :accessibility_id , 'Fragment' }
215
215
assert rect . x == el . rect . x
216
216
assert rect . y == el . rect . y
217
217
@@ -237,11 +237,11 @@ def test_swipe
237
237
end
238
238
239
239
def test_hidekeyboard
240
- @@core . wait { @driver . find_element :accessibility_id , 'App' } . click
241
- @@core . wait { @driver . find_element :accessibility_id , 'Activity' } . click
242
- @@core . wait { @driver . find_element :accessibility_id , 'Custom Title' } . click
240
+ @driver . wait_until { | d | d . find_element :accessibility_id , 'App' } . click
241
+ @driver . wait_until { | d | d . find_element :accessibility_id , 'Activity' } . click
242
+ @driver . wait_until { | d | d . find_element :accessibility_id , 'Custom Title' } . click
243
243
# make sure to show keyboard
244
- @@core . wait { @driver . find_element :id , 'io.appium.android.apis:id/left_text_edit' } . click
244
+ @driver . wait_until { | d | d . find_element :id , 'io.appium.android.apis:id/left_text_edit' } . click
245
245
246
246
latin_android = 'com.android.inputmethod.latin/.LatinIME'
247
247
latin_google = 'com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME'
@@ -257,7 +257,7 @@ def test_hidekeyboard
257
257
258
258
assert @driver . keyboard_shown?
259
259
260
- @@core . wait { @ driver. hide_keyboard }
260
+ @driver . wait ( & : hide_keyboard)
261
261
sleep 1 # wait animation
262
262
263
263
assert !@driver . is_keyboard_shown
0 commit comments