[Feature] Support predicate receiving Request interface to match while routing in page.route(url, handler)
See original GitHub issueContinuation of #6199 In my project we use GraphQL where all requests have the same URL but differs only in body. In order to use page.route(url, handler) I have to first retrieve body of request and make some checks if this is the request I am looking for. This function page.route(url, handler) does not support predicate with Request interface which makes impossible to stub requests when using GraphQL.
I envision it like this:
async routeFindingRequests(stringToSearch) {
// request instead of URL here
await this.page.route(request => {
return request.postData().includes(stringToSearch)
}, route => {
route.fulfill({
body: JSON.stringify({
someKey: "someValue"
})
})
})
}
I would like to ask you to add the ability to work with request in addition to URL in page.route(url, handler) as this is blocker for using playwright.
P.S. Initially I thought there is a need to have async predicate but I see almost all functions are synchronous in Request interface. Thus I made a change above.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
[Question] How to wait for several responses that differs only ...
[Feature] Support predicate receiving Request interface to match while routing in page.route(url, handler) #6243.
Read more >Spring Cloud Gateway
Spring Cloud Gateway matches routes as part of the Spring WebFlux HandlerMapping infrastructure. Spring Cloud Gateway includes many built-in route predicate ...
Read more >BrowserContext (Playwright - Main Library 1.21.0 API) - javadoc.io
public interface BrowserContext extends AutoCloseable ... Page.route() ) take precedence over browser context routes when request matches both handlers.
Read more >URL Dispatch — The Pyramid Web Framework v2.0
A route predicate argument specifies that some aspect of the request must be true for the associated route to be considered a match...
Read more >HTTP route components (proto) - Envoy Proxy
A route is both a specification of how to match a request as well as an indication of what to do next (e.g.,...
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 Free
Top 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
@dgozman It is working flawlessly. I suggest that you add your example to documents and close this ticket, no need to implement my suggestion.
While there are no plans to add support for this, you can just route all the requests and call
continue()
vsfulfill()
: