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

Use page.waitForNavigation() when a click is expected to navigate or reload the document; use waitForSelector(), a locator, or a targeted predicate when JavaScript updates the existing page. If either outcome is possible, start a bounded navigation wait before clicking, then check the URL and wait for the expected element if no navigation occurred.

Choose the wait from the change you expect

A navigation wait listens for a new URL or a reload. A selector wait listens for an element to exist in the page. The key distinction is whether the browser changes documents or the current document changes its DOM.

What the click does What to wait for What the result tells you
Loads another page or reloads the current one page.waitForNavigation() A document navigation occurred; inspect the resulting URL and response.
Uses JavaScript to add or reveal content without changing documents page.waitForSelector() or a locator The expected DOM state appeared in the current page.
May navigate or may update the DOM Start a finite navigation wait before the click; then inspect the outcome and, if needed, wait for a specific element You can handle both outcomes without leaving the navigation promise unobserved.

A URL change by itself does not always mean a new document loaded: anchor changes and History API updates can count as navigation while producing no HTTP response. Conversely, a page can change substantially through JavaScript while retaining the same URL.

Handle clicks that may navigate or update the DOM

For an action with either possible outcome, record the starting URL and arm the navigation wait before the click. Give the wait a finite timeout so a same-document update does not leave the script waiting indefinitely. Then inspect the response and URL; if neither indicates navigation, wait for the specific result element.

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.
#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.
const before = page.url();
const navigation = page.waitForNavigation({
  waitUntil: 'domcontentloaded',
  timeout: 10000,
});

await page.click('button');

const response = await navigation.catch(error => {
  if (error.name === 'TimeoutError') return null;
  throw error;
});
const after = page.url();

if (response || after !== before) {
  console.log('Navigation or URL change detected:', after);
} else {
  await page.waitForSelector('[data-result]', {
    visible: true,
    timeout: 10000,
  });
  console.log('The result appeared in the existing document.');
}

Replace button and [data-result] with selectors for the actual control and expected outcome. The timeout values are examples; choose limits that fit the application and test environment. The catch handles only Puppeteer’s timeout error and rethrows other failures rather than masking them.

This approach treats a timeout as evidence that the expected navigation was not observed within the chosen interval, not proof that the click did nothing. The URL check catches URL changes that may not provide a response. If neither navigation nor URL change occurred, the selector wait checks for the DOM outcome you actually care about.

For a click that should navigate, arm the wait first

When the control is known to navigate, start waitForNavigation() before clicking. Starting the wait afterward creates a race: the click may begin navigation before Puppeteer begins listening.

const [response] = await Promise.all([
  page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
  page.click('a.some-link'),
]);

console.log('Final URL:', page.url());
console.log('Navigation response:', response);

Promise.all() starts both operations together, with the navigation wait registered before the click promise is run. Puppeteer’s navigation wait resolves for a new URL or a reload. If the navigation involves several redirects, the response is for the last redirect in the chain. For same-document anchor or History API navigation, the response can be null, so inspect page.url() as well.

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.
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.

Use waitUntil: 'domcontentloaded' when reaching the point that the document has been parsed is sufficient. Waiting for a later lifecycle state can be inappropriate on pages with long-lived connections or activity that prevents the chosen condition from settling.

For JavaScript updates, wait for the resulting state

If a click opens a panel, inserts a search result, or reveals an inline message without loading a new document, wait for a stable selector that represents the result. Puppeteer’s waitForSelector() resolves immediately if the selector already exists; otherwise it waits for it to appear and throws when its timeout expires.

await page.click('[data-action="search"]');

const result = await page.waitForSelector('[data-testid="search-result"]', {
  visible: true,
  timeout: 10000,
});

console.log('Search result is visible:', Boolean(result));

Prefer selectors tied to stable semantics or test attributes over fragile layout details such as a deeply nested chain of classes. Decide whether you need mere presence or visibility: an element can exist in the DOM while hidden. A finite timeout makes a missing or late result fail clearly instead of turning into an indefinite wait.

Use a locator when the goal is an action-ready element

Puppeteer locators automatically wait for an element to be present and in an appropriate state for an action. They inherit the page timeout by default. This is useful when the next step is to interact with an element, rather than to classify whether a click caused navigation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
await page.locator('[data-testid="continue"]')
  .setTimeout(10000)
  .click();

A locator’s action readiness does not replace an explicit wait for a particular post-click outcome. After clicking, use a navigation wait or a wait for the resulting DOM state according to what the application is expected to do.

Interpret navigation signals carefully

  • Response and changed URL: the browser observed navigation with a response; for a redirect chain, Puppeteer reports the last redirect’s response.
  • Changed URL and null response: this can be same-document navigation, such as a History API URL change or anchor navigation. Check the resulting URL and application state rather than assuming a full document load.
  • Unchanged URL and no navigation response: the page may have updated through JavaScript. Wait for the precise element or state that signals success.
  • No expected signal: the click may not have matched, the action may be blocked, the expected selector may be wrong, or the application may take longer than the configured timeout. Diagnose the action and target before simply increasing the timeout.

Wait for content in the correct frame

If the target element is inside an iframe, run the selector wait on that frame, not on the top-level page. A top-level wait cannot find content that belongs to a child frame. Puppeteer documents that Frame.waitForSelector() works across navigations; obtain the frame that owns the target content and wait there.

const frame = page.frames().find(frame => frame.url().includes('/embedded/'));
if (!frame) throw new Error('Target frame was not found');

await frame.waitForSelector('[data-testid="embedded-result"]', {
  visible: true,
  timeout: 10000,
});

Use a frame-identification condition suited to the application; the URL fragment above is only an example. If the frame itself is created asynchronously, first wait for or locate the frame, then wait for its content.

Troubleshoot common timeouts and missed results

waitForNavigation() times out after a successful-looking click

The click may update the current document rather than navigate. Replace the navigation-only wait with a specific selector or state wait, or use the bounded dual-outcome pattern when the behavior is genuinely uncertain.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

The navigation happens, but the wait still times out

Check that the wait was created before the click. If the page navigates quickly, registering the wait afterward can miss the event. Also confirm that the selected lifecycle condition is appropriate; a later condition may not settle on a page with continuing network activity.

The selector wait resolves immediately, before the new result appears

The selector may match an element already present, perhaps a hidden or stale result container. Wait for a more specific state, such as a visible result, changed text, or a unique item associated with the latest action. Do not treat mere container presence as proof that new content arrived.

The selector wait times out although the content is visible

Verify that the selector matches the actual DOM and that the content is in the top-level document rather than an iframe. If the node exists but visibility is the issue, remove visible: true only when hidden presence is genuinely the desired condition.

The URL changes but the response is null

This is compatible with same-document History API or anchor navigation. Compare the starting and ending URL and wait for the application’s resulting state if you need to confirm that the route content changed.

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.

A wait seems to hang

Use an intentional finite timeout rather than timeout: 0, which disables the timeout for waitForSelector(). Keep the wait narrow: a named selector or relevant navigation is more diagnostic than waiting for broad network idleness on a page with persistent connections.

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 to capture a page rather than test a click’s behavior, ScreenshotNeo provides a screenshot API and MCP server. A single request can return a PNG, JPEG, WebP, or PDF; the API options include waiting for a selector, delay, or network idle, as well as custom CSS and JavaScript. See the ScreenshotNeo API documentation for request details.

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

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with page and billing outcomes reported in response headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month with no card.

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

Frequently Asked Questions

What is Puppeteer’s default timeout for waitForSelector()?

The documented default is 30,000 milliseconds. Set an explicit finite timeout when a different limit is appropriate; timeout: 0 disables it.

Can I detect a redirect just by checking whether the URL changed?

A changed URL is useful evidence, but it does not alone establish a new document load: History API and anchor navigation can change the URL without an HTTP response. Check the navigation response and the resulting page state too.

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.