Working with UI Automator for Android and AWS Device Farm - AWS Device Farm

Working with UI Automator for Android and AWS Device Farm

Device Farm provides support for UI Automator for Android.


This framework is currently in preview. It might not work with all scripts and apps.

What Is UI Automator?

The UI Automator testing framework provides a set of APIs to build user interface tests that perform interactions on user and system apps for Android. The UI Automator APIs allow you to perform operations such as opening the Settings menu or the app launcher in a test device. For more information, see UI Automator in the "Testing Support Library" section of the Android Developer Tools documentation.

Prepare Your Android UI Automator Tests

The Android UI Automator tests must be contained in a single JAR file. The package name in this file must match the package name used by the Android app. For example, if the Android app's package name is, the Android UI Automator tests must be in a package named

Upload Your Android UI Automator Tests

Use the Device Farm console to upload your tests.

  1. Sign in to the Device Farm console at

  2. In the list of projects, choose the option next to the project where you want to upload your tests.


    If the list of projects is not displayed, then on the secondary navigation bar, for Projects, choose the name of the project where you want to upload your tests.

    To create a project, follow the instructions in Create a Project in AWS Device Farm.

  3. If the Create a new run button is displayed, choose it.

  4. On the Choose your application page, choose Upload.

  5. Browse to and choose your Android app file. The file must be an .apk file.

  6. Choose Next step.

  7. On the Configure a test page, choose uiautomator, and then choose Upload.

  8. Browse to and choose the JAR file that contains your tests.

  9. Choose Next step, and then complete the remaining instructions to select devices and start the run.

Taking Screenshots in Android UI Automator Tests

You can take screenshots as part of your Android UI Automator tests.

To take a screenshot, call the takeScreenshot method (for example, takeScreenshot("/sdcard/uiautomator-screenshots/home-screen-1234.png");).


All screenshots must be stored in the /sdcard/uiautomator-screenshots directory. You must specify the full path (including the file name) of the screenshot to be stored.

The takeScreenshot method works for API Levels 17 and higher only. For API Level 16, UI Automator is supported, but screenshots are not supported.

Additional Considerations for Android UI Automator Tests

Device Farm re-signs Android UI Automator test packages, but it does not modify Android UI Automator tests.