Finding elements with uiautomatorviewer

uiautomatorviewer is one of tool in android sdk packages, you can find it under <ANDROID_HOME>/tools folder:

Screen Shot 2017-04-04 at 4.28.54 PM.png

To open uiautomatorviewer you need to double click on it or type command uiautomtorviewer in windows commandline:

Screen Shot 2017-04-04 at 4.30.08 PM

Now you can going to take example with android calculator app by following steps below:

Step 1: open android simulator or real device

Step 2: open calculator app

Step 3: click on the devices’s screenshot (Screen Shot 2017-04-04 at 4.36.09 PM) button from UiAutomatorVier:

Screen Shot 2017-04-04 at 4.39.03 PM

Finding elements by ID

In case you want to locate android elements by ID, you need find the resource-id value of its.


here is java code to locate button number 5 via id


Finding elements by NAME

With the button 5 above, when locate it with name is mean use text property



Finding elements by CLASSNAME



Finding elements by ACCESSIBILITY ID

If you want use this way, please get value of content-desc:



Finding elements by ANDROIDUIAUTOMATOR

With the button 5 above, when locate it with android UiAutomator method:

driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"\")");

Finding elements by XPATH


One thought on “Finding elements with uiautomatorviewer

  1. mani says:

    how to handle the resource id like =!@$id/digit_5

    I am getting the error message like – $ is not support in resource id. how do handle the issue.

    Please guide me. I am waiting for your valuable reply


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.