App Development Testing

What’s inside Selendroid: Selenium for Android?

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.

Overview:

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:
  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 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
  1. Interact with multiple devices
  2. No modification of AUT required
  3. Support Multiple Android target API
  4. Built-in Inspector
  5. 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).

Built-in Inspector:

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:
  1. View hierarchy
  2. View UI element properties
  3. UI screenshot with view locator
  4. Record the click actions
  5. Display the source HTML of a web view
  6. 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:
  1. Get Text
  2. Click
  3. Send Keys
  4. Get Attribute of Element
  5. Clear
  6. Submit
  7. Is Selected
  8. Is Displayed
  9. Is Enabled
  10. Get Size
  11. Get Location

The biggest advantage of using this automation testing tool 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. 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.
Supported Interactions:

  1. doubleTap(WebElement onElement)
  2. down(int x, int y)
  3. flick(int xSpeed, int ySpeed)
  4. flick(WebElement onElement, int xOffset, int yOffset, nt speed)
  5. longPress(WebElement onElement)
  6. move(int x, int y)
  7. singleTap(WebElement onElement)
  8. up(int x, int y)
Perfomatix | Product Engineering Services Company