Appium Inspector for Element Discovery

8 min read

Before you can write a locator, you need to know what attributes the element actually has. On the web, you open Chrome DevTools and inspect the DOM. On mobile, you use Appium Inspector — a standalone GUI application that connects to a running Appium session, captures a screenshot, and lets you tap on elements to reveal their accessibility attributes. It is the single most important tool in your daily Appium workflow.

Installing Appium Inspector

Download the latest release from github.com/appium/appium-inspector/releases. Installers are available for macOS (.dmg), Windows (.exe), and Linux (.AppImage).

Appium Inspector connects to an existing Appium server — it does not start one. Make sure the server is running:

appium

Connecting to a session

Open Appium Inspector. You will see a Desired Capabilities form. Enter the capabilities for your target device. For an Android emulator:

{
  "platformName": "Android",
  "appium:automationName": "UiAutomator2",
  "appium:deviceName": "emulator-5554",
  "appium:platformVersion": "14",
  "appium:app": "/absolute/path/to/app.apk"
}

Click Start Session. Appium Inspector will:

  1. Connect to the Appium server
  2. Create a new automation session
  3. Install the app on the device (if not installed)
  4. Launch the app
  5. Capture a screenshot
  6. Fetch the accessibility tree (XML source)

This takes 10–30 seconds for an emulator, slightly longer for a real device.

The Inspector interface

The interface has three main panels:

Left panel — App screenshot. A static image of the current screen. Tap an element on the screenshot to select it and highlight the matching node in the source tree.

Middle panel — Source tree. The full XML accessibility tree of the current screen. Expand nodes to navigate the hierarchy. Click a node to see its attributes on the right.

Right panel — Element attributes. When an element is selected, all its attributes are displayed here. This is where you find the resource-id, content-desc, text, and class values for your locators.

Reading element attributes on Android

A typical button in the Android source tree looks like this:

<android.widget.Button
  index="2"
  package="com.example.myapp"
  class="android.widget.Button"
  text="Sign In"
  resource-id="com.example.myapp:id/sign_in_button"
  content-desc="Sign in to your account"
  checkable="false"
  checked="false"
  clickable="true"
  enabled="true"
  focusable="true"
  focused="false"
  scrollable="false"
  long-clickable="false"
  password="false"
  selected="false"
  bounds="[88,1234][672,1310]" />

The locator you should prefer:

  1. resource-id → use as AppiumBy.id("com.example.myapp:id/sign_in_button")
  2. content-desc → use as AppiumBy.accessibilityId("Sign in to your account")
  3. text → use as AppiumBy.androidUIAutomator("new UiSelector().text(\"Sign In\")")
  4. XPath → last resort

Reading element attributes on iOS

On iOS, the source tree contains XCUITest element types:

<XCUIElementTypeButton
  type="XCUIElementTypeButton"
  value="Sign In"
  label="Sign In"
  name="sign_in_button"
  enabled="true"
  visible="true"
  x="88" y="650" width="200" height="44" />

The name attribute is the accessibilityIdentifier set by the developer. Use it as:

AppiumBy.accessibilityId("sign_in_button")

The label maps to accessibilityLabel. If name is empty, use label.

Generating locators automatically

When you click an element in the Inspector, the right panel shows suggested locators. Use the Copy button next to the locator you want. Inspector generates:

  • Accessibility ID (if available)
  • ID / resource-id
  • XPath (always available, but use only as a last resort)

Refreshing the screenshot

After navigating to a new screen in the app, click the Refresh button (circular arrow icon) to capture a new screenshot and fetch the updated source tree. The Inspector does not auto-refresh — it only captures a snapshot when you ask.

Search for element

The Search tab lets you test a locator against the current screen without writing any test code. Select the strategy (Accessibility ID, XPath, ID, etc.), enter the selector value, and click Find. Inspector highlights matching elements and tells you how many were found.

This is the fastest way to validate that a locator works before putting it in a test.

Saving and loading capability sets

Inspector lets you save capability sets as named presets. Save one preset per device you test on — you won't have to re-enter all the capabilities every time you start a session.

Common pitfalls

Element attributes are empty. The app was not built with accessibility attributes. Ask developers to add contentDescription (Android) or accessibilityIdentifier (iOS) to interactive elements.

Source tree is huge and nested. Zoom into the relevant part of the screenshot first. Use the search functionality instead of manually expanding nodes.

The screenshot is stale. Always refresh after navigating, scrolling, or performing an action.

Session times out. Inspector sessions time out after a period of inactivity. If the screenshot is grey, restart the session.

// tip to track lessons you complete and pick up where you left off across devices.