Skip to content

An easy to use, Espresso like, syntax on top of the Android UI Automator testing framework

License

Notifications You must be signed in to change notification settings

sshropshire/device-automator

 
 

Repository files navigation

device-automator

Build Status

Device Automator is an Android library built on top of the UI Automator testing framework. Device Automator provides an easy to use syntax for writing UI Automator tests that interact across apps and the device itself. The Device Automator API very closely resembles the Espresso API and similarly encourages test authors to think in terms of what a user might do while interacting with the application - locating UI elements and interacting with them.

Origins

Special thanks to Luke Korth (@lkorth) for the original device-automator implementation.

Setup

Download device-automator

Add the dependency in your build.gradle file:

dependencies {
  androidTestCompile 'com.braintreepayments:device-automator:1.0.0'
}

Set the instrumentation runner

Add the following line to your build.gradle file in android.defaultConfig:

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Writing Tests

It's recommended that you start every test from your device's home screen. To do that, run the following before each test:

onDevice().onHomeScreen();

To launch an app, call:

onDevice().launchApp("com.myapp.package");

To click on a view:

onDevice(withText("My Button")).perform(click());

To type text:

onDevice(withText("Enter text here")).perform(setText("foobar"));

To make assertions after interacting:

onDevice(withContentDescription("message field")).check(text(containsString("my message")));

About

An easy to use, Espresso like, syntax on top of the Android UI Automator testing framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 93.1%
  • Ruby 5.4%
  • Shell 1.5%