Skip to content
Latchkey

Appium "An element could not be located on the page" in CI

The UiAutomator2 or XCUITest driver searched the current view hierarchy and found nothing matching your locator. On a slower CI device this is usually a timing race: the element was not rendered yet when the search ran.

What this error means

A step fails with "An element could not be located on the page using the given search parameters" (a NoSuchElementError). The same test passes locally where the device renders faster.

Appium
NoSuchElementError: An element could not be located on the page using the given
search parameters. Selector: //android.widget.Button[@text="Sign in"]

Common causes

The element was not rendered yet

A CI emulator paints screens more slowly, so an immediate find runs before the target view exists in the hierarchy.

A brittle or stale locator

A locator tied to text or index changes across builds or locales, so it matches nothing on the CI build.

How to fix it

Wait explicitly for the element

  1. Replace immediate finds with an explicit wait for presence or visibility.
  2. Set the wait timeout to tolerate a slow CI device.
  3. Prefer accessibility id locators over text or XPath.
test.py
WebDriverWait(driver, 30).until(
    EC.presence_of_element_located((AppiumBy.ACCESSIBILITY_ID, "sign_in"))
)

Stabilize the locator

Add a stable accessibility id / testID in the app and target that, so the locator does not depend on visible text or position.

How to prevent it

  • Use explicit waits instead of immediate finds on CI.
  • Locate by accessibility id, not brittle XPath or text.
  • Give CI waits longer timeouts than local runs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →