Chhagan Mathuriya
Chhagan Mathuriya

Reputation: 61

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

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 ?

Upvotes: 6

Views: 9859

Answers (3)

zsts
zsts

Reputation: 21

To get content-desc use:

myElement.getAttribute("contentDescription")

Upvotes: 1

Ryan
Ryan

Reputation: 71

for resource-id use: webElement.getAttribute("resourceId")

Upvotes: 7

etxalpo
etxalpo

Reputation: 1176

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

Upvotes: 9

Related Questions