-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Add page.waitForRequest() and page.waitForResponse() #2362
Comments
I think this would be pretty helpful |
Kindly submit a Pull request 😄 |
This looks reasonable. Feel free to submit a PR. Let's pass // Wait for regex to match
const request = await page.waitForRequest(new RegExp('https?://example.com/(users|companies)'), { method: 'POST' });
// Wait for exact url
const request = await page.waitForRequest('https://example.com/'); |
@aslushnikov @dowsanjack Thanks! Will get to it within the next couple of days :) |
Agreeing with @aslushnikov, but since there's some minor differences between RegExp objects and literals, please do test both :-) |
@matthaywardwebdesign - are you working on this? Can I help? (: |
@aslushnikov - I started implementing this feature, and I have a questions regarding the api: |
@yanivefraim yes, options object with timeout will come handy. It will also make API consistent with other waitFor* methods. |
This patch introduces `page.waitForRequest` and `page.waitForResponse` helper methods. Fixes #2362
@aslushnikov it looks like the second argument isn't really made for options like the issue was requesting?
Do we need to always return |
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.
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 millisecondsAnd additionally
With a similar set of options. I'd probably also additionally add support for filtering by response code.
An example
Happy to submit a PR if you all think it's a worthwhile addition!
Thanks!
The text was updated successfully, but these errors were encountered: