Use Playwright’s page.on('request') and page.on('response') listeners to observe background traffic, waitForResponse() to capture the response caused by a specific action, and page.route() or browserContext.route() to intercept, mock, modify, or block requests. Register listeners and waits before navigation or the action that triggers traffic, then choose the narrowest tool that matches your goal.
Choose the right Playwright network API
| Goal | API | Scope and result |
|---|---|---|
| Log a stream of traffic | page.on('request'), page.on('response') |
One page; passive observation |
| Log traffic from every page, including popups | browserContext.on('request'), browserContext.on('response') |
All pages in a browser context |
| Wait for one response after a click or submit | page.waitForResponse() |
A promise resolved by a URL, glob, regular expression, or predicate |
| Wait for the outgoing request | page.waitForRequest() |
Captures method, URL, headers, and post data |
| Mock, alter, continue, or abort traffic | page.route(), browserContext.route() |
Intercepts matching requests; every handler must decide what happens |
Playwright’s network guide and Page API document these interfaces. Use listeners when you only need to see traffic; routing changes the request path and can affect application behavior.
Capture every request and response on one page
Attach handlers before goto() or before the user action under investigation. Otherwise an early request can occur before your code starts listening.
import { test } from '@playwright/test';
test('log background traffic', async ({ page }) => {
page.on('request', request => {
console.log('REQUEST', request.method(), request.url());
});
page.on('response', response => {
console.log('RESPONSE', response.status(), response.url());
});
page.on('requestfailed', request => {
console.log('FAILED', request.failure()?.errorText, request.url());
});
await page.goto('https://example.com');
});
The request event fires when Playwright sends the request. The response event fires when status and headers arrive; it does not guarantee that the body has downloaded. A request that reaches an HTTP server and receives 404 or 503 is still an HTTP response, not a transport failure. requestfailed is for conditions such as DNS errors, connection failures, or timeouts. See the Request API for lifecycle details.
#1 Best Overall
- Compatible with Nintendo Switch 2’s new GameChat mode
- Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
- Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
- Built-In Mic: The built-in microphone lets others hear you clearly during video calls
- Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works
Read a response body
page.on('response', async response => {
if (!response.url().includes('/api/')) return;
try {
const contentType = response.headers()['content-type'] || '';
const body = contentType.includes('application/json')
? await response.json()
: await response.text();
console.log(response.status(), response.url(), body);
} catch (error) {
console.warn('Body unavailable:', response.url(), error);
}
});
Body reads can fail for an aborted request, a response whose body is unavailable, or a non-text binary resource. Filter before reading to avoid attempting to parse images, fonts, and large files.
Capture traffic from every page in a browser context
Use context listeners when a test opens popups, creates multiple pages, or needs one central network log.
const context = await browser.newContext();
context.on('request', request => {
console.log('>>', request.method(), request.url());
});
context.on('response', response => {
console.log('<<', response.status(), response.url());
});
const page = await context.newPage();
await page.goto('https://example.com');
Context-level events cover pages sharing that context. The BrowserContext API also provides context routing. For popup traffic, context routing is safer: the Page API notes that page.route() does not intercept the first request made by a popup.
Filter noisy logs
Network-heavy pages can produce thousands of events. Filter by URL, method, resource type, or status.
Recommended Free Tools
Rank #2
- Compatible with Nintendo Switch 2’s new GameChat mode
- Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
- The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
- C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
- The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.
page.on('request', request => {
if (request.method() === 'POST' && request.url().includes('/api/')) {
console.log(request.url(), request.postData());
}
});
page.on('response', response => {
if (response.url().includes('/api/') && response.status() >= 400) {
console.error(response.status(), response.url());
}
});
Playwright URL globs support * for characters other than /, ** across path separators, and braces for alternatives. Regular expressions and predicate functions are also supported; details are in the network documentation.
Wait for the response caused by an action
Create the wait promise first, perform the action second, and await the promise third. This ordering prevents a fast response from winning a race against your listener.
const responsePromise = page.waitForResponse(response =>
response.url().includes('/api/search') &&
response.request().method() === 'GET' &&
response.status() === 200
);
await page.getByRole('button', { name: 'Search' }).click();
const response = await responsePromise;
const data = await response.json();
console.log(data);
The predicate should match the URL the application actually requests. You can pass a glob such as **/api/search, a regular expression, or a function. Set an explicit timeout when a missing response should fail quickly:
const response = await page.waitForResponse(
r => r.url().endsWith('/api/search') && r.ok(),
{ timeout: 15_000 }
);
For the outgoing request, use the analogous page.waitForRequest() before the action. Avoid using networkidle as a general readiness signal; the Page documentation marks it as discouraged for tests. Assert on the UI or wait for the specific response your scenario requires.
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 →Rank #3
- 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
- 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
- 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
Understand the request lifecycle
For a successful request, the normal order is request, response, then requestfinished. The response event means that status and headers arrived. requestfinished follows completion of the response body download. A redirect finishes the original request and creates a new request for the redirected URL.
page.on('requestfinished', request => {
console.log('BODY COMPLETE', request.url());
});
page.on('requestfailed', request => {
console.log('NO HTTP RESPONSE', request.url(), request.failure());
});
Do not classify an HTTP error status as a failed transport. Check response.status() or response.ok() for server errors, and request.failure() for network-level failures. The lifecycle is described in the Request API.
Intercept, mock, or modify requests
Listeners observe traffic; routes intercept it. Register a route before navigation or the action that causes the request. A matching route remains stalled until your handler calls continue(), fulfill(), or abort().
Return a fixture instead of calling the real API
await page.route('**/api/search', route => route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ results: [] }),
}));
await page.goto('https://example.com');
Let the request continue
await page.route('**/analytics/**', route => route.continue());
Fetch the real response, then change it
await page.route('**/api/profile', async route => {
const response = await route.fetch();
const json = await response.json();
json.plan = 'test';
await route.fulfill({
response,
contentType: 'application/json',
body: JSON.stringify(json),
});
});
Use browserContext.route() when all pages need the same interception or when a popup’s first request must be handled. Routing is documented in the network guide and BrowserContext API.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #4
- 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
- Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
- Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
- Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
- High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
Why page.route() may not catch a request
A Service Worker handled it
Native page and context routing does not intercept requests intercepted by a Service Worker. When the worker is not the subject of the test, create the context with workers blocked:
const context = await browser.newContext({ serviceWorkers: 'block' });
This changes the site’s behavior, so do not block workers in a test whose purpose is to verify worker caching or fetch handling. Mock Service Worker (MSW) also installs a Service Worker and can make requests invisible to built-in routing.
You registered too late
Move the route, listener, or wait before goto(), popup creation, or the click that starts the request.
The matcher is wrong
Log request.url() first, then adjust the glob, regular expression, or predicate. Query strings, redirects, versioned paths, and different HTTP methods commonly cause a mismatch.
Best Value
- Compatible with Nintendo Switch 2’s new GameChat mode
- HD lighting adjustment and autofocus: The Logitech webcam automatically fine-tunes the lighting, producing bright, razor-sharp images even in low-light settings. This makes it a great webcam for streaming and an ideal web camera for laptop use
- Advanced capture software: Easily create and share video content with this Logitech camera that is suitable for use as a desktop computer camera or a monitor webcam
- Stereo audio with dual mics: Capture natural sound during calls and recorded videos with this 1080p webcam, great as a video conference camera or a computer webcam
- Full HD 1080p video calling and recording at 30 fps. You'll make a strong impression with this PC webcam that features crisp, clearly detailed, and vibrantly colored video
Inspect worker-originated traffic
Context request and response events include Service Worker requests. Where supported, inspect request.serviceWorker(); a Service Worker-originated request has no frame. response.fromServiceWorker() identifies a page response handled by a worker. Playwright’s documented Service Worker support is limited to Chromium-based browsers; see Service Workers.
Reliability, performance, and test design
- Install only the listeners needed for the test and filter early; logging every body can consume memory and slow runs.
- Prefer a targeted
waitForResponse()over sleeping for a fixed duration. - Use unique predicates when several identical API calls can occur, such as checking method, URL, status, and a request payload value.
- Always remove long-lived listeners in shared fixtures when they should not leak into later tests.
- Set timeouts appropriate to your CI network, and report the URL and predicate when a wait times out.
- Use
requestfinishedwhen you need to know that the body downloaded, not merely that headers arrived. - Remember that routes alter application behavior; use passive listeners for diagnostics and route interception for deliberate mocks.
Or skip the browser setup
If your real goal is a clean visual capture rather than inspecting API traffic, ScreenshotNeo provides a single website-screenshot API call. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Only clean shots are billed: bot checks, 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.
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 documentation for the 63 capture options, including full-page lazy-image loading, CSS-selector elements, devices and viewports, dark mode, retina scale, PDF output, custom CSS and JavaScript, clicks, waits, blocking, headers, cookies, authorization, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, async webhooks, bulk capture, usage, and OpenAPI compatibility.
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 also provides an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
FAQ
Does response mean the body is ready?
No. It means status and headers arrived. Wait for requestfinished when body-download completion matters.
Should I use page or context listeners?
Use page listeners for one page and context listeners for all pages, including popup-related traffic.
Why does a 404 not trigger requestfailed?
A 404 is a valid HTTP response. requestfailed indicates that no HTTP response was successfully received.
Can routing and Service Workers coexist?
Worker-intercepted requests are invisible to native routing. Block workers when appropriate, or observe worker behavior with context events.
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.




