Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →For a Puppeteer HTTPResponse, call response.ok() to check whether its HTTP status is in the 200–299 range. If your test requires one exact status or a custom rule, check response.status() instead. Guard against a missing response before calling either method.
Check the response returned by navigation
page.goto() returns an HTTPResponse that you can inspect. A completed navigation alone does not prove that the HTTP status was successful.
As an Amazon Associate I earn from qualifying purchases.
const response = await page.goto('https://example.com');
if (!response) {
throw new Error('Navigation produced no HTTP response');
}
if (!response.ok()) {
throw new Error(`HTTP ${response.status()} for ${response.url()}`);
}
ok() and status() are methods, so include parentheses. Puppeteer documents ok() as true for status codes from 200 through 299. A 404 or 500 response does not necessarily cause goto() to throw; inspect the returned response when HTTP status matters. Puppeteer: HTTPResponse.ok() · Puppeteer: Page.goto()
Choose between ok() and status()
response.ok()accepts any 2xx status. Use it when the test treats all 2xx responses as successful.response.status()returns the numeric status. Compare it directly when the application requires a specific code, such asresponse.status() === 200.
Do not use status text as the success test. The numeric status or Puppeteer’s ok() method expresses the HTTP condition. Puppeteer: HTTPResponse.status()
#1 Best Overall
Wait for a response triggered by an action
Start waiting before the click or other action that triggers the request. This avoids missing a response that arrives quickly. Match the response by URL or with a predicate:
const responsePromise = page.waitForResponse(
response => response.url() === 'https://example.com/api/data'
);
await page.click('#load-data');
const response = await responsePromise;
if (!response.ok()) {
throw new Error(`HTTP ${response.status()} for ${response.url()}`);
}
waitForResponse() resolves to the matching HTTPResponse. Its documented default timeout is 30 seconds; you can adjust the method’s timeout option or the page’s default timeout. Puppeteer: Page.waitForResponse()
Rank #2
Check application-level success separately
An HTTP 2xx status only establishes HTTP-level success. The response body may still describe an application error, and an API may require a narrower status rule. If the test depends on the content, inspect it as well as the status:
const response = await page.waitForResponse(
response => response.url() === 'https://example.com/api/data'
);
if (!response.ok()) {
throw new Error(`HTTP ${response.status()}`);
}
const data = await response.json();
if (!data.success) {
throw new Error(`Application error: ${data.message ?? 'unspecified'}`);
}
Use a body assertion that matches your API’s actual response shape. Puppeteer’s response.json() throws if the body is not valid JSON; use response.text() when the response is not JSON or you need to assert raw content. The HTTPResponse API also exposes response URL, request, and headers for identifying or examining a response. Puppeteer: HTTPResponse
Rank #3
Common problems and fixes
- Calling a method on
null:page.goto()can returnnullfor navigation toabout:blankor to the same URL with a different hash. Check the result before callingok(),status(), orurl(). Page.goto() documentation - A 404 or 500 did not throw: a valid HTTP response can still have an unsuccessful status. Inspect the returned response with
ok()orstatus(). waitForResponse()times out: ensure the wait is created before the triggering action and that the URL or predicate matches the response actually generated. The documented default timeout is 30 seconds; adjust it if the request legitimately takes longer.response.json()fails: the body is not valid JSON. Check the response content type and usetext()or an appropriate parser for the actual format.
Or skip the browser setup
If you only need a website screenshot rather than a browser response assertion, ScreenshotNeo offers a one-request screenshot API. Its cookie and consent handling removes known consent banners, newsletter popups, and chat widgets before capture; failed loads, blank pages, bot checks, and cache hits are not billed. It also provides an MCP server for AI agents.
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. ScreenshotNeo is not a substitute for testing HTTP response status in Puppeteer; it is an alternative when the task is capturing a page. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Version note
Puppeteer documentation surfaced for versions 25.10.0 and 25.12.0. If your project uses an older release, check its installed version and matching API documentation when method availability or type definitions are in question.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteQuick Recap
Rank #4
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.




