Appium Architecture & Setup
Appium is the only open-source framework that enables writing a single test suite that runs on both Android and iOS. Understanding its architecture — the Appium server, driver model, and capabilities system — is essential before writing your first mobile test.
Appium Architecture
- Your Test Code → HTTP (WebDriver Protocol) → Appium Server → UIAutomator2 (Android) or XCUITest (iOS) → Device/Emulator
- Appium Server: Node.js HTTP server that translates WebDriver commands to native mobile automation commands
- UIAutomator2 driver: Google's Android automation framework (API 16+) — used for all Android tests
- XCUITest driver: Apple's iOS automation framework — used for all iOS tests
- Desired Capabilities: JSON configuration that tells Appium what platform, OS version, device, and app to use
- AppiumDriver: Your test's connection to Appium server (AndroidDriver or iOSDriver)
- Same WebDriver API: Appium extends WebDriver — find_element, click, send_keys work on mobile elements too
Appium Setup and First Test
# ══════════════════════════════════════════════════════════════
# PREREQUISITES
# ══════════════════════════════════════════════════════════════
# 1. Node.js installed
# 2. Appium server: npm install -g appium
# 3. UIAutomator2 driver: appium driver install uiautomator2
# 4. XCUITest driver: appium driver install xcuitest (macOS only)
# 5. Android SDK + AVD Manager (for Android emulator)
# 6. Xcode (for iOS simulator — macOS only)
# 7. Python Appium client: pip install Appium-Python-Client
# Start Appium server:
# appium server --port 4723 --address 127.0.0.1
# ══════════════════════════════════════════════════════════════
# ANDROID TEST SETUP (Python)
# ══════════════════════════════════════════════════════════════
from appium import webdriver
from appium.options import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pytest
@pytest.fixture(scope="function")
def android_driver():
options = UiAutomator2Options()
# Device capabilities:
options.platform_name = "Android"
options.platform_version = "13"
options.device_name = "emulator-5554" # from 'adb devices' output
# App under test:
options.app = "/path/to/myapp.apk" # Local APK path
# OR if app is already installed:
options.app_package = "com.mycompany.myapp"
options.app_activity = "com.mycompany.myapp.MainActivity"
# Appium behavior:
options.no_reset = False # Clear app state before each test
options.full_reset = False # Don't reinstall app each time
options.auto_grant_permissions = True # Auto-grant all permissions
driver = webdriver.Remote(
command_executor="http://127.0.0.1:4723",
options=options
)
driver.implicitly_wait(10)
yield driver
driver.quit()
# ── FIRST ANDROID TEST ─────────────────────────────────────────
def test_android_login(android_driver):
driver = android_driver
# Find elements using AppiumBy strategies
email_field = driver.find_element(AppiumBy.ID, "com.myapp:id/email_input")
email_field.send_keys("alice@test.com")
password_field = driver.find_element(AppiumBy.ID, "com.myapp:id/password_input")
password_field.send_keys("Test@1234")
login_btn = driver.find_element(AppiumBy.ID, "com.myapp:id/login_button")
login_btn.click()
# Wait for home screen
wait = WebDriverWait(driver, 15)
home_title = wait.until(
EC.presence_of_element_located((AppiumBy.ID, "com.myapp:id/home_title"))
)
assert home_title.is_displayed(), "Home screen should be visible after login"
# ── iOS SETUP ─────────────────────────────────────────────────
# options.platform_name = "iOS"
# options.platform_version = "17"
# options.device_name = "iPhone 15 Pro"
# options.app = "/path/to/MyApp.app" # Simulator build
# options.automation_name = "XCUITest"
# bundle_id = "com.mycompany.myapp"Common Mistakes
- Starting without a prerequisite checklist — Appium has 5+ prerequisites (Node, SDK, drivers); missing any one causes cryptic errors; follow the setup guide exactly
- Using wrong appium driver version — match Appium driver version to target OS version; use 'appium driver list' to see installed versions
- Not setting auto_grant_permissions — apps that request permissions during test will hang waiting for permission dialog; always auto-grant
- Using implicitly_wait as the only wait strategy — mobile apps have longer load times; use explicit waits for critical elements
Tip
Tip
Practice Appium Architecture Setup in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
More unit tests, fewer E2E tests — the ideal testing balance
Practice Task
Note
Practice Task — (1) Write a working example of Appium Architecture Setup from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Appium Architecture Setup is skipping edge case testing — empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready software testing code.
Key Takeaways
- Appium is the only open-source framework that enables writing a single test suite that runs on both Android and iOS.
- Your Test Code → HTTP (WebDriver Protocol) → Appium Server → UIAutomator2 (Android) or XCUITest (iOS) → Device/Emulator
- Appium Server: Node.js HTTP server that translates WebDriver commands to native mobile automation commands
- UIAutomator2 driver: Google's Android automation framework (API 16+) — used for all Android tests