Object Identification in Mobile Automation Using UIAutomator VIEWER

14 / Jan / 2016 by Kimi Agarwal 0 comments

Mobile testing is a very hot topic nowadays. There are two ways to test how the application is interacting with the user on the mobile device one is manually and the other is through automation.

Manual testing takes lot of time and it’s a very slow process. While automation testing is more efficient and effective process. In automation testing we have to write the test cases to cover the specific scenarios and then run those test cases automatically. While we are writing the test cases, we have to identify the objects, and for this we use UIAutomator VIEWER.

Appium uses UIAutomator VIEWER.

Appium is an open source mobile automation tool which is useful to automate android and IOS platform apps. It support Native, Hybrid and Web Application.

How to use UIAutomator VIEWER

UIAutomator Viewer is a GUI tool that comes with Android SDK. It is used to examine and inspect the UI components of an Android Application that are visible on the forefront of the device.


  1. Install the android SDK. When the SDK has been installed in the system, you have to move that SDK folder from C Drive to another Drive suppose E Drive.
  2. Under SDK folder, go to SDK then go to the Tool Folder. Double click on UIAutomator viewer batch file to launch it

You will find uiautomatorviewer.bat file in Tools folder of SDK. e.g. E:\SDK\tools.

  1. Attach your device with your PC using USB cable.
  2. Verify the device is connected to the system by using adb devices command on CMD prompt.


  1. Enable the developer option in the Android Device from the Settings.
  2. Select LinkedIn application.
  3. Click on the device screenshot button and the LinkedIn application opens up.


     How to identify elements for automation

  • text attribute can be used as “name” findElement(By.name(“Sign in”));
  • resource-id attribute can be used as “id” findElement(By.id(“com.linkedin.android:id/login_button”));
  • class attribute can be used as “className” findElement(By.className(“android.widget.Button”));


Challenges with the tool and there resolution

  1. To use UIAutomator VIEWER please make sure Android SDK is installed in the laptop.
  1. UIAutomator VIEWER does not support WebView. Firebug is used to identify the objects.
  1. Works on Android Devices with Version 4.1 (or higher).If you want to test UI on lower versions of Android Devices with Version2, use ‘Espresso’.
  1. When the mobile device is not connected to the PC and the user click on the ‘Device Screenshot’ button on top right corner of the screen, an error will occur “No Android devices were detected by adb”.


Comparison between UIAutomator Viewer and Calabash

  1. UIAutomator Viewer only works on API level 16 and above which means you can’t run your test on older devices while Calabash works on API level 8 and above.
  1. Unlike Calabash, UIAutomator Viewer runs on your computer which is driven by a server on the device that interacts with the app.

Leave a comment -