The Request class represents network requests made by pages. Whenever a page makes a request, the following events are emitted:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/microsoft/playwright/llms.txt
Use this file to discover all available pages before exploring further.
page.on('request')- emitted when the request is issuedpage.on('response')- emitted when the response is received
Methods
url
Returns the URL of the request.string
resourceType
Returns the resource type of the request.string
Possible values: document, stylesheet, image, media, font, script, texttrack, xhr, fetch, eventsource, websocket, manifest, other
method
Returns the HTTP method of the request.string
postData
Returns the request’s post data as a string.string | null
postDataBuffer
Returns the request’s post data as a Buffer.Buffer | null
postDataJSON
Parses the request’s post data as JSON.Object | null
Automatically handles both JSON and form-encoded data.
headers
Returns the request headers.Object
allHeaders
Returns all request headers.Promise<Object>
headersArray
Returns the request headers as an array of objects.Promise<Array<{name: string, value: string}>>
headerValue
Returns the value of a specific header.The header name (case-insensitive)
Promise<string | null>
response
Returns the response for this request.Promise<Response | null>
frame
Returns the frame that initiated the request.Frame
Throws an error for service worker requests.
isNavigationRequest
Returns whether this is a navigation request.boolean
redirectedFrom
Returns the request that was redirected to this request.Request | null
redirectedTo
Returns the request that this request was redirected to.Request | null
failure
Returns error details if the request failed.{errorText: string} | null
timing
Returns timing information for the request.Object
Returned object properties:
startTime: numberdomainLookupStart: numberdomainLookupEnd: numberconnectStart: numbersecureConnectionStart: numberconnectEnd: numberrequestStart: numberresponseStart: numberresponseEnd: number
sizes
Returns sizes information for the request.Promise<Object>
Returned object properties:
requestBodySize: numberrequestHeadersSize: numberresponseBodySize: numberresponseHeadersSize: number
