The Touchscreen class provides methods to simulate touch interactions on touch-enabled devices. Access the Touchscreen instance through page.touchscreen.
Methods
tap
Simulates a tap at the specified position.
await page.touchscreen.tap(100, 200);
The x coordinate to tap at
The y coordinate to tap at
Example Usage
Tap an Element
const button = await page.locator('button');
const box = await button.boundingBox();
if (box) {
await page.touchscreen.tap(box.x + box.width / 2, box.y + box.height / 2);
}
Multiple Taps
// Tap multiple locations
await page.touchscreen.tap(100, 100);
await page.touchscreen.tap(200, 200);
await page.touchscreen.tap(300, 300);
For more complex touch interactions, consider using page.tap(selector) which handles element positioning automatically.