top of page

Create First Appium Test

How To Create First Test Using Appium ?

To create a test in appium here are some steps :

  • Create a Maven Project.

  • Add dependencies in pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">


  • Create a package in src/test/java as 'appiumexamples'.

  • Create a testng class within this package.

  • To inspect a web element :

    • Launch the emulator.

    • Go to the desired mobile page.

    • Now,start Appium Server.

    • Click on Search icon.

    • It will open a session window.

    • Add Desired capabilites as shown in the image :

    • Start session.

    • A window will be opened that contains the mobile screen view of the emulator.

    • Right-click on this mobile screen view and click on Inspect Element.

    • Locate the webelement.

  • To know the udid of device :
    • Run command 'adb devices' on command prompt.
    • It will show a list of attached emulator.
    • The integers written next to emulator is its udid.

  • Add below lines of code in testng class :

package appiumexamples;

import org.testng.annotations.Test;

import io.appium.java_client.MobileElement;

import org.testng.annotations.BeforeClass;


import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterClass;

public class FirstAppiumTest {
   AndroidDriver<MobileElement> driver;
   @FindBy(xpath = "//*[@text='AUTHENTICATE']")
   WebElement authenticationButton;

   public void firstAppiumTest() {;

   public void startSession() throws MalformedURLException {
       DesiredCapabilities caps = new DesiredCapabilities();
       caps.setCapability("deviceName", "Pixel 3 API 28");         
// device Name
       caps.setCapability("udid", 5554);                                         // DeviceId from "adb devices" command
       caps.setCapability("platformName", "Android");
       caps.setCapability("skipUnlock", "true");
       caps.setCapability("app","C:\\Users\\Dell\\appiumProject\\AndroidAppium\\src\\main\\resources\\apk\\cleardil_sdk_android_example_1.0.0.apk");caps.setCapability("noReset", "false");
       driver = new AndroidDriver<MobileElement>(new URL(""), caps);

   public void closeSession() {


  • Launch the emulator.

  • Start the Appium Server.

  • Run as 'TestNG Test'.

appium session.png
bottom of page