iOS Simulator: Tap Element
ios_simulator_tap_elementTap iOS Simulator UI elements by accessibility identifier or label instead of fixed coordinates, so taps stay reliable when the screen scrolls or layout changes. Resolves the element's position automatically from the UI tree.
Instructions
Tap the element with this accessibility identifier or label, letting the device resolve its position. This is the tool to reach for: it survives the screen scrolling, the layout changing and the copy being reworded, none of which a coordinate does. Give exactly one of id, label or predicate; identifiers from ios_simulator_ui_tree.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Accessibility identifier — the `id` field from ios_simulator_ui_tree, e.g. "garden.tab". The most durable way to address an element, because it is set in code and does not change when the visible text does. | |
| index | No | Which match to tap when several match, zero-based, counted in the order ios_simulator_ui_tree lists them. Giving it turns off the control preference `label` normally applies, because it means you have read the tree and are counting real positions in it. Leave it off unless that is what you are doing. | |
| label | No | Exact accessibility label, i.e. the visible text — e.g. "Today". Matched exactly, and it changes with the app's language, so prefer `id` where one exists. A label is shared by a control and every container around it, so this matches controls first and falls back to the rest only when no control carries it. | |
| device | No | Which simulator: its UDID or its name as shown by ios_simulator_list. Omit it when exactly one is booted — that is the normal case, and IOS_SIMULATOR_ID pins it when it is not. Unlike simctl's own `booted`, this never picks arbitrarily between two. | |
| predicate | No | Escape hatch: a raw NSPredicate over element attributes, e.g. `type == "XCUIElementTypeButton" AND label BEGINSWITH "Add"`. | |
| settle_ms | No | Milliseconds to wait before the follow-up screenshot, so an animation finishes first. Raise it for a screen that loads data; a capture taken mid-transition shows neither state. This is a pause for an animation, not a wait for work to finish — which is why it stops at ten seconds. For anything longer, use ios_simulator_wait_for_element. | |
| screenshot | No | Return a screenshot of the resulting screen. On by default, and worth leaving on: it is how you find out that the action landed where you meant it to. Turn it off only for a sequence whose intermediate states you do not need to see. |