Skip to content
← All case studies

Case study 02

Building a cross-platform mobile automation framework

One set of Appium + WebdriverIO specs that runs against Android and iOS on a local emulator or on BrowserStack, starting from an audit of 479 critical-path regression scenarios.

Appium · WebdriverIO · TypeScript · BrowserStack · Bitrise · React Native

479
regression scenarios audited for feasibility
1
spec set for Android + iOS
2
targets: local emulator & device cloud

The problem

Mobile regression for a React Native field app was almost entirely manual and took a large share of every release cycle. Elements had no stable identifiers, so early automation attempts broke on every build.

Before writing code I needed to know which scenarios were worth automating, what the app needed to become testable, and what device infrastructure that implied.

What I did

  1. 1.Audit first, automate second

    I reviewed 479 critical-path regression scenarios and scored each for business risk, automation feasibility and infrastructure needs (offline mode, camera, push notifications). That produced a roadmap the team could commit to instead of a wish list.

  2. 2.A test ID convention developers actually adopt

    Stable selectors are a product change, not a QA task. I proposed a small naming convention and a helper so every platform resolves the same ID the same way. Developers added IDs as part of normal feature work.

    support/selectors.ts
    // Convention: <screen>.<element>[.<qualifier>]  e.g. "form.submit", "list.item.3"
    // React Native: <Pressable testID="form.submit" accessibilityLabel="form.submit" />
    
    export function byId(id: string) {
      // Android exposes testID as resource-id; iOS as accessibility id.
      return driver.isAndroid
        ? `android=new UiSelector().resourceIdMatches(".*${id}$")`
        : `~${id}`;
    }
  3. 3.Screens, not platforms, in the page objects

    Page objects describe screens once. Platform differences live in a single place, so a spec never branches on Android vs iOS.

    screens/form.screen.ts
    import { byId } from "../support/selectors";
    
    export class FormScreen {
      get title() { return $(byId("form.title")); }
      get submit() { return $(byId("form.submit")); }
      field(name: string) { return $(byId(`form.field.${name}`)); }
    
      async fill(values: Record<string, string>) {
        for (const [name, value] of Object.entries(values)) {
          await this.field(name).setValue(value);
        }
      }
    
      async submitAndWaitForSync() {
        await this.submit.click();
        await $(byId("sync.status.done")).waitForDisplayed({ timeout: 15_000 });
      }
    }
  4. 4.One config, two execution targets

    The same specs run on a local emulator for fast feedback and on BrowserStack real devices in CI (Bitrise), selected by an environment variable rather than duplicated configs.

    wdio.conf.ts
    const target = process.env.TARGET ?? "local"; // "local" | "browserstack"
    const platform = process.env.PLATFORM ?? "android";
    
    const capabilities = {
      local: [{ platformName: "Android", "appium:automationName": "UiAutomator2", "appium:app": "./apps/app.apk" }],
      browserstack: [{
        platformName: platform === "ios" ? "iOS" : "Android",
        "appium:app": process.env.BS_APP_URL,
        "bstack:options": { deviceName: platform === "ios" ? "iPhone 15" : "Google Pixel 8", buildName: process.env.BUILD_ID },
      }],
    }[target];
    
    export const config: WebdriverIO.Config = {
      runner: "local",
      specs: ["./tests/**/*.spec.ts"],
      capabilities,
      services: target === "browserstack" ? ["browserstack"] : ["appium"],
      framework: "mocha",
      reporters: ["spec"],
    };

Outcome

Lessons learned

Code samples are original demonstrations written for this site. They show the pattern, not any employer’s implementation.

Next case studyCutting regression from over 60 minutes to under 20 →