Snapshots
Snapshots provide a structured view of the UI and generate current-screen refs.
Note: If XCTest returns 0 nodes (foreground app changed), agent-device fails explicitly. It does not automatically switch to AX.
Efficient snapshot usage
- iOS and Android share the same mobile snapshot contract: visible-first output, actionable-now refs, and hidden list content communicated via discovery hints.
- Default to
snapshot -ifor agent loops. - Default human-readable snapshot output is visible-first. Off-screen interactive content is collapsed into compact discovery summaries such as
[off-screen below] 3 interactive items: "Privacy", "Battery", "About". - If a target only appears in an off-screen summary, use
scroll <direction>and re-snapshot until the target becomes visible. - When container ownership is known, hidden content is shown inline under the visible scroll/list container, for example
[content above scroll-area hidden]or[content below list hidden]. - Those summaries intentionally show only a few labels for token efficiency. Use
snapshot --rawwhen you need the full off-screen tree instead of the compact summary. - Add
-s "<label>"(or-s @ref) to keep results screen-local. - Add
-d <depth>when you only need upper hierarchy layers. - If
snapshot -ireturns 0 nodes on Android but the screen is visibly populated, trustscreenshotas visual truth, wait briefly, then take one freshsnapshot -i. - If
snapshot -i -d <n>says the interactive output is empty at that depth, retry once without-dbefore taking more shallow snapshots. - Re-snapshot after any UI mutation before reusing refs.
- On Android after navigation or submit, snapshot capture retries suspicious trees for a short post-action deadline and
@refinteractions refresh while that freshness window is active. Ifsnapshot -istill disagrees with the visible screen, trustscreenshot, wait briefly, then take one fresh snapshot instead of looping stale snapshots. - For automation runs affected by Android animation churn, use
settings animations offas an opt-in stabilizer and restore withsettings animations onafter the run. - Use
diff snapshotbetween mutations to validate structural changes with lower output volume. - Use
snapshot --diffwhen you discover the feature from snapshot help, but keepdiff snapshotas the default exploration command. - Keep
--rawfor troubleshooting only when you need the full tree instead of visible-first output.
diff snapshot and snapshot --diff behavior:
- First run initializes baseline (
baselineInitialized: truein JSON). - Later runs return unified-style lines (
+added,-removed, unchanged context) and update baseline after each call.
Example output:
Backends (iOS):
xctest(default): full fidelity, fast, no Accessibility permission required.ax: fast accessibility tree, may miss details, requires Accessibility permission; simulator-only.
