Delivered by FeedBurner

Run Appium Android Automation Test In Emulator

Earlier we learnt how to run android automation test in real android device using appium as described in THIS POST. So I am suggesting you to read It before running appium test in AVD. Also you can run appium test on android emulators (Android virtual device). We will learn how to run first appium test in android emulator in this appium tutorial post. We will use android emulator's build in installed calculator app to create and run appium automation test. Let's start it.

  1. All previous 16 steps of appium tutorial given on this LINK and this LINK should be completed without any error.
  2. Android emulator should be created.
  3. TestNG should be installed in eclipse. View THIS POST.
1. Start Appium Node Server
Start appium node server as described in THIS POST.

2. Start Android Virtual Device (Emulator)
Once appium starts properly, You need to launch android virtual device as described in THIS POST.

3. Get Emulator Platform Version
Also you need to provide android emulator platform version. You can get it as described bellow.
  • Unlock Android emulator screen.
  • Go to Settings. You will find About Phone under settings.
  • Go to About Phone.

  • It will show you Android version as shown in bellow image. For me it is 5.1

Note down android version for your emulator.

4. Verify calculator App Is Available In Emulator 
We are going to run appium test for calculator application so it should be there in emulator. Generally calculator app will be already installed in emulator. To check if it is installed or not,
  • Unlock emulator.
  • Verify if there is any application with name Calculator as shown in bellow image. You can download Android Calculator App from THIS PAGE if it is not available with you.

5. Get app Activity and Package Name
We need launcher activity and package name of calculator app. You can use any of the method from THIS PAGE or THIS PAGE to get activity and package name of calculator app.

Activity and package name of calculator app for me is as bellow.
Package name :
Activity name :

6. Create Appium Test Script In Eclipse
Now we are ready to create and run our first appium test on android emulator for calculator application. I have prepared appium test script as bellow. I have used RemoteWebDriver of selenium webdriver to launch app with required capabilities.

Create new class file under Android package in eclipse with name SimpleEmulatorCalcTest and paste bellow given test script in it.
package Android;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;

public class SimpleEmulatorCalcTest {

 WebDriver driver;

 public void setUp() throws Exception {

  // Created object of DesiredCapabilities class.
  DesiredCapabilities capabilities = new DesiredCapabilities();

  // Set android deviceName desired capability. Set it Android Emulator.
  capabilities.setCapability("deviceName", "Android Emulator");

  // Set browserName desired capability. It's Android in our case here.
  capabilities.setCapability("browserName", "Android");

  // Set android platformVersion desired capability. Set your emulator's android version.
  capabilities.setCapability("platformVersion", "5.1");

  // Set android platformName desired capability. It's Android in our case here.
  capabilities.setCapability("platformName", "Android");

  // Set android appPackage desired capability. It is for calculator application.
  // Set your application's appPackage if you are using any other app.
  capabilities.setCapability("appPackage", "");

  // Set android appActivity desired capability. It is for calculator application.
  // Set your application's appPackage if you are using any other app.
  capabilities.setCapability("appActivity", "");

  // Created object of RemoteWebDriver will all set capabilities.
  // Set appium server address and port number in URL string.
  // It will launch calculator app in emulator.
  driver = new RemoteWebDriver(new URL(""), capabilities);
  driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

  // Click on CLR button.

  //OR you can use bellow given syntax to click on CLR/DEL button.

  // Click on number 2 button.

  // Click on + button.

  // Click on number 5 button.

  // Click on = button.

  // Get result from result text box of calc app.
  String result = driver.findElement(By.className("android.widget.EditText")).getText();
  System.out.println("Number sum result is : " + result);

Running First Appium Test In Emulator
Now we are ready to run appium test for calculator app in emulator. 

Note : Please make sure appium node server and emulator are launched and appium server is started by pressing start button.

Run test using testng and observe test execution in android emulator. It will 
  • Open calc app in emulator.
  • Tap on calc app's buttons in this sequence -> CLR, 2, +, 5 and =.
  • Get result from text area of calculator app.
  • Print result in eclipse console.
This way you can run appium test in android emulator.


  1. its superb tutorial..thanks a lot for giving such a understandable instruction..thank you

  2. This comment has been removed by the author.