12

I was trying to use LayoutInspector for apps from Google Play. I have a rooted device so when I do "Show all processes", all the running apps developed by me are displayed but not the official ones.

Sunil
  • 541
  • 2
  • 8
  • 17
  • 7
    Layout Inspector is only for debuggable apps. Use `uiautomatorviewer` for arbitrary apps. – CommonsWare Jun 03 '18 at 17:16
  • I need LayoutInspector/HierarchyViewer because I am trying to automate the listview from the current GUI. As far as I know, UIAutomator only gives me the elements that are currently being displayed in the screen but the hierarchy viewer gives me all the elements of the list so that I can scroll down to that specific element that I want. I'm trying to automate the GUI testing process. Any suggestions? – Sunil Jun 03 '18 at 17:25
  • None of these tools work in the way that you describe. All of these tools only show the views that are in the view hierarchy. So, for example, with a `ListView` or `RecyclerView` where you can scroll through 10000 items, there will not be 10000 child views, because `ListView` and `RecyclerView` recycle their rows. If you are automating GUI testing, you should be in contact with the developers of the app, and perhaps they can provide advice as to how best you should write your tests. – CommonsWare Jun 03 '18 at 17:51
  • Since Java 11 is getting popular for Android dev. If you get an Error when opening uiautomatorviewer, switch your Java to Java 1.8. – aldok Jun 07 '22 at 06:55

2 Answers2

17

You can use UiAutomator2 Viewer ( a tool from android SDK)

{ your sdk path} \tools\bin\uiautomatorviewer.bat

This tool shows the complete hierarchy and attributes of all elements visible on the device display (no matter which app is running).

enter image description here

Also in the "Katalon studio" we have a tool named Mobile Spy which do the same + full Xpath

enter image description here

Note that you should have adb server running with connecting the device. so the "adb devices" must return device id.

10

you ca go to the /Users/.../Library/Android/sdk/tools/monitor

enter image description here

and select dump view

enter image description here

Rasoul Miri
  • 11,234
  • 1
  • 68
  • 78