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

A Playwright waitForEvent timeout usually means the listener was attached too late, the event was emitted by a different page or context, a predicate rejected every event, or the page was closed before the event arrived. The reliable fix is to create the wait promise first, perform the action second, and await the stored promise third.

const downloadPromise = page.waitForEvent('download');
await page.getByText('Download file').click();
const download = await downloadPromise;

This ordering is the pattern shown in the Playwright Page API documentation. A longer timeout cannot repair a missing event.

The synchronization order that prevents most timeouts

waitForEvent returns a promise that resolves when the selected object emits the named event. Do not await that promise before performing the action that causes the event; doing so blocks the action indefinitely.

Correct download pattern

const downloadPromise = page.waitForEvent('download');
await page.getByRole('button', { name: 'Download file' }).click();
const download = await downloadPromise;
await download.saveAs('artifacts/report.pdf');

The first line installs the listener. The click then causes the download, and the final line retrieves the event data. The documentation describes this as “Start waiting for download before clicking. Note no await.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Amazon Basics Wired QWERTY Keyboard, Works with Windows, Plug and Play, Easy to Use with Media Control, Full-Sized, Black
  • KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
  • EASY SETUP: Experience simple installation with the USB wired connection
  • VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
  • SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
  • FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.

Incorrect order

// Do not do this: the action cannot run until the event occurs.
const download = await page.waitForEvent('download');
await page.getByRole('button', { name: 'Download file' }).click();

If the event is very fast, registering after the click can also miss it:

// The download may already have happened here.
await page.getByRole('button', { name: 'Download file' }).click();
const download = await page.waitForEvent('download');

Use the event scope that owns the event

Page and browser-context waits observe different scopes. A page wait is appropriate when the known action on one page creates the event. A context wait is better when any page in the context may be created and the triggering action is not reliably tied to one page.

Popup opened by a known page

const popupPromise = page.waitForEvent('popup');
await page.getByText('open the popup').click();
const popup = await popupPromise;

A page-scoped popup event represents a popup opened by that page.

Any new page in the browser context

const newPagePromise = new Promise(resolve => {
  context.once('page', resolve);
});
await triggerThatMayOpenAPage();
const newPage = await newPagePromise;

The Playwright Pages guide shows listening for browserContext.on('page') to collect new pages, including popups. Use this when the code that creates the page is unknown, happens in another tab, or can be initiated by more than one existing page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Logitech MK270 Full Size Wireless Keyboard and Mouse Combo - Black
  • Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
  • Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
  • Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
  • Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
  • Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites

Choosing between the two

Question Use Reason
Do you know which page and action create the event? page.waitForEvent() Narrow scope makes the relationship explicit.
Could any page in the context be created? context.waitForEvent('page') or a context listener Observes the whole browser context.
Do you need to reject unrelated events? A predicate Resolves only for an event payload that matches your condition.

Check the event name and the object

The event name passed to waitForEvent must be one emitted by the object on which you call it. Confirm both sides of the expectation:

  • Identify what the application actually does: download, popup, response, request, dialog, file chooser, page creation, or another event.
  • Check whether that event belongs to the page, browser context, browser, request object, or another Playwright object.
  • Make sure the action is capable of producing the event in this test state. A disabled button, client-side validation error, or blocked permission can mean no event is emitted.
  • Do not substitute a similarly named event. Waiting for response will not resolve from a request, and a page popup wait will not observe an unrelated context page.

When a timeout says it is waiting for an event such as response or download, treat that text as a clue about the listener—not proof that the application should have emitted the event.

Diagnose predicates that never match

A predicate is an additional filter. The wait resolves only when the event payload is truthy for that predicate. A correct event with a wrong URL, status, filename, or other assumption still times out.

Response predicate

const responsePromise = page.waitForEvent('response', response =>
  response.url().endsWith('/api/export') && response.status() === 200
);
await page.getByRole('button', { name: 'Export' }).click();
const response = await responsePromise;

During diagnosis, temporarily remove the predicate to determine whether the event arrives at all:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
  • All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
  • Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
  • Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
  • Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
  • Plastic parts in K120 include 51% certified post-consumer recycled plastic*
const responsePromise = page.waitForEvent('response');
await page.getByRole('button', { name: 'Export' }).click();
const response = await responsePromise;
console.log(response.url(), response.status());

Then tighten the filter using values observed from the event. Be careful with redirects, query strings, trailing slashes, non-200 success responses, and multiple requests generated by one click.

Download predicate

const downloadPromise = page.waitForEvent('download', download =>
  download.suggestedFilename().endsWith('.csv')
);
await page.getByRole('button', { name: 'Export CSV' }).click();
const download = await downloadPromise;

If the application can produce more than one download type, verify the suggested filename rather than assuming the first event is the desired file.

Understand timeout settings before changing them

waitForEvent accepts a timeout option. The Page API documents a default of 0 and points to action-timeout configuration and timeout-setting methods. Browser-context event waits also document a 0 default and support the context’s default timeout settings.

Set a deliberate per-wait timeout

const popupPromise = page.waitForEvent('popup', { timeout: 15_000 });
await page.getByText('Open report').click();
const popup = await popupPromise;

Use a finite value when you want a bounded diagnostic failure. If your project configures defaults, inspect the test configuration and any calls to methods such as page.setDefaultTimeout(), browserContext.setDefaultTimeout(), or equivalent configuration. Also distinguish this event-wait timeout from navigation, assertion, and action timeouts; changing one may not change another.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Redragon K521 Upgrade Rainbow LED Gaming Keyboard, 104 Keys Wired Mechanical Feeling Keyboard with Multimedia Keys, One-Touch Backlit, Anti-Ghosting, Compatible with PC, Mac, PS4/5, Xbox
  • 【Dreamy Rainbow Gaming Keyboard】K521 Gaming Keyboard Adopts a Different LED Backlight Design, Upgraded on the Traditional LED Backlight Effect, Making the Light More Penetrating, Giving You a More Dazzling Visual Effect, Making Your Gaming Process More Enjoyable
  • 【One Touch Opens & Visual Feast】The K521 Red Dragon Keyboard has a One-Touch on/off Lighting Button for Added Convenience. It also has a Three-Position Adjustable Breathing Mode and a Four-Position Adjustable Brightness Lighting Mode
  • 【Mechanical Feeling & Fast Tapping】The PC Keyboard Keys are Designed for Mechanical Feeling, Giving You a Better Feel During Use and the Ability to Trigger Keys Quickly, Allowing You to Win All Your Games
  • 【19 Keys Anti-Ghosting Keyboard】Anti-Ghosting Ensures Every Button Can Be Triggered. This Allows You to Trigger Key Combinations In The Game Accurately, And Each Skill Can Be Accurately Released to Increase Your Winning Rate. Redragon K521 Will Be Your Perfect Partner
  • 【12 Multimedia Combination Keys】The K521 Wired Gaming Keyboard is Equipped with 12 Multimedia Keys That Can Greatly Enhance Your Gaming/Office Efficiency and Make It More Convenient to Use

Increasing a timeout is appropriate only when the event is known to occur slowly and the listener, scope, predicate, and lifecycle are already correct. It is not a fix for a click that never emits the expected event.

Separate event arrival from page readiness

Receiving a popup means a new page object exists; it does not mean its document or application content is ready. Wait for the event first, then wait for the readiness condition your test actually needs.

const popupPromise = page.waitForEvent('popup');
await page.getByText('Open account').click();
const popup = await popupPromise;
await popup.waitForLoadState('domcontentloaded');
await popup.getByRole('heading', { name: 'Account' }).waitFor();

Use a web assertion or a specific selector for useful content. The Playwright documentation discourages networkidle as a generic testing strategy; network activity can continue because of analytics, polling, or other background work even when the UI is ready.

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

Check page and context lifecycle

A page-scoped wait can fail if that page closes before the event arrives. A context-scoped wait can fail if the browser context closes first. Review teardown hooks, explicit page.close() or context.close() calls, navigation that replaces the page, and fixtures whose lifetime ends before the stored promise is awaited.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Logitech K270 Full Size Wireless Keyboard for Windows - Black
  • All-day Comfort: This USB keyboard creates a comfortable and familiar typing experience thanks to the deep-profile keys and standard full-size layout with all F-keys, number pad and arrow keys
  • Built to Last: The spill-proof (2) design and durable print characters keep you on track for years to come despite any on-the-job mishaps; it’s a reliable partner for your desk at home, or at work
  • Long-lasting Battery Life: A 24-month battery life (4) means you can go for 2 years without the hassle of changing batteries of your wireless full-size keyboard
  • Simply plug the USB receiver into a USB port on your desktop, laptop or netbook computer and start using the keyboard right away without any software installation
  • Simply Wireless: Forget about drop-outs and delays thanks to a strong, reliable wireless connection with up to 33 ft range (5); K270 is compatible with Windows 7, 8, 10 or later

Keep the owner alive

const popupPromise = page.waitForEvent('popup');
await page.getByRole('link', { name: 'External report' }).click();
const popup = await popupPromise;
// Do not close page or context before all popup assertions finish.
await popup.waitForLoadState('domcontentloaded');

If a helper starts the wait but returns after closing its fixture, move the wait and the action into the same lifetime scope or return the promise without disposing the owner.

Do not replace the event with a fixed sleep

The Page API guidance says, “Never wait for timeout in production. Tests that wait for time are inherently flaky.” page.waitForTimeout() is for debugging, not synchronization. Replace sleeps with the signal that represents the condition: the event itself, a URL change, a specific response, a selector, or a web assertion.

A practical troubleshooting checklist

  1. Store the waitForEvent promise before clicking or triggering the action.
  2. Confirm the event name matches an event emitted by the chosen object.
  3. Use the page for a known page-owned event and the context for new pages across the context.
  4. Remove predicates temporarily, log the event payload, then correct URL, status, filename, or other filters.
  5. Inspect explicit timeout options and project defaults; do not assume an action timeout controls every wait.
  6. Verify the page and browser context remain open until the event promise resolves.
  7. After an event arrives, add a separate readiness assertion instead of relying on a generic delay or networkidle.
  8. Reproduce with the smallest action that should emit the event and capture the resulting error text.

Or skip the browser setup

If your goal is a clean image or PDF of a URL rather than an interactive Playwright event, ScreenshotNeo provides a single HTTP request. It accepts cookie and consent banners as a visitor, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets each cleanup step be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and whether the shot was billed. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

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 all options, including full-page capture, CSS selectors, device presets, custom waits, headers and cookies, PDF output, caching, bulk jobs, and signed links.

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

Python

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)

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 includes 1,000 screenshots per month free without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Frequently Asked Questions

Does a zero timeout mean the wait never times out?

In the current Playwright web documentation, the documented default for these event waits is 0. Your installed binding, project configuration, or an explicit option can still impose a different effective limit, so check the matching API reference and test configuration.

Why does a popup wait pass but the next assertion fail?

The popup event only proves that a page object was created. Wait for a concrete load or DOM condition on that popup before asserting its content.

Should I use a context listener for every popup?

No. Use a page-scoped wait when the creating page and action are known. Use the context scope when page creation can originate anywhere or the triggering action is uncertain.

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

Quick Recap

Bestseller No. 1
SaleBestseller No. 3
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Plastic parts in K120 include 51% certified post-consumer recycled plastic*; Product carbon footprint: 4.02 kg CO2e
$12.34
SaleBestseller No. 5
Logitech K270 Full Size Wireless Keyboard for Windows - Black
Logitech K270 Full Size Wireless Keyboard for Windows - Black
Plastic parts in K270 include 38% certified post-consumer recycled plastic; Eight hot keys: For instant access to the Internet, e-mail, music volume and more
$21.48

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.