Home » appium-tutorial » First Appium Test to Launch Flipkart

Newly Updated Posts

First Appium Test to Launch Flipkart

Previous Topic, In this tutorial we will learn to write our First Appium Test to Launch Flipkart.

How to write First Appium Test to Launch Flipkart?

Before writing script , we need to launch Appium server first, below are the steps to launch server.

Step 1) Open the Appium server.

Launching appium server

Let keep the host=”″ and port “4723” as it is( default).

Step 2) Click to Start Server button and the server will get start working with default host number and port number.

First Appium Test to Launch whatsapp

Step 3) Now copy the below code and paste in a class inside the eclipse ide.

package code2test.MavenAppiumProject;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;

public class Harness {

public AndroidDriver<AndroidElement> adriver;		
public void openapp(){
System.out.println("Opening App");
File app =new File(System.getProperty("user.dir")+"\\apks\\Flipkart-7.3.apk");
DesiredCapabilities capabilities =new DesiredCapabilities();
capabilities.setCapability("platformVersion","9 PKQ1.181203.001");
capabilities.setCapability("app", app.getAbsolutePath());		
try {
adriver = new AndroidDriver<AndroidElement>(new URL(""), capabilities); 
   } catch (MalformedURLException e) {

Assert.fail("Driver failed to start" + e.getMessage());
adriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);							
public static void main(String[] args) {
Harness flipDriver=new Harness();

Code Inside Eclipse will look as below:

First Appium Test to Launch Flipkart application

Step 4) Now run the code by right click to code Run->Run As->Java Application.

Step 5) In few minutes of time we see that the flipkart application in mobile gets opened.

Code explanation step by step:

//Code to provide the path of Flipkart APK in system

File app =new File(System.getProperty(“user.dir”)+”\apks\Flipkart-7.3.apk”);

Desired Capabilities:

DesiredCapabilities capabilities =new DesiredCapabilities(); // Creating object for desired capabilities.

// Defining the name of your device

//Defining the name of mobile browser as empty

// Defining the platform version of the device
capabilities.setCapability(“platformVersion”,”9 PKQ1.181203.001″);

//Defining Name of the platform, as Android

//defining the mobile to open in noReset

//Defining the capability to not re-install application

capabilities.setCapability(“appPackage”,”com.flipkart.android”); // defining the application packackage of Flipkart

//Defining application activity of flipkart

//Defining the file path in one statement and retuning a String
capabilities.setCapability(“app”, app.getAbsolutePath());

try {
// Creating the object of android driver and passing host and port number and capabilities to it
adriver = new AndroidDriver<AndroidElement>(new URL(""), capabilities); 
   } catch (MalformedURLException e) {

Assert.fail("Driver failed to start" + e.getMessage());

So following the below steps, we now able to create and execute the appium script to launch flipkart application and other application too.



  1. Thank you for the code and i am new to this but i wanted to automate some things but am finding it really hard for the apps i want to automate..is there any way i can reach you for some help

Comments are closed.