INNER CODE UNIT · Python

select_first_usb_device_if_multiple

etchdroid/etchdroid · appium-tests/etchdroid/actions.py:46

def select_first_usb_device_if_multiple(driver: Remote, timeout: int = 1):
    try:
        usb_device = wait_for_element(driver, '//*[@content-desc="USB drive"]', timeout=timeout)
        usb_device.click()
    except TimeoutException:
        pass


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, 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"]', timeout=2)
        except TimeoutException:
            return

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…