fix(appium-tests): stop waiting 50s for a USB dialog Android never shows
Android often grants USB permission silently, so waiting out the dialog timeout on every attempt burned ~150s per test on CI and left the confirmation screen in a state where the next tap was dropped, so the job never started at all. Keep the retry, but make the dialog wait short: the grant button disappearing is the real signal that permission landed, however it was granted. Verify the 'write image' tap took as well, by waiting for what must follow it -- the lay-flat sheet, or the progress screen when the sheet auto-proceeds on a device with a working gravity sensor.
This commit is contained in:
1 file changed
+21
-7
@@ -51,17 +51,17 @@ def select_first_usb_device_if_multiple(driver: Remote, timeout: int = 1):
|
||||
|
||||
def grant_usb_permission(driver: Remote):
|
||||
# The tap is swallowed if it lands while the confirmation activity is still settling,
|
||||
# and then nothing requests permission at all: retry until the system dialog shows or
|
||||
# the grant button is gone (permission already granted, so no dialog is coming).
|
||||
# and then nothing requests permission at all. Retry, but keep the dialog wait short:
|
||||
# Android often grants silently, and then no dialog is ever coming. The grant button
|
||||
# disappearing is the signal that permission landed, however it was granted.
|
||||
for _ in range(3):
|
||||
try:
|
||||
grant_btn = wait_for_element(driver, '//*[@resource-id="grantUsbPermissionButton"]')
|
||||
grant_btn = wait_for_element(driver, '//*[@resource-id="grantUsbPermissionButton"]', timeout=2)
|
||||
except TimeoutException:
|
||||
return
|
||||
try:
|
||||
grant_btn.click()
|
||||
# The system dialog can take several seconds to render on a cold guest.
|
||||
accept_usb_permission(driver, timeout=10)
|
||||
accept_usb_permission(driver, timeout=2)
|
||||
return
|
||||
except (TimeoutException, StaleElementReferenceException):
|
||||
continue
|
||||
@@ -73,8 +73,22 @@ def accept_usb_permission(driver: Remote, timeout: float = 1):
|
||||
|
||||
|
||||
def confirm_write_image(driver: Remote):
|
||||
write_image_btn = wait_for_element(driver, '//*[@resource-id="writeImageButton"]')
|
||||
write_image_btn.click()
|
||||
# Like the other taps on this screen, this one can be swallowed while the UI settles.
|
||||
# Confirm it took by waiting for what must follow: the lay-flat sheet, or the progress
|
||||
# screen when the sheet auto-proceeds (a device with a working gravity sensor).
|
||||
for _ in range(3):
|
||||
write_image_btn = wait_for_element(driver, '//*[@resource-id="writeImageButton"]')
|
||||
try:
|
||||
write_image_btn.click()
|
||||
wait_for_element(
|
||||
driver,
|
||||
'//android.widget.TextView[@resource-id="layFlatSkipButton"] | '
|
||||
'//android.widget.TextView[@resource-id="write_progress_title"]',
|
||||
timeout=5,
|
||||
)
|
||||
return
|
||||
except (TimeoutException, StaleElementReferenceException):
|
||||
continue
|
||||
|
||||
|
||||
def skip_lay_flat_sheet(driver: Remote):
|
||||
|
||||
Reference in new issue
Block a user