Suppose I have an app (in debug/release build , made by me or not), which has an ID for a specific view.
Is it possible to call adb command to click on this view?
I know it's possible to make it click on a specific coordinate, but is it possible to use the ID instead ?
I ask this because I do know that the "Layout Inspector" tool (available via Android Studio) and the "View hierarchy" tool (available via "Android Device Monitor", previously used via DDMS) can show the ids of the views (and even their coordinates and bounding box), so maybe it can be a better way to simulate touches when performing some automatic tests.
I can use a rooted method if needed.
EDIT: I've set a bounty in case there is an easier/better way than what I've written in my own answer, which was to parse the result of "adb shell dumpsys activity top" .
I would like to know if it's possible to get the views coordinates (and sizes of course) that are shown on the screen, including as much information about them (to identify each). This should be possible via the device too. Maybe something that has the same output data of what's available from the "monitor" tool :
Notice how it can get the basic information of the views, including the text, the id, and the bounds of each.
As I've read, this might be possible via AccessibilityService, but sadly I can't understand how it all works, what are its capabilities, how to trigger it, what are its requirements, etc...
Using what @pskink explained in the comments above, here's how I achieved this:
First, I ran this command:
Then, I used this code to parse it: