Syntax
- Instrumentation getInstrumentation()
- UIDevice UiDevice.getInstance(Instrumentation instrumentation)
- boolean UIDevice.pressHome()
- boolean UIDevice.pressBack()
- boolean UIDevice.pressRecentApps()
- void UIDevice.wakeUp()
- boolean UIDevice.swipe(int startX, int startY, int endX, int endY, int steps)
- boolean UIDevice.drag(int startX, int startY, int endX, int endY, int steps)
- UIObject2 UIDevice.findObject(By.desc(String contentDesc))
- boolean UIObject2.click()
UIAutomator are especially good for testing user stories. You run into problems if view elements have neither a unique resource-id nor content-desc. In most of the cases there is a way to complete the test anyways, what that takes a lot of time. If you can influence the code of your app, UIAutomator may be your testing tool.