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.
- JAVA should be installed (JAVA Setup link).
- Android SDK should be installed.
- 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
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.
To launch uiautomatorviewer, we have to type “uiautomatorviewer” in terminal and
How to use uiautomatorviewer to inspect elements of Android App?
- Connect your device to the PC using a USB cable.
- Launch the desired app.
- Launch uiautomatorviewer
- Click on green colored icon device icon takes a snapshot of your device.
- Move the cursor to the desired object and Select the Object Properties.
- 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
Android App Attributes:
- Link text
- Partial Link text
- Tag Name
- Class name
Errors and their solution while Accessing UI Automator:
- Error- “No Android devices were detected by adb”
Ans. For this reconnect your device and then click on refresh.
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.