Back to cheat sheets

Test Frameworks

Appium

Cross-platform mobile automation: client/server architecture, platform drivers, capabilities, locator strategies, waits, gestures, native-vs-webview contexts, and Page Object Model — with rapid-fire Q&A.

Now playing: Appium

Appium

Two-host episode · 14:32

0:0014:32
 Download

Now playing: Appium

Appium

Mock interview · 9:58

0:009:58
 Download

01Architecture

Appium automates native, hybrid, and mobile-web apps on Android and iOS from a single API. It is an HTTP server written in Node.js that exposes the W3C WebDriver protocol — the same protocol Selenium speaks — so your existing WebDriver client (Java, Python, JS, C#, Ruby) drives a phone the way it drives a browser.

Client → W3C WebDriver (HTTP/JSON) → Appium server → platform driver → vendor automation framework → device/emulator. The cross-platform promise lives in one layer: your test talks to Appium, and Appium delegates to whatever the OS provides.

The key idea is delegation. Appium itself doesn't know how to tap a button on iOS — it forwards the command to Apple's own XCUITest framework. On Android it forwards to Google's UiAutomator2. Appium is the universal translator; the vendor frameworks do the real driving.

02Platform Drivers & Appium 2.0

A driver is the plugin that bridges Appium to a specific platform's automation engine:

  • UiAutomator2 — the default and recommended Android driver (wraps Google's UiAutomator2).
  • XCUITest — the iOS driver (wraps Apple's XCUITest).
  • Espresso — alternative Android driver, faster and in-process, but Android-only.
  • Mac2 / Windows / Flutter — desktop and framework-specific drivers.
Appium 2.0 changed the packaging model: drivers and plugins are decoupled from the core server and installed on demand — appium driver install uiautomator2. The server ships lean; you add only the drivers you need. The default base path also moved to / (Appium 1.x used /wd/hub).

03Capabilities (Appium Options)

A test session is configured with capabilities — key/value pairs telling Appium what to automate. Vendor-specific keys carry an appium: prefix under W3C.

Cross-platform

platformName (Android / iOS), appium:automationName (UiAutomator2 / XCUITest / Espresso), appium:deviceName, appium:platformVersion, appium:udid (a specific real device), appium:app (path/URL to the .apk/.ipa).

Android-specific

appium:appPackage and appium:appActivity identify an already-installed app to launch without reinstalling.

iOS-specific

appium:bundleId identifies an installed app; real devices also need signing via appium:xcodeOrgId and a provisioning team.

app vs appPackage/bundleId: use app to install a fresh build; use appPackage/appActivity (Android) or bundleId (iOS) to launch an app already on the device.

04Locator Strategies

Order of preference favors stability and cross-platform reuse:

  • accessibility id — best choice: maps to Android content-desc and iOS accessibilityIdentifier, so one locator can work on both platforms.
  • id — Android resource-id; fast and stable when present.
  • -android uiautomator — runs a native UiSelector query on-device (powerful, fast).
  • -ios predicate string and -ios class chain — native iOS queries, far faster than XPath.
  • class name — element type (android.widget.Button, XCUIElementTypeButton).
  • xpath — works everywhere but is the slowest and most brittle; the whole UI tree is serialized and searched on every query.
Interview favorite: prefer accessibility id for cross-platform locators; avoid XPath on mobile because resolving it walks the entire native element tree and is dramatically slower than on the web.

05Waits & Flakiness

Because Appium is WebDriver-based, the synchronization story mirrors Selenium — and is just as central to interviews.

Implicit Wait

A global timeout applied to every element lookup. Blunt; can mask real timing issues.

Explicit Wait

WebDriverWait + ExpectedConditions on a specific element/condition — the recommended approach.

Never mix implicit and explicit waits (unpredictable cumulative timeouts), and avoid hard sleeps. Mobile adds its own flake sources: animations, slow app launch, network on real devices, and emulator warm-up.
new WebDriverWait(driver, Duration.ofSeconds(15))
    .until(ExpectedConditions.elementToBeClickable(
        AppiumBy.accessibilityId("submit")));

06Gestures & Mobile Commands

Taps, swipes, scrolls, and drags are core to mobile. The modern approach uses the W3C Actions API (pointer input sequences) or, more simply, driver-side mobile: commands.

  • mobile: scroll, mobile: swipe, mobile: tap, mobile: longClickGesture — executed natively by the platform driver; concise and reliable.
  • W3C Actions — build a PointerInput sequence (press → move → release) for custom gestures like pinch or precise drags.
Deprecated: the old TouchAction / MultiTouchAction classes are removed in newer clients. Use W3C Actions or executeScript("mobile: ...") instead — a common "is your knowledge current?" probe.

07Native vs WebView (Hybrid Apps)

A hybrid app embeds web content (a WebView) inside a native shell. Appium exposes each as a context:

  • NATIVE_APP — drive native widgets via UiAutomator2/XCUITest.
  • WEBVIEW_* — drive the embedded web page with Selenium-style CSS/DOM locators.

Switch with the context API:

driver.getContextHandles();          // [NATIVE_APP, WEBVIEW_com.app]
driver.context("WEBVIEW_com.app");   // now use CSS selectors
driver.context("NATIVE_APP");        // back to native
On Android, WebView automation drives an embedded Chromedriver that must match the WebView's Chrome version (Appium can auto-download it). Mobile-web testing in a real browser is just a special case: set browserName instead of app.

08Page Objects, Inspector & Appium vs Native

Page Object Model applies exactly as on the web — one screen object per screen, encapsulating locators and actions, so a UI change touches one file. Appium Inspector is the GUI that connects to a session, renders the live element tree, and helps you craft and verify locators.

AspectAppium / Native (Espresso, XCUITest)
Platform reachOne codebase for Android + iOS / one platform only.
SpeedOut-of-process, slower / in-process, faster and more stable.
LanguageAny WebDriver language / the app's language (Kotlin/Java, Swift).
SetupServer + driver + capabilities / built into the IDE toolchain.

Appium wins on cross-platform reuse and language freedom; native frameworks win on raw speed and stability. The usual recommendation: Appium for broad black-box E2E across both platforms, native frameworks when a single-platform team wants the fastest possible feedback.

09Rapid-Fire Q&A

Reveal each answer to self-check, then test yourself with the quiz.

How does Appium actually drive a device?

Appium is an HTTP server speaking W3C WebDriver; it translates commands and delegates to the vendor frameworks — UiAutomator2 (Android) and XCUITest (iOS).

Which locator strategy is best for cross-platform reuse?

accessibility id maps to content-desc (Android) and accessibilityIdentifier (iOS), so one locator can serve both platforms; XPath is the slowest and most brittle on mobile.

Why is XPath discouraged on mobile?

Each XPath query serializes and searches the whole native UI hierarchy on-device — far slower and more brittle than accessibility id, resource-id, or native predicate/UiSelector queries.

How do you automate a hybrid app's embedded web view?

getContextHandles() lists NATIVE_APP and WEBVIEW_*; context("WEBVIEW_...") switches in so you can use web-style selectors, then context("NATIVE_APP") returns to native.

What is the difference between the app and appPackage/bundleId capabilities?

Use app (path/URL to the .apk/.ipa) to install a fresh build; use appPackage/appActivity or bundleId to launch an already-installed app without reinstalling.

What changed about drivers in Appium 2.0?

Appium 2.0 decoupled drivers/plugins from the core server — you install only what you need — and moved the default base path to / (1.x used /wd/hub).

What is the current, non-deprecated way to perform a custom swipe?

TouchAction/MultiTouchAction are deprecated/removed in modern clients. Use the W3C Actions API or driver-side mobile: commands (mobile: swipe, mobile: scroll).

When would you choose a native framework (Espresso/XCUITest) over Appium?

Native frameworks run in-process and are faster/more stable but single-platform and tied to the app's language. Appium wins on cross-platform reuse and language freedom.