I've got an Android UI element that looks like this in source:
"@enabled" : "true",
"@focusable" : "false",
"@index" : "0",
"@text" : "Your Rewards",
"@checkable" : "false",
"@package" : "com.kabam.sdk.sample",
"@scrollable" : "false",
"@class" : "android.widget.TextView",
"@password" : "false",
"@long-clickable" : "false",
"@bounds" : "[97,73][360,122]",
"@selected" : "false",
"@content-desc" : "",
"@clickable" : "false",
"@focused" : "false",
"@checked" : "false"
Appium Inspector finds it thusly:
wd.findElement(By.xpath("//list[1]/linear[1]/relative[1]/text[1]"))
This also works:
wd.findElement(By.xpath("//list[1]/linear[1]/relative[1]/textView[1]"))
Note that getText() works correctly for these two.
As much as I like using paths, those won't suffice. I have tried the following without success:
wd.findElement(By.xpath("//list[1]/linear[1]/relative[1]/text[@text='Your Rewards']"))
wd.findElement(By.xpath("//list[1]/linear[1]/relative[1]/textView[@text='Your Rewards']"))
wd.findElement(By.xpath("//list[1]/linear[1]/relative[1]/text[text()='Your Rewards']"))
wd.findElement(By.xpath("//list[1]/linear[1]/relative[1]/textView[text()='Your Rewards']"))
wd.findElement(By.xpath("//list[1]/linear[1]/relative[1]/text[@value='Your Rewards']"))
wd.findElement(By.xpath("//list[1]/linear[1]/relative[1]/textView[@value='Your Rewards']"))
that is generally useful for building Selenium locators, but it doesn't help me here.