Inspect Android Elements in Linux

Inspect Android Elements in Linux

 

 

Here in this blog, we will discuss Inspect Android Elements in Linux using UIautomatorviewer.

Before designing a test we have to find the elements on which we perform desired actions.To analyze the UI interface we will use uiautomatorviewer. UIautomatorviewer shows a split screenshot of all the UI components in the “Node Detail” so you can see their different properties. From the properties, you can find the desired element locators.

Pre-requisites:

  1. JAVA should be installed (JAVA Setup link).
  2. Android SDK should be installed.
  3. ANDROID_HOME path must be set.

What is UIautomatorviewer?

UIautomatorviewer is a GUI tool to scan and analyze the UI components of an Android application. It provides convenient ways to identify android App UI components displayed on Android App. It is used to inspect the layout hierarchy and properties of Android UI components available on the device screen.

Where is UIautomatorviewer located?

uiautomatorviewer is located in the directory <android-sdk>/tools/

Steps to Launch “UIautomatorviewer”:

Go to the <android-sdk>/tools/ directory where Andriod SDK is located.

Now type “uiautomatorviewer” in the terminal.

As in the above image, we found the message that “The program ‘uiautomatorviewer‘ is currently not installed. You can install it by typing: ”

sudo apt install androidsdk-uiautomatorviewer

After successful installation, we are able to launch uiautomatorviewer.

Launch uiautomatorviewer:

To launch uiautomatorviewer, we have to type “uiautomatorviewer” in terminal and

 

How to use uiautomatorviewer to inspect elements of Android App?

  1. Connect your device to the PC using a USB cable.
  2. Launch the desired app.
  3. Launch uiautomatorviewer
  4. Click on green colored icon device icon takes a snapshot of your device.                                                                           3
  5. Move the cursor to the desired object and Select the Object Properties.                                                                     2
  6. In the ” Node Details ” section we will find the desired object locators with their properties. Here in the below screenshot you will find the properties of selected object “Electronics” com.flipkart.android:id/flyout_parent_title                                                                                          4

Android App Attributes: 

  1. Id
  2. Name
  3. Link text
  4. Partial Link text
  5. Tag Name
  6. Class name
  7. Css
  8. XPath                                                                                                                                                                                             5

 

Errors and their solution while Accessing UI Automator:

  1. Error- “No Android devices were detected by adb”                                                                                                  Error 11

Ans. For this reconnect your device and then click on refresh.

 

Conclusion:

After following all the above steps, hopefully, this explanation is enough to launch uiautomatorviewer which helps us to extract the UI element locators properties successfully.

2 thoughts on “Inspect Android Elements in Linux

  • Pingback: at home jobs
  • Nice article,
    Could you explain the difference between clickable and enabled in the node details. It’s a bit confusing when clickable is false and enabled is tue.

Leave a Reply

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