What Is UIAutomatorViewer?
UIAutomatorViewer is part of the Android SDK manager. It is a UI inspector GUI (graphical user interface) tool that allows for the easy and quick inspection of UI elements contained in an android application.
Why Use UIAutomatorViewer?
To write automated tests for Android applications, you need to be able to identify locators such as resource IDs, classes and strings. To use when automating the application under test.
How Does It Work?
UIAutomatorViewer can take an XML screenshot of the current screen open on an android device or emulator. Clicking on any element on the screen, you can see details of the class used to represent the element along with all the properties.
Let's See It in Action
Using UIAutomaterViewer I have taken a screenshot of my Android testing application and clicked the Username element in the screenshot.
By clicking the element, I can now see the hierarchy information in the top right panel. It details how the UI components are arranged and contained. In the bottom right panel, I can see the properties of the element such as index, text, resource-id, class and package.
There you have it. A quick and easy way, to get to grips with an android application and locate the information required to write automated tests.