How to get the value of the attribute "resource id" and "content description" of the android element in appium java?

I wanted to get the resource identifier and description of the contents of the android elements at runtime.

I tried this:

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

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

Is there any way to get this?

+4
source share
3 answers

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

+9
source

to use the resource: webElement.getAttribute("resourceId")

+4
source

-desc:

myElement.getAttribute("contentDescription")

+1

All Articles