2

I'm trying to get identifiers for Uielements using appium inspector for an app generated with appcelerator

When I used Appium inspector to get UIElements IDs the result for both elements is similar to

name: 
type: UIATextField
value:
label: 
hint: 
enabled: true
visible: true
valid: true
location: {73, 37.5}
size: {218, 15}
xpath: //UIAApplication[1]/UIAWindow[1]/UIATextField[1]

In both cases I can't retrieve the name property

Mi index.xml is similar to:

<Alloy>    
<Window class="container">
<TextField id="username"/>
<TextField id="password"/>
</Window>
</Alloy>

Which property should I use to identify UiElements? Do I Have to use xpath instead to identify this elements ?

Best Regards

pepe
  • 21
  • 1

1 Answers1

1

I have not found a way to specifically set the id field on a native control. I hope that someone out there knows a module or something that can do this better, but until then, here's how I do it.

There's a field called accessibilityLabel on Titanium's View classes that I use to identify my textfields/buttons. In iOS, Titanium will set the name and label properties of the native controls to the accessibilityLabel field. Then, you can simply use XPath to find them via a query like //*[@name='usernameField'].

Android will work a little differently and will set the content-desc field and append a . to the end of it, but the query is still as simple as //*[@content-desc='usernameField.']

Two caveats: iOS will start to hide nested elements from XPath if you set the accessibilityLabel field. So if you set an accessibilityLabel on the top level View class, you won't be able to query anything within that. The other issue is I don't have any experience with accessibility features in iOS and Android, and this solution may certainly impact any plans you may have to use them.

Hope this helps

Bryan Johnson
  • 405
  • 5
  • 9