Please follow the below guides for getting started with the Appium Desktop Inspector session.

Starting Appium Desktop Inspector to inspect Android/iOS Apps locally

Starting Appium Desktop Inspector to inspect Android/iOS Apps from TestObject

Once you have started the Inspector session, we can record the steps in Appium to get the UI Identifiers easily. Here's how it is done:

1. Click on the 'Start Recording' button on the top toolbar to start recording the Steps and the UI Identifiers.

You can see that a new 'Recorder' area has been added on the middle.

2. Select the required element on the UI Snapshot view on the left and then click on one of the three actions in the Selected Element view on the right.

3. Repeat the procedure until all the actions are performed. You will see that the steps are getting added as shown below:


Note: You may select the 'Robot Framework' option on the selector to get the UI Identifiers in an easily usable format. You may skip this step as this is optional.

4. Finally, copy the Recorded steps using the Copy button.

Now, you can use the 'xpath' or 'id' values in the copied code to create UI Identifiers for your mobile Application. This is a sample code:

# xpath=(//android.widget.ImageView[@content-desc="More options"])[1]
Click Element    xpath=(//android.widget.ImageView[@content-desc="More options"])[1]
# xpath=/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.LinearLayout
Click Element    xpath=/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.LinearLayout
# xpath=/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/[1]/android.view.ViewGroup/[3]/android.view.ViewGroup/[1]/android.widget.TextView[1]<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span>
Click Element    xpath=/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/[1]/android.view.ViewGroup/[3]/android.view.ViewGroup/[1]/android.widget.TextView[1]

From the above code, we got the UI identifiers as shown below after some cleanup(split the UI Identifiers at occurence of '#' character):

xpath = (//android.widget.ImageView[@content-desc="More options"])[1]

xpath = /hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.LinearLayout

xpath = /hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/[1]/android.view.ViewGroup/[3]/android.view.ViewGroup/[1]/android.widget.TextView[1]

You can use these values to create your UI identifiers now.

Creating Manual XPaths using Appium Inspector

In the above case, except the first one, the suggested XPath in Appium Desktop Inspector is very long and not the optimal one. Therefore, it is recommended to create XPath manually in those cases.

Here's a video that shows how to create manual XPaths for UI Identifiers from Appium Inspector: