question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Add page.waitForRequest() and page.waitForResponse()

See original GitHub issue

Hey!

After using Puppeteer for a little while now in a number of different scenarios (SSR, automated testing) a common piece of functionality that often came up as needed, or at very minimum a nice to have, was the ability to wait for a specific network request to be made, or alternatively for a specific network response to come back. As a result I propose the addition of the following two functions.

page.waitForRequest( match[, options])
  • match <string> A regular expression to match against the request URL
  • options <Object> Optional parameters
    • method <string|Array> Either a single HTTP request method (GET, POST, etc) as a string or an array of values ["GET", "POST"]. Defaults to all HTTP request methods.
    • timeout <number> Maximum time to wait in milliseconds

And additionally

page.waitForResponse( match[, options])

With a similar set of options. I’d probably also additionally add support for filtering by response code.

An example

await page.waitForRequest( 'https?://example.com/(users|companies)', { method: 'POST' });

Happy to submit a PR if you all think it’s a worthwhile addition!

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:16
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
yanivefraimcommented, May 28, 2018

@aslushnikov - I started implementing this feature, and I have a questions regarding the api: Do we want to get an options object, with timeout, for example? (or is it enough to use default timeout)

1reaction
yanivefraimcommented, May 21, 2018

@matthaywardwebdesign - are you working on this? Can I help? (:

Read more comments on GitHub >

github_iconTop Results From Across the Web

puppeteer.Page.waitForResponse JavaScript and Node.js ...
Closes browser with all the pages (if any were opened). Page.evaluate. Evaluates a function in the browser context. Page.click,; Page.waitForSelector,; Page.
Read more >
Playwright waitForResponse how to wait till the response has ...
I tried below code but it is not waiting till the status is completed. const response = await page.waitForResponse(response => response.url().
Read more >
Page.waitForResponse() method - Puppeteer
Returns: Promise<HTTPResponse>. Promise which resolves to the matched response. Remarks​. Optional Parameter have: timeout : Maximum wait time in ...
Read more >
Consistently waiting for network responses in Playwright
One of the neat features I like about Playwright is how easily it is to wait for network responses that are triggered by...
Read more >
Puppeteer documentation - DevDocs
executablePath() is affected by the PUPPETEER_EXECUTABLE_PATH and PUPPETEER_CHROMIUM_REVISION env ... An example of using a Browser to create a Page:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found