dispatch synthetic touch gestures in a playwright mobile-emulated context using page.touchscreen
domain: playwright.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
launch a browser context with a mobile device descriptor (e.g. devices['iPhone 13']) so hasTouch and the viewport match a touch-capable device
call page.touchscreen.tap(x, y) to dispatch a touchstart/touchend pair at specific page coordinates, simulating a tap gesture
for element-targeted taps, locate the element's bounding box first and compute the center coordinates to pass into touchscreen.tap()
combine multiple tap calls with page.waitForTimeout or state assertions in between to simulate multi-step touch interactions like a swipe sequence
verify touch-specific UI behavior (e.g. touch-only hover states or swipeable carousels) that would not be exercised by a standard mouse click
Known gotchas
touchscreen actions only produce realistic behavior in a context where hasTouch is enabled; using them in a desktop, non-touch context can produce events the page's touch handlers don't expect
page.touchscreen.tap() dispatches raw touch events at coordinates -- it does not perform the same auto-waiting/visibility checks that a locator-based click does
Give your agent this knowledge — and 15,500+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?