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.
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
- Replace immediate finds with an explicit wait for presence or visibility.
- Set the wait timeout to tolerate a slow CI device.
- Prefer accessibility id locators over text or XPath.
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.