Supporting track

Mobile Automation (Appium)

One framework, two platforms, stable locators.

What this track covers

Appium architectureDesired capabilitiesUiAutomator2 & XCUITestAccessibility idsGesturesHybrid app contextsReal device vs emulatorParallel mobile execution

Cross-platform page objects

Keep one page object with platform-specific locator annotations.

Why it is required: Duplicating page objects per platform doubles maintenance for no benefit.

Example: A checkout button located on both Android and iOS.

java
1public class CartScreen extends BaseScreen {
2 @AndroidFindBy(accessibility = "checkout_button")
3 @iOSXCUITFindBy(iOSNsPredicate = "name == 'checkout_button'")
4 private WebElement checkout;
5
6 public CheckoutScreen checkout() {
7 tap(checkout);
8 return new CheckoutScreen(driver);
9 }
10}

Expected result

The same test class runs on Android and iOS drivers.

Common mistakes

  • XPath-heavy locators (very slow on mobile)
  • No accessibility ids requested from developers
  • Testing only on emulators

How do you keep one mobile suite working on both platforms?

Related interview questions

Open bank
  • How do you handle element location differences between Android and iOS?

    Keep a single page object interface with platform-specific locator strategies resolved at runtime (@AndroidFindBy / @iOSXCUITFindBy or a locator map).

  • Explain the Appium architecture and how you make locators stable.

    Appium is a client/server implementing W3C WebDriver; the server delegates to platform drivers (UiAutomator2 on Android, XCUITest on iOS). Stable locators come from accessibility ids set by developers, not XPath.

  • Explain Appium's architecture.

    Your test speaks W3C WebDriver over HTTP to the Appium server, which routes the session to a platform driver (UiAutomator2/Espresso on Android, XCUITest on iOS) that drives the device through the vendor automation framework.

  • Which capabilities do you set for an Android and an iOS session?

    platformName, automationName, deviceName/udid, app or appPackage+appActivity (bundleId on iOS), plus newCommandTimeout, autoGrantPermissions and noReset/fullReset to control state.

  • Which locator strategies are most reliable on mobile?

    accessibility id first (content-desc on Android, accessibilityIdentifier on iOS), then id/resource-id, then UiSelector or iOS class chain/predicate — XPath last.

  • How do you perform gestures like swipe, scroll and long press?

    Build W3C actions with a PointerInput sequence, or call the mobile: scripts (mobile: swipeGesture, mobile: longClickGesture) which are simpler and more reliable on Android.