how to get android element's 'resource id' and 'content description' attributes value in appium java?

Chhagan Mathuriya picture Chhagan Mathuriya · Nov 17, 2014 · Viewed 8.2k times · Source

I wanted to get resource id and content description of android elements at runtime.

i tried this:

myElement.getAttribute("resource-id")
myElement.getAttribute("content-desc")

but getting error as "this element does not have the resource-id attribute".

Is there any way to get this ?

Answer

etxalpo picture etxalpo · Nov 19, 2014

According to this post, the way to get "content-desc" is to use myElement.getAttribute("name").