puppeteerRequestInterception
Index
Type Aliases
Functions
Type Aliases
InterceptHandler
Type declaration
Parameters
request: PuppeteerRequest
Returns unknown
Functions
addInterceptRequestHandler
Parameters
page: Page
Puppeteer
Page
object.handler: InterceptHandler
Request interception handler.
Returns Promise<void>
removeInterceptRequestHandler
Removes request interception handler for given page.
Parameters
page: Page
Puppeteer
Page
object.handler: InterceptHandler
Request interception handler.
Returns Promise<void>
Adds request interception handler in similar to
page.on('request', handler);
but in addition to that supports multiple parallel handlers.All the handlers are executed sequentially in the order as they were added. Each of the handlers must call one of
request.continue()
,request.abort()
andrequest.respond()
. In addition to that any of the handlers may modify the request object (method, postData, headers) by passing its overrides torequest.continue()
. If multiple handlers modify same property then the last one wins. Headers are merged separately so you can override only a value of specific header.If one the handlers calls
request.abort()
orrequest.respond()
then request is not propagated further to any of the remaining handlers.Example usage: