Skip to content

How to test an iOS app with an AI agent

An agent can perform steps such as ‘Complete onboarding, don’t allow notifications, reach the paywall.’ Mobster checks the result against assertions written before the run. The agent saying ‘done’ does not determine the verdict.

A model may perform the steps in mobster verify. Mobster uses code to check the assertions you wrote before the run (Checks reference).

That’s the difference from AI assertions that ask a model. Maestro’s assertWithAI, for one, uploads a screenshot to an LLM with your assertion and takes back true or false, and Maestro marks it experimental (its docs). Mobster checks saved assertions and reports the result, with a frame when available.

Check the app’s accessibility tree

An assertion is a small object with one kind key. Mobster checks it against the tree WebDriverAgent reports for the app, with no model, OCR or pixel comparison.

KindFormHolds when
Text presenttext: "No tasks yet"A shown element’s label or value contains the text
Text absentno_text: "Loading"No shown element’s label or value contains it
Element shownvisible: {selector}At least one shown element matches
Element absentabsent: {selector}No shown element matches
Valuevalue: {selector} with equals: XExactly one shown element matches, and its value equals X
Countcount: {selector} with equals, at_least or at_mostThe number of shown elements that match meets the bound

A selector matches on id (the accessibility identifier), label, value, role, enabled and selected, and every field you give must match. label and value take an exact string or a /regex/.

A check file puts the flow and the assertions together. In this made-up to-do app, you start with three tasks. After you mark the first task done, you expect it to be ticked, Done to count one task, and the remaining count to fall to two:

version: 1name: Marking a task done lowers the countapp:  bundle: com.example.yourapp  path: .mobster/build/Build/Products/Debug-iphonesimulator/YourApp.apptags: [smoke, tasks]launch:  args: ["-SkipOnboarding", "YES"]  env: { SEED_TASKS: "3" }  url: yourapp://taskssteps:  - Tap the first task to mark it done.expect:  - name: The task is ticked    visible: { id: task_1, selected: true }  - name: One task is under Done    value: { id: done_count }    equals: 1  - name: Two tasks are left    value: { id: tasks_left }    equals: 2budget: { max_seconds: 180, max_usd: 0.25 }

An unknown key at any level is an error. Text is normalized before it’s compared (curly quotes, dashes and invisible marks), so a label that says Don’t Allow matches Don't Allow. text and no_text never join two elements: “3” in one and “tasks left” in the next don’t make “3 tasks left”.

Check tree assertions together

Reading a screen during an animation can produce an unstable result. Mobster evaluates the accessibility-tree assertions in expect together against one read:

  1. It reads the tree, waits 0.3 s and reads again.
  2. When matching reads satisfy all of those tree assertions, it returns those results.
  3. Otherwise it reads again every 0.5 s until the timeout, 5 s by default (--assert-timeout, 0 to 60).
  4. At the timeout it uses the last read, and the result says whether the screen was still changing. Other checks and execution evidence also affect the verdict.

So a no_text: Loading that holds on one read and a text: Plans that holds on another never combine into a pass. An element the accessibility tree reports behind a full-screen cover or scrolled out of view doesn’t count as shown, and an agent scrolls to it with swipe and until, which stops as soon as an assertion holds.

Four verdicts, and two rules that keep a pass honest

The exit code is the verdict, so a script can branch on it:

VerdictExitMeans
passed0The assertions and execution checks passed
failed1An assertion or another check failed, such as crash detection
needs_review2The run needs review, for example because evidence or required measurements are missing
couldnt_run3The run could not finish, for example because of an invalid check, an execution error or a resource limit

A detected app crash produces failed with reason app_crashed, even if the assertions hold. A run can also need review for either of these reasons:

  • No assertions. A run without assertions may end needs_review; add an expectation that can establish success.
  • Held before the flow. A run with steps may end needs_review if its final expectations already held before those steps ran. For a paywall flow, assert something that becomes true only after onboarding.

Three ways to drive, one way to judge

ModeWho performs the stepsModel calls
Launch-onlyNobody. Mobster launches the app, opens a deep link if given, and checksNone
Key-lessYour coding agent, through mobster mcpNone by Mobster
SmartMobster, on your OpenAI or Anthropic keyOne per agent turn, with the run’s spend capped by --max-usd (default $0.25, at most $1.00)

Launch-only checks make no model calls. When your coding agent drives the tools, Mobster makes no additional model calls; your agent still uses its own model service. In the key-less mode, your agent’s model drives and Mobster only judges: Give Claude Code a real iPhone and Test your iOS app with Codex walk through that loop. Checks run on simulators Mobster manages, and mobster verify --device checks an app you already installed on your USB iPhone without clearing its data.

Inspect the evidence for each verdict

Every run writes a folder with result.json, report.html, the run’s check.yaml, its events and its frames. The report is one HTML file with no external requests. It shows each assertion with what the accessibility tree reported, each step with its frame, and the verdict frame beside the accessibility overlay: every element Mobster read outlined, and each asserted element in green when it held or red when it failed.

A failure says what it found instead. Say a change stops the remaining count from falling. The task check on that build:

✗ failed  Marking a task done lowers the count  (31.4 s)  ✓ visible id=task_1 selected=true  ✓ value id=done_count == 1  ✗ value id=tasks_left == 2: was "3 tasks left"

A value that’s wrong says what it read. When text or an element isn’t found, the line lists up to 5 near misses from the screen. Use these details to inspect the failure and decide what to fix.

How long it takes

Measured on an M5 Max with macOS 26.5.1, Xcode 26.4 and the iOS 26.4 simulator, running a launch-only check with five assertions on a sample SwiftUI app:

RunTookn
First run: create and boot the simulator, build and start WebDriverAgent, install, check77.7 s and 103.6 s2
Warm run: simulator and WebDriverAgent up, the app reinstalled, five assertions6.8 s and 8.6 s2

A warm run spends about 1.5–2.5 s installing, 1.3–1.5 s launching and 1.4–1.7 s asserting. Simulators stay booted between runs, so the next run starts warm.

Make your app checkable

  • Give the controls your checks depend on an identifier: .accessibilityIdentifier("tasks_left") in SwiftUI. An id selector then survives copy changes and translations.
  • Mark selection as a trait: .accessibilityAddTraits(.isSelected). The selected selector reads it.
  • Write each expectation so it only holds after the steps.

Write your first check

Get Mobster for Mac, then press Add next to your coding agent in Settings › Connectors. Build your app for the simulator:

xcodebuild -scheme <Scheme> -destination 'generic/platform=iOS Simulator' \  -derivedDataPath .mobster/build CODE_SIGNING_ALLOWED=NO build

Then ask your agent for a launch-only check, which needs no key:

Use mobster to open .mobster/build/Build/Products/Debug-iphonesimulator/<App>.appwith no steps, and expect "Welcome" on the first screen.

Getting started with verify takes you from there to checks with steps.

Maestro vs XCUITest vs Mobster says when to use which, and Mobster vs Maestro and Mobster vs XCUITest compare them row by row.

Questions

  • Does Mobster use a model to decide whether a test passed?

    No. A model may perform the steps. Mobster checks declared assertions in code. The accessibility-tree assertions in `expect` are evaluated together against one read.

  • What does needs_review with held_before_flow mean?

    Every assertion already held right after launch, before any step ran. Such a check doesn't show that the flow works, so add an expectation that only holds after the steps.

  • Do I need accessibility identifiers for Mobster checks?

    No. Selectors also match labels, values, roles and enabled or selected state. Identifiers make a check survive copy changes and translations, so add them to the controls your checks depend on.

  • Can AI write UI tests for an iOS app?

    Yes. A coding agent can write a Mobster check: the steps in plain English and the assertions that must hold, saved as a YAML file you commit. Mobster runs it and checks the saved assertions.

  • What are AI agents good for in iOS e2e testing?

    Getting through a mobile app’s flow: a model can follow “complete onboarding, reach the paywall” past a renamed button or a new screen. Mobster checks saved assertions.

Sources