Appium Tutorial for Testing Android and iOS Mobile Apps

How to Install and Setup Appium on Windows with First Program to Get a Kick Start on Appium:

Appium is an open source and cross-platform tool that helps automate Mobile Apps testing – both Android and iOS Apps. Appium supports Native, Mobile and Hybrid Apps.

There are three types of Mobile Apps:

  • Native: Native apps built using the iOS, Android, or Windows SDKs. They are platform specific. They are built to work on a platform and/or device.
  • Hybrid: Hybrid apps are web applications developed using HTML, CSS, and wrapper of a native application on top of UIWebView for iOS and “webview” for Android Apps.
  • Mobile web apps: Mobile web apps are the apps ones accessed using mobile browsers.

Why is Appium a popular tool for automating Mobile Apps?

Appium is a “cross-platform tool” i.e. it allows you to write tests on multiple platforms (iOS, Android, Windows), using the same APIs. It is the most widely used tool for regression testing Mobile Apps on mobile phones and tablets.

Setting up the Appium Tool on Windows

Prerequisites: This is a short list of software and hardware required for automating a mobile App testing using Appium:

  • Your PC should have JDK, Appium Server, Eclipse, Android SDK installed
  • Apk: Mobile Application to be automated in our Case ContactManager.apk
  • Testing Device: In this case Moto G
  • Jars: Java-client jars and Selenium Jars.
  • USB driver for Testing Device: In this case Moto G

Step #1: Install the Java Development Kit (JDK)

Step #2: Set up Java Environment Variable Path

Step #3: Download and install Android SDK here and update the APIs

To update API, Open Eclipse -> Click on Window in the Eclipse Menu and -> Select Android SDK manager

Update the APIs as shown in the below Screenshot:

Step #4: Now we need to install Appium for Windows. Go here and download Appium for Windows.

Step #5: Install Node JS from here: Node JS download

Step #6: Set the ANDROID_HOME path as well as JAVA_HOME path

Specify the path for tools and platform-tool present in Android SDK path.

These folders would be present in adt-bundle-windows-x86_64-20140702\sdk

Now we need to update the Environment variable (Refer below Screenshot)

(Note: Click on any image for enlarged view)

Update path with tools and platform-tools (folder present in Android SDK).

The entry in Path will look as below:

C:\Program Files\nodejs\;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

Step #7:  Access adb

Press Win+R keys combination
Type CMD. Now in CMD type ‘adb’. adb will be accessible

Preparing Mobile Device for Automation with Appium

Connect your Mobile Testing device via USB to PC. Enable Developer Mode on Mobile Phone before automating the app.

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

1) Open Settings, Tap on ‘About’ Option, Tap on ‘Software Information’, Tap On ‘More’.

2) Tap on “Build number” 7 times to enable Developer options.

3) Go back to Settings and make sure that “Developer options” is there.

4) Tap on Developer options and turn on USB Debugging option from the menu on the next screen.

For more help follow this link.

5) Download and install USB Drivers for the Mobile Testing device on PC.

6) In adb terminal type ‘adb devices’
C:\Users\NEERAJ>adb devices
List of devices attached
TA93305G0L      device

This will display the list of devices connected to the system.We will be using App Contact Manager.apk as a sample App to automate. Download and install Contact Manager.apk on the device.

Starting  Automating Android App using Appium

Now run the appium.exe on PC.

Appium needs to be running and pass the following parameters and Device Name in Android Settings.

Note: Don’t change port number or anything in general setting icon. When Appium Server starts, the Server address, as well as Port address, will set by default. Port address will be 4723 by default

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

  • Connect your android phone to PC and turn on USB debugging mode.
  • Open Command prompt.
  • Type command adb logcat.
  • Open app on your android phone. Immediately press CTRL + C in command prompt is package name and is activity name of Contact Manager app.

In above screenshot, we have populated all the needed information in Appium i.e package, launch activity, Mobile Device Name.

How to Locate Element using UIAutomatorViewer?

1) To automate the App firstly we will need to find the elements of the app that we will need to interact
for that, we will use UIAutomatorViewer

2) Connect the device in which App is installed to PC

3) Go to Terminal.

Type ‘adb devices‘

C:\Users\NEERAJ>adb devices
List of devices attached
TA93305G0L      device

This will show the list of devices connected to your PC.

4) Open the App which you want to automate in Mobile Device.

5) Open UIAutomatorViewer and go to the following path


6) So making sure your App is launched and UIAutomaterViewer is launched click on Device screenshot.

7) This option will take the screenshot of the App with all the detailed information of all the elements visible on the App.

Click on Add contact Button for our Test Scenario

From above screenshot, we can use locator“Add Contact”)

From above screenshot we can take By.className(“android.widget.EditText”)) as our locator for Contact Name“Save”) can be used as our locator for Save Button

First program For automating an App on Appium

Run the below Script, Contact Manager application will be launched on the real device and all the logs will be displayed in the Appium console showing you the all the actions getting invoked by the above script.;;


public class appium {

 WebDriver driver;

 public void setUp() throws Exception {

//location of the app
 File app = new File("C:\\Users\\NEERAJ\\Downloads", "ContactManager.apk");
 //To create an object of Desired Capabilities
 DesiredCapabilities capability = new DesiredCapabilities();
//OS Name
 capability.setCapability(CapabilityType.BROWSER_NAME, "");
//Mobile OS version. In My case its running on Android 4.2
 capability.setCapability(CapabilityType.VERSION, "4.2");
 capability.setCapability("app", app.getAbsolutePath());
//To Setup the device name
 capability.setCapability("deviceName","Moto G");
//set the package name of the app
 capability.setCapability("app-package", "");
 //set the Launcher activity name of the app
 capability.setCapability("app-activity", ".ContactManager");
//driver object with new Url and Capabilities
 driver = new RemoteWebDriver(new URL(""), capability);

public void testApp() throws MalformedURLException{

System.out.println("App launched");
 // locate Add Contact button and click it
WebElementaddContactButton = driver.findElement("Add Contact"));;
 //locate input fields and type name and email for a new contact and save it
 List<WebElement>textFields = driver.findElements(By.className("android.widget.EditText"));
textFields.get(0).sendKeys("Neeraj Test");
 //insert assertions here


With Emerging Trend and more demand for Mobile Apps, all major companies are migrating to get their business on mobile apps. Thus to release the quality Mobile apps, automation Testing of Mobile Apps is the latest trend in the industry.

Appium, because of its simplicity and ease of use, is one of the leaders and most widely used tool all over the globe for performing Automation testing of Mobile Apps i.e. for iOS or Android.

About the author: This post is written by STH team member Neeraj. He is a passionate Software tester currently working as a Senior Software Development Engineer in Test and enjoys testing Web and mobile applications.

In our next article, we will discuss more on Mobile Automation Using Appium Studio Tool..

Recommended Reading

Last Updated: August 21, 2019 5:27 am