Appium cheatsheet
A one-page reference for Appium. For architecture, driver internals, and interview Q&A, see the complete guide.
๐ Full guide: Appium โDesired capabilitiesโ
{
"platformName": "Android",
"appium:automationName": "UiAutomator2",
"appium:deviceName": "Pixel_7",
"appium:app": "/path/to/app.apk"
}
Android vs iOS driversโ
| Android | iOS | |
|---|---|---|
| Driver | UiAutomator2 | XCUITest |
| Locator id | resource-id | accessibility id |
| Tooling | Android SDK | Xcode |
Locator strategiesโ
driver.find_element(AppiumBy.ACCESSIBILITY_ID, "Login")
driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,
'new UiSelector().text("Login")')
driver.find_element(AppiumBy.IOS_CLASS_CHAIN,
'**/XCUIElementTypeButton[`label == "Login"`]')
Prefer accessibility id โ most stable, cross-platform.
Real device vs emulator vs cloud farmโ
- Emulator/simulator โ fast, free, good for CI smoke tests.
- Real device โ catches OS/hardware quirks emulators miss.
- Cloud farm (BrowserStack, Sauce Labs) โ real-device matrix at scale, no lab to maintain.
Native, hybrid, web contextsโ
driver.contexts # ['NATIVE_APP', 'WEBVIEW_1']
driver.switch_to.context('WEBVIEW_1') # now driving a webview via CSS/XPath
driver.switch_to.context('NATIVE_APP')
Gesturesโ
TouchAction(driver).press(x=100, y=800).move_to(x=100, y=200).release().perform()
# or the W3C Actions API for swipe/pinch/multi-touch
Common flakiness pitfallsโ
- Fixed sleeps instead of explicit waits for app-ready state.
- Not resetting app state between tests (
noReset/fullResetcapability). - Hardcoded coordinates for gestures instead of element-relative gestures.
- Ignoring platform differences in the same test (Android/iOS require different locators).
Framework & CI notesโ
- Appium server + emulator/device farm both needed in CI โ device farms remove the local-lab bottleneck.
- Pair with a real assertion library (JUnit/TestNG/pytest), Appium only drives the app.
- Parallelize across multiple emulators/devices for suite speed.