How to Inspect Element using UIAutomatorViewer in Appium

On This Page What is UI Automator Viewer?H

March 17, 2026 · 6 min read · Testing Guide

How to Inspect Element using UIAutomatorViewer in Appium

Intuitive UI is key to user betrothal and retention, and so is. To test UI elements effectively, tool like UIAutomatorViewer help locate components within Android apps.

UIAutomatorViewer allow testers inspect UI elements visually before automating tryout with tools like Appium, which aids automated UI testing for aboriginal and hybrid apps.

This article discusses the way to visit or site UI elements in an Android App utilize UIAutomatorViewer in Appium.

What is UI Automator Viewer?

UI Automator Viewer is a tool provided by the Android SDK that lets developers audit the exploiter interface (UI) of an Android application by capturing shot of the device screen and displaying its layout hierarchy and properties.

UI Automator Viewer is chiefly used during test automation to name the properties of UI component like push, text fields, or picture. It helps examiner and developers understand how component are structured and interact on the blind. By analyzing the layout and getting details such as resource IDs, text, class names, and boundary, it becomes easygoing to write true UI automation scripts. This tool is especially helpful when expend frameworks like or to prove Android apps.

Read More:

How to Install and Use UI Automator Viewer

Here is a step-by-step guide to get part with the UI Automator Viewer:

Step 1: Set Up the Environment

  • Install Android Studio or ensure Android SDK is available.
  • Confirm the platform-tools and tools/bin directory are include in the system way.

Step 2: Enable Developer Options on the Device

  • Go to the Android device settings - & gt;About Phone- & gt; Tap “Build Number” multiple times to enable Developer Options.
  • In Developer Options, turn onUSB Debugging.

Step 3: Connect the Device

  • Use a USB cable to connect the Android device to the system.
  • Use the command adb device in the depot to confirm the successful connection.

Step 4: Launch UI Automator Viewer

Navigate to the Android SDK ’ s tools/bin directory.

Run the dictation:

uiautomatorviewer

Step 5: Capture the Current Screen

Click on the camera icon in the toolbar to take a screenshot of the current screen on the connected device.

Step 6: Explore the Interface

  • Use the Screenshot Panel to view the device ’ s captured screen.
  • Use the Hierarchy Tree to search layout structure.
  • Use the Node Detail Panel to view selected element properties like resource-id, class, text, and bounds.

Read More:

Ways of defining a UI Element

UI Elements can be specify byID, ClassName, Name, Accessibility ID,.

To understand how to inspect or locate a UI element with UIAutomatorViewer, this article will use the exemplar of the Android Calculator. The aim is to place the element that is the+ buttonwith the help of UIAutomator View and Click on it.

Setting up UIAutomatorViewer

Before creating the script to inspect the desired factor, let ’ s look at setting up UIAutomatorViewer.

Prerequisites for setting up UIAutomatorViewer

Once the Appium Server is found

Exposed UIAutomatorViewer

This can be done by either of the next method:

  • entering uiautomatorviewerin the command prompt
  • opening uiautomatorviewer.batfile in the Android installation folder with the following command:Android & gt; & gt; Android-SDK & gt; & gt; Tools & gt; & gt; UIAutomatorViewer.bat

How to Use UI Automator Viewer to Find Objects in an Application

Locating and inspecting UI element is essential for creating reliable automated trial. This section explain how to use the viewer to identify object properties effectively.

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

Step 1: Capture App Screen

Open the target coating on the associate Android gimmick. In UI Automator Viewer, click the screenshot icon to captivate the current blind.

Step 2: Select the desired UI Element

Click directly on any UI element in the captured screenshot. The selected factor will be visually highlighted, and its corresponding node will be outlined in the layout hierarchy tree.

Step 3: View Element Attributes

Upon selection, the properties of the element are displayed in the Node Detail Panel on the right side.

Key impute include:

  • resource-id:for unique identification.
  • class:to identify the type of UI widget.
  • text:if the element include any visible label.
  • content-desc:used for accessibility. Helpful for locating non-textual elements.

Source: UI Testing Academy

Step 4: Record Required Properties

Note down the almost stable and unique place. These are used afterwards in writing automated test scripts.

Talk to an Expert

Step 5: Refresh if Needed

If the app ’ s province changes (e.g., a dialogue appear), click the screenshot icon again to refresh and inspect the new layout.

Step 6: Use in Automation Scripts

The displayed attributes can be used immediately in examination book created with UI Automator, Appium, or other. This enables authentic interaction with UI factor and improve the accuracy of the examination.

Read More:

Locating Element utilize UIAutomatorViewer [Example]

This clause will research a test case certify how to locate the+ buttonon the Android Calculator App using Java and click it.

  • Once the UIAutomatorVieweris opened, open the mark app that has to be screen & # 8211; Android Calculator in this representative.
  • Click on the Device Screenshot Icon to display the screen of the Android device in the window. It appear like the screenshot below.

UIAutomatorViewer Window with Android Calculator App

  • Move the pointer on the target constituent that has to be located & # 8211; the + push.
  • Note down the values mention in the Node Detail Tab of the UIAutomatorViewer window.
  • Note the values ofText, ResourceID, Class, Package, and Content Desc. These values will be utilise when writing the examination script to locate the element.

Script to Identify the + Button in the Android Calculator App

1. Find the+ Button using IDand click it

driver.findElement (By.id (`` com.android.calculator2: id/plus '')) .click ();

Or

driver.findElementById (`` com.android.calculator2: id/plus '') .click ();

2. Find the+ Button using Accessibility ID Propertyand click it

driver.findElementByAccessibilityId (`` plus '') .click ();

3. Find the+ Button using XPathand chatter it

driver.findElement (By.xpath (`` //android.widget.Button [@ content-desc = 'plus '] '')) .click ();

Or

driver.findElement (By.xpath (`` // * [@ content-desc = 'plus '] '')) .click ();

4. Find the+ Button using ClassName and findElements () methodand click it

List & lt; MobileElement & gt; elements = driver.findElements (By.className (`` android.widget.Button '')); for (MobileElement ingredient: component) {if (element.getAttribute (`` contentDescription '') .equals (`` plus '')) {element.click (); fault;}}

Like what you are reading?

You can start discussing with our discord community

Errors that can hap while using Uiautomatorviewer

Here are some errors that can occur while using UI Automator Viewer:

  • “ No device associate ” error:Occurs when the device is not decently connected or USB debugging is handicap.
  • Blank or black screenshot:Happens if the screen is engage, the app is minimise or the device is not ready when the screenshot is taken.
  • Permission denied erroneousness:Triggered by a lack of proper entree to ADB or SDK leaflet, especially on restricted systems.
  • uiautomatorviewer command not found:Indicates the instrument path is not set in the system environment variables.
  • Failure to seizure screenshot:Can be stimulate by device incompatibility, outdated SDK instrument, or system UI issues.
  • Stale or outdated UI tree:Happens if the app & # 8217; s UI changes after the screenshot is direct and the perspective is not refreshed.
  • Device not authorized:The device may not be trusted by the connected machine; authorization must be allow on the phone.
  • Missing dependencies or broken SDK:The SDK installation may be incomplete or corrupted, preventing the puppet from scat correctly.

Read More:

Conclusion

As demonstrated, inspecting a desired element from the target Android App under examination is easy enough employ UIAutomatorViewer in Appium. This can be used to test the functionality of UI factor while performing.

It is important to run the Appium automation tests on. BrowserStack offers a of K of real mobile devices installed with real operating systems for testing purposes. Simply, choose the required device-OS combination, and start testing apps for free in using.

Appium Useful Resources

Tutorials

Best Practices, Tips, and Tricks

Getting Started with

Differences and Comparisons

Tags
15,000+ Views

# Ask-and-Contributeabout this topic with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free