Just imagine, you developed an Android application and published it to Google Play. Then you get a user review like ‘This app has too many bugs, I don’t like it’. Hence, it is important that you test the app well before publishing. There are a ton of test scenarios that should be executed before publishing an app. To save the testing effort, automation testing tools are relied upon. Selendroid is one of the best frameworks for testing Android apps.
Selendroid is an open source automation framework which drives off the UI of Android native, hybrid and mobile web application. It is based on the Android instrumentation framework. Furthermore, the tests are written using the API of Selenium 2 client otherwise called as Selenium webdriver. As a result, the existing Selenium framework is still reused by Selendroid. It also can be integrated with selenium grid for parallel execution on multiple nodes.
Selendroid contains 4 major components:
- Web Driver Client
- Selendroid Server
- Android driver app
- Selendroid Standalone
Web Driver Client — The Java client library based on Selenium. This library should be installed on the computer (which is used to develop the test cases).
Selendroid Server — The server which runs be in the app under test on Android device or simulator. This is the main component of the Selendroid architecture.
Android Driver App — A built-in Android driver, Web View app to test the mobile web.
Selendroid-Standalone — This component is used to install the server and the application under test (AUT).
Important features of the Selendroid
- Interact with multiple devices
- No modification of AUT required
- Support Multiple Android target API
- Built-in Inspector
- Supports Gestures
Interact with multiple devices:
Selendroid can interact with multiple Android devices (emulators or hardware devices) at the same time. So you can test your app with various Android devices to check compatibility. Existing emulators start automatically and it supports hot-plugging of hardware devices. You can change the hardware devices (Plug and unplug) during the testing without restarting or stopping the test. It also recognizes the new devices automatically.
No modification of AUT required:
No modification of app under test is required in order to automate it. You can test the application under test using Selendroid without any modification of the app. You just need the binary file (APK) installed on the computer. In order to install the binary file on the device, the test app, and the mobile app must be signed with same sign key. No source code is needed to automate application.
Support Multiple Android target API:
Corresponding to the Android API version up, Selendroid also supports the new Android API (From API 10 to API 19).
Selendroid also has some built-in inspector tool to help you identify the UI element of the application under test. For example the ID of a button, text field, text view etc. Selendroid comes with a useful little tool called Selendroid Inspector. It’s a little web app which is embedded inside your Selendroid test server. Its purpose is to let you inspect the current state of your app’s UI.
The main features are:
- View hierarchy
- View UI element properties
- UI screenshot with view locator
- Record the click actions
- Display the source HTML of a web view
- XPath helper
UI elements can be found by different locator types. Before interacting with elements, first, the elements need to be found. It also supports Multiple Element locator strategies; look at the Selendroid documentation for details.
This is the list of supported element interactions:
- Get Text
- Send Keys
- Get Attribute of Element
- Is Selected
- Is Displayed
- Is Enabled
- Get Size
- Get Location
The biggest advantage of using this automation testing tool is the smooth switch between native and web contexts.
Gestures are supported: Advanced User Interactions API. Selendroid can simulate human user actions on an app, such as touch, swipe, drag and drop on devices. It is implementing the Advanced User Interactions API. This is a new, more comprehensive API for describing actions a user can perform on an app. This includes actions such as drag and drop or clicking multiple elements while holding down the Control key.
- doubleTap(WebElement onElement)
- down(int x, int y)
- flick(int xSpeed, int ySpeed)
- flick(WebElement onElement, int xOffset, int yOffset, nt speed)
- longPress(WebElement onElement)
- move(int x, int y)
- singleTap(WebElement onElement)
- up(int x, int y)