APIRequest
Exposes API that can be used for the Web API testing. This class is used for creating APIRequestContext instance which in turn can be used for sending web requests. An instance of this class can be obtained via playwright.request. For more information see APIRequestContext.
apiRequest.newContext([options])
Added in: v1.16options?
<Object>baseURL?
<string> Methods like apiRequestContext.get(url[, options]) take the base URL into consideration by using theURL()
constructor for building the corresponding URL. Examples:#- baseURL:
http://localhost:3000
and sending request to/bar.html
results inhttp://localhost:3000/bar.html
- baseURL:
http://localhost:3000/foo/
and sending request to./bar.html
results inhttp://localhost:3000/foo/bar.html
- baseURL:
http://localhost:3000/foo
(without trailing slash) and navigating to./bar.html
results inhttp://localhost:3000/bar.html
- baseURL:
extraHTTPHeaders?
<Object<string, string>> An object containing additional HTTP headers to be sent with every request.#httpCredentials?
<Object> Credentials for HTTP authentication.#ignoreHTTPSErrors?
<boolean> Whether to ignore HTTPS errors when sending network requests. Defaults tofalse
.#proxy?
<Object> Network proxy settings.#server
<string> Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for examplehttp://myproxy.com:3128
orsocks5://myproxy.com:3128
. Short formmyproxy.com:3128
is considered an HTTP proxy.bypass?
<string> Optional comma-separated domains to bypass proxy, for example".com, chromium.org, .domain.com"
.username?
<string> Optional username to use if HTTP proxy requires authentication.password?
<string> Optional password to use if HTTP proxy requires authentication.
storageState?
<string|Object> Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via browserContext.storageState([options]) or apiRequestContext.storageState([options]). Either a path to the file with saved storage, or the value returned by one of browserContext.storageState([options]) or apiRequestContext.storageState([options]) methods.#timeout?
<number> Maximum time in milliseconds to wait for the response. Defaults to30000
(30 seconds). Pass0
to disable timeout.#userAgent?
<string> Specific user agent to use in this context.#
- returns:Promise<APIRequestContext>># <
Creates new instances of APIRequestContext.