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.

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 You Will Learn:

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?

A simple 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(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.

Note down the SDK Path while installing.

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

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

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


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

#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.


#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)

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

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

#5) Inspecting the APK’s

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.

Writing First Script Using APK Files Over Real Devices


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.

Please share your comments, questions, and thoughts below.