Getting Resource Id’s for Android UIAutomator Testing

When you are testing Android applications you can lookup the object to receive user input either via text or via the resource id.

The resource id is more stable since the text may change dramatically between versions and upon the user interface language.

The best tool is the uiautomatorviewer viewer. It is included in the android sdk tools directory. Launch it via:

cd /path_to_your_android_sdk/android-sdk/tools/
uiautomatorviewer

Then click the second icon from the left which will dump the screen. You can then lookup the resource-id from lower right:

uiautomatorviewer-screenshot

George Lee

A full stack engineer who has coded on front end, back end, and mobile and embedded system. Have worked on large scale systems at eBay and agile environments at startups. Specialties: Python, PHP, Objective C, Java, Perl, SQL, Javascript, IOS, Android, Amazon EC2, Linux and Windows.

Leave a Reply

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