DEV Community

Cover image for Complete Appium Inspector Tutorial For Testing Mobile Apps
Steve Wortham
Steve Wortham

Posted on

Complete Appium Inspector Tutorial For Testing Mobile Apps

Appium is one of the most renowned open-source automation testing frameworks for app testing. It supports multiple programming languages and has a handy utility called the Appium Inspector. Appium Inspector allows users to inspect the UI of a mobile app, helping them to evaluate key UI elements such as buttons, images, form fields, etc. across various Android and iOS devices.

We will look at the capabilities and functionality of Appium Inspector in this blog and how it can help developers and testers make more efficient use of app evaluation. If you’re new to Appium, you can read our previous article on “What is Appium” to get a better understanding of Appium and its relevance in software testing.

What is Appium Inspector?

Appium Inspector is a graphical user interface (GUI) tool that is a component of the Appium framework, an open-source automation tool created especially to help with the testing and automation of mobile applications across many platforms, including Android and iOS. Appium Inspector gives testers and developers a visual depiction of the user interface (UI) elements existing in a mobile app, enabling them to interact with, examine, and test those parts’ composition and characteristics.

Users can navigate around the UI hierarchy of an app using Appium Inspector to quickly discover UI elements such as buttons, text fields, checkboxes, and more. Additionally, it has capabilities like element highlighting, which graphically shows the selected element on the app’s screen, and the capacity to provide in-depth information about each element, including its features, hierarchy, and events that user interactions may cause.

Image description

Benefits of Appium Inspector:

Using Appium Inspector offers several benefits when it comes to inspecting and automating mobile applications:

  • Support for CrossPlatforms: With Appium Inspector, you have the ability to monitor and control applications on various operating systems using a single tool, with support for iOS and Android platforms.
  • Element Selection: You can select individual elements in the app by clicking on them in the Inspector. This will make it possible to focus on a particular element, and view its properties, attributes, or location in an element tree.
  • Interaction with elements: the Appium Inspector is capable of interacting with elements in an application. Actions such as pressing buttons, inserting text in a text field, selecting an option from drop-down menus, or triggering events can be performed depending on the type of element. These interactions are used in tests and debugging to check the app’s behavior.
  • View element properties: Appium Inspector will provide full information about the chosen element, including its identifier, class name, text content, position, size, and other related attributes. To learn more about the characteristics of that element, you can view these properties.
  • Highlighting elements: By highlighting a relevant element from the mobile app, it gives visual feedback when you are interacting with an element in Appium Inspector. This makes it easier to confirm that during automation you’ve been dealing with the right element.
  • XPath and CSS Selector Support: Appium Inspector supports XPath and CSS selectors, allowing you to use these powerful locator strategies for identifying elements during automation. It’s a convenient way of generating XPath or CSS selectors based on the chosen element.
  • Debug test scripts: by inspecting elements and their properties, Appium Inspector can be used to debug test automation scripts. In your test script, you will be able to check if the elements are correctly identified and acted upon. You can fix or make necessary changes to your script when there’s an issue or a surprising behavior.
  • Hierarchy Navigation: A visual representation of an app’s UI hierarchy is provided by Appium Inspector. In order to understand the relationship between elements and their parent-child connections, you can explore and navigate through different levels of hierarchy. With these features of Appium Inspector, in the context of Test Automation or Debugging, you shall be able to gain a complete view of elements within your Mobile app by analyzing, understanding, and interacting effectively with them.

Getting Started with Appium Inspector:

However, before using Appium Inspector, you must have Appium installed on your system. Appium Inspector’s user-friendly UI interface makes it simple for developers to inspect and understand the UI elements of their mobile apps, despite the fact that it may seem complicated.

How to Set up Appium Inspector and Launch Your First Test?

Follow these steps to set up Appium Inspector:

Step 1: Install Appium: The process begins with installing Appium on your computer. you can download the most recent version of Appium for your operating system.

Step 2: Install Appium Desktop: After installing Appium, you must install Appium Desktop, which includes Appium Inspector. You may install Appium Desktop on your PC by downloading it from the official website.

Step 3: Install Appium server: The next step prior to starting Appium Inspector is installing the Appium server. By pressing the “Start Server” button, the Appium desktop will appear. The Appium server on your computer will start up as a result.

As soon as you will click on the “Start Server” button, it will show three alternatives (ie. Simple, Advance, Present)

  1. Simple — It uses the default values to start the server using the Host Server Address and Server Port.

Image description

2. Advanced: The host server’s unique address and port can be given. The Chrome driver port address will be available for us to use when testing a Web application on Chrome.

Image description

3. Presets: This will help us use any preset values which we have used in the Advanced tab. We are saving the new custom Host Server Address and Server Port by using the “Save As Preset” option in the Advanced tab. Then use them back by clicking on them from the Preset tab.

Image description

Once your server is running you will see a screen similar to this. It will show the Appium version and the server host and the port address.

Image description

For us to start the Appium Inspector session we need to click on the magnifying glass button(🔍) on the top panel.

Step 4: Connect your device: Connect your mobile device to your computer with a USB cable. Make sure the device is in developer mode with USB debugging enabled.

The next we need to do is, to configure the application’s capabilities for testing.You should be able to add your capabilities under the Desired Capabilities tab after starting your Appium Inspector session.

Step 5: Setting up the required Capabilities: To connect your device to the Appium server, you need to specify the necessary features. Click the “New Session” Window button on the Appium desktop and enter the required capabilities for your device. On the Appium website, you can find information about the features available for your device.

Here are some commonly used desired capabilities for Appium Inspector:

  • Platform Name: Specifies the platform on which the app is being tested, such as “Android” or “iOS.”
  • Platform Version: Specifies the version of the platform, e.g., “7.0” for Android or “12.1” for iOS.

  • Device Name: Specifies the name of the device or emulator on which the app is being tested.

  • App: Specifies the path or URL to the application binary file (APK for Android or IPA for iOS).

  • App Package: For Android, specify the package name of the app under test.

  • App Activity: For Android, specify the activity name to launch the app.

  • Automation Name: Specifies the automation technology to be used, such as “Appium” or “XCUITest.”

  • Orientation: Specifies the initial screen orientation for the app, such as “PORTRAIT” or “LANDSCAPE.”

  • Browser Name: If testing a web application, specifies the browser to be used, such as “Chrome” or “Safari.”

  • UDID: Specifies the unique device identifier (UDID) of the physical device being used for testing.

  • Bundle ID: Specifies the bundle identifier of the iOS application to be tested.

  • Orientation: Specifies the initial orientation of the device, such as “portrait” or “landscape”.

  • AutoWebview: Enables or disables the automatic switching to the web context if a web view is detected.

  • AutoGrantPermissions: Specifies whether to automatically grant app permissions during installation (set to true or false).

  • NoReset: Specifies whether to reset the app state between sessions (set to true or false).
    These are just a few examples of the desired capabilities that can be set in Appium Inspector. The specific capabilities required may vary depending on the testing scenario, target platform, and application being tested. It’s important to refer to the documentation and guidelines provided by the Appium project or the specific automation tool being used for a comprehensive list of available desired capabilities and their usage.

There are two different ways of adding capabilities here:

By using the text boxes for capability names and mentioning the type and value.

Image description

By adding them in JSON format.

Image description
Once your capabilities are set, we need to click on the “Start Session” button.

Image description

And then the screen looks like the below,

Image description

Step 7: Use Appium Inspector: You can now use Appium Inspector to inspect content in your mobile app. You can click on any item on the screen and view its properties. By interacting with the content, you can perform actions such as clicking, scrolling, and typing.

Now you are all set, Just click on the element to get their details.

Image description

1st section of the screen is the screenshot of the application. 2nd section of the screen is the App Source. 3rd section of the screen shows the Element details.

Finally, these are the steps to create an Appium tester. You can help achieve better test results by using Appium Inspector to easily automate mobile app testing.

Conclusion:

The powerful tool Appium Inspector provides information about the structure and functionality of mobile applications during testing. Although it has a few flaws, like inconsistent recognition and performance problems, it has a significant benefit over these limitations. Inadequate support for replicators is among the other limitations.

Source: This article was originally published at testgrid.io.

Top comments (0)