Skip to main content

Appium and Android setup

Back to Appium Tutorial Index

Android Requirements
  • Android SDK API >= 17 (Additional features require 18/19)
  • Appium supports Android on OS X, Linux and Windows. Follow these directions for setting up your environment properly for testing on different OSes:
Android setup does not differ greatly on different operating system. Let’s look at detailed setup instructions for Ubuntu  -

Installing Appium app on MAC or Windows 

Installing Appium on Ubuntu  -

Install node.js (v0.10 or greater) -

Since appium server is written in node.js, first node.js needs to be installed. Following this appium can be installed from npm -

Setup with Ubuntu: curl -sL | sudo bash -
Then install with Ubuntu: sudo apt-get install -y nodejs

DON’T install node js using above method, it would result in following error when starting appium -
error: Appium will not work if used or installed with sudo. Please rerun/install as a non-root user. If you had to install Appium using `sudo npm install -g appium`, the solution is to reinstall Node using a method (Homebrew, for example) that doesn't require sudo to install global npm packages.

To fix it -

  • Download latest nodejs linux binaries (or windows, mac if you are not on linux) form
  • Extract into a folder that doesn't need sudo rights to access, for example your home folder.
tar -xvf <downloaded_binary_tar.gz>
{extracted file looks as following in my home directory -
  • Add the following line to your ~/.bashrc file.
export PATH=$PATH:<full_path_of_the_extracted_node_folder>/bin

appium is installed in bin folder and updating path would let you execute appium from command line as described later -
refresh bashrc so you don’t have to logout and login -
source ~/.bashrc
  • Open a new terminal and execute
npm install -g appium
    {appium installation looks as following on my ubuntu -
  • Now start appium as -
cd /home/tarun/node-v0.12.2-linux-x64/bin
If everything goes right then you would have appium server up and running as following  
info: Welcome to Appium v1.3.7 (REV 72fbfaa116d3d9f6a862600ee99cf02f6d0e2182)
info: Appium REST http interface listener started on
info: Console LogLevel: debug

Install Android SDK

  • If you are using Android Studio then you can set up Android Virtual Device from AVD under Tools > Android > AVD Manager as following - 

  • Install android sdk from -

Unpack the .zip file you've downloaded. The SDK files are downloaded separately to a user-specified directory

By default, Android SDK does not include everything required to start development. The SDK separates tools, platforms, and other components into packages that can be downloaded as needed using the Android SDK Manager. Hence we must first download a few packages and add to Android SDK.
  • Downloading additional packages and latest SDK tools. launch the Android SDK Manager.
Open a terminal and navigate to the tools/ directory in the location where the Android SDK was installed, then execute android sdk.
For ex it looks as following on my ubuntu -
cd /Documents/mine/lib/android-sdk-linux/tools$
./android &

  • As a minimum when setting up the Android SDK, you should download the latest tools and Android platform:
    1. Open the Tools directory and select:
      • Android SDK Tools
      • Android SDK Platform-tools
      • Android SDK Build-tools (highest version)
    1. Open the first Android X.X folder (the latest version) and select:
      • SDK Platform
      • A system image for the emulator, such as ARM EABI v7a System Image
  1. AndroidTools.png
3. Get the support library for additional APIs
The Android Support Library provides an extended set of APIs that are compatible with most versions of Android.
Open the Extras directory and select:
    • Android Support Repository
    • Android Support Library
  • AndroidTools.png
  • Once you've selected all the desired packages, continue to install:

  1. Click Install X packages.
  2. In the next window, double-click each package name on the left to accept the license agreement for each.
  3. Click Install.

The download progress is shown at the bottom of the SDK Manager window. Do not exit the SDK Manager or it will cancel the download.

Creating new emulator
Android emulator can be created from command line or using AVD (Android Virtual Device manager). AVD can be launched from Android SDK Manager as following -
Android SDK Manager > Tools > Manage AVDs  - launches Android Virtual Device (AVD) manager
You can create a new device or select any of the existing Device Definitions, for example select Nexus 5 by Google and click Create AVD button

Select Target, CPU/ABI, Skin and click ok to set up new virtual device. When you click Ok then device would be listed under “Android Virtual Devices” tab -

Select device > click Start button and Launch the device. This would launch Android emulator -

NOTE: if Android emulator opens a blank screen then select Emulation Options > Use Host GPU and start emulator again. This would also increase the emulator performance drastically.

Setup ANDROID_HOME variable

Finally, set $ANDROID_HOME to be your Android SDK path. This looks as following on my ubuntu -
  • export ANDROID_HOME=/home/tarun/Documents/mine/lib/android-sdk-linux
  • export PATH=$PATH:/home/tarun/Documents/mine/lib/android-sdk-linux/tools

  • and then execute source ~/.bashrc
Install Android Debug Bridge (adb) -
Execute following command to install adb on Ubuntu -

sudo apt-get install android-tools-adb

and following for mac - 

  1. brew install android-platform-tools

Android Debug Bridge (adb) is a command line tool that lets you communicate with an emulator or android device. It is a client-server program and includes three components:
  • A client, which runs on development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients. For example if you want to see list of emulator/devices running then execute following command -
adb devices
  • A server, which runs as a background process on development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
  • A daemon, which runs as a background process on each emulator or device instance.
Refer ADB for more on this topic.

You can find the adb tool in <sdk>/platform-tools/ directory. It is available on following directory on my linux - /home/tarun/Documents/mine/lib/android-sdk-linux/platform-tools

Appium Inspector

If you installed appium on OSX or Windows using appium binary then you can use appium inspector to inspect to inspect app. Appium inspector has two functions - 
  • Inspect elements in app
  • Enable record and playback

Appium inspector does not work very well with android. Appium encourages to use uiautomatorviewer. An inspector tool from Google which is same as Appium inspector. You can find information on this here

Before using UIAutomatorViewer you should shut down appium as appium uses UIAutomatorViewer internally and this will prevent UIAutomatorViewer from working.
Once you have android SDK installed then you can start UIAutomatorViewer from command line - 


This would start UiAutomatorViewer as - 

Now open the app (for example calculator) in emulator or device and click on Device Screenshot (uiautomator dump) in the UIAutomatorViewer menu.
Following this you would see the snapshot of application in UIAutomatorViewer as - 

Now you can analyze the app element by hovering mouse on them. Mousehover would highlight the element in red circle in UIAutomatorViewer and would detail down the hierarchy in RHS. 

Popular posts from this blog

Distributed Load Testing with JMeter

Distributed Testing with JMeter When one JMeter client is not able to offer amount of threads required for load testing then distributed testing is used. In distributed testing - One instance of JMeter client can control number of JMeter instances and collect data from them Test plan does not need to be copied to each server, the client sends it to all servers note - JMeter will run all the threads on all the servers, hence 100 threads on 5 JMeter server would pump 500 threads in total. If many server instances are used, the client JMeter can become overloaded and so the client network connection. This has been improved in latest versions of JMeter by switching to Stripped modes, but you should always check that your client is not overloaded When Client (master) and Server (slave) nodes are on same network (no SSH required) Configure Client Node Herein client is referred as the machine controlling test execution on other JMeter nodes. This is also referred

Appium and android mobile app automation

Next appium and Android mobile app automation video tutoria l is live. If you are new to appium then please check - appium-tutorial This video tutorial covers - Start vysor (Just for this session and not mobile automation :)) Start appium and start appium inspector Desired Capabilities platformName - Android deviceName - L2N0219828001013 (as seen on "adb devices") Saved Capability Sets Start Session Scan app elements using appium inspector Get appPackage and appActivity using "APK info" app Install "APK info" app and open app whose appPackage and appActivity are required i.e. calculator Check top section of app icon is app package is app activity testng.xml file settings for running Android app tests Test details and CalculatorScreen class View beautiful STF test report  

Verify email confirmation using Selenium

Note: If you are new to java and selenium then start with selenium java training videos .     Email confirmation seems to be integral part of any registration process. I came across an application which lets you provide your email address. You can follow the sign up link in you mail and then complete the registration process. Lets consider we provide GMail address for it. Now if were to use only Selenium then we would have to follow following steps - Launch GMail using Selenium; Some how search for new mail in the list of available mails; Some how click on it; Parse the mail message; Get the registration link; Follow up with registration process What do you think of an approach in which you can