Skip to content

Commit 2fa2440

Browse files
authored
test: tweak espresso (#278)
* tweak test_permissions * fix more * fix rubocop
1 parent ba7f71d commit 2fa2440

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

test/functional/android/android/device_test.rb

+20-7
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,20 @@ def test_background_reset
8585

8686
@driver.background_app(-1)
8787
sleep 1 # to wait the app has gone
88-
error = assert_raises ::Selenium::WebDriver::Error::WebDriverError do
89-
@driver.find_element :accessibility_id, 'App'
90-
end
91-
assert 'An element could not be located on the page using the given search parameters.', error.message
88+
assert @driver.app_state('io.appium.android.apis') != :running_in_foreground
89+
90+
# Instrumentation process will crash in Espresso
91+
if @@core.automation_name == :espresso
92+
@driver.activate_app('io.appium.android.apis')
93+
@@core.wait { assert @driver.app_state('io.appium.android.apis') == :running_in_foreground }
94+
else
95+
error = assert_raises ::Selenium::WebDriver::Error::WebDriverError do
96+
@driver.find_element :accessibility_id, 'App'
97+
end
98+
assert 'An element could not be located on the page using the given search parameters.', error.message
9299

93-
@driver.reset
100+
@driver.reset
101+
end
94102

95103
e = @@core.wait(timeout: 60) { @driver.find_element :accessibility_id, 'App' }
96104
assert_equal 'App', e.text
@@ -132,6 +140,8 @@ def test_app_string
132140
end
133141

134142
def test_re_install
143+
skip 'Instrumentation process will stop by remove_app in Espresso' if @@core.automation_name == :espresso
144+
135145
assert @driver.app_installed?('io.appium.android.apis')
136146

137147
@driver.remove_app 'io.appium.android.apis'
@@ -146,8 +156,11 @@ def test_re_install
146156
def test_app_management
147157
assert @driver.app_state('io.appium.android.apis') == :running_in_foreground
148158

149-
assert @driver.terminate_app('io.appium.android.apis')
150-
@@core.wait { assert @driver.app_state('io.appium.android.apis') == :not_running }
159+
# Instrumentation process will crash in Espresso
160+
unless @@core.automation_name == :espresso
161+
assert @driver.terminate_app('io.appium.android.apis')
162+
@@core.wait { assert @driver.app_state('io.appium.android.apis') == :not_running }
163+
end
151164

152165
assert @driver.activate_app('io.appium.android.apis').nil?
153166
@@core.wait { assert @driver.app_state('io.appium.android.apis') == :running_in_foreground }

test/functional/android/android/mobile_commands_test.rb

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def test_permissions
5454
assert @driver.execute_script('mobile: getPermissions',
5555
{ type: type[:requested], appPackage: package }).member?(permissions.first)
5656

57+
# Espresso driver works only getPermissions, so finish
58+
return if @core.automation_name == :espresso
59+
5760
@driver.execute_script 'mobile: changePermissions',
5861
{ action: action[:revoke], appPackage: package, permissions: permissions }
5962

0 commit comments

Comments
 (0)