Mobile apps (preview)
Preview. Native app tests are new in 1.6.0. They work on an iOS simulator, an Android emulator and an Android phone (new in 1.6.2, not yet run against a range of models); a physical iPhone is not supported yet.
A scenario tagged @mobile drives a native app on a simulator, an
emulator or an Android phone, in the same plain language as a browser scenario. The agent
records it once per platform; every later run replays that recording at
zero tokens, and a replay that fails heals and files a proposal for review,
as it does for the browser.
@mobile
Feature: The demo app
Scenario: A user signs in
When I open the sign-in screen
And I sign in as "ann@example.com" with password {env:DEMO_PASSWORD}
Then I am welcomed as "Ann"
@ios
Scenario: Face ID unlocks the app
...
@mobile runs a scenario on every platform the configuration sets up.
@ios or @android beside it restricts the scenario to one. API and
database steps run inside a mobile scenario, as they do in a browser one.
@mobile means a device only in a project whose saffron.config.json has
a mobile block. Without one it is a browser scenario's tag, as it was
before 1.6.0: such a scenario runs in the browser, and the run says so
once. Tag a browser test of a phone-sized page @mobile-view (the size
comes from device or viewport), in every project; tag a native app
test @mobile, never @mobile-view. The authoring skill, the MCP server
and the AGENTS.md block saffron init writes tell agents the same. Run the
phone-sized tests apart, saffron run --filter "@mobile-view" --device "iPhone 15", and the rest with --filter "not @mobile-view".
Set it up
npm install --save-dev --save-exact mobilewright@0.0.71
npx saffron init --mobile
Saffron drives the device through Mobilewright, which your project
installs; Saffron never ships it. init --mobile adds the mobile block
below, an example scenario that needs no secret, and Mobile MCP beside
Saffron's own server (with its telemetry off). Its device check only reads: it changes nothing on the
device. Until a simulator or an emulator is set up, run the browser suite
without the mobile scenarios:
npx saffron run --filter "not @mobile"
{
"mobile": {
"platforms": ["ios", "android"],
"ios": { "bundleId": "com.example.app", "device": "iPhone 17", "locale": "en-US" },
"android": { "bundleId": "com.example.app", "device": "Pixel_9_Pro", "app": "android/app/build/outputs/apk/debug/app-debug.apk", "locale": "en-US" }
}
}
| Setting | Meaning |
|---|---|
ios, android |
One block per platform: bundleId (the bundle id or package), device (the simulator's name or UDID; the emulator's AVD name, such as Pixel_9_Pro, never its serial; an Android phone's adb serial), app (the simulator's .app or .zip, the .apk), locale (the locale the app launches with). devices in place of device lists several, such as ["iPhone 17", "iPhone 17e"] |
platforms |
The platforms an @mobile scenario runs on; every configured one by default |
actionTimeoutMs |
How long an act or a check waits for its element (15000) |
readyTimeoutMs |
How long the app may take to show a stable first screen (30000) |
scrollLimit |
How many swipes a scroll makes before it is red (10) |
app is optional on iOS: when it is set, every run installs it, so a
rebuilt app is always the one tested; without it, the app must already be
on the simulator. On Android it is required: the run checks that the APK
exists, and installs it afresh before every scenario.
With devices, the platform's scenarios run on whichever of them is free,
one scenario per device at a time, so with --workers 2 (or workers)
two devices each run one. Every device is checked before the run starts,
and each records and heals on its own; two entries that name one device
(a simulator's name and its UDID) are refused. Boot every one before the
run.
Boot the simulator or the emulator before the run. Android runs use the
emulator whose AVD name device is, or a phone attached over USB (or
adb connect) named by its adb serial, as adb devices lists it (an
emulator reached over the network is refused: name an emulator started on
this machine by its AVD). Every
scenario uninstalls the app from the phone and installs it afresh, so its
data there is lost: use a phone kept for tests. On a phone, a step that
sets a location is the phone's to allow, and the run keeps no video when
the phone cannot record its screen. Phones are new in 1.6.2 and not yet
qualified on a range of models. iOS runs look only among the booted
simulators; a physical iPhone is not supported.
Every saffron run with @mobile scenarios first checks that the driver,
the device and the app answer, and stops with the fix when one does not.
It then sets the device up for tests: on iOS it installs the DeviceKit
agent on the simulator and turns on Reduce Motion; on Android it turns the
emulator's animations off. An app that cannot be set up on the device (its
install fails, the package is not the configured one, no stable first
screen shows) is blocked by the environment (§5), not the app's red, and
never starts a heal.
saffron run --platform ios runs the @mobile scenarios of one platform,
and the browser and API scenarios beside them. When it leaves out another
platform the project sets up, it counts as a partial run in trends, which
count suite runs only; a --shard job counts as part of the suite, and
the iOS and Android jobs' shards merge into one run (§15).
What every scenario starts from
A clean app: its data cleared, the iOS simulator's Keychain reset, an Android app installed afresh from its APK (accounts survive a data clear there), and any system alert left over dismissed. One device runs one scenario at a time.
How an element is found
An act or a check needs exactly one visible element that fits its target, and the same one in two reads. Two that fit are a red, never the first of them. A control under the keyboard, behind an alert or a sheet, or clipped by its list is not visible. The status bar, the navigation bar and the keyboard are not the app's screen: nothing in them is found, for a check, an act or a check that something is not shown, though the keyboard still covers what lies under it; a system alert or a permission prompt is found. A text or a name is never what a test typed into a field (check a field with its value instead), and a text check holds only where the value stands as a whole word or number: "Welcome, Ann" is not in "Welcome, Annabel", nor "Item 1" in "Item 10".
A count or an "every" check scrolls its list to the end and counts every item, identical rows included. The agent records it within the list, even a list with no label of its own when it is the only list on screen. A count counts every row of the list's row type, whatever each one shows; to count the items that show a word, the check names that text within the list. An accessibility identifier or a text of its own on each row lets the list's screens be lined up as it scrolls. A list whose rows are all alike, with no text or id of their own, cannot be lined up, and the check is red, as it is when such rows hold one element that stays put (a floating button). Items side by side in a grid count apart. A list that scrolls sideways (a carousel) is red with the way out, a carousel of full-width cards showing one card at a time too: check a total the screen shows, or count through an API or database step.
A check that something is not shown holds for the screen as it is now, or, scoped within a list, for the whole list; scoped within a section that is not a list it is refused, because what the section holds off screen is not in the tree. It is red while any alert or sheet is open.
A gesture whose send failed is never sent again: a tap that may have landed is a red, not a second tap.
A drag and drop ("When I drag the card to Done") presses on the element, holds it long enough to pick it up, moves to the drop target and lifts there. Both must be on screen, each found alone, as for any act; a drop target off screen is a red, never scrolled to.
A link that opens another app (a help page in Safari or Chrome, the system
Settings) is checked with a step that names the app in front: "Then the
system settings are in front" holds once that app stayed in front for the
absence window, and is recorded with the app's bundle id or
package (com.apple.Preferences, com.android.settings), checked against
the device when it is recorded, and is never healed. Any other check is red
while another app is in front, naming that app.
A fill holds once the field holds what was typed. A field that formats its input, such as "(555) 123-4567" for "5551234567", holds it when its letters and digits are the same and every typed character is still there, in order: a dropped or changed character is a red, "12.50" held as "1250" too.
A check of a field's value compares it exactly, as the browser does: "AB 12", with two spaces, is not "AB 12". A placeholder shown in an empty field is no value.
What is recorded
Recordings sit beside the web ones, <scenario>.ios.json and
<scenario>.android.json, at format version 27, which older runners
refuse. A recording that holds a drag or a check of the app in front is
version 28, which 1.6.0 refuses by name, asking for an update. An Android heal never writes the iOS recording, and one platform's
steps never seed the other's. In the report, a mobile scenario's result names its platform in
platform, and in browser too, where a browser scenario's result names
its browser, so the editors and dashboards keep the two platforms apart.
With trace on (or retain-on-failure), a replay keeps each action with
the screen after it, which saffron trace opens as it opens a browser's:
the steps and their actions, the screen at each and a filmstrip. With
video, the device's screen is recorded while the scenario holds it, kept
as video.mp4 beside its screenshots. Neither keeps a screen that showed a
secret typed into a plain field.
The run's last line, the HTML report and totals.deviceMs in the JSON
give each platform's device time, apart from the agent's usage: how long
its scenarios held a device, agent sessions included (device time iOS 3m 12s, Android 2m 40s). Merged shards add theirs up.
A heal refused before (a Then that still failed as written) is tried
again once the screen the scenario stopped on changed, as in the browser:
the screen's elements, without their places or what was typed, are part of
what it is remembered by. In an editor that uses Saffron's language server
(JetBrains, Claude Code), a scenario's line says which
platforms it is recorded on, and what a run would refuse an @mobile
scenario for is marked on its line. saffron coverage gives each
platform's recording and last result. saffron status shows one state per scenario, the worst of its
platforms, and a stale or unreadable recording's reason names the
platform. The dashboard
keeps each platform's history, saffron diff names the platform of each
proposal, and the hints for reusing recorded steps are per platform.
Run saffron prune only with this runner: an older one removes
.ios.json and .android.json as orphans.
A run that types an {env:...} value into a field that is not secure
keeps no screenshot of that scenario (a password field that shows one dot
per character keeps them).
Not yet
- A physical iPhone: an iOS run looks only among the booted simulators.
- Browser sessions (
As "...") and aFixture:in a mobile feature, and a scenario tagged both@mobileand@api: each is refused before the run starts. saffron ejectwrites an@mobilescenario as atest.fixme(not exported yet).- A Jetpack Compose list reads as a plain view: a "not in the list" check is refused there. Check the screen, or the data with an API or database step.
- The accessibility tree cannot tell a transparent control, or one under an
opaque cover, from a visible one. (In a browser,
opacity: 0hides.) - Android does not report whether a control is enabled, so enabled and disabled checks are refused while recording there, and red if a recording holds one. A Jetpack Compose switch reports its state only while it is on, so turning one on or off is recorded as a tap, and it can be checked only as on: check what turning it off changes.
- iOS is slower: about half a second a tap and up to 3 seconds to read a screen of 1,200 elements.
- A count, an "every" check or a check that something is not in a list reads about 400 rows of 44 points from the list's top within the step's time (50 swipes, at most 150 seconds), about 300 from its middle, and fewer for taller rows. A longer list is red as an endless feed: check a total the screen shows, or count with an API or database step. Measured on a 200-row list: about 64 seconds on an iOS simulator and 30 on an Android emulator from the list's top, and 97 and 46 seconds from its middle, where the rows above are read too.
- The editors read each platform's recordings for a step's badge, name
a proposal's platform (
· ios,· android) and leave Headed off an@mobilescenario, but run no single platform: pass--platformin a run configuration's arguments or the terminal.