tap, tapAppIcon

in Japanese(日本語)

Taps an element, or raw coordinates, on the screen.

Functions

function description
tap(sel, holdSeconds: 0, maxGestureSeconds:containerInference:linkText:settle:waitSeconds:scroll:maxSwipes:) Taps the first element matching the selector. holdSeconds greater than 0 makes it a long press (default 0 = normal tap, capped at 10 seconds by default — pass maxGestureSeconds: to allow up to 60 for this one call). Waits for the target to become enabled before tapping (see Notes). Returns the tapped element, so assertions chain directly: tap("#btn_ok").textIs("OK").
tap(sel, linkText: "text") Taps the place where linkText is drawn inside the element the selector resolves to — for an inline link in a paragraph, which the accessibility tree does not expose as a node on Compose Multiplatform, Android Views (ClickableSpan) and SwiftUI (AttributedString links). Located first from the tree (a descendant whose label or value equals linkText, as Flutter and React Native expose links), then by OCR on the element's pixels. OCR is available on macOS 27+ only — on macOS 26, when the tree does not locate the text the step fails before taking a screenshot and says so. If neither finds it the step fails and lists what OCR read — it never falls back to the element's centre. The step note records which way located it (tree / ocr). On iOS the MCP tools (which run through the XCUITest bridge) may show such a link as its own element, but scenarios run in inapp-boost mode by default, where it is not — so write tap(element, linkText:) even if exploration showed the link as an element. A link wrapped across two lines is not found by OCR. Without linkText: it taps the centre of the element.
tap(x: Double, y: Double, holdSeconds: 0, maxGestureSeconds:, settle:) Taps raw coordinates. Coordinates use the same system as the screen frame in a snapshot — iOS = pt, Android = px (not dp). Prefer a selector whenever one is available. A point outside the screen fails without sending anything (a negative coordinate always; the screen size is checked when the element list is read anyway). On iOS in inapp-boost mode, a point off the screen fails; a point on the software keyboard is tapped through the XCUITest bridge, so the key is pressed — to reach what is under the keyboard, close it first with pressEnter or hideKeyboard; and an element clipped out of its scroll container is not activated even if its frame contains the point — the touch is sent to whatever is actually visible at that point (the step gets the note <element> contains this point but is clipped by its scroll container here (not drawn), so it was not activated; sent a touch to what is on screen at that point).
tap(sel, scroll: .noScroll) Taps without scrolling, even inside a withScrollDown { } block.
tapAppIcon(name?) Taps the app icon on the home screen. For name matching and search order, see navigation.

Example

tap("#login_btn||Log In")
tap("Settings", scroll: .down)         // searches while scrolling down
tap("#row_03", holdSeconds: 1)         // long press
tap("#txt_terms", linkText: "Terms of Service")   // a link inside a paragraph
tap(x: 120, y: 640)                    // only when no selector is available

Notes