Tuesday 10 January 2017

Locating Android App Elements Using UI Automator Viewer

Inspecting App's UI Element Using UI Automator Viewer
We will use default and simple calculator app of android phone to learn how to inspect its's UI elements using UI Automator Viewer tool. Follow the steps given bellow.
  • Connect your android device with PC (USB debugging mode should be enabled) as described in THIS POST.
  • Run command "adb devices" in command prompt to verify device is connected properly with PC.
  • Run uiautomatorviewer.bat file from E:\SDK\tools folder. View THIS POST to know more about SDK folder. It will open UI Automator Viewer tool's UI as bellow.
  • Open Calculator application in your android phone. You can download Android Calculator App from THIS PAGE if it is not available with you.
  • In UI Automator Viewer software tool, Click on Device Screenshot image button as shown in bellow image. (Before clicking on button please make sure Calculator app is open in your android phone and it is in active mode. Means phone is unlocked and you are able to see Calculator app on screen).
  • It will process to capture device screenshot.
  • After capturing screenshot of android phone screen, It will show your android phone's calculator's UI in UI Automator Viewer as bellow. 
  1. On left site it will show you calculator app's screenshot which is open in android device.
  2. Right side top part will show calculator app's UI element's hierarchy view. It will display node structure to explain how elements are arranged.
  3. Right side bottom part will show property detail of selected element.


  • In calculator screenshot (which is display in UI Automator Viewer), Select button 5 to view it's different properties as shown in bellow image.

  • It is showing different properties of button 5 in right side node detail section which we can use to locate it using different element locating strategy. 
This way you can inspect any element of android native app using UI Automator Viewer software tool. You just need to click on element and it will show you that element's relative property detail.NEXT POST will show you different ways(XPath, id, className) to locate android app elements.

No comments:

Post a Comment