---
title: How to Inspect Element using UIAutomatorViewer
description: How to use UIAutomatorViewer from the Android SDK to inspect app screens
  and find the selectors your automated Android tests need.
source_url:
  html: https://testingbot.com/resources/articles/android-uiautomatorviewer
  md: https://testingbot.com/resources/articles/android-uiautomatorviewer.md
---

![How to Inspect Element using UIAutomatorViewer](https://testingbot.com/assets/resources/articles/23.webp)

# UIAutomatorViewer for Automated Android Tests

How to use UIAutomatorViewer from the Android SDK to inspect app screens and find the selectors your automated Android tests need.

By [Jochen D.](https://testingbot.com/about/jochen-d)2023-07-14Updated 2026-08-31

 Share on Facebook 

 Share on Twitter 

 Post on Reddit 

 Share link 

> **Read this first if you are setting up today.** UIAutomatorViewer ships inside the legacy **Android SDK Tools** package, which Google has deprecated. Its release notes state: "This SDK Tools package is deprecated and no longer receiving updates. Instead, use the new Android SDK Command-Line tools package." The last documented revision of that package is 26.1.1, from September 2017, so on a current SDK install you may not have the tool at all.
> 
> If you are writing Appium tests, use [Appium Inspector](https://github.com/appium/appium-inspector) instead (latest release 2026.7.1). It inspects the same view hierarchy, works against iOS as well as Android, and can attach to a remote session, including one running on TestingBot. For local Android debugging rather than Appium work, Android Studio's [Layout Inspector](https://testingbot.com#alternatives) is the direct replacement. The locator advice further down this page still applies whichever inspector you use. Checked 31 August 2026.

UIAutomatorViewer is an app testing tool, developed by Google, which comes with the Android SDK to inspect application screens from an Android device (or emulator). It offers a UI to inspect various elements on an Android screen. Simply use your mouse to navigate through the various screen components and find the selectors which you can use in your automated tests.

Using UIAutomatorView in combination with [Appium](https://testingbot.com/support/app-automate/appium) is a good idea, because it allows you to find the most optimal selectors to automate any Android app.

## Table of Contents

- [Setting up UIAutomatorViewer](https://testingbot.com#install)
- [What should I use instead of UIAutomatorViewer?](https://testingbot.com#alternatives)
- [How do I locate elements using UIAutomatorViewer?](https://testingbot.com#locate)
- [Using UIAutomatorViewer with TestingBot](https://testingbot.com#testingbot)

## Setting up UIAutomatorViewer

UIAutomatorViewer was distributed with the Android SDK Tools package, as `uiautomatorviewer` (or `uiautomatorviewer.bat` on Windows) under the SDK's `tools/bin` directory. That package is deprecated and its replacement, the Android SDK Command-Line Tools, is a different set of executables, so a fresh SDK install is not guaranteed to give you this tool.

If you still have it, launching it and clicking the screenshot button gives you a live view of whatever is on the connected device, with a hierarchy panel on the right. If you do not, [Appium Inspector](https://github.com/appium/appium-inspector) is the direct replacement for Appium work and needs no Android SDK component at all.

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.

## What should I use instead of UIAutomatorViewer?

Two tools cover what UIAutomatorViewer did, and which one you want depends on whether you are debugging locally or writing Appium tests.

### Android Studio's Layout Inspector

This is the Android-native replacement, and it is a current, maintained part of Android Studio. Google describes it as letting you "inspect and debug the layout inside a running app in an emulator or physical device", where "you can inspect the attributes of each component". That is the same job UIAutomatorViewer did, with a live view rather than a captured snapshot.

To open it, run your app, go to the **Running Devices** window and click **Toggle Layout Inspector**. The **Component Tree** gives you the view hierarchy and the **Attributes** panel gives you the properties of whatever you select, which is where you will find the `content-desc`, `resource-id`, `text` and `class` values the locators below are built from.

A few practical notes. It runs embedded in the Running Devices window by default, and you can un-embed it from **Settings \> Tools \> Layout Inspector** if you prefer a separate window. Turn on **Deep Inspect** to click components in the layout instead of interacting with the app normally. Inspecting a physical device rather than an emulator requires device mirroring to be enabled. It also handles Jetpack Compose, including recomposition counts, which UIAutomatorViewer never did.

### Appium Inspector

If you are writing [Appium](https://testingbot.com/support/app-automate/appium) tests, use [Appium Inspector](https://github.com/appium/appium-inspector) instead. It shows the same hierarchy and attributes, but it does so through an Appium session, so the locators it hands you are the ones your test will actually use, and it works against iOS as well as Android. It can also attach to a remote session, including one running on TestingBot, which Layout Inspector cannot do.

Note that it is distributed as a desktop application from its GitHub releases page, currently 2026.7.1. The `appium-inspector` package on npm has not been updated since 2023 and is not the thing to install.

## 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:

- `content-desc: myButton`
- `text: my-button`
- `resource-id: com.testingbot.test:id/mybutton`
- `class: android.widget.Button`

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)

The `content-desc` attribute can be used as an `AccessibilityId`:

```java
driver.findElement(AppiumBy.accessibilityId("myButton"));
```

### Using text

The `text` attribute can be used as a `name`:

```java
driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().text(\"my-button\")"));
```

### Using resourceId

The `resourceId` attribute can be used as an `id`:

```java
driver.findElement(AppiumBy.id("com.testingbot.test:id/mybutton"));
```

### Using class

The `class` attribute can be used as a `className`:

```java
driver.findElement(AppiumBy.className("android.widget.Button"));
```

## Using UIAutomatorViewer with TestingBot

Using UIAutomatorViewer allows you to find the locators you need for your tests.   
 You can make sure your test automation stays functioning by choosing the right locators. The right locators are the most simple locators, which are not likely to change during the lifetime of the app.   
 For example, instead of choosing a `resourceId`, it might make more sense to assign the element a specific `AccessibilityId` which will not change.

TestingBot offers [manual mobile app testing](https://testingbot.com/features/manual-mobile-testing), which offers a Mobile Inspector. The Mobile Inspector allows you to inspect the view hierarchy of your app and find locators, similar to how UIAutomatorViewer works.

Topics [Mobile App Testing](https://testingbot.com/resources/articles/topic/mobile-testing) 

## Sidebar

### TestingBot Cloud Testing

Run automated, manual and visual tests on remote browsers and devices. Sign up for a free trial.

[Free Trial](https://testingbot.com/users/sign_up)

### Latest articles

[![Mobile App Test Automation at Scale](https://testingbot.com/assets/resources/articles/mobile-app-test-automation-12d7e7edc7c551f05282cd03ccd0de42da8e4c740d754286777972249471a36e.webp)](https://testingbot.com/resources/articles/mobile-app-test-automation)

#### [Mobile App Test Automation at Scale](https://testingbot.com/resources/articles/mobile-app-test-automation)

How to choose between Appium, Espresso, XCUITest and Maes...

[Read article →](https://testingbot.com/resources/articles/mobile-app-test-automation)

[![Run Maestro tests in the cloud](https://testingbot.com/assets/resources/articles/45-54aab6a840d2561eab846e8bfde7ec26113ba601a9fcc15ddea883c2a80ec29c.webp)](https://testingbot.com/resources/articles/maestro-cloud-testing)

#### [Run Maestro tests in the cloud](https://testingbot.com/resources/articles/maestro-cloud-testing)

What Maestro is, how its declarative flows differ from Ap...

[Read article →](https://testingbot.com/resources/articles/maestro-cloud-testing)

[![Appium 2 and Appium 3 Migration Guide](https://testingbot.com/assets/resources/articles/27-121da26036885301ba438e1cdfc81e7ae8045cbc53c0dafaff5b4436000590b1.webp)](https://testingbot.com/resources/articles/appium-2-migration)

#### [Appium 2 and Appium 3 Migration Guide](https://testingbot.com/resources/articles/appium-2-migration)

What changed between Appium 1, 2 and 3: drivers, capabili...

[Read article →](https://testingbot.com/resources/articles/appium-2-migration)

## Other Articles

[![Automate native iOS Apps with XCUITest](https://testingbot.com/assets/resources/articles/25-bb2ccb531384c461ef792214839e9e8f99a4b08b1293730ceeab67e4a8352563.webp)](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest "Automate native iOS Apps with XCUITest")

### [Automate native iOS Apps with XCUITest](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest)

How to automate Apple's own iOS apps with XCUITest, with code for driving Settings, Messages and Photos, and how to extend it to other apps.

[Read article →](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest)

[![Using Touch Actions with Appium](https://testingbot.com/assets/resources/articles/24-490f70ad8a80e4534523707125b88e44e70fe19b126be4f44e689bbd5f6a0cbf.webp)](https://testingbot.com/resources/articles/touch-actions-appium "Using Touch Actions with Appium")

### [Using Touch Actions with Appium](https://testingbot.com/resources/articles/touch-actions-appium)

How to simulate taps, swipes and pinches on real devices with Appium Touch Actions, with examples, best practices and common pitfalls.

[Read article →](https://testingbot.com/resources/articles/touch-actions-appium)

[![Dark Mode Testing with Appium](https://testingbot.com/assets/resources/articles/22-ed15fa0f3fde7566416fff5078b44689dc274439b2fb829f8c68603e909a65d6.webp)](https://testingbot.com/resources/articles/dark-mode-testing "Dark Mode Testing with Appium")

### [Dark Mode Testing with Appium](https://testingbot.com/resources/articles/dark-mode-testing)

How to switch a native app between light and dark mode from an Appium test on iOS and Android, and the layout bugs dark mode tends to expose.

[Read article →](https://testingbot.com/resources/articles/dark-mode-testing)

[![Android Espresso Tutorial](https://testingbot.com/assets/resources/articles/19-fe4971eb8049097c25f2cc2fce95b71b94f3bb342e094c219b2404c09374f015.webp)](https://testingbot.com/resources/articles/android-espresso-testing "Android Espresso Tutorial")

### [Android Espresso Tutorial](https://testingbot.com/resources/articles/android-espresso-testing)

Why Espresso suits Android UI testing, how to add it to a project and write a first test, and how it compares with the alternatives.

[Read article →](https://testingbot.com/resources/articles/android-espresso-testing)

## Ready to start testing?
[Start a free trial](https://testingbot.com/users/sign_up)
