[Feature] Add page.waitForRequest() and page.waitForResponse()
See original GitHub issueHey!
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 URLoptions
<Object> Optional parametersmethod
<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:
- Created 5 years ago
- Reactions:16
- Comments:9 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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)
@matthaywardwebdesign - are you working on this? Can I help? (: