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

To interact with a web page using Puppeteer, open a browser, create a Page, navigate to the site, locate the control you need, perform an action, and wait for the resulting state. For most clicks and form actions, start with Puppeteer locators: they wait for a matching element to be present and in a suitable state. The examples below follow the Puppeteer 25.12.0 Getting Started guide and use selectors you may need to adapt to your page. Puppeteer Getting Started

Set up Puppeteer and open a page

Puppeteer is a JavaScript library for browser automation. Its official overview describes automation for Chrome and Firefox through the Chrome DevTools Protocol and WebDriver BiDi. A Page represents a tab-level surface where you navigate, inspect content, and interact with elements. Chrome for Developers: Puppeteer Puppeteer Page API

Install the Puppeteer package in a JavaScript project using the installation method documented for the version you choose. The following example uses the package import shown in the official 25.12.0 Getting Started guide. It launches a browser, opens a page, navigates, and closes the browser even if an action fails:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com');

  // Replace these selectors with ones that match the target page.
  await page.locator('::-p-aria(Search)').fill('Puppeteer');
  await page.locator('button[type="submit"]').click();
} finally {
  await browser.close();
}

The accessibility selector in this example expects a control whose accessible name is “Search”; the CSS selector expects a submit button. They are illustrative, not guaranteed to match example.com or another site. Inspect the target page and choose selectors that match its actual controls.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Choose a selector that expresses the target

Puppeteer supports CSS selectors as well as its own selector syntax for text, accessibility attributes, XPath, and shadow DOM. Prefer a selector that identifies the control by stable meaning where possible; use CSS when the page structure or attributes are stable. No selector form works unless the page exposes a matching element. Puppeteer Page interactions

  • Accessibility name: Useful when a control has a stable accessible name, such as a search field labeled “Search.”
  • Text: Useful when visible wording identifies the target, provided the wording is stable and sufficiently specific.
  • CSS: Concise for stable IDs, attributes, or structure, but classes and deeply nested paths can change as a site evolves.
  • XPath: Another supported choice when relationships between elements are useful to describe the target.

For interactions, use a locator rather than finding an element once and assuming it remains available. A locator resolves the target when the action is performed and automatically waits for the element to be present and in a suitable state.

Click, fill, select, and hover

Use locator actions for common user-like interactions. Replace the example selectors with those found on the page you are automating.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Click a button or link

await page.locator('button[type="submit"]').click();

Enter text into a field

await page.locator('input[name="email"]').fill('person@example.com');

fill() sets the field value through the locator interaction API. If the task depends on individual keystrokes or keyboard behavior, use Puppeteer’s keyboard APIs instead of treating a direct value assignment as equivalent.

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

Select an option or hover

await page.locator('select[name="country"]').select('CA');
await page.locator('.account-menu').hover();

The Page API also documents mouse, touch, and keyboard input, along with page-level click(), type(), select(), and hover() operations. Older calls such as page.click(selector) and page.type(selector, text) remain documented for backwards compatibility; locators are the current guide’s preferred default for actions. Puppeteer Page API Puppeteer Page interactions

Wait for the result, not an arbitrary delay

The right wait depends on what the action does. A link or form submission may navigate to a new document; a button may instead update part of the current page. Choose a wait condition that matches the expected result rather than adding a fixed sleep and assuming the work is done.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

When a click causes navigation

Register the navigation wait before clicking. Starting the wait only after the click can miss a fast navigation and create a race:

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

Use the actual selector for the link or control. If you need to inspect the navigation response, the resolved value is available in response; navigation behavior varies by site.

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

When the page updates without navigation

Wait for an observable result, such as a confirmation message or a changed element:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
await page.locator('button.save').click();
await page.locator('[role="status"]').wait();

The status selector is an example only; choose a locator for the state your page actually exposes. Puppeteer also documents waits for selectors, functions, requests, and responses. Puppeteer Page API Puppeteer Page interactions

Read page information or inspect browser state

Use Page methods for straightforward page information, and page.evaluate() when you need to read or manipulate state in the page’s JavaScript context:

const title = await page.title();
const currentUrl = page.url();
const heading = await page.evaluate(() => document.querySelector('h1')?.textContent);

Evaluation runs in the page context, so it can access the document and page JavaScript environment. For a real interaction intended to behave like user input, prefer locators and browser input methods rather than changing DOM state directly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify the interaction and capture evidence

After an action, check the result that matters: the URL, visible text, a changed control state, or another page condition. A screenshot can help diagnose what rendered, but an image alone does not prove that the intended interaction succeeded.

const resultText = await page.locator('[role="status"]').textContent();
await page.screenshot({ path: 'page.png', fullPage: true });

Puppeteer’s Page API also includes page.screenshot() and page.pdf(). The browser overview lists screenshots, PDFs, UI testing, and performance analysis among Puppeteer use cases. Puppeteer Page API Chrome for Developers: Puppeteer

Locators versus explicit element handles

Approach Waiting and retries Lifecycle work Best fit
Locator Automatically waits for the target to be present and in an appropriate state for the action. Resolves the target when the action is performed; no separate element-handle disposal in the ordinary locator flow. Default for clicks, form entry, and other actions.
waitForSelector() and an element handle Provides an explicit lower-level wait; it does not automatically retry the subsequent action if that action fails. Dispose of element handles when finished to avoid memory leaks. Cases needing explicit element acquisition or lower-level control.

Puppeteer’s interactions guide recommends locators for actions and describes waitForSelector() as a lower-level option. Puppeteer Page interactions

Troubleshoot common interaction failures

  • Locator does not match anything: The accessible name, text, or CSS selector may not match the rendered page. Inspect the page and choose a selector for an element that actually exists.
  • Click fails or targets the wrong control: The selector may be ambiguous, or the element may not be in an actionable state. Narrow the selector and use a locator action so Puppeteer can wait for an appropriate state.
  • Script continues before navigation finishes: Start waitForNavigation() in the same Promise.all() as the click that triggers navigation.
  • Navigation wait never resolves after a click: The action may update the current page without a document navigation. Wait for the resulting element, state, request, or response instead.
  • Page appears unchanged after an action: Verify the target state or URL rather than relying on a screenshot alone; the selector may have hit the wrong control or the page may use a different update flow.
  • Memory use grows in a long-running script: If using waitForSelector() and retaining element handles, dispose of handles when they are no longer needed.

Or skip the browser setup

If your task is to capture a page rather than interact with its controls, ScreenshotNeo provides a screenshot API and MCP server for developers. One GET request can return an image or PDF. See the ScreenshotNeo documentation for options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

Version and documentation notes

The Puppeteer Getting Started guide reviewed for this article identifies version 25.12.0. Puppeteer documentation can change, so check the live interaction guide and API reference if a method’s behavior differs from your installed version. Getting Started Page interactions

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.