From 1bf2e9975eb7de5d2d98c13eaee3c2d73bd12f2c Mon Sep 17 00:00:00 2001 From: Davide Depau Date: Wed, 12 Aug 2026 16:31:40 +0200 Subject: [PATCH] test(appium): scale element waits in CI --- appium-tests/etchdroid/config.py | 6 ++++++ appium-tests/etchdroid/utils.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/appium-tests/etchdroid/config.py b/appium-tests/etchdroid/config.py index 64493a6..f3b69d1 100644 --- a/appium-tests/etchdroid/config.py +++ b/appium-tests/etchdroid/config.py @@ -13,6 +13,12 @@ class Config: QEMU_USB_SLOW_BUS = os.environ.get("QEMU_USB_SLOW_BUS", "uhci.0") QEMU_USB_DEV_ID = os.environ.get("QEMU_USB_DEV_ID", "usbstick") + # Every Appium element wait is multiplied by this. CI has no host GPU, so the guest + # software-renders (see appium-tests/scripts/vm-config.sh) and first-frame latency + # regularly exceeds the short timeouts the flow helpers use. Locally the guest is + # GPU-accelerated, so 1x keeps failures quick to report while iterating. + WAIT_TIMEOUT_SCALE = float(os.environ.get("WAIT_TIMEOUT_SCALE", "5" if os.environ.get("CI") else "1")) + DISABLE_SETUP = os.environ.get("DISABLE_SETUP", "0") == "1" DISABLE_SHUTDOWN = os.environ.get("DISABLE_SHUTDOWN", "0") == "1" diff --git a/appium-tests/etchdroid/utils.py b/appium-tests/etchdroid/utils.py index b2f77f2..f111274 100644 --- a/appium-tests/etchdroid/utils.py +++ b/appium-tests/etchdroid/utils.py @@ -5,6 +5,7 @@ import tempfile from appium.webdriver.common.appiumby import AppiumBy from collections import namedtuple from contextlib import contextmanager +from etchdroid.config import Config from pathlib import Path from selenium.common import ElementNotVisibleException, NoSuchElementException from selenium.webdriver.support.wait import WebDriverWait @@ -39,6 +40,9 @@ def wait_for_element( xpath: str, timeout: float = 3, ) -> appium.webdriver.WebElement: + # Capped so that scaling up doesn't turn a genuine failure in one of the 120s waits into a + # ten-minute stall. + timeout = min(timeout * Config.WAIT_TIMEOUT_SCALE, 120) wait = get_wait(driver, timeout) return wait.until( lambda x: x.find_element(