Setting up UIAutomatorViewer
Setting up UIAutomatorViewer is easy as it comes with the Android SDK. It is located under the
tools directory as a file called
Once the program is started, you can click the screenshot button to indicate that you want to see a live view of the app currently running on the device. Once the live view appears, a sidepanel on the right will show a hierarchy view of the components that make up the current screen.
How do I locate elements using UIAutomatorViewer?
The right side panel of UIAutomatorViewer will contain a hierarchical view of the current application's layout structure. As you click some of the items in the panel, you will see the properties for each of these items.
Properties such as content-desc, class, resource-id and text can be helpful to construct locators which you can use in your automated Appium tests.
For example, you have a layout with a button that you want to click. You use UIAutomatorViewer to inspect the button and see that it has these properties:
We can now construct several locators that will each target the same element, using different selector strategies. Each of these locators can be used in an Appium test.
Using content-desc (AccessibilityId)
content-desc attribute can be used as an
text attribute can be used as a
resourceId attribute can be used as an
class attribute can be used as a