https://github.com/lkorth/device-automator
An easy to use, Espresso like, syntax on top of the Android UI Automator testing framework
https://github.com/lkorth/device-automator
android espresso testing ui-automated-tests ui-automation ui-testing
Last synced: 4 months ago
JSON representation
An easy to use, Espresso like, syntax on top of the Android UI Automator testing framework
- Host: GitHub
- URL: https://github.com/lkorth/device-automator
- Owner: lkorth
- License: mit
- Created: 2015-11-15T04:51:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-09-18T15:06:52.000Z (over 4 years ago)
- Last Synced: 2025-01-19T04:58:35.598Z (4 months ago)
- Topics: android, espresso, testing, ui-automated-tests, ui-automation, ui-testing
- Language: Java
- Size: 143 KB
- Stars: 66
- Watchers: 3
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# device-automator
[](https://travis-ci.org/lkorth/device-automator)
Device Automator is an Android library built on top of the [UI Automator testing
framework](http://developer.android.com/training/testing/ui-testing/uiautomator-testing.html).
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](https://google.github.io/android-testing-support-library/docs/espresso/basics/index.html)
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.## Setup
### Download device-automator
Add the dependency in your `build.gradle` file:
```groovy
dependencies {
androidTestCompile 'com.lukekorth:device-automator:1.1.0'
}
```To use the latest build from the `master` branch use:
```groovy
dependencies {
androidTestCompile 'com.lukekorth:device-automator:1.1.0-SNAPSHOT'
}
```### 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:```java
onDevice().onHomeScreen();
```To launch an app, call:
```java
onDevice().launchApp("com.myapp.package");
```To click on a view:
```java
onDevice(withText("My Button")).perform(click());
```To type text:
```java
onDevice(withText("Enter text here")).perform(setText("foobar"));
```To make assertions after interacting:
```java
onDevice(withContentDescription("message field")).check(text(containsString("my message")));
```