What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use await page.tap('button.submit') to send a touch tap to the first matching element. Puppeteer scrolls it into view if needed and taps its center. For most element interactions, Puppeteer recommends a locator: await page.locator('button.submit').tap().

Tap an element with a selector

Here is a complete example using Puppeteer’s direct selector-based tap method:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.tap('button.submit');
} finally {
  await browser.close();
}

Replace button.submit with a CSS selector for the target. page.tap(selector) scrolls the matched element into view when necessary, then taps its center. If the selector matches multiple elements, it taps the first; if it matches none, Puppeteer throws an error.

Prefer a locator for ordinary element interactions

Puppeteer’s locator API is designed to wait for an element to be present and in a state suitable for the requested action. That makes it a good default when a page renders or updates asynchronously:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.locator('button.submit').tap();

Use a selector specific enough to identify the intended control. Locators help with waiting, but they do not make an ambiguous selector identify the right item for you.

Choose between a selector, an element handle, and coordinates

Method Use it when Behavior to know
page.locator(selector).tap() You want to locate an element and tap it in a normal page workflow. The locator waits for the element and actionable state.
page.tap(selector) You want a concise selector-based touch action. Scrolls the match into view as needed and taps its center; taps the first match and throws if there is no match.
elementHandle.tap() You already hold a handle to the element. Scrolls into view if needed and taps the center. Throws if the element has detached from the DOM.
page.touchscreen.tap(x, y) You need to tap a known viewport position rather than find an element. Arguments are horizontal and vertical coordinates; the method dispatches touchstart and touchend.
page.click(selector) The interaction should be a mouse click. It sends mouse input, not touch input.

For example, a coordinate tap looks like this:

await page.touchscreen.tap(160, 240);

Coordinates are tied to the current viewport and layout. If the page scrolls or its dimensions change, confirm the target’s position before reusing them.

Emulate a mobile device before navigating

If the page should behave as though it is being visited on a particular device, configure emulation before navigation. Puppeteer’s emulation sets the user agent and viewport; changing these after loading can affect the site.

import puppeteer, {KnownDevices} from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.emulate(KnownDevices['iPhone 17 Pro']);
  await page.goto('https://example.com');
  await page.locator('button.submit').tap();
} finally {
  await browser.close();
}

Use a device name exported by the KnownDevices collection in the Puppeteer version installed in your project. If that name is unavailable in your installed version, choose one it does export.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot taps that fail or hit the wrong target

  • No matching element: Check the selector and whether the target exists when the action runs. If the page is still rendering, use a locator or otherwise wait for the page state you need.
  • The wrong matching element is tapped: page.tap(selector) uses the first match. Narrow the selector so it identifies the intended control.
  • An element handle is detached: The page changed after you acquired the handle. Locate the element again after the update, then tap the new handle or use a locator.
  • The page reacts differently than expected: Check whether the test requires touch or mouse input. Use tap() for touch behavior and click() for mouse behavior.
  • The mobile layout is unexpected: Apply device emulation before page.goto(), then inspect the resulting page and selector.

Or skip the browser setup

ScreenshotNeo takes website screenshots; it does not perform Puppeteer touch interactions. If the goal is a screenshot rather than testing a tap, one GET request can capture a page:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation. Cookie banners are accepted and removed before the shot, along with supported newsletter popups and chat widgets. Bot checks, blank pages and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month, no card required.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

FAQ

Does the Puppeteer version matter?

It can. Check the version installed in your project if you need compatibility with older releases, especially when using locator methods or device names.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.