A Brief Introduction to Appium Inspector: Part 1 — Creating Sessions
How to use Appium Inspector’s GUI to create an inspection session
A repost of my daughter’s article with permission. I added a few notes. This is also included in the “Courtney’s Appium Series”.
In previous articles, we focus on the set-up of Appium (XCUITest) Execution in a 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 equivalent built-in inspector in mobile apps.
Zhimin: for this reason alone, mobile test automation is a lot more challenging thatn web test automation. Having said that, 99+% web test automation attempts failed (see, Definition of End-to-End Test Automation Success) sfor various reasons.
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.
Table of Contents:
· Installation
· How to Use Appium Inspector
· Creating a Brand New Session
· Attaching to an Existing Session
Installation
To install Appium Inspector, install the latest release from their Github page: https://github.com/appium/appium-inspector/releases
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:
Creating a session
To start inspecting, you will either need to create a brand-new Appium session or attach it to an existing session.Navigating the app
You can navigate through Appium Inspector or through the simulator.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.
Zhimin: please note, the uses of Appium Inspector for both Moible and Desktop platforms are nearly identical.
Creating a Brand New Session
First of all, make sure
The Appium server is up and running (see this article).
The app is ready.
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 of 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"
}
Appium Inspector does not allow a straight JSON input (in the right panel) 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.
Zhimin: for web testers, it is a long wait.
Appium Inspector’s Inspect Mode is 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 fresh (installing 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.
Keep reading with a 7-day free trial
Subscribe to AgileWay’s Test Automation & Continuous Testing Blog to keep reading this post and get 7 days of free access to the full post archives.