Appium Tool for Automation Testing of Android Apps on an iOS System

Appium is an open source test automation tool used for testing mobile applications. It allows users to test various types of mobile applications (such as Native, Hybrid and Mobile Web) using standard WebDriver library.

Using Appium, you also run automated tests on actual devices like tablets, mobile phones etc. Appium makes mobile app regression testing easy; especially, for large mobile apps that  are updated frequently with new features and functionalities.

Most testing professionals prefer Windows platform for Appium testing and there is enough help on the web on this topic. However, this Appium tutorial will help you automate android apps on an iOS system for which little documentation is available.

The article is divided into three sections:

  1. The first section explains the software required for the task
  2. The second is the setup on the device and
  3. Finally, the procedure to run the automation tasks on the device

Setup Appium with Eclipse IDE:

Software Required for Appium:

  • JDK, Appium Server, Eclipse, Android SDK
  • Jars: java-client jars and Selenium Jars.
  • Apk: Application to be automated
  • Real Device: In this case SAMSUNG Note3
  • USB driver for Real Device: In this case SAMSUNG Kies

Step 1: Install the Java Development Kit (JDK)

Step 2: Setup Java Environment Variable Path

Go to the Terminal and type:
Open .bash_profile

Set the ANDROID_HOME Path as well as JAVA_HOME Path

Step 3: Install Android SDK / ADB on MAC

We need to install Tools, Extras and corresponding API Level packages (in this  case Android 4.4.2 API 19).

(Note: Click on any image for enlarged view)

Step 4: Download and install Appium Server

Note 1: No need to set anything in general setting icon. When Appium Server is installed, the Server address as well as Port address will be set by default. Port address will be 4723. The user can change server address if required.

Note 2: In Android Setting, the user needs to set APK path where the APK is located, Check app path, package and launch Activity.

How to Find .Apk File Package Name and Launcher Activity Name:

There are so many ways to find out Package name and Launcher Activity Name of an application. Here terminal is used to get Package and Launcher Activity name.

Go to terminal and type:

aapt dump badging <apk_File_Path><apk_File_Name.apk>

Hit “Enter” for the below screen:

If a user specifies package name in Appium Server, then Launcher Activity Name, wait for Activity names to be displayed automatically.

In this case Launcher Activity Name is:”

Steps to Enable Developer Mode / Options on Android Phone or Tablet

Step 1: Enable Developer Options

1) Tap on the Main Menu icon.

2) Go to Settings.

3) Scroll down to ‘About phone‘ and tap on it.

4) Scroll down to the bottom, tap on ‘Build number’ Seven (7) times. (Your build number may vary). After the third tap, the user can see a playful dialog “You are a developer”. Keep on tapping until the dialog is displayed.

5) You can notice the Developer Options on your screen now.

Step 2: Switch On USB Debugging

1) Go to Developer Options.

2) Select USB Debugging.

3) It may display the Pop Up message and if it does, simply click OK.

Step 3: Download and install USB Driver for Corresponding Real Device. In this case SAMSUNG Kies.

How to Locate Element using UIAutomatorViewer?

1) The first step before locating any element on the device is to connect the device to the computer.

Follow the below steps to check the device connectivity:

  • Go to Terminal.
  • Type ‘adb devices

This will display the list of devices connected to the system.

2) On the real device, open the app that has to be automated (Here amazon app is automated)

3) Go to the following directory to open UIAutomatorViewer:

Users -> Library -> android -> sdk -> tools -> uiautomatorviewer.bat

EX: users/bikram.badatya/Library/Android/sdk/tool/

4) In UIAutomatorViewer, click on Device screenshot.

5) On clicking Device screenshot, device image along with the detailed information will be displayed on the left side of the UIAutomator window.

6) On clicking any element in the page, relevant information about that element will be displayed on the right side.

7) Click on Main Menu button to display all properties.

Appium Test to Launch Amazon App

1) Launch Appium Server.

2) Android Settings.

3) General Settings for Server Address and Port address:

4) Click on the launch button.

Code snippet to launch Amazon Application:

package com.AppiumDemo;

//Library to create the path to APK
//Library used to verify if URL is malformed

//Library used to create URL for the Appium server

import java.util.concurrent.TimeUnit;

//Libraries for import selenium WebDriver
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

//Libraries for configuring Desired Capabilities
import org.openqa.selenium.remote.DesiredCapabilities;

//Library for import TestNG
import org.testng.annotations.Test;

//Libraries for import Appium Drivers
import io.appium.java_client.MobileElement;

public class LauchAmazon {
 private static AndroidDriver<MobileElement> driver;
  //static WebDriver driver;
  public void setup() throws MalformedURLException, InterruptedException{
   // Path to <project folder><Amazon>
   File appDir = new File("//Users//bikram.badatya//Library//Android//sdk//platform-tools//");
   //Path to <project Folder> to  Amazon apk File>
   File app = new File(appDir, "Amazon.apk");
   //To create an object of Desired Capabilities
   DesiredCapabilities capabilities = new DesiredCapabilities();
   //To set Command Timeout in appium server.Its optional you can set in appium Server itself.
         capabilities.setCapability("newCommandTimeout", 100000);
         // Name of the OS: Android, iOS or FirefoxOS
      capabilities.setCapability("platformName", "Android");
      //set the name of the connected have to give same name in both server and the code
      //Mobile OS version. My device is running Android 4.4.2
      //set the package name of the app 
      capabilities.setCapability("appPackage", "");
      //set the Launcher activity name of the app
      capabilities.setCapability ("appActivity","");
      // Name of mobile web browser to automate. It should be an empty string, as we are automation an app.
      capabilities.setCapability("browserName", "");
      //driver object with new Url and Capabilities
   driver = new AndroidDriver<MobileElement;(new URL(""), capabilities);
      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);     
      driver.findElement(By.xpath ("//android.view.View[@content-desc='Hello.Sign inSign inHello. Link']")).click();
      driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);      
      driver.findElement(By.xpath ("//android.widget.EditText[@index='0']")).sendKeys("");
      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
      driver.findElement(By.xpath ("//android.widget.EditText[@bounds='[101,188][499,231]']")).sendKeys("yyyzzz");
      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);     
      driver.findElement(By.xpath ("//android.widget.Button[@content-disc='Submit']")).click();     

When the above Script is executed, Amazon application will be launched on the real device and a list of messages will be displayed in the Appium console.

Important commands:

1) To kill adb server:

adb kill-server

2) To start adb server:

adb start-server

3) To set JAVA_Home Path as well ANDROID_Home Path

open .bash_profile

4) To get package name and android Launcher name in apk (another way)

aapt dump badging <path to the apk>.apk name

Ex- aapt dump badging

5) To install apk in real device

adb install <apk path>.apk name

6) To uninstall apk in real device

adb uninstall <app_package_name>
Exadb uninstall

Limitations of Appium:

  • It does not support Android API level less than 17
  • Toast messages are not supported
  • Script execution on IOS platform is very slow
  • Gestures support is limited

Challenges faced while working with Appium:

#1) To get the launcher activity name, which is required to launch the application, many methods can be followed like an extra apk named “apkInfo” needs to be installed, certain lines of code have to be written etc .But, in this document, the following command is used to get the launcher activity name.

i.e. aapt dump badging <path to the apk>.apk name

#2) During setup in android SDK manager we need to focus on the following packages that have to be uninstalled. Otherwise, application will not launch

#3) Especially on MAC we need to setup Java_HomePath and Android HomePath in .bash_profile so that it is not required to setup again and again.

#4) Launching the application using Emulator consumes more time compared to a real device. Hence, use of a real device is recommended.


Everybody knows how mobile devices and their applications are increasing. These mobile applications work on multiple platforms. Appium is a very good tool for mobile automation. Lots of organizations prefer it for its simplicity, ease of use and robustness.

Personally, I have worked with it and I am satisfied.

About the author: This is a guest post written for STH by Bikram Badatya and reviewed by Vivek Babu Gondi (QA Manager).

If you have any questions about this Appium tutorial, feel free to post in comments below.

Recommended Reading

Last Updated: August 21, 2019 5:28 am