Selendroid Tutorial: Android Mobile Test Automation Framework (Part 1)

Mobile Automation using Selendroid (Part-I):

Until now, millions of apps are already been developed using Android as a platform and the count still keeps on increasing day by day.

The catch is, how to validate each and every app? As we will be requiring dedicated resources such as manpower, real devices (say e.g. mobile) etc., and again it is a time-consuming task. On the other hand,  android version, applications (.apk) version, device dimension etc., are not constant. 

Hence, it becomes very difficult to define test exit criteria as we cannot define the complete testing scope, thereby exact testing effort estimation cannot be done.

Selendroid Test Framework Tool

In order to overcome the device dependency, emulators are being developed, which can provide real-time like environment, where we can test the application without worrying about the android version, devices, and their version. But, still testing of applications (.apk) over emulator is a manual activity and a time-consuming task even. Hence the idea of automating mobile testing is being evolved.

To perform mobile automation, test automation framework is developed, which enables automation of Android-based application by using a scripting language.

There are many automation frameworks developed such as Selendroid, Appium, Robotium, Espresso.

This tutorial is divided into two parts:

Tutorial #1: Selendroid Introduction: Android Mobile Test Automation Framework
Tutorial #2: How to use Selendroid framework to automate the user interactions over a mobile application (coming soon)

What is Selendroid?

Selendroid is an amazing Android mobile application test automation framework tool with several important features. Selendroid is a very powerful automation tool which can interact with multiple devices simultaneously and an application can be tested without any modification or change using Selendroid.

It is also called “Selenium for Android” for testing native and hybrid mobile apps and mobile web.

Why Selendroid?

  • It is an open source (free to use)
  • Supports Selenium as a scripting language
  • Supports web driver compatible languages such as Java, C#, Perl
  • Supports all Android Versions
  • Works both on an emulator as well as the real device
  • Works on a native, hybrid and web-based application
  • Effective while executing native applications as well cloud-based application. as it supports selenium grid
  • It supports object recognition using object properties
  • Easy to implement
  • Hardware devices can be Plugged, unplugged from the PC during test execution, without restarting or stopping the test. Selendroid can recognize the new devices automatically. This feature is known as “Hotplugging”

A simple Architecture of Selendroid

Architecture of Selendroid

Selendroid Components

Selendroid – Client

Basically, it is a java client library. From this component, The HTTP & WebDriver request are being sent using JSON to the Selendroid Standalone server.

Selendroid – Standalone

This component manages different devices as well as the .apk’s by installing the Selendroid-server and the app under test. The Http request (to be executed over real device/simulator) are being sent from Selendroid standalone server to the device and the apk under test.

Selendroid – Server

This server runs over the device along with the application under test. There is a two-way communication between the server as well as the application under test.


It is a built-in Android driver as well as a Web View app to test the mobile web.

Another test framework named as APPIUM works similar to a Selendroid.

Here is a small comparison between the both.

Support for Lower android version(<4.1)YesNo
Hot pluggingYesNo
User Agent TestingNoYes
Support for iOS based applicationNoYes
Environmental RequirementFor Android - Mac, Linux, Windows(any version)For iOS – Mac OSX 107.
For Android – Windows 7+, Linux, Mac OSX 107.


To start with the Intended audience should be very well aware of using selenium, any IDE tools such as Eclipse etc. Basic concepts of programming say Java, C etc…  and must be aware of using Maven and other TESTING tools.

  • Install Intel x86 Emulator Accelerator (not mandatory) to view the simulator from here
  • Java SDK, JRE already installed in a test environment. Alternately you can download the same from here

Note down the SDK Path while installing.

Set the environmental variables present over My Computer -> rightclick it -> Properties -> Advance System Setting

Android Path

Java Home

  • Eclipse is already installed on your machine. If not, you can also download the same from here
  • Selenium jar files are to be downloaded. You can download the same from here as well
  • TestNG jars are already downloaded
  • Android SDK to be downloaded and installed. You can also download the same from here

Note down Android SDK Path while installing

Once downloaded the ANDROID_HOME should be set in the environmental variables present over:

My Computer -> right click it -> Properties -> Advance System Setting

Android Path

  • Selendroid jar files are to be downloaded. You can also download the same from here

Remember to download the Selendroid standalone jar file from the above location. Usually, the name is like selendroid-standalone-0.9.0-with-dependencies.jar. Also, download one sample APK file say selendroid-test-app-0.8.0.apk from the above location


  • We can also use maven repository  to give the reference to all the jars or else you have to download them manually and attach it to the build path (Over Eclipse Project)
  • Devices/Emulators – In android all the installed application will have the .apk extension. In other ways you can download apps such as APK Info which will inform you about the list of applications installed on your android device and its actual name, size etc…

Environmental Setup

#1) Keep the APK which needs to be installed over a proper location

In my case I kept it over G:\\Jars\\selendroid-test-app-0.8.0.apk

#2) Next, keep the application over the project folder

In my case it is D:\AppiumAutomation\SelendroidFirst

Local APK

#3) Connect the real device to the PC

Making sure the USB Debugging mode is enabled and also you are allowing external apps to get installed through USB connection.


  • Please refer the USB debugging setting required for mobile say Redmi Note 3 from here
  • Allow external application installed using USB say Redmi note 3 from here

#4) Open the command prompt over Windows

Navigate to the folder where Selendroid standalone jar, as well as the downloaded apk file, are present.

Now specify the similar command and press enter in the command prompt

E.g. java –jar selendroid-standalone-0.15.0-with-dependencies.jar -aut selendroid-test-app-0.8.0.apk

Or java –jar selendroid-standalone-0.15.0-with-dependencies.jar

APK File: selendroid-test-app-0.8.0.apk

Note: When the above command is executed, make sure that the APK is signed and also the real device is connected to the PC and debugging is enabled over the device.

(Note: Click on the image for an enlarged view)

Command Console

Check the following points over command prompt to make sure the environment is ready for automation:

  • Verify for message “Device Specified with valid number”
  • Verify for message “server is started in default port say (4444)…”
  • Verify for message “Session being created…”

Again we can always reconfirm whether a server is started or not using the following URL over any of your web browsers.

e.g. http://localhost:4444/wd/hub/status

Confirmation of Server

#5) Inspecting the APK’s

  • We can use Real Apps by connecting real mobile devices
  • We can use any offline APK files downloaded

Selendroid Inspector is useful in debugging/inspecting the web elements of APK.

Once the device is identified and started we can view the APK (in virtual mode) and find the references, which is useful for writing the scripts, using the following URL over any of your web browsers.

E.g: http://localhost:4444/inspector

Here we have the screenshot of the application under test and we have the facility to inspect the element as well.

Or you can always use uiautomatorviewer to find the objects from the application under test.

The default path for this is mentioned below:


C:\Users\admin – This is the location where I have installed Android SDK’s but it can be different as per the location specified during its installation.

Selendroid Device

Writing First Script Using APK Files Over Real Devices


  • Start the server ( on default port say 4444)
  • Create a session
  • Install the application(.apk file) over the connected real device
  • Automate the text field with some data
  • Automatically click on the button
package SelendroidFirst;
import io.selendroid.client.SelendroidDriver;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import io.selendroid.common.SelendroidCapabilities;
import io.selendroid.common.device.DeviceTargetPlatform;
import io.selendroid.standalone.SelendroidConfiguration;
import io.selendroid.standalone.SelendroidLauncher;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.openqa.selenium.remote.*;
import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
import static org.openqa.selenium.remote.CapabilityType.PLATFORM;
import static org.openqa.selenium.remote.CapabilityType.VERSION;
public class RealDevices{

public SelendroidLauncher selendroidServer = null;
public WebDriver driver = null;
public void conf() throws Exception
SelendroidConfiguration config = new SelendroidConfiguration();
SelendroidLauncher selendroidServer = new SelendroidLauncher(config);

//**Creating capabilities**//
SelendroidCapabilities sc = new SelendroidCapabilities(); sc.setAut("io.selendroid.testapp:0.8.0");	

//**Instantiating new Selendroid driver**//
WebDriver driver = new SelendroidDriver(sc);

//**Sending data to the text field**//
driver.findElement("my_text_field")).sendKeys("Selendroid Test");

//**Clicking on the button**//


Selendroid is a very powerful automation test framework tool which can be used to test native, hybrid as well as a web app on any Android device as well as a simulator.

It supports Hotplugging, which means a user can have multiple devices tested at a time hence parallel test execution is possible across multiple devices. It supports various kind of interactions like long press, touch actions etc…

Only complexity with it is the environmental setup, which is also there in other frameworks. Once it is setup correctly then we can have our scripts running without any difficulties.

In part 2 of this Selendoid tutorial, we will cover – How to use Selendroid framework to automate the user interactions over a mobile application.

In our next article, we will discuss more on pCloudy Hands-on Review Tutorial.

Recommended Reading

2 thoughts on “Selendroid Tutorial: Android Mobile Test Automation Framework (Part 1)”

Leave a Comment