feat(locator): tap a node count times with tap({ count })

Merged
PR
1d ago
+483-69

What and why

  • locator.tap({ count }) and click({ count }) tap count times in a row: Detox's multiTap(n) and Playwright's clickCount.
  • count is any positive safe integer; each engine keeps its own limit. count: 1 is a plain tap.
  • count: 2 sends the existing doubleTap action, so it does what doubleTap() does on every engine. Its step is labelled … 2 times, like 3 or more.
  • 3 or more go through a new multiTap action kind { count, modifiers? }. Following #1883, it isn't in LOCATOR_ACTION_KINDS (SPI v1); web and mobile list it explicitly. An engine without it fails with UNSUPPORTED_CAPABILITY before lookup instead of tapping once.
    • Web: click({ clickCount }), one sequence with a rising detail, so a triple click selects a paragraph.
    • Mobile: agent-device press({ count }), count presses at the doubleTap cadence. Mobile refuses more than 200 (agent-device's limit) with UNSUPPORTED_CAPABILITY before pressing.
  • A count above 1 beside position is INVALID_ARGUMENT, as modifiers beside position is (as agreed in #1855).
await screen.getByText('Shipping address').tap({ count: 3 });

Issue

Part of #1855, item locator.tap({ count: 3 }) under Locators and actions. @okwasniewski

Verified

Ran it locally: yes, except the mobile benchmark, which ran in CI (see below).

  • After merging main (5ab9121): pnpm check passes, and the e2e (6,048), web (1,055) and mobile (633) suites pass. Core's provider-credentials.test.ts "leaves a provider key no pattern can be built for alone" times out at 30 s here, and fails the same way on a clean main checkout, so it isn't from this PR.
  • Unit (locator-action-options.test.ts): count 1 → tap with a bare label; 2 → doubleTap labelled … 2 times; 3+ → one multiTap; modifiers carried; Number.MAX_SAFE_INTEGER passes through; an engine without multiTap refused before lookup; bad counts and a count above 1 with position refused before lookup; count: 1 with position still taps at the point.
  • Engine protocol: a served engine declaring multiTap advertises it, and { kind: 'multiTap', count: 3, modifiers: ['Shift'] } reaches it unchanged over JSON-RPC. The valid manifest fixture lists multiTap.
  • Chromium (web/tests/integration/tap-actions.test.ts): click detail 1, 2, 3 in one sequence, a triple click selects a paragraph, Shift held for each click.
  • Mobile: multiTap maps to interactions.press({ count }); count 201 is refused with no device call at all, 200 goes through.
  • Testbed on the built CLI: Playwright's "should select the text by triple clicking" is ported into click.e2e.ts and passes.
  • Mutation checks: each new rule (count 2 label, count 1 label, the mobile 200 guard and its placement, count 1 with position) fails a test when broken.
  • Device: apps/mobile-benchmark/tests/controls.e2e.ts adds "tap({ count: 3 }) lands three presses" on "Double-tap me", expecting "3 taps". I couldn't run it locally (no Xcode or Android SDK); it passed in CI on both the iOS simulator and the Android emulator with the real agent-device at fb1a25e. It checks that three presses arrive, not that the app reads them as one triple-tap gesture. Not tried on a physical device.

Checklist

  • Changeset added (core, e2e, web, mobile).
  • Breaking change: n/a.
  • Mobile benchmark test added (runs in CI).
  • Docs updated: reference/screen.mdx, reference/engine.mdx, reference/mobile.mdx, migrate/detox.mdx, migrate/playwright.mdx, skills/e2e/ (ja/zh synced, except the migrate/detox rows).
  • Contract change: tests/types/sdk-types.ts updated; engine manifest schema and valid fixture list multiTap.
  • Engine contract change: changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.