Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Most Pyppeteer click hangs are caused by waiting for the wrong event or starting waitForNavigation() after the click. For a real document navigation, start the wait and click concurrently with asyncio.gather(). For a single-page update, do not wait for navigation at all: wait for the result element or application condition your next step needs.
The correct pattern for a click that navigates
Pyppeteer’s API warns that a separate navigation wait can race with a navigation-triggering click. The reliable pattern starts both coroutines together, with the navigation wait created first:
import asyncio
from pyppeteer import launch
async def main():
browser = await launch(headless=True)
page = await browser.newPage()
try:
await page.goto('https://example.com', {'waitUntil': 'domcontentloaded'})
await asyncio.gather(
page.waitForNavigation({'waitUntil': 'domcontentloaded'}),
page.click('a.my-link'),
)
print('Destination:', page.url)
finally:
await browser.close()
asyncio.run(main())
Putting waitForNavigation() and click() in separate sequential statements can miss a fast navigation: the click may trigger and complete the transition before the wait begins. The concurrent pattern avoids that gap.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Use the selector and click options together
Replace a.my-link with a stable selector. Prefer an ID, data attribute, or semantic class over a position-dependent selector such as div:nth-child(3). If the control is hidden or covered, make it actionable before the gather call:
#1 Best Overall
- Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
- Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
- Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
- Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
- Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)
await page.waitForSelector('button.continue', {'visible': True})
await asyncio.gather(
page.waitForNavigation({'waitUntil': 'load'}),
page.click('button.continue'),
)
Do not add a second click after a timeout without checking whether the first click actually navigated. Retrying blindly can submit a form twice or create duplicate actions.
Choose the right waitUntil readiness state
waitUntil describes the event that ends the navigation wait; it is not a universal “page is ready” switch. Pyppeteer 0.0.25 documents four choices:
| Value | What it waits for | Use it when | Important limitation |
|---|---|---|---|
domcontentloaded |
The HTML document has been parsed. | Your next operation only needs the initial DOM. | Images, stylesheets, and late scripts may still be loading. |
load (default) |
The page’s load event. | You need the browser’s normal load milestone. | It still does not prove that application data has rendered. |
networkidle0 |
No more than zero active connections for 500 ms. | A page genuinely becomes quiet after loading. | Analytics, polling, websockets, or other background traffic can prevent completion. |
networkidle2 |
No more than two active connections for 500 ms. | You need a quiet network but the site keeps a small amount of background traffic. | It can still wait indefinitely on continuously active applications. |
Pick the earliest state that satisfies the task. If you need a product card, dashboard value, or search result, waiting for that element is usually more precise than waiting for global network idleness.
When a click does not navigate
Many controls open a modal, reveal a panel, fetch JSON, or update the current document through JavaScript. A navigation wait is then the wrong event and will eventually time out.
Wait for a result selector
await page.click('button.show-results')
await page.waitForSelector('.results', {
'visible': True,
'timeout': 10000,
})
text = await page.querySelectorEval('.results', '(el) => el.textContent')
print(text.strip())
waitForSelector can wait for presence or visibility and accepts a per-call timeout. Waiting for the actual output also protects you from a click handler that responds before its network request has finished.
Rank #2
- The next-generation optical HERO sensor delivers incredible performance and up to 10x the power efficiency over previous generations, with 400 IPS precision and up to 12,000 DPI sensitivity
- Ultra-fast LIGHTSPEED wireless technology gives you a lag-free gaming experience, delivering incredible responsiveness and reliability with 1 ms report rate for competition-level performance
- G305 wireless mouse boasts an incredible 250 hours of continuous gameplay on just 1 AA battery; switch to Endurance mode via Logitech G HUB software and extend battery life up to 9 months
- Wireless does not have to mean heavy, G305 lightweight mouse provides high maneuverability coming in at only 3.4 oz thanks to efficient lightweight mechanical design and ultra-efficient battery usage
- The durable, compact design with built-in nano receiver storage makes G305 not just a great portable desktop mouse, but also a great laptop travel companion, use with a gaming laptop and play anywhere
Wait for an application condition
await page.click('#run-report')
await page.waitForFunction(
"""() => document.querySelector('#status')?.textContent.trim() === 'Complete'""",
{'timeout': 15000},
)
Use a condition that represents success: a status becoming “Complete,” a disabled attribute disappearing, a row count reaching an expected value, or a known URL field changing. Avoid arbitrary sleeps when a deterministic condition is available.
History API and hash changes
A site can call history.pushState() or history.replaceState() to change the URL without a full reload. Pyppeteer treats History API URL changes as navigation. A same-document hash transition can instead return None, so a navigation wait may not give you a new document. For hash links and client-side routers, wait for the route-specific element or URL condition as well as, or instead of, navigation.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Diagnose a navigation timeout in order
- Confirm the click occurred. Wait for the selector to be visible, verify it is not covered, and log immediately before and after
page.click(). A selector error is different from a navigation timeout. - Classify the transition. Decide whether it is a reload/full document navigation, a History API route change, a hash change, or a DOM-only update. Only the first two normally justify
waitForNavigation(). - Relax an over-strict readiness condition. Replace
networkidle0withdomcontentloadedorload, then wait for the specific element required by your task. Persistent polling can make network-idle impossible. - Read the exception text. Pyppeteer navigation failures include SSL errors, invalid URLs, timed-out operations, and main-resource failures. Fix the underlying URL, certificate, server, or request problem rather than only increasing the timeout.
- Check whether the destination is genuinely slow. If the expected event is correct and the server is simply slow, increase the timeout for that call or set a suitable default.
Timeouts: what they change and what they cannot fix
Pyppeteer’s documented default navigation timeout is 30 seconds. You can set a timeout for one call:
await page.waitForNavigation({
'waitUntil': 'domcontentloaded',
'timeout': 60000,
})
Or configure the page’s default navigation timeout:
page.setDefaultNavigationTimeout(60000)
A timeout of 0 disables the timeout:
page.setDefaultNavigationTimeout(0)
Disabling or extending the timer does not create a navigation event. If the click opens an in-page panel, the wait will still never finish; change the event you are waiting for. Avoid an unlimited timeout in unattended jobs unless you also implement your own cancellation and monitoring.
Rank #3
- Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
- Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
- Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
- Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
- Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)
A complete diagnostic script
This example distinguishes a document navigation from a DOM update and reports the resulting URL:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsimport asyncio
from pyppeteer import launch
from pyppeteer.errors import TimeoutError
async def main():
browser = await launch(headless=True)
page = await browser.newPage()
page.setDefaultNavigationTimeout(30000)
try:
await page.goto('https://example.com', {'waitUntil': 'domcontentloaded'})
# For a link that performs a document or History API navigation:
try:
await asyncio.gather(
page.waitForNavigation({'waitUntil': 'domcontentloaded'}),
page.click('a.my-link'),
)
print('Navigated to', page.url)
except TimeoutError:
print('No qualifying navigation completed; inspect the click behavior.')
# For a control that updates the current document instead:
# await page.click('button.show-results')
# await page.waitForSelector('.results', {'visible': True, 'timeout': 10000})
finally:
await browser.close()
asyncio.run(main())
In production, add logging for the selector, current URL, chosen waitUntil value, and elapsed time. Capture a screenshot or HTML snapshot on failure so you can see whether a consent dialog, login page, error page, or bot check blocked the expected control.
Installation and Chromium setup failures
Some “navigation” failures happen before a page can navigate. Pyppeteer downloads Chromium on its first run; the documentation also describes running pyppeteer-install to install the browser ahead of time. Verify that the executable can launch, the process has permission to write its cache, and the machine has enough shared memory and outbound network access.
python -m pip install pyppeteer
pyppeteer-install
Pin and test the Pyppeteer version used by your project. The API details above come from the 0.0.25 documentation, so check your installed release for spelling or option differences.
Reliability practices for real sites
Wait for task state, not arbitrary time
await asyncio.sleep(5) can be too short on a busy run and wasteful on a fast one. Prefer a visible selector, a URL predicate, a status value, or a bounded function wait.
Recommended Free Tools
Rank #4
- Computer mouse for easily navigating a computer interface; click, scroll, and more
- USB-A wired connection; if existing device only supports USB-C, an additional adapter will be required
- High-definition (1000 dpi) optical tracking ensures responsive cursor control for precise tracking and easy text selection
- 3 buttons offer effortless fingertip control
- Plug-and-go ready for instant use
Use layered waits
A practical sequence is: wait for the clickable control; perform the click and navigation wait together when appropriate; then wait for the destination’s key element. This separates “the browser changed documents” from “the application finished rendering.”
Handle redirects and external destinations
After navigation, inspect page.url and verify the expected origin or path. Authentication redirects, regional redirects, and server error pages can all satisfy a generic load event while leaving your script on the wrong page.
Keep retries safe
Retry only idempotent navigation or a click you know was not delivered. For form submissions and purchases, first inspect the current URL or page state before repeating the action.
Pyppeteer maintenance and a Playwright decision
The Pyppeteer project repository currently says it is unmaintained and recommends considering Playwright Python. That is a maintenance signal, not an automatic requirement to rewrite. Evaluate migration if you need ongoing browser-version support, active bug fixes, or modern locator APIs. Playwright’s Python guidance emphasizes locator auto-waiting and web assertions for readiness rather than relying on network-idle in tests. A migration is not necessarily drop-in: review selectors, browser launch code, event handling, and fixtures before changing a production suite.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchOr skip the browser setup
If your goal is a clean image or PDF rather than interaction testing, ScreenshotNeo provides a single screenshot API request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
See the ScreenshotNeo API documentation for all options. A minimal cURL request is:
Best Value
- 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
- 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
- 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
- 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
- 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The equivalent Python call is:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
And Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also supports full-page captures with lazy images loaded, CSS-selector element shots, dark mode, device presets or custom viewports, retina scale, PDF paper and page-range controls, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector/delay/network-idle waits, request and resource blocking, custom headers/cookies/user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed image links, asynchronous jobs with signed webhooks, up to 100 URLs per bulk call, a usage API, an OpenAPI specification, and familiar parameter names for easier switching. Every feature is on every plan. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Frequently Asked Questions
Why does waitForNavigation() return None?
A same-document hash transition can complete without a new document response. Check the URL or wait for the route-specific DOM state instead.
Should I always use networkidle0 for screenshots?
No. Pages with polling, analytics, or websocket traffic may never become idle. Use the narrowest readiness condition that proves the content you need is present.
Is Playwright Python a drop-in replacement for Pyppeteer?
No. The projects have different APIs and maintenance models. Treat migration as a planned change and test launch settings, selectors, waits, and assertions.
Quick Recap
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.

