Search code examples
appiumappium-android

Appium Android XPath Wildcard Class


I'm trying to write an XPath query for Appium tests for an Android app where I find an element by it's ID regardless of it's class.

This is the XPath I'm trying but it doesn't seem to work: //*[@id='toFind']

Is it possible to do this?


Solution

  • My problem was two fold.

    Firstly you need to use resource-id not id also Resource ID can be a longer value than the one you are looking for so you need to contains

    //*[contains(@resource-id, 'toFind')]