
πSelendroid Tutorial for Beginners
Table of Contents
- What is Selendroid?
- Why Use Selendroid for Android Testing?
- Selendroid Architecture
- Getting Started with Selendroid
- How to Launch Selendroid
- Selendroid Basic Commands
- Create Your First Selendroid Test Script
- Summary
π What is Selendroid?
Selendroid Tutorial for Beginners: Selendroid is a powerful test automation framework designed for native, hybrid, and mobile web Android applications. It supports writing test cases using Selenium 2 client APIs and integrates smoothly with existing Selenium infrastructure. Selendroid can run on both real devices and emulators, making it a versatile tool for mobile automation.
π Why Do We Need Selendroid?
Selendroid Tutorial for Beginners: Selendroid comes packed with advanced features:
- No app modification required for testing.
- Tests can run across multiple devices simultaneously.
- Simulates real-user interactions: touch, swipe, drag & drop.
- Supports Android API versions from 10 to 19.
- Hot plug-in support for devices without restarting the server.
- Built-in Selendroid Inspector Tool for identifying UI elements.
π Selendroid Architecture Overview
Selendroid Tutorial for Beginners: Selendroid consists of four main components:
- WebDriver Client β Based on Selenium Java Client API.
- Selendroid-Server β Embedded in the app under test.
- Android Driver App β Tests web view content in mobile browsers.
- Selendroid-Standalone β Handles server setup and app installation.
Selendroid relies on Android’s Instrumentation framework and Seleniumβs WebDriver API for seamless integration.
π Getting Started with Selendroid
βοΈ Prerequisites:
- Java JDK (1.6 or higher)
- Android SDK (with AVD or real device)
- Selendroid Standalone & Selendroid Client
- Selenium WebDriver Libraries
- Eclipse IDE
System Environment Variables:
Selendroid Tutorial for Beginners: Set up environment paths:
- JAVA_HOME β Java SDK path
- ANDROID_HOME β Android SDK path
Update the system PATH variable accordingly and restart your PC.
π How to Launch Selendroid
- Download the sample app (APK) and Selendroid standalone JAR.
Run Selendroid in terminal:
bash
java -jar selendroid-standalone.jar
- The server starts on port 4444 by default.
Check device status:
bash
http://localhost:4444/wd/hub/status
Selendroid scans for connected Android devices and recognizes their configurations automatically.
π Selendroid Basic Command Line Options
Parameter | Description |
-port [port#] | Change default port (default: 4444) |
-app [path] | Set path to APK under test |
-selendroidServerPort [port#] | Change communication port (default: 8080) |
-timeoutEmulatorStart [ms] | Set timeout for emulator start (default: 300,000 ms) |
-logLevel [level] | Set log verbosity (ERROR, INFO, DEBUG, etc.) |
π Create Your First Test Script Using Selendroid
Test Scenario:
- Selendroid Tutorial for Beginners: Launch
- Enter text
- Press βShow Textβ button
- Verify output matches entered text
Setup Project in Eclipse:
- Create Java Project
- Add external JARs:
- selendroid-client-0.10.0.jar
- selendroid-standalone-0.11.0-with-dependencies.jar
- selenium-java-2.40.0.jar
- selendroid-client-0.10.0.jar
- Install TestNG plugin in Eclipse
- Create Java class .java in package com.guru.test
Get App ID and Element Locators:
Launch the Selendroid Inspector:
bash
http://localhost:4444/inspector
Use the inspector to get the following element IDs:
- Button: btnShow
- TextField: edtText
- Label: txtView
β Sample Code Snippet (Test Execution):
java
driver.findElement(By.id(“edtText”)).sendKeys
driver.findElement(By.id(“btnShow”)).click();
Thread.sleep(2000);
String actualText = driver.findElement(By.id(“txtView”)).getText();
Assert.assertEquals(actualText, “
π Run the Selendroid Test
- Connect your Android device (ensure no screen lock).
- Run the test from Eclipse β Run As > TestNG Test.
- View TestNG report for results.
π Test Report
After execution, TestNG will automatically generate a detailed test report including passed/failed test cases and logs.