simulator
The command Agents use to start, drive, read and capture the Team's iOS Simulators, Apple Watch Simulators and Android emulators.
simulator is how an Agent works with the app it built while it runs: it starts a device, installs and opens the app, reads what is on screen, taps and types, captures screenshots, recordings and logs, and changes device settings. Each command does one action and prints its result as JSON.
Where it runs
| Cloud Team | Mac Team | |
|---|---|---|
| Devices | Remote devices shared by the whole Team: one per device model AirBuild offers, iPhone and iPad, an Apple Watch paired with each iPhone, and Android emulators | The Team’s own iOS Simulators (“AirBuild …” devices) on your Mac, each iPhone with its Apple Watch. They show in your Simulator.app beside your own devices, so you can watch |
| Device ids | Model names, for example iphone-18-pro-max, iphone-18-pro.watch |
ios:<UDID>, ios:<UDID>.watch |
| Default device | The platform’s choice; it is never an Android device and cannot be changed | The one picked in the app, where a build installs |
Android commands (clear-data, permissions, shell, logs --crashes) |
Yes | No |
| Your own Simulators | — | Never booted, installed to or shut down |
Sign-in and the service address come from the Agent’s environment; there is nothing to set up. See Choose where your Agents run for the two kinds of Team.
Synopsis
simulator <command> [arguments] [--simulator ID] [--then-describe-ui]
simulator --helpOptions every command takes
| Option | Value | Default | Meaning |
|---|---|---|---|
--simulator ID |
An id from simulator list (letters, digits, : . _ -, up to 128 characters) |
The default device | Drives that device instead of the default. It can sit anywhere on the line. --simulator=ID also works. |
--then-describe-ui |
— | Off | Only with tap, swipe, type, set-text, key, button, launch and open-url. Waits for the screen to settle and adds after to the answer: changed (whether the action changed the screen) and the new screen in the same short form as describe-ui --short. One call instead of an action, a wait and a read. |
-h, --help |
— | — | Prints the full help. |
Output and exit codes
Results are JSON on stdout, one line, always with "ok":true and the device id on success. Screenshots, recordings, the clipboard and logs print their raw bytes or lines instead. Progress messages and errors go to stderr.
| Exit code | Meaning |
|---|---|
0 |
Done. |
1 |
The action failed. The error starts with Error: and may be followed by a Hint: line. Also: a partial adjust, a failed batch step, a drag that failed, a service under failed. |
2 |
The command line is wrong: an unknown command, a missing or out-of-range value. A wrong line prints Usage: simulator <the command's usage>. |
| any | shell exits with the device command’s own exit code. |
129, 130, 143 |
A logs --follow ended by SIGHUP (or its parent going away), SIGINT or SIGTERM. |
Devices on a Cloud Team
simulator listprints every device with its id, model, runtime,platform(iOS,watchOSorAndroid), itsstate, and which one is thedefault. A command without--simulatormeans the default.- Devices run side by side. Run
simulator startfor a device before any other command on it. startfrom any Agent of the Team returns the same device. A model that isn’t ready yet can take a few minutes.- A device other than the default that nobody watches or drives for ten minutes shuts down by itself. All devices are released when the Agents’ sandbox goes idle and shuts down.
Apple Watch
Every iPhone has an Apple Watch, listed right after it as <iPhone id>.watch with "platform":"watchOS" and companionOf naming its iPhone.
simulator start --simulator <iPhone id>.watchstarts the iPhone first if it is off, then the watch. On a Mac Team, the first start creates the watch on the newest watchOS the Mac has.- Every other command drives the watch the way it drives an iPhone.
- A watch has no Home, App Switcher, Lock or volume button and does not rotate. Use
button digital-crown(pressing the crown is Home) andbutton side-button. - Install a watch app on the watch itself:
simulator install PATH --simulator <iPhone id>.watch. Installing the iPhone app does not put its watch app on the watch. - Shutting the iPhone down ends its watch.
Android emulators
Android devices are listed with "platform":"Android". The default is never one of them, so always pass --simulator ID. The common commands work with Android’s meaning:
| Command | On Android |
|---|---|
install |
Takes an .apk. |
launch, terminate, uninstall, apps |
Take or show the package name, for example com.example.app. |
button |
back, home, app-switcher (Recents), power, volume-up, volume-down. |
Selectors, describe-ui |
Read the Android accessibility tree. --id is the view’s resource id. |
logs |
logcat. |
appearance, content-size, increase-contrast, pbpaste, pbcopy |
Set the emulator’s own settings. content-size maps to the font scale. |
rotate |
Turns the emulator. The screen follows when the app in front allows it; a phone’s launcher stays upright. |
add-media |
Photos and videos go into the camera roll (/sdcard/DCIM/Camera). Contacts are for Apple devices only. |
foreground |
On the home screen, prints the launcher’s package. |
An Android device has no watch, and these commands are for Apple devices only: fold, displays, heal, services, slider, adjust, screenshot-3d. runbuild --platform android_beta builds the .apk (Android projects are in beta). See runbuild.
Lifecycle
| Command | What it does |
|---|---|
list |
Every device: id, model, runtime, platform, state, default, and companionOf for a watch. Takes no arguments. |
start [--timeout SECONDS] |
Starts the device, or returns it if it is already running, and waits until it is ready. Prints id, ready, url, simulator, model, runtime. On a Mac Team it creates a device if there is none yet. |
shutdown [--timeout SECONDS] |
Shuts down this one device and waits until it is off. The Team’s other devices keep running. Safe to run when it is already off. If someone starts it again while this waits, it stops waiting. Prints {"ok":true,"simulator":"…"}. |
apps [--all] |
The installed apps as a JSON array. --all also lists the ones apps leaves out by default. |
install PATH |
Uploads and installs an app: an iOS Simulator .app folder or an .ipa, or an .apk on Android. Prints installed with the path. Installs on one device run one after another. |
launch BUNDLE_ID [--env KEY=VALUE]... |
Opens the app (a package name on Android). Prints launched. |
terminate BUNDLE_ID |
Stops the running app. Prints terminated. |
uninstall BUNDLE_ID |
Removes the app. Prints uninstalled. |
foreground |
The app in front, as app. |
open-url URL |
Opens a URL or a deep link on the device. Prints opened. |
add-media PATH... |
Adds photos, videos and contacts (see below). |
clear-data PACKAGE |
Android only. Wipes the app’s data, as a fresh install would have it, and stops the app. Prints cleared. |
permissions PACKAGE [--grant NAME,...] [--revoke NAME,...] |
Android only. Grants or revokes runtime permissions, so a run never stops at a permission dialog. Prints package, granted, revoked. |
shell [--timeout SECONDS] COMMAND... |
Android only. Runs one command in the device’s shell, for example pm path com.example.app, run-as com.example.app ls files or am broadcast …. Prints its stdout and stderr and exits with its exit code. |
Lifecycle flags
| Flag | Command | Value | Default | Meaning |
|---|---|---|---|---|
--timeout SECONDS |
start, shutdown |
Whole number, 1–3600 | 180 | How long to wait for the device to be ready or off. |
--all |
apps |
— | Off | Lists every installed app. |
--env KEY=VALUE |
launch |
A name made of letters, digits and _ (not starting with a digit), =, then any value. Repeat for several. |
None | iOS: sets an environment variable for this launch. The app starts in a new process; a running copy is closed first. |
--grant NAME,... |
permissions |
Comma-separated names | None | Permissions to grant. Only what the app’s manifest asks for is granted. |
--revoke NAME,... |
permissions |
Comma-separated names | None | Permissions to revoke. Revoking stops the app. |
--timeout SECONDS |
shell |
Whole number, 1–600 | 60 | The device command is killed after this. |
Permission names: camera, microphone, location, background-location, contacts, calendar, photos, notifications, phone, bluetooth, activity, or a full android.permission.* name. permissions needs at least one --grant or --revoke.
After a build. runbuild never installs. Stop the running copy with simulator terminate BUNDLE_ID first, or the old process stays; then simulator install PATH and simulator launch BUNDLE_ID.
App Clips. An App Clip gets its invocation URL as the _XCAppClipURL environment variable, not as an NSUserActivity, so its DEBUG build has to read that variable and route it like an invocation. Quote the pair, because ? and & mean something to the shell:
simulator launch com.example.app.Clip --env '_XCAppClipURL=https://appclip.apple.com/id?p=com.example.app.Clip'add-media
add-media PATH... adds files to the device’s Photos and Contacts, each under its own name:
| Kind | Extensions |
|---|---|
| Photos | .jpg, .jpeg, .png, .heic, .heif, .gif, .tif, .tiff, .bmp, .webp |
| Videos | .mov, .mp4, .m4v |
| Contacts | .vcf (Apple devices only) |
Every path is checked before the first upload, so one typo adds nothing.
Lifecycle errors
| Message | What to do |
|---|---|
Error: the <model> Simulator is <state>; run simulator start and wait for readiness. |
Run the simulator start the message names (it adds --simulator ID when needed), then repeat the command. |
Error: the Simulator did not become ready within Ns. |
Run start again, or with a longer --timeout. |
Error: the Simulator did not shut down within Ns. |
Run shutdown again, or with a longer --timeout. |
Error: app does not exist: PATH |
Check the path runbuild printed. |
Error: install directories must be iOS .app bundles. |
Pass the .app folder, not another folder. |
Error: install files must end in .ipa or .apk. |
Pass an .app, .ipa or .apk. |
Error: <bundle id> opened without its environment variables: this Simulator can't pass them to an app yet. |
The app opened, but without --env. Run simulator shutdown, then simulator start, to get a current device. |
Error: media file does not exist: PATH / Error: not a media file (…): PATH / Error: media file is empty: PATH |
Fix the path or the file type. Nothing was added. |
Error: --timeout must be an integer from 1 to 600 seconds. |
shell --timeout takes 1–600. |
Error: this Simulator's gateway is too old for simulator <command>. Run simulator shutdown, then simulator start, to get a current one. |
Do what it says, then repeat. |
Settings
| Command | Values | What it does |
|---|---|---|
appearance light / appearance dark / appearance |
light, dark |
Sets light or dark mode. Without a value, prints the current one as appearance. |
content-size [CATEGORY] |
See below | Sets the text size. Without a value, prints it as contentSize. |
increase-contrast enabled / increase-contrast disabled / increase-contrast |
enabled, disabled |
Turns Increase Contrast on or off. Without a value, prints it as increaseContrast. |
rotate ORIENTATION |
portrait, landscape-left, landscape-right, portrait-upside-down |
Turns the device to that absolute orientation, so repeating it does nothing more. |
fold POSITION |
closed (0), half (130), open (180), or 0–180 |
Moves a foldable’s hinge (iPhone Duo). A device with one display ignores it. Prints degrees. |
displays |
— | The device’s displays: screenId, size, and which one is active. |
heal |
— | Takes the device’s input back from Xcode’s Device Hub (see below). Prints reclaimed. |
services / services enable ITEM... / services disable ITEM... |
See below | Lists or changes the device’s background services. |
A read can also answer unsupported or unknown.
Content-size categories, smallest to largest: extra-small, small, medium, large, extra-large, extra-extra-large, extra-extra-extra-large, accessibility-medium, accessibility-large, accessibility-extra-large, accessibility-extra-extra-large, accessibility-extra-extra-extra-large.
rotate and fold
rotate answers with orientation and screen: what the screen shows after the turn. screen differs from what you asked for when the app in front doesn’t rotate (a home screen stays as it is, but the device has turned, and the next app that rotates follows). On an unfolded iPhone Duo the inner screen is mounted a quarter turn round: held upright it reads landscape-left, and its screenshot shows the interface turned. Coordinates always stay in the portrait frame simulator screen reports.
fold returns as soon as the device has the event; it swaps displays a moment later. Screenshots, screen, describe-ui, selectors and recordings follow the active display, which can take up to three seconds to catch up: check displays before acting on the other one. tap and swipe go to the active display unless --display SCREEN_ID names another.
heal
With Xcode 27 open, an iOS 27 Simulator can stop receiving touches, keys and buttons while every command still answers ok. Such a device refuses input with input_shadowed and the hint run simulator heal. heal fixes it by restarting SpringBoard, which ends every running app, so relaunch yours afterwards. On a device that was not affected it prints "reclaimed":false and changes nothing.
services
A Simulator starts with services that apps rarely need turned off (Siri, Spotlight indexing, iCloud, telemetry, photo analysis, Messages, Family Controls, HomeKit and others). simulator services lists them by category and feature.
| ITEM | Meaning |
|---|---|
all |
Every service. |
slim |
What a new device starts with turned off. |
| A category or feature id | As services lists them, for example siri, search, icloud. |
| A launchd label | One service. |
Separate items with spaces or commas. A service under pending starts only when the device next boots; on a Cloud Team a device started again is a fresh one, so it stays off for now. On a Mac Team run simulator shutdown, then simulator start. A service under failed makes the command exit 1 after it prints the result. An unknown id fails with a hint to run simulator services.
Clipboard
| Command | What it does |
|---|---|
pbpaste |
Prints the device clipboard exactly, with no newline added, so it pipes cleanly. |
pbcopy [TEXT] |
Sets the device clipboard to TEXT. With - or no TEXT, reads stdin exactly, trailing newlines included. |
type can only send US-layout ASCII. To enter other characters, put them on the clipboard with pbcopy and paste, or use set-text.
Passwords
simulator fill NAME --field LABEL [--type]fill enters one value from the Team’s password book into the field that has focus, so tap the field first. password-book list names the entries (see password-book).
| Flag | Value | Default | Meaning |
|---|---|---|---|
NAME |
Entry name | Required | The password-book entry. |
--field LABEL |
Field label | Required | Which field of the entry, for example Username or Password. |
--type |
— | Off | Always types the value as key presses (printable ASCII only). Use it where ⌘V does nothing, as in Flutter text fields. |
By default the value goes onto the device clipboard, is read back to check it landed, is pasted with ⌘V, and then the clipboard is emptied. Any character works. If the clipboard doesn’t take it, a printable-ASCII value is typed instead and any other value fails. Typed text goes through the field’s auto-capitalization and smart punctuation; secure fields have neither.
The value is never printed. The result names the entry, the field and the method:
{"ok":true,"id":"…","filled":{"name":"Test account","field":"Password","method":"pasted"}}method is pasted or typed. Use fill to sign in, rather than piping a password into type.
| Message | What to do |
|---|---|
Error: --type can only type printable ASCII, and this value has other characters; fill it without --type. |
Run it without --type. |
Error: the device clipboard did not take the value, so there is nothing to paste. Try again; if it keeps failing, report it. |
Try again. |
Error: the value may still be on the device clipboard. Empty it with: simulator pbcopy '' |
Run simulator pbcopy ''. |
Capture
| Command | What it does |
|---|---|
screenshot [OUTPUT] [--upright] |
Saves the screen. |
screenshot-3d [OUTPUT] [--rotation X,Y,Z] [--size WxH] [--background COLOR] |
Draws a foldable on its 3D model, as it stands. --background is transparent or #RRGGBB. |
screen |
The screen’s coordinate space, which tap, swipe and describe-ui use. |
record [--timeout SECONDS] |
Starts a screen recording. |
record-status |
The recording slot: recording, finished, failed, or null. |
record-stop [OUTPUT] |
Stops the recording and downloads the MP4. |
logs [--lines COUNT] [--app ID] [--level LEVEL] [--crashes] / logs --follow [--duration SECONDS] … |
Reads the device log. --lines and --follow don’t go together. |
screenshot
OUTPUT ending in .png or with no extension saves a PNG; .jpg or .jpeg saves a JPEG. With -, or no OUTPUT and stdout piped, the PNG goes to stdout. Saved to a file, it prints {"ok":true,"id":"…","output":"/absolute/path.png"}.
--upright turns the picture so the interface is upright in it (a landscape app, an unfolded iPhone Duo). It is for reading: coordinates, frames and taps stay those of the plain screenshot, so take a plain one to pick a point from.
screenshot-3d
Only foldables (iPhone Duo) have a 3D model. It draws the device folded to the hinge angle it reports, with the lit screen painted from a live frame, on a 1024×1024 transparent canvas. A flat screenshot shows one display and nothing of the fold.
| Flag | Value | Default | Meaning |
|---|---|---|---|
--rotation X,Y,Z |
Degrees | — | Turns the model. |
--size WxH |
Pixels | 1024x1024 |
Canvas size. |
--background |
transparent or #RRGGBB |
Transparent | Canvas fill. |
Output works like screenshot. Saved to a file it also prints foldable, hingeDegrees and litPanel.
Recording
One recording per device, in real time: a still screen takes up real duration. Every recording stops by itself after its timeout and finalizes on its own.
| Flag | Command | Value | Default | Meaning |
|---|---|---|---|---|
--timeout SECONDS |
record |
Whole number, 1–3600 | 180 | Auto-stop. |
OUTPUT |
record-stop |
File path, or - |
stdout when piped | Where the MP4 goes. |
record-stop can be run after the timeout already stopped it. Saved to a file it prints output and recording. The file stays downloadable until the next recording starts.
logs
| Flag | Value | Default | Meaning |
|---|---|---|---|
--lines COUNT |
1 or more | 120 | Prints that many lines. Not with --follow. |
--follow, -f |
— | Off | Streams lines until stopped. |
--duration SECONDS |
1–3600 | Unbounded | With --follow only: stops after that long and exits 0. |
--app ID |
Bundle id or package | All | Keeps one app’s lines. On iOS, the app and its extensions; on Android, the app including its crash, across restarts. |
--level LEVEL |
iOS: debug, info, warn, error, fatal. Android: also verbose. |
All | Keeps lines at that level or above. |
--crashes |
— | Off | Android only: reads only the crash buffer. |
- iOS logs are live, not a history:
--linescollects what the device writes in the next few seconds, so start the read, then do the thing. - On iOS,
--appand--levelfilter on the device, so a follow of one app doesn’t drop lines the way a follow of everything can. Reinstalling the app ends a filtered follow; start it again. - A follow ends on SIGTERM, SIGINT or SIGHUP (so
timeout 60 simulator logs --followworks), when its parent process goes away, or when its reader closes stdout. - On a Cloud Team, lines the device writes faster than they can be carried are dropped, and a
simkit: dropped N log line(s) hereline marks the spot. - Prefer the bounded form,
--follow --duration 60, and stop a follow you no longer need: a running follow keeps the device busy.
Capture errors
| Message | What to do |
|---|---|
Error: refusing to write image bytes to a terminal; pass an output path or pipe stdout. |
Give OUTPUT, or pipe stdout. Same for video bytes with record-stop. |
Error: screenshot output must end in .png, .jpg or .jpeg: PATH |
Change the file name. |
Error: this Simulator's gateway is too old to save a <format> screenshot. … / … too old for simulator screenshot-3d. … |
Run simulator shutdown, then simulator start. |
Error: --timeout must be an integer from 1 to 3600 seconds. |
Fix record --timeout. |
Error: --duration must be an integer from 1 to 3600 seconds. |
Fix logs --duration. |
Error: this Simulator's gateway cannot filter logs yet (--app, --level, --crashes). … |
Run simulator logs without them and filter the lines yourself. |
Error: the Team Simulator log stream ended unexpectedly (curl N). |
Start the follow again. |
UI automation
Reading the screen
| Command | What it does |
|---|---|
describe-ui |
The accessibility tree of the screen, with frames, ids and nodeIds. Tens of kilobytes. |
describe-ui --short |
The screen as names, in a few hundred bytes: tap (what can be pressed), fill (text fields and what they hold), adjust (sliders, pickers), disabled, text (what it says), and whether the keyboard is up. |
describe-ui --x X --y Y |
The element at one point. Give both. Not with --short. |
find SELECTOR |
Every usable match, best first, and excluded, without touching the device. |
Use --short to see where you are and the full tree when you need frames or ids. Selectors read the same tree; there is no text recognition from pixels. When the app in front is busy and returns no accessibility data, the read asks again after 2 and 4 seconds before failing with a hint to wait and retry; screenshots still work meanwhile.
Selectors
tap, find, wait-visible, wait-hidden, slider, adjust and set-text take a selector instead of coordinates:
| Flag | Meaning |
|---|---|
--text TEXT |
Case-insensitive part of the element’s visible label or value. |
--id ID |
The exact accessibilityIdentifier (on Android, the view’s resource id). |
--value VALUE |
Case-insensitive part of the element’s value only. |
--role ROLE |
The exact platform role, for example AXSlider. |
--exact |
--text and --value must equal, not contain. Needs one of them. |
--strict |
Fail instead of ranking when more than one usable element matches. |
--node-id NODE |
The opaque nodeId from describe-ui or find, for exactly that element. |
Every filter given must match. When several elements match, the best is: an exact text match over a partial one, a label match over a value match, an interactive element (button, field, switch, cell) over static text, then the smaller element, then top to bottom, left to right. Matches that are hidden, off-screen or have no frame are not used; they are listed under excluded with the reason. Every element carries enabled.
--node-id acts on exactly that element even after its value changed. It never falls back to a label or old coordinates: a rebuilt control or a restarted app fails with stale_node, so read a fresh one. It is short-lived and is not the --id.
A selector that never resolves fails like this, naming skipped candidates:
Error: no usable element matching text="Sign in" within 10.0s (matched but skipped: 1 disabled)Waiting
| Command | What it does |
|---|---|
wait-visible SELECTOR [--timeout SECONDS] |
Waits until a matching element is there. Prints the element, like tap. |
wait-hidden SELECTOR [--timeout SECONDS] |
Waits until no matching element is there. Prints elapsedMs. |
wait-idle [--timeout SECONDS] [--stable SECONDS] |
Waits until the UI tree hasn’t changed for --stable seconds. Prints elapsedMs. |
--timeout defaults to 10 seconds, at most 600; --stable defaults to 0.5, at most 10. A disabled element counts as present for the waits. Use wait-idle after an action that animates or loads, before reading the result; a spinner alone does not change the tree.
Touch
| Command | What it does |
|---|---|
tap X Y [--duration SECONDS] [--display SCREEN_ID] |
Taps a point. --duration makes it a long press. |
tap SELECTOR [--timeout SECONDS] [--duration SECONDS] |
Waits for an enabled matching element to appear and hold still, then taps its center. |
swipe X1 Y1 X2 Y2 [--duration SECONDS] [--display SCREEN_ID] |
A flick from one point to another. |
drag X1 Y1 X2 Y2 [--duration SECONDS] [--steps COUNT] |
Moves one finger along a line and lets go without a fling: for reordering, sheets and custom sliders. |
scroll-to TARGET [options] |
Scrolls until an off-screen element shows, without tapping it. |
slider SELECTOR --percent 0..100 |
Sets a standard horizontal slider and reads the value back. |
adjust STEPS SELECTOR |
Steps anything describe-ui marks adjustable (steppers, pickers, time wheels). |
Coordinates are in the space simulator screen reports. --display SCREEN_ID sends tap or swipe to another display (a whole number from displays), in that display’s own coordinates.
tap SELECTOR waits 10 seconds by default, at most 600, and skips a disabled match while it waits for it to become enabled. It prints element, point, exact and matchCount; more than 1 means the selector was ambiguous and the ranking chose.
drag takes --duration 0.05–60 seconds (default 0.6) and --steps 2–1000 (default 30).
slider counts a value within 3 points as success; a failed check can leave the slider moved. Takes no --timeout.
adjust STEPS is a signed count such as +3 or -2, not 0; the control decides how big a step is. Its selector is always strict. The result has completedActions and the before and after elements; a partial run prints it and exits 1.
scroll-to
The target is --text TEXT, --id ID or --node-id NODE.
| Flag | Value | Default | Meaning |
|---|---|---|---|
--exact |
— | Off | --text must equal. |
--direction |
down, up, left, right |
down |
Where the content lies. |
--within-id ID / --within-text TEXT |
— | Whole screen | The scroll area to use when the screen has several. It must be uniquely visible. |
--within-exact |
— | Off | --within-text must equal. |
--timeout SECONDS |
Up to 25 | 20 | How long one search runs. |
--max-scrolls COUNT |
1–100 | 25 | Most drags. |
It re-reads the screen after every drag, so lazy content loads, and stops when the content stops changing, at --max-scrolls or at --timeout. A visible target needs no drag. The result includes scrolls and elapsedMs. For a longer hunt, run it again: it carries on from where the list was left. It does not tap; tap does not scroll.
Text and keys
| Command | What it does |
|---|---|
set-text TEXT SELECTOR [--paste] [--timeout SECONDS] |
Makes a text field hold exactly TEXT: finds it, focuses it, replaces what it held and reads it back (verified: true). Any language and emoji, with any keyboard in front. - reads the text from stdin. |
type TEXT / type --file PATH / type - |
Sends key presses to whatever has focus. |
key CODE [--modifier M]... |
Presses one key code, for example KeyV. |
button BUTTON [--duration SECONDS] |
Presses a hardware button. |
input JSON |
Sends one raw input event. - reads it from stdin. |
set-text prints method, verified and the field’s value. --paste pastes the text; --timeout is at most 20 seconds.
type checks the whole text before the first key and keeps its whitespace. The keyboard is US-layout ASCII, so other characters are an error. An input method in front (a Chinese or Japanese keyboard) turns key presses into something else; use set-text for text. --file and - carry text that is hard to quote.
--modifier takes shift, control (ctrl), option (alt, opt) or command (cmd, meta); repeat it for several.
button names: on Android back, home, app-switcher, power, volume-up, volume-down; on an Apple Watch digital-crown and side-button.
input takes one event object with a type:
type |
Fields |
|---|---|
tap |
x, y, optional duration, display |
swipe |
startX, startY, endX, endY, optional duration, display |
type |
text |
key |
code, modifiers (array) |
button |
button, optional duration |
simulator input '{"type":"key","code":"KeyV","modifiers":["command"]}'batch
batch FILE runs 1–1000 steps in order in one request, which saves the round trip of each command in a known flow. - reads the JSON array from stdin.
[{"action":"tap","selector":{"id":"next","strict":true}},
{"action":"wait-visible","selector":{"id":"title"},"timeoutMs":5000},
{"action":"input","event":{"type":"type","text":"Hello!"}},
{"action":"slider","selector":{"id":"volume"},"percent":75}]action |
Fields |
|---|---|
tap, find, wait-visible, wait-hidden |
selector (text, id, value, role, exact, strict, or nodeId), optional timeoutMs |
slider |
selector, percent |
adjust |
selector, steps |
drag |
start and end as {x,y}, duration, steps |
input |
event, in the simulator input form |
sleep |
ms, at most 60000 |
Every selector step reads a fresh tree. The batch stops at the first failure without undoing earlier steps; the result lists each step’s outcome and the zero-based failedStep, and the command exits 1. One request must begin answering within 30 seconds, so keep a batch’s waits and sleeps well under that in total, or split it.
UI automation errors
| Message | What to do |
|---|---|
Error: no usable element matching … within Ns |
Read the screen again (describe-ui --short), fix the selector, or wait longer. |
stale_node |
Read a fresh nodeId from describe-ui or find. |
input_shadowed |
Run simulator heal, then relaunch the app. |
| Hint: the app in front returned no accessibility data … | The app is busy. Wait a few seconds and retry. |
Error: set-text --timeout is at most 20 seconds: … |
Use 20 or less. |
Error: scroll-to --timeout is at most 25 seconds: … |
Use 25 or less, and run scroll-to again to keep searching. |
Error: unknown --modifier M; use shift, control (ctrl), option (alt, opt) or command (cmd, meta). |
Use one of those. |
Error: a batch is a JSON array of 1 to 1000 {"action": …} steps. |
Fix the batch file. |
Error: batch file not found: PATH / Error: text file not found: PATH |
Fix the path. |
Error: invalid input event JSON. |
Pass one JSON object with a type. |
Error: --then-describe-ui goes with tap, swipe, type, set-text, key, button, launch and open-url. |
Drop the option, or run describe-ui --short after the command. |
Error: this Simulator's gateway is too old for describe-ui --short; run describe-ui. |
Use describe-ui, or restart the device with shutdown and start. |
Error: the Team Simulator gateway did not answer within N seconds. |
The action may still have happened. Look (screenshot, describe-ui) before repeating it. |
Examples
Install and open a fresh build on the default device, and see the screen it opened on:
simulator terminate com.example.app
simulator install /path/to/Example.app
simulator launch com.example.app --then-describe-uiEnter a password-book value into a password field, then submit:
simulator tap --text "Password" # focus the field first
simulator fill "Staging login" --field Password
simulator tap --text "Continue" --exact --then-describe-uiDrive an Android emulator (take its id from simulator list, where platform is Android):
simulator start --simulator ANDROID_ID
simulator install app-debug.apk --simulator ANDROID_ID
simulator permissions com.example.app --grant camera --simulator ANDROID_ID
simulator launch com.example.app --simulator ANDROID_ID
simulator logs --app com.example.app --crashes --simulator ANDROID_IDTake a dark-mode screenshot, then put the setting back:
simulator appearance # prints the current value, e.g. light
simulator appearance dark
simulator screenshot /tmp/dark.png
simulator appearance light