This is the second article in our series on popular or otherwise interesting tools and frameworks used in test automation. I hope it will make your time valuable on explore about test automation. Just image, you developed an Android application and publish it to Google Play. Then you get a user review like below.
So when you publish an app to Google play, it must be well tested to avoid the potential bugs. There’s a ton of test scenarios that should be executed before publishing an app. To save the testing effort, you need to use automation testing. For that you should use suitable test automation frameworks.
Today I want to share you something about one of the best framework for testing Android apps. Yes you may know or may not it’s “Selendroid”.
Selendroid Overview:
Selendroid is an open source automation framework which drives of UI of android native, hybrid and mobile web application. Selendroid is based on the Android instrumentation framework. Selendroid tests are written using the API of Selenium 2 client otherwise called as Selenium webdriver, as result Selendroid still reuses the existing Selenium framework. It can be integrated with selenium grid for parallel execution on multiple nodes.
Selendroid Architecture:
Fig 2.2 Selendroid Architecture
Selendroid contains 4 major components:
  1. Web Driver Client
  2. Selendroid Server
  3. Android driver app
  4. 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 components of 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 Selendroid 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. It’s a great advantage of Selendroid. So you can test your app with various android devices to check compatibility. Existing emulators are started automatically. Selendroid supports hot plugging of hardware devices. You can change the hardware devices (Plug and unplug) during the testing without restarting or stopping the test. Selendroid recognizes the new devices automatically.

No modification of AUT  required:
No modification of app under test 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 mobile app must be signed with same sign key. not need source code 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).
Built in Inspector:
Selendroid also has some built in inspector tool to help you identify the UI element of application under test. For example the ID of button, text field, text view… 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. Multiple Element locator strategies are supported, look at the Selendroid documentation for details.

This is the list of supported element interactions:
  • Get Text
  • Click
  • Send Keys
  • Get Attribute of Element
  • Clear
  • Submit
  • Is Selected
  • Is Displayed
  • Is Enabled
  • Get Size
  • Get Location

The biggest advantage of using Selendroid is the smooth switch between native and web contexts.

Supports Gestures:
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. Selendroid 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.
Supported Interactions:
  • 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)

That’s it…!

In next blog of this series we will discuss about how to install, configure and run Selendroid test with simple example. Thank You…!

For more information, you can visit their official website.