Appium: First Program

Table of contents
Reading Time: 2 minutes

Hello readers, welcome back. In this blog, we will do some hands-on with Appium and we will write our first Program. As we have already discussed what is Appium how it helps in application automation testing, what all other features of the Appium. But in this blog, we will only focus on how to start with our first program.

In our first program, we will try to install an apk and open that application on the emulator.
you can refer below code snippet as a reference for installing and opening an application on an android device.

import org.openqa.selenium.remote.DesiredCapabilities;

public class AppiumBasic {
    AndroidDriver driver;
    public void testAppium() throws MalformedURLException, InterruptedException {

File file = new File("/home/knoldus/Desktop/appium/apk/ApiDemos-debug.apk");

DesiredCapabilities capability  = new DesiredCapabilities();
 capability.setCapability("app", file.getAbsolutePath());        driver = new AndroidDriver(new URL(""), capability);


We can divide this code into two parts.

  1. Desired Capabilities.
    As we have already discussed that desired capabilities are required to set up the desired environment on the emulator like what app we want to test, on which device we want to test and all.
  2. Android Driver.
    The android driver helps us to connect with the server. Once we are invoking the android driver we need to pass two arguments with it.
    a. server link where Appium is running (here it is “”)
    b. Desired capability object.

apart from this, these are some prerequisites before running this code.

  • Make sure that the Appium server is started and running.
  • There should exist an emulator or real device on which we will test our application.
  • There should exist an app that we want to install and run on an emulator.


Written by 

Vandana is a Sr. QA Consultant having experience of more than 2.5 years. She is familiar with the core concepts of manual and automation, postman and Newman are her expertise. She is always eager to learn new and advance concepts in order to expand her horizon and apply them in project development with her existing knowledge. Her hobbies include reading novels and listening to music.