Appium Inspector and how to use it

Appium Inspector:

This document explains how to use Appium Inspector, UI Automator viewer and how to use Desired Capability.

What is appium inspector?

Appium inspector is a part of Appium GUI tool. This is a combination of Appium server itself and Inspector tool. This is designed to identify all the visible elements of the app while developing the test scripts.  

How to Use Appium Inspector?

Open the Appium and start the Appium server

Click on the Start Inspector Session button to open the Appium Inspector. Make sure you are in the Desired Capabilities tab.

Enter all the Desired Capability in the Name and Value text boxes. To know more about Desired Capability click on the link –

Click on Start Session button and the new Appium session will be created.

You will see a screen like the following screen

You have to construct your own locator strategy for locating any elements.

XPath Syntax – //ClassName[@Attribute=”Value”]

For e.g, the XPath for the above Get Started button will be as follows

android.widget.Button[@text=”Get Started”]

The Attribute and Value are displayed in the Select Element selection in the above screen.

I would recommend you to use Appium Inspector only for iOS. Use Android UI Automator for android devices. Follow the below sections for Android UI Automator

Where to find Android UI Automator?

You can find the Android UI Automator in

Your User Directory/Library/Android/sdk/tools/bin/uiautomatorviewer

How to run Android UI Automator?

  • Open terminal
  • Enter the following command
 $ Your User Directory/Library/Android/sdk/tools/bin/uiautomatorviewer
  • UI Automator Viewer opens
  • Click on the Device Screenshot button to capture the screenshot.
  • Make sure your device is connected to your machine and the device is not connected to the appium session. You will get a screenshot like following with all the properties

You can construct the XPath as mentioned in the Appium Inspector session above.

Desired Capability:

Quote from official Appium Documentation,

“Desired Capabilities are keys and values encoded in a JSON object, sent by Appium clients to the server when a new automation session is requested.”

The desired capability is generally used to set the device properties like Name of the device, Device ID, OS version, Location of the app etc.

Example desired capabilities:

Android Real Device:

{

 “deviceName”: “9da487b2”,

 “platformName”: “Android”,

 “platformVersion”: “7.0”,

 “app”: “/Users/ajaykumar/Documents/Apps/ZoomRx 6.3.1.apk”

}

Explanation of the above Key and Value pair.

How to find the deviceName value:

  • Connect the Android device to your machine using USB
  • Open eclipse and execute the following command
$ adb devices
  • This will display the device name as below

Platform Name:

The platform name is “Android

Platform Version:

You can find the OS version in the System settings of your android device

App:

This is the location of your apk file

iOS Real Device :

{

 “platformName”: “iOS”,

 “automationName”: “XCUITest”,

 “deviceName”: “Ajay kumar Manoharan’s iPhone”,

 “platformVersion”: “11.4.1”,

 “udid”: “a92e880ea121de5ea9acbdbbad72d0b5bf80e1cf”,

 “xcodeOrgId”: “3B26S8P239”,

 “xcodeSigningId”: “iPhone Developer”,

 “noReset”: “true”,

 “app”: “/Users/ajaykumar/Documents/Apps/zoomrx zeus va-6.3.2.ipa”

}

Platform name:

The platform name is iOS for the iOS device.

Automation name :

The automation name is “XCUITest” for iOS version greater than 9.3 and you don’t have use this capability if the iOS version is less than iOS 9.3

Device name:

The Device name is the name of your device. You can find the name in Settings → General of your device.

UDID:

To find the udid of the device follow the below link – Finding UDID

XcodeOrgId:

This is your team id of the developer account.

App:

This is the location of your apk file

Leave a Reply

Your email address will not be published. Required fields are marked *