A Brief Introduction to Appium Inspector: Part 1 — Creating Sessions

How to use Appium Inspector’s GUI to create an inspection session

Courtney Zhan
4 min readApr 23, 2023

--

In previous articles, we focus on the set-up of Appium (XCUITest) Execution in Simulator. In most of those articles, I provided element Ids and XPaths to get there. In this article, I’ll briefly introduce how to set up and use Appium Inspector so that you can get these locators yourself.

For web automation, browser’s have an Inspect mode to view attributes such as id and name.

While the same principle applies to mobile test automation, it is harder because as far as I am aware there is no built-in inspector. Therefore, we will use a separate utility, such as Appium Inspector. Appium Inspector (also created by the Appium team) is a GUI Inspector for mobile and desktop apps.

Installation

To install Appium Inspector, install the latest release from their Github page:

Follow the installation process for your operating system and Appium Inspector should be up and running in no time!

Note, there is a web version of Appium Inspector (available here), however, I prefer to use the application.

How to Use Appium Inspector

There are three key parts of Appium Inspector:

  1. Creating a session
    To start inspecting, you will either need to create a brand-new Appium session or attach to an existing session.
  2. Navigating the app
    You can navigate through Appium Inspector or through the simulator.
  3. Viewing an element’s details
    This will help retrieve an element’s locators that you can use in your scripts.

This article will only cover step 1 — Creating and attaching to Appium sessions in Appium Inspector.

Creating a Brand New Session

In order to create a session, you will need to provide some Appium settings (named “capabilities”). Some of the important capabilities are the: desired platform (iOS/Android), device type and app path.

For instance, the capabilities for the TicTacToe app from this article are:

{
"automationName": "xcuitest",
"platformName": "ios",
"platformVersion": "16.2",
"deviceName": "iPhone 13",
"app": "/Users/courtney/work/books/PracticalMobileTestAutomation/sample-apps/MorpionTPE.app.zip"
}

Unfortunately, Appium Inspector does not allow a straight JSON input for capabilities yet. Instead, you will need to copy each field over manually (see red fields below).

Please also leave the Automatically add necessary Appium vendor prefixes on start box ticked. You can verify your capabilities on the right-hand side’s JSON translation.

You can choose to save this capability set under a shortcut (e.g. “iOS Tic Tac Toe”) to avoid manually entering these fields again. I highly recommend saving your capability set if you plan to access that app more than once.

Once it’s ready, you can click “Start Session”. You should see Appium Inspector transition to inspect mode. Meanwhile, a simulator will boot up, install and start the specified app.

Appium Inspector’s Inspect Mode right next to the Simulator it is attached to.

Attaching to an Existing Session

Starting a brand new session is easy, however, it forces you to start at the very start (a freshly installed copy of the app). This can be inconvenient for debugging or if you want to pick up where a script leaves off. Luckily, Appium Inspector does provide one method to “attach” (i.e. continue on) from an existing Appium session.

If you start your own Appium session (either through a script or otherwise), this line will appear on the command line running the appium server:

[XCUITestDriver@76ce (8ee913d1)] Session created with session id: 8ee913d1-8c08-4d50-bf7d-dac3b74ce3dc

Copy this sessionId, as we’ll use this in Appium Inspector to attach.

In Appium Inspector, click on the third tab “Attach to Session…”.

There is a drop-down box where you can paste the sessionId from the command-line and select it from the drop-down. The input box should autofill with the capability information to help verify you have the right session.

From here, you can click “Attach to Session” and you Appium Inspector will load their Inspector Mode on where your simulator already is!

In the next two articles, I will go through how to navigate, interact and inspect elements in Appium Inspector.

--

--