Native Mobile Apps Test Automation with NativeDriver
Google has created NativeDriver, an implementation of the WebDriver API, a test automation framework that uses the native UI instead of a browser UI, as Selenium does, to run functional tests on an application. Google has decided to reuse the WebDriver API for native applications instead of creating a new one due to many similarities between them - they both control the same UI operations such as click, type, read text, switch window-, and users familiar with WebDriver do not need to learn another API and can start using NativeDriver immediately.
NativeDriver can be used to perform automated UI commands in a native application in order to test how the application behaves under various conditions. On Android, NativeDriver uses Instrumentation, a mechanism for programmatically controlling various OS components outside of their natural functioning cycle inside of an application. An example of a simple NativeDriver test looks like this:
AndroidNativeDriver driver = new AndroidNativeDriverBuilder().withDefaultServer().build();
// Open the Places activity by clicking the places button (to the right of the search box)
AndroidNativeDriver btn= driver.findElement(By.id("btn_header_places"));
// Dismiss the Places window. Equivalent to pressing the Android Back button
// Rotate the device to show the UI in landscape mode
Beside this test framework for mobile OSes, Google made available the WebDriver for mobile browsers, which offers testing support for web applications running in a browser on Android, iOS, and there is project started for Blackberry.
Craig Motlin Sep 01, 2014