Jason Hartley
Jason Hartley

Reputation: 2509

In Appium find an Android view by a unique id that isn't the view's id field

I've created an Android app where I have programmatically created a number of controls such as radio buttons, up and down buttons, etc. These views have ids in their id field that are not unique and I cannot make unique. I want to be able to reliably locate these elements for the sake of automated testing using Appium.

I had hoped I could put a unique id in the tag field of these views (as this is an appropriate use of a view's tag field) to solve this problem, but it seems that Appium cannot (or will not) use the tag field for identification purposes.

A solution that is working is to put the unique id in the view's content-desc field. The Appium method findElementById() will successfully find the element that way. But this is a misuse of content-desc as it is intended to be used to describe the view in a way that is useful for accessibility purposes.

Since the controls are created programmatically and their order is not guaranteed, so I don't want to find the elements by index.

Is there a way to include a unique id in an Android view that Appium can find that isn't a view's content-desc field?

Upvotes: 2

Views: 1666

Answers (1)

Jonathan Lipps
Jonathan Lipps

Reputation: 468

As of 12/19/2016, Appium doesn't support finding views by Tag. We're going to be looking into that soon, however. Keep an eye on https://github.com/appium/appium/issues/6025.

You're right that the current workaround is to set the content-desc.

Upvotes: 1

Related Questions