An Android app to be automated tested has no Accessibility IDs (aka element's content-desc attribute) whatsoever. I'm hearing that it would be good for the developers to put this in, but I've also heard others say that going by the Element ID, or the "id" field is enough for the purposes of finding elements in your test scripts.

What are people's thoughts on this? If Accessibility IDs are the way to go, are there any guidelines we can give to our developers? All I know of is that all of these should have unique names.

1 Answer 1


Usually it would be recommended to use resource IDs as the primary identifier for element location in Android automation tests. If resource IDs are not available or not unique, then other identifying attributes like element IDs, class names, text, and content descriptions can be used. Accessibility IDs can be a helpful addition, but they should be used as a fallback option and not relied on exclusively.

When it comes to adding Accessibility IDs to your app's UI elements, here are some guidelines that I would suggest:

  1. Ensure that each Accessibility ID is unique and specific to the UI element it represents.

  2. Use descriptive names for Accessibility IDs that clearly indicate the purpose or function of the element.

  3. Avoid using special characters or spaces in the Accessibility ID, as this can cause issues with automated tests.

  4. Use Accessibility IDs in combination with other identifying attributes to ensure the most stable and efficient element location.

For example, if you have a button that opens a menu, and the menu items do not have unique resource IDs, you can add unique Accessibility IDs to the menu items to make them easily locatable in automated tests. The Accessibility IDs can be something like "menu_item_1", "menu_item_2", etc.

While Accessibility IDs can be helpful in some cases, it's important to prioritize using resource IDs and other identifying attributes first for the most efficient and reliable element location in automated tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.