Appium Tutorial: 8 Easy Steps to Your First Mobile Test
A beginner-friendly Appium tutorial — install Appium and the UiAutomator2 driver, set up an Android emulator, inspect elements, write your first Java test, handle waits, gestures and run it in a framework.
Mobile apps are now the main product for banks, food delivery, fintech, ed-tech and e-commerce companies, and mobile automation testers are in steady demand across India. Appium is the most widely used open-source tool for automating Android and iOS apps. This Appium tutorial walks you through everything you need to run your first automated Android test in Java — setup, drivers, inspecting elements, writing the test and making it reliable.
If you already know Selenium WebDriver, you will feel at home: Appium uses the same W3C WebDriver protocol, so concepts like drivers, locators, waits and the Page Object Model carry over directly. If you do not, our Selenium WebDriver tutorial is a good warm-up.
Key takeaways
- Since Appium 2, the server and platform drivers are installed separately — for Android you install the UiAutomator2 driver.
- The default server URL is http://127.0.0.1:4723 — the old /wd/hub path is no longer needed.
- Prefer accessibility id and resource-id locators; use XPath only as a last resort.
- Use explicit waits and W3C/mobile gestures instead of the removed TouchAction class.
What is Appium and how does it work?
Appium is an open-source automation framework for native, hybrid and mobile web apps on Android and iOS (and, through additional drivers, other platforms). Your test code — written in Java, Python, JavaScript, C# or Ruby — sends WebDriver commands to the Appium server. The server passes them to a platform driver: UiAutomator2 for Android, built on Google’s UiAutomator framework, or XCUITest for iOS, built on Apple’s XCTest. The driver performs the action on the emulator, simulator or real device and returns the result.
A key advantage is that you test the same app build that users install — you do not need to recompile the app or add special code to it.
| Component | Purpose |
|---|---|
| Appium server | Receives WebDriver commands from your tests (Node.js app) |
| UiAutomator2 driver | Automates Android apps |
| XCUITest driver | Automates iOS apps (requires macOS and Xcode) |
| Client library | Language binding, e.g. io.appium:java-client for Java |
| Appium Inspector | GUI to view the app’s element tree and build locators |
Appium tutorial: 8 steps to your first Android test
Step 1: Install the prerequisites
- A current LTS version of Node.js (Appium is installed through npm).
- A recent JDK (17 or later is a safe choice) and an IDE such as IntelliJ IDEA or Eclipse.
- Android Studio, which provides the Android SDK, platform tools (adb) and the emulator.
- Environment variables: set ANDROID_HOME (or ANDROID_SDK_ROOT) to the SDK path and JAVA_HOME to the JDK, and add platform-tools to PATH.
Step 2: Install Appium and the UiAutomator2 driver
npm install -g appium
appium -v
appium driver install uiautomator2
appium driver list --installed
# start the server (default: http://127.0.0.1:4723)
appiumRecent Appium versions also include a doctor check per driver (appium driver doctor uiautomator2) that reports missing SDK paths or tools.
Step 3: Start an emulator or connect a device
In Android Studio open Device Manager, create a virtual device (for example a Pixel image with a recent Android version) and start it. For a real phone, enable Developer options and USB debugging, connect it and accept the debugging prompt. Confirm the device is visible:
adb devices
# List of devices attached
# emulator-5554 deviceStep 4: Get a practice app
The Appium project publishes a sample app, ApiDemos-debug.apk, in its GitHub repositories — it is widely used for practice. Place it in an apps folder inside your project. You can also automate any app already installed on the device by using its package and activity names.
Step 5: Inspect elements with Appium Inspector
Download Appium Inspector (a separate desktop app), point it at http://127.0.0.1:4723 and start a session with these capabilities:
{
"platformName": "Android",
"appium:automationName": "UiAutomator2",
"appium:deviceName": "Android Emulator",
"appium:app": "/path/to/apps/ApiDemos-debug.apk"
}Click any element on the screenshot to see its attributes — resource-id, content-desc (accessibility id), text and class — and Inspector suggests locators for you.
Step 6: Set up the Java project
Create a Maven project and add two dependencies: io.appium:java-client (latest 9.x, which brings Selenium 4) and TestNG. Use the latest stable versions from Maven Central.
Step 7: Write your first test
import io.appium.java_client.AppiumBy;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.*;
import java.net.URI;
import java.time.Duration;
public class ApiDemosTest {
private AndroidDriver driver;
private WebDriverWait wait;
@BeforeMethod
public void setUp() throws Exception {
UiAutomator2Options options = new UiAutomator2Options()
.setDeviceName("Android Emulator")
.setApp(System.getProperty("user.dir") + "/apps/ApiDemos-debug.apk");
driver = new AndroidDriver(URI.create("http://127.0.0.1:4723").toURL(), options);
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}
@Test
public void openViewsScreen() {
wait.until(ExpectedConditions.elementToBeClickable(
AppiumBy.accessibilityId("Views"))).click();
WebElement item = driver.findElement(AppiumBy.androidUIAutomator(
"new UiScrollable(new UiSelector().scrollable(true))"
+ ".scrollIntoView(new UiSelector().text(\"WebView\"))"));
Assert.assertTrue(item.isDisplayed());
}
@AfterMethod
public void tearDown() {
if (driver != null) {
driver.quit();
}
}
}With the server and emulator running, execute the test from your IDE. Appium installs the app, opens it, taps “Views”, scrolls to the “WebView” item and verifies it is displayed.
Step 8: Add waits, gestures and structure
Mobile screens load at different speeds on different devices, so rely on explicit waits rather than Thread.sleep. For gestures, the old TouchAction and MultiTouchAction classes were removed from recent java-client versions. Use the UiAutomator2 mobile commands or W3C Actions instead:
// Scroll down inside a screen area using a UiAutomator2 mobile command
driver.executeScript("mobile: scrollGesture", java.util.Map.of(
"left", 100, "top", 300, "width", 800, "height", 1200,
"direction", "down",
"percent", 1.0
));As tests grow, organise them with the Page Object Model: one class per screen, holding locators and actions, while test classes contain only steps and assertions. Keep capabilities in config files so the same suite can run on an emulator locally and on real devices in a cloud device farm such as BrowserStack or Sauce Labs. Version-control everything — see Git for testers.
Locator strategies compared
| Strategy | Example | Notes |
|---|---|---|
| Accessibility id | AppiumBy.accessibilityId(“Login”) | Fast, cross-platform; best choice |
| ID (resource-id) | AppiumBy.id(“com.app:id/login”) | Stable on Android if developers set ids |
| UiAutomator | AppiumBy.androidUIAutomator(…) | Powerful for scrolling and text matching |
| iOS predicate / class chain | AppiumBy.iOSNsPredicateString(…) | Fast native iOS options |
| XPath | AppiumBy.xpath(“//…”) | Flexible but slow and brittle; last resort |
Common beginner errors and fixes
- “Could not find a driver for automationName”: the UiAutomator2 driver is not installed — run appium driver install uiautomator2.
- ANDROID_HOME not set: set the variable in the same terminal where you start Appium, then restart it.
- 404 on session creation: remove /wd/hub from the URL unless you started the server with that base path.
- Element not found: add an explicit wait, and re-check the locator in Appium Inspector on the current screen.
For details on every driver and capability, use the official Appium documentation. If you are comparing web automation tools too, our Cypress tutorial covers the JavaScript side.
🚀 Looking for mobile testing jobs?
QA Jobs India shares 100+ fresh QA & software testing openings every morning — manual, automation, mobile, API and remote roles.
See today’s QA jobs →FAQs
Is this Appium tutorial valid for iOS?
The concepts are the same, but iOS needs a Mac with Xcode and the XCUITest driver (appium driver install xcuitest), plus extra signing setup for real devices.
Do I need to know Selenium before Appium?
It helps a lot, because Appium uses the same WebDriver concepts, but it is not strictly required.
Can Appium test mobile web and hybrid apps?
Yes. It can automate mobile browsers like Chrome on Android and switch between native and WebView contexts in hybrid apps.
Emulator or real device for testing?
Use emulators for daily development and fast feedback, and real devices (or a device cloud) before release to catch hardware and OEM-specific issues.
Which language is best for Appium?
Java is the most common in Indian job descriptions, followed by Python and JavaScript. Choose the language your team or target companies use.
Conclusion
You have now completed a full Appium tutorial: installing the server and driver, starting an emulator, inspecting elements, writing a Java test, and making it reliable with waits, gestures and good structure. Next, automate three or four real flows of a sample app, add reports and push the project to GitHub — that portfolio will make your mobile automation resume stand out. Then check today’s QA jobs for Appium openings.
- 100+ fresh QA jobs daily + Direct HR email IDsLive every morning at 9 AM — apply straight to HR
- Weekly Mega Job Fair800+ QA jobs from India & around the world, every week
- Certified QA coursesUp to 17 courses, with certificate
- AI ATS Resume BuilderFree resume points included
- Full LinkedQA feedEvery post, fully unblurred
- Complete QA Material libraryInterview Q&A, cheat sheets, templates & roadmaps
Instant activation right after payment · One login for jobs, courses, resume & LinkedQA
💎 Get every QA opening, every day
Join QA Jobs India Premium for 100+ verified QA jobs daily with HR contact details.