How can I fetch all elements from a screen automatically

Hi, I am trying to implement a solution where it is possible to automate the elements attributes automatically, but there is no success yet.

For example, there is a login screen of an app. If I need to fetch out all elements of the login screen (i.e. username, password, forgot password, login etc) along with all attribites/properties like class, text, clickable, checkable etc, is there a way to implement that?

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.

Thanks Willosser, it helps!
I have one further doubt - I am able to fetch the elements of a class and for an element I am able to find attributes like text, checkable etc; however I am not able to fetch some of the attributes like Resource-id and index etc.

How can I fetch the resource-id of an element?
I tried: x.get_attribute(“id”), x.get_attribute(“resource-id”) -These dont work. I tried as well, it gives some id, but not the resource id.

You can always get the page source and parse it out yourself. On java, it’s…


That’ll return an xml string with everything on the page. You can then use your favorite xml parsing library to pick it apart and get any info you need.

1 Like

Thanks Brian.
In python I was able to do it with driver.find_elements_by_xpath(".//*") and then getting attributes using x.get_attribute(“resourceId”), x.get_attribute(“className”)

Is there a way in appium where I can fetch all elements of screen from the screenshot+xml saved using UIautomator viewer, instead of a running driver??

If you are using appium, why wouldn’t you use the driver? Perhaps I don’t understand your condition.

Basically, I am trying to create data repository automatically. Where am capturing the screenshot and from the screenshot i want to fetch out all elements, on which I can work later on, instead of going to UI automator for every element attribute

I also use get_page_source to access elements. The results, once parsed, should have all the information that you need.

Yes, get the page source like I mentioned above, and then parse it all out if you need to. willosser mentioned that the python way to do it is…


Once you have that string, you can use a python xml parse library to parse out whatever you want.