DEV Community

Cover image for How to run one Appium test on Android and iOS without forking your framework
Mayvin Ramasawmy
Mayvin Ramasawmy

Posted on

How to run one Appium test on Android and iOS without forking your framework

Your Appium framework runs on Android. Every screen object uses @AndroidFindBy. Point it at an iOS simulator and AppiumFieldDecorator finds no annotations it recognizes — every field stays null, and the session dies before it touches an element.

The reflex is to build a second iOS suite. You don't need one.

AppiumFieldDecorator reads two locator annotations on the same field — @AndroidFindBy and @iOSXCUITFindBy — and resolves the one matching the active driver type at runtime. The Android annotation is read by an AndroidDriver; the iOS annotation by an IOSDriver. The other is skipped.

The article walks through:

  • 🔀 How AppiumFieldDecorator selects a locator by driver type at runtime
  • 🧩 Declaring @AndroidFindBy and @iOSXCUITFindBy on a single field
  • 📱 Running the same Cucumber scenario on an iOS simulator unchanged
  • ⚠️ The one field where Android and iOS genuinely diverge — system AlertDialog ID vs iOSNsPredicate
  • 🚨 The three session failures that actually surface on the iOS run
  • 🧠 When dual annotations stop scaling, and what to extract instead

One concrete detail: most fields reuse the same accessibility ID across both platforms, so the iOS annotation is often a verbatim copy of the Android one. The work isn't rewriting locators — it's identifying the few elements that truly differ.

Step definitions, feature files, and DriverManager don't change. You add one iOS annotation per field and switch two lines in application.properties.

👉 Read the full guide here: https://www.mobile-automation.io/cross-platform-mobile-testing-pom/

Top comments (0)