Response class represents responses which are received by page.
Since Playwright 1.8.
The examples alias the modules they use (alias Playwright.{Locator, Page}).
Summary
Functions
An object with all the response HTTP headers associated with this response.
Like all_headers/1, but returns the value and raises on error.
Returns the buffer with response body.
Like body/1, but returns the value and raises on error.
Waits for this response to finish, returns always nil.
Like finished/1, but returns the value and raises on error.
Returns the Frame that initiated this response.
Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via FetchEvent.respondWith).
Returns the value of the header matching the name. The name is case-insensitive. If multiple headers have
the same name (except set-cookie), they are returned as a list separated by ,. For set-cookie, the \n separator is used. If no headers are found, nil is returned.
Like header_value/2, but returns the value and raises on error.
Returns all values of the headers matching the name, for example set-cookie. The name is case-insensitive.
Like header_values/2, but returns the value and raises on error.
An object with the response HTTP headers. The header names are lower-cased.
Note that this method does not return security-related headers, including cookie-related ones.
You can use Playwright.Response.all_headers/1 for complete list of headers that include cookie information.
An array with all the response HTTP headers associated with this response. Unlike Playwright.Response.all_headers/1, header names are NOT lower-cased.
Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.
Some browser network stacks combine multiple field values before reporting them, so separate entries are not always available.
Like headers_array/1, but returns the value and raises on error.
Returns the http version used by the response.
Like http_version/1, but returns the value and raises on error.
Returns the JSON representation of response body.
Like json/1, but returns the value and raises on error.
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
Returns the matching Request object.
Returns SSL and other security information.
Like security_details/1, but returns the value and raises on error.
Returns the IP address and port of the server.
Like server_addr/1, but returns the value and raises on error.
Contains the status code of the response (e.g., 200 for a success).
Contains the status text of the response (e.g. usually an "OK" for a success).
Returns the text representation of response body.
Like text/1, but returns the value and raises on error.
Contains the URL of the response.
Types
Functions
@spec all_headers(t()) :: {:ok, %{optional(String.t()) => String.t()}} | {:error, Playwright.error()}
An object with all the response HTTP headers associated with this response.
Since Playwright 1.15.
Like all_headers/1, but returns the value and raises on error.
@spec body(t()) :: {:ok, binary()} | {:error, Playwright.error()}
Returns the buffer with response body.
Since Playwright 1.8.
Like body/1, but returns the value and raises on error.
@spec finished(t()) :: {:ok, nil | Exception.t()} | {:error, Playwright.error()}
Waits for this response to finish, returns always nil.
Since Playwright 1.8.
@spec finished!(t()) :: nil | Exception.t()
Like finished/1, but returns the value and raises on error.
@spec frame(t()) :: Playwright.Frame.t()
Returns the Frame that initiated this response.
Since Playwright 1.8.
Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via FetchEvent.respondWith).
Since Playwright 1.23.
@spec header_value(t(), String.t()) :: {:ok, nil | String.t()} | {:error, Playwright.error()}
Returns the value of the header matching the name. The name is case-insensitive. If multiple headers have
the same name (except set-cookie), they are returned as a list separated by ,. For set-cookie, the \n separator is used. If no headers are found, nil is returned.
Since Playwright 1.15.
Arguments
name- Name of the header.
Like header_value/2, but returns the value and raises on error.
@spec header_values(t(), String.t()) :: {:ok, [String.t()]} | {:error, Playwright.error()}
Returns all values of the headers matching the name, for example set-cookie. The name is case-insensitive.
Since Playwright 1.15.
Arguments
name- Name of the header.
Like header_values/2, but returns the value and raises on error.
An object with the response HTTP headers. The header names are lower-cased.
Note that this method does not return security-related headers, including cookie-related ones.
You can use Playwright.Response.all_headers/1 for complete list of headers that include cookie information.
Since Playwright 1.8.
@spec headers_array(t()) :: {:ok, [%{name: String.t(), value: String.t()}]} | {:error, Playwright.error()}
An array with all the response HTTP headers associated with this response. Unlike Playwright.Response.all_headers/1, header names are NOT lower-cased.
Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.
Some browser network stacks combine multiple field values before reporting them, so separate entries are not always available.
Since Playwright 1.15.
Like headers_array/1, but returns the value and raises on error.
@spec http_version(t()) :: {:ok, String.t()} | {:error, Playwright.error()}
Returns the http version used by the response.
Since Playwright 1.59.
Like http_version/1, but returns the value and raises on error.
@spec json(t()) :: {:ok, term()} | {:error, Playwright.error()}
Returns the JSON representation of response body.
This method will fail if the response body is not parsable via JSON.parse.
Since Playwright 1.8.
Like json/1, but returns the value and raises on error.
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
Since Playwright 1.8.
@spec request(t()) :: Playwright.Request.t()
Returns the matching Request object.
Since Playwright 1.8.
@spec security_details(t()) :: {:ok, nil | %{ optional(:issuer) => String.t(), optional(:protocol) => String.t(), optional(:subjectName) => String.t(), optional(:validFrom) => number(), optional(:validTo) => number() }} | {:error, Playwright.error()}
Returns SSL and other security information.
Since Playwright 1.13.
@spec security_details!(t()) :: nil | %{ optional(:issuer) => String.t(), optional(:protocol) => String.t(), optional(:subjectName) => String.t(), optional(:validFrom) => number(), optional(:validTo) => number() }
Like security_details/1, but returns the value and raises on error.
@spec server_addr(t()) :: {:ok, nil | %{ipAddress: String.t(), port: integer()}} | {:error, Playwright.error()}
Returns the IP address and port of the server.
Since Playwright 1.13.
Like server_addr/1, but returns the value and raises on error.
Contains the status code of the response (e.g., 200 for a success).
Since Playwright 1.8.
Contains the status text of the response (e.g. usually an "OK" for a success).
Since Playwright 1.8.
@spec text(t()) :: {:ok, String.t()} | {:error, Playwright.error()}
Returns the text representation of response body.
Since Playwright 1.8.
Like text/1, but returns the value and raises on error.
Contains the URL of the response.
Since Playwright 1.8.