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 ?
Syntax: driver. findElement(By.id(“resource-id Value”));
You can use the find_elements/findElements call provided by the appium driver to find all elements of a particular type (resource-id, class, etc), Once you have the elements, you can query each one to obtain the desired attributes or properties.
It can be used to find any element in the XML structure available to Appium. This means that even if an element has no ID or Name, it can still be located with XPath.
According to this post, the way to get "content-desc" is to use myElement.getAttribute("name").
for resource-id use: webElement.getAttribute("resourceId")
To get content-desc use:
myElement.getAttribute("contentDescription")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With