October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Click Elements with Puppeteer

Use Puppeteer locators for new clicks, understand page.click() behavior, and handle selector waits, navigation races, and timeouts.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For new Puppeteer code, click with a locator: await page.locator('button').click();. A locator waits for the element to be visible, enabled, in the viewport, and stable before clicking. Use page.click(selector) when maintaining older code or when you specifically need its lower-level behavior.

Use a locator for a straightforward click

Puppeteer’s page-interactions guide recommends locators for selecting and interacting with page elements. A basic click looks like this:

await page.locator('button').click();

Replace button with a selector that identifies the element you intend to click. The locator waits for its documented action preconditions and can retry if the target is not ready. If those conditions are not met before the applicable timeout, the action throws a TimeoutError. See the page interactions guide and Locator.click() API reference.

Choose a selector for the target

CSS selectors are the default, but Puppeteer also supports its own selector syntax for text, accessibility role and name, XPath, and queries through open shadow roots. Examples:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.locator('button#submit').click();
await page.locator('::-p-aria(Submit)').click();
await page.locator('div ::-p-text(Checkout)').click();

Prefer a selector that identifies the intended control rather than a broad selector that might match several elements. The official guide describes the supported selector forms.

When to use page.click()

page.click(selector) remains documented and is useful in existing code or when you need its direct page-level behavior:

await page.click('#submit');

Puppeteer finds the matching element, scrolls it into view if needed, then clicks its center using Page.mouse. If multiple elements match, it clicks the first; if none match, it throws. Refer to the Page.click() API reference.

Wait when an element appears asynchronously

A locator click is often enough: its action waits for the target to become ready. For a separate, explicit wait, use page.waitForSelector():

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.waitForSelector('#submit', { visible: true });
await page.locator('#submit').click();

waitForSelector can wait for DOM presence, visibility, or a hidden state. Its documented default timeout is 30 seconds, and you can configure it. Unlike a locator action, the wait only establishes the selector condition; it does not itself retry a later click if that action fails. See the waitForSelector() API reference.

Coordinate a click that triggers navigation

Start waiting for navigation at the same time as the click. Waiting only after the click can miss a navigation that begins immediately:

const [response] = await Promise.all([
  page.waitForNavigation(),
  page.click('a.next'),
]);

This pattern is documented in the Page.click() API reference. The response may be null for navigation types that do not produce a response, so avoid assuming it is always an HTTP response.

Locator and page-level click compared

Situation Use What to know
New interaction code page.locator(selector).click() Recommended by the guide; waits for documented readiness conditions.
Existing code or direct page-level interaction page.click(selector) Scrolls into view and clicks the matching element’s center; clicks the first match.
Click starts navigation Promise.all([page.waitForNavigation(), page.click(selector)]) Sets up the navigation wait before the click can trigger it.
Need an explicit selector wait page.waitForSelector(selector) Waits for presence, visibility, or hidden state; it does not make a later click retry automatically.

Troubleshoot a click that fails

  • No matching element: A missing match makes page.click() reject. Check that the browser is on the expected page and state, and that the selector matches the intended element. If the page renders it asynchronously, wait for it or use a locator.
  • Locator timeout: The element may be absent, hidden, disabled, outside the viewport, or moving such that its bounding box is not stable. Check the page state and selector, then address the specific unmet condition rather than disabling checks indiscriminately. Locator actions inherit the page timeout and can have an individual timeout; details are in the Page.locator() reference and Locator class reference.
  • The click happens but the next page is not ready: If the click navigates, start page.waitForNavigation() concurrently with the click using Promise.all.
  • A wait succeeds but clicking still fails: waitForSelector confirms its configured selector condition, not every locator click precondition. Use a locator action or inspect whether the element is enabled, visible, in view, and stable.
  • Using an ElementHandle workflow: The guide treats ElementHandle as a lower-level alternative. Dispose of a returned handle when finished to avoid retaining it unnecessarily.

Locator configuration can relax particular readiness checks, including viewport, visibility, enabled state, and stable bounding box. Change a check only when the page interaction genuinely requires it; doing so can allow a click in a state the default behavior is designed to wait out. See the Locator class API reference.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
The SQL Programming Language: .
  • Used Book in Good Condition
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a screenshot rather than browser interaction, ScreenshotNeo takes a screenshot or PDF from one API request. Its API does not click page elements for you; use Puppeteer when the interaction itself is required.

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

See the ScreenshotNeo API documentation for request options. Before capture, it can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Version note

The linked official Puppeteer documentation covers versions 25.10.0 to 25.12.0. Check the documentation for the version installed in your project if behavior or API details differ.

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

Frequently Asked Questions

Does Puppeteer still support page.click()?

Yes. It remains documented as a page-level method; locators are the recommended approach for new interactions.

Can Puppeteer click text or an accessible name instead of a CSS selector?

Yes. Puppeteer supports text and accessibility selector syntax as well as CSS, XPath, and open-shadow-root queries.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.