---Advertisement---

UIAutomatorViewer Tutorial: Inspector Tool for Android App Automation Great 2025

By Manisha

Updated On:

---Advertisement---
UIAutomatorViewer Tutorial

UIAutomatorViewer Tutorial: UIAutomatorViewer is a GUI-based inspection tool provided by the Android SDK that helps testers analyze the UI components of an Android application. It is used to capture the structure, properties, and hierarchy of UI elements in an app under test.

This tool is crucial for automation testers using Appium as it allows them to identify elements using properties like resource-id, text, class, and content-desc.


UIAutomatorViewer Tutorial: To write automation scripts in Appium, you need to uniquely identify UI elements within your Android app. UIAutomatorViewer makes this easy by:

  • Displaying the UI element tree
  • Highlighting properties of individual UI nodes
  • Assisting in generating XPath and locators
  • Visualizing screen layouts for better test strategy

UIAutomatorViewer Tutorial: UIAutomatorViewer is part of the Android SDK. Follow these steps to install:

Step-by-Step Installation Guide:

  1. Download and install the Android SDK/Android Studio from the

Once installed, navigate to:

php

<SDK Directory>\tools\bin

  1. Locate and double-click the file named uiautomatorviewer.bat (for Windows) to launch the UIAutomatorViewer tool.

Step 1: Enable Developer Options

  • Go to your Android device settings → About Phone → Tap “Build Number” 7 times to enable Developer Options.
  • Then go to Developer Options and enable USB Debugging.

Step 2: Connect Android Device to PC

  • Use a USB cable to connect your Android phone to the system.

Step 3: Open Your Test Application

  • Launch the application you want to test (e.g., Guru99 app) on your mobile device.

Step 4: Take a Screenshot with UIAutomatorViewer

  • Open UIAutomatorViewer.
  • Click the “Device Screenshot” button.
  • A snapshot of your current screen will appear, along with the UI hierarchy.

UIAutomatorViewer Tutorial: In the UIAutomatorViewer window, you’ll find two major sections:

  • Upper Panel (Node Tree): Displays the hierarchy of UI components.
  • Lower Panel (Properties): Shows the selected element’s properties like:
    • text
    • resource-id
    • class
    • content-desc

Example: If you click on a “Quiz” button, the properties of that button will be shown, which you can use in Appium scripts.


UIAutomatorViewer Tutorial: Here’s how different properties can be mapped in Appium:

UIAutomatorViewer PropertyAppium Locator
textname or text
resource-idid
classclassName
content-descAccessibilityId

You can also create XPath expressions using these attributes for more complex selectors.

Example:

java

driver.findElementByXPath(“//android.widget.Button[@text=’Quiz’]”).click();


Error:

pgsql

No Android devices were detected by adb

Solution:

  • Ensure your Android device is connected properly.
  • Confirm USB Debugging is enabled.

Run the following in Command Prompt to verify:

nginx
adb devices

If your device is listed, UIAutomatorViewer should recognize it.

Appium Tutorial

official Android developer site.


Leave a Comment

Index