Appium : Multiple ways to identify the UI elements of Android app

In this post, I would provide you the information about the tool that you can use to identify the UI elements of android native app. There is a tool called UIAutomatorviewer provided by Android SDK to scan and analyze the UI elements of android native apps.


  • JDK must be installed.
  • Android SDK must be installed on your system only then you will be able to use UIAutomatorviewer.
  • Android emulator must be installed and configured.

How to use UIAutomatorviewer?

Just follow below steps :

1. Launch Emulator
2. Open Command Prompt and then navigate to your Android SDK’s \platform-tools\ directory
(Eg. cd C:\Users\himanshu.puri\AppData\Local\Android\sdk\platform-tools). Run “adb devices” command.
You should see your connected devices listed in Command Prompt window. As we already opened the emulator in step-1, so you should be able to see the unique id of it. I am doing this action just to make sure that the emulator is connected or not.
3. Now Navigate to \Android\sdk\tools.. directory.

4. Double click on uiautomatorviewer.bat file. It will open up UIAutomation Viewer.
5. Click on the Device screenshot option on the top left. It will take the screen shot of the emulator screen.
6. Now move your mouse to an element which you want to inspect and click on it. Now you will be able to see the properties of that element on the right side of UIAutomationviewer.

Lets discuss about the possible locators that one can use for a UI Element in android native app

Here, I am going to inspect Email input box(as shown in the above screen shots) by different locators :

First one is : X-PATH
Most of you aware of x-path as we generally use it in web automation testing.

X-path of email input box would be :

//android.widget.EditText[@text=’Email or username’]

Command to type email id using XPATH would be :

driver.findElement(By.xpath("//android.widget.EditText[@text='Email or username']")).sendKeys("");
//In Appium, xpath starts with class name.

Second one is : Name

Command to type email id using name would be :

driver.findElement("Email or username")).sendKeys("");
//Here If you notice that I used text attribute of email input box as a name. Hence in Appium, text attribute would be used as a name.

Third one is : ID
Id is always our first priority, so if we have the ID then there is no need to use any other locator.

Command to type email id using ID would be :


Fourth one is : className


//In the above screen shot, there are two input box(email and password) and the class name is same for both. So my above command will identify the first element from the top which is email input box.

If you really like the information provided above, please don’t forget to like us on Facebook, you can also leave the comment.

Leave a Reply

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