2020-12-03 18:11:48 +01:00
## navigation-wait-until
2021-11-02 01:12:19 +01:00
- `waitUntil` < [WaitUntilState]< "load"|"domcontentloaded"|"networkidle"|"commit">>
2020-12-03 18:11:48 +01:00
2020-12-04 01:02:34 +01:00
When to consider operation succeeded, defaults to `load` . Events can be either:
2020-12-26 23:31:41 +01:00
* `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
* `'load'` - consider operation to be finished when the `load` event is fired.
2023-04-06 22:00:34 +02:00
* `'networkidle'` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
2021-11-02 01:12:19 +01:00
* `'commit'` - consider operation to be finished when network response is received and the document started loading.
2020-12-04 01:02:34 +01:00
2020-12-03 18:11:48 +01:00
## navigation-timeout
2023-03-15 00:34:30 +01:00
* langs: python, java, csharp
2021-01-05 18:42:49 +01:00
- `timeout` < [float]>
2020-12-04 01:02:34 +01:00
Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
The default value can be changed by using the
2020-12-29 08:42:51 +01:00
[`method: BrowserContext.setDefaultNavigationTimeout`],
[`method: BrowserContext.setDefaultTimeout`],
[`method: Page.setDefaultNavigationTimeout`] or
[`method: Page.setDefaultTimeout`] methods.
2020-12-03 18:11:48 +01:00
2023-03-15 00:34:30 +01:00
## navigation-timeout-js
* langs: js
2021-01-05 18:42:49 +01:00
- `timeout` < [float]>
2020-12-04 01:02:34 +01:00
2023-03-15 00:34:30 +01:00
Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `navigationTimeout` option in the config, or by using the [`method: BrowserContext.setDefaultNavigationTimeout`],
[`method: BrowserContext.setDefaultTimeout`],
[`method: Page.setDefaultNavigationTimeout`] or
[`method: Page.setDefaultTimeout`] methods.
## wait-for-function-timeout
* langs: python, java, csharp
- `timeout` < [float]>
Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
value can be changed by using the [`method: BrowserContext.setDefaultTimeout`] or [`method: Page.setDefaultTimeout`] methods.
## wait-for-function-timeout-js
* langs: js
- `timeout` < [float]>
Maximum time to wait for in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [`method: BrowserContext.setDefaultTimeout`] or [`method: Page.setDefaultTimeout`] methods.
2020-12-03 18:11:48 +01:00
2021-07-27 07:00:23 +02:00
## input-strict
- `strict` < [boolean]>
When true, the call requires selector to resolve to a single element. If given selector resolves to more
2022-08-26 21:57:18 +02:00
than one element, the call throws an exception.
2021-07-27 07:00:23 +02:00
2020-12-03 18:11:48 +01:00
## input-timeout
2023-03-15 00:34:30 +01:00
* langs: python, java, csharp
2021-01-05 18:42:49 +01:00
- `timeout` < [float]>
2020-12-04 01:02:34 +01:00
2023-03-15 00:34:30 +01:00
Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
2020-12-29 08:42:51 +01:00
using the [`method: BrowserContext.setDefaultTimeout`] or
[`method: Page.setDefaultTimeout`] methods.
2020-12-03 18:11:48 +01:00
2023-03-15 00:34:30 +01:00
## input-timeout-js
* langs: js
- `timeout` < [float]>
Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [`method: BrowserContext.setDefaultTimeout`] or
[`method: Page.setDefaultTimeout`] methods.
2020-12-03 18:11:48 +01:00
## input-no-wait-after
2024-07-18 09:19:08 +02:00
* deprecated: This option will default to `true` in the future.
2020-12-04 01:02:34 +01:00
- `noWaitAfter` < [boolean]>
Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating
to inaccessible pages. Defaults to `false` .
2020-12-03 18:11:48 +01:00
2024-07-18 09:19:08 +02:00
## input-no-wait-after-removed
* deprecated: This option has no effect.
- `noWaitAfter` < [boolean]>
This option has no effect.
2020-12-03 18:11:48 +01:00
## input-force
2020-12-04 01:02:34 +01:00
- `force` < [boolean]>
2022-03-25 19:30:45 +01:00
Whether to bypass the [actionability ](../actionability.md ) checks. Defaults to `false` .
2020-12-03 18:11:48 +01:00
## input-selector
2020-12-04 01:02:34 +01:00
- `selector` < [string]>
2022-12-03 06:48:37 +01:00
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
2021-07-19 19:42:55 +02:00
## input-source
- `source` < [string]>
2022-07-14 18:42:26 +02:00
2022-12-03 06:48:37 +01:00
A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will be used.
2021-07-19 19:42:55 +02:00
## input-target
- `target` < [string]>
2022-07-14 18:42:26 +02:00
2022-12-03 06:48:37 +01:00
A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first will be used.
2020-12-03 18:11:48 +01:00
## input-position
2020-12-04 01:02:34 +01:00
- `position` < [Object]>
2021-01-05 18:42:49 +01:00
- `x` < [float]>
- `y` < [float]>
2020-12-03 18:11:48 +01:00
2020-12-04 01:02:34 +01:00
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
element.
2020-12-03 18:11:48 +01:00
## input-modifiers
2024-04-29 17:15:12 +02:00
- `modifiers` < [Array]< [KeyboardModifier]< "Alt"|"Control"|"ControlOrMeta"|"Meta"|"Shift">>>
2020-12-04 01:02:34 +01:00
Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
2024-04-29 17:15:12 +02:00
modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
and Linux and to "Meta" on macOS.
2020-12-03 18:11:48 +01:00
## input-button
2021-02-08 20:58:25 +01:00
- `button` < [MouseButton]< "left"|"right"|"middle">>
2020-12-04 01:02:34 +01:00
Defaults to `left` .
2020-12-03 18:11:48 +01:00
## input-files
2021-01-06 02:05:43 +01:00
- `files` < [path]|[Array]< [path]>|[Object]|[Array]< [Object]>>
2021-02-24 23:29:14 +01:00
- `name` < [string]> File name
- `mimeType` < [string]> File type
2021-01-11 03:18:35 +01:00
- `buffer` < [Buffer]> File content
2020-12-03 18:11:48 +01:00
## input-down-up-delay
2021-01-05 18:42:49 +01:00
- `delay` < [float]>
2020-12-04 01:02:34 +01:00
Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
2020-12-03 18:11:48 +01:00
## input-click-count
2021-01-05 18:42:49 +01:00
- `clickCount` < [int]>
2020-12-04 01:02:34 +01:00
defaults to 1. See [UIEvent.detail].
2020-12-03 18:11:48 +01:00
2021-04-21 21:22:19 +02:00
## input-trial
- `trial` < [boolean]>
2022-03-25 19:30:45 +01:00
When set, this method only performs the [actionability ](../actionability.md ) checks and skips the action. Defaults to `false` . Useful to wait until the element is ready for the action without performing it.
2021-04-21 21:22:19 +02:00
2024-09-23 22:17:47 +02:00
## input-trial-with-modifiers
- `trial` < [boolean]>
When set, this method only performs the [actionability ](../actionability.md ) checks and skips the action. Defaults to `false` . Useful to wait until the element is ready for the action without performing it. Note that keyboard `modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys are pressed.
2021-08-03 19:12:34 +02:00
## input-source-position
- `sourcePosition` < [Object]>
- `x` < [float]>
- `y` < [float]>
Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not specified, some visible point of the element is used.
## input-target-position
- `targetPosition` < [Object]>
- `x` < [float]>
- `y` < [float]>
Drops on the target element at this point relative to the top-left corner of the element's padding box. If not specified, some visible point of the element is used.
2021-08-30 05:00:40 +02:00
## input-checked
2021-09-02 12:06:31 +02:00
* langs:
- alias-csharp: checkedState
2021-08-30 05:00:40 +02:00
- `checked` < [boolean]>
Whether to check or uncheck the checkbox.
2020-12-03 18:11:48 +01:00
## query-selector
2020-12-04 01:02:34 +01:00
- `selector` < [string]>
2022-12-03 06:48:37 +01:00
A selector to query for.
2021-07-23 06:37:20 +02:00
## find-selector
- `selector` < [string]>
2022-12-03 06:48:37 +01:00
A selector to use when resolving DOM element.
2020-12-03 18:11:48 +01:00
2023-03-03 23:50:53 +01:00
## find-selector-or-locator
- `selectorOrLocator` < [string]|[Locator]>
A selector or locator to use when resolving DOM element.
2020-12-03 18:11:48 +01:00
## wait-for-selector-state
2021-02-08 20:58:25 +01:00
- `state` < [WaitForSelectorState]< "attached"|"detached"|"visible"|"hidden">>
2020-12-04 01:02:34 +01:00
Defaults to `'visible'` . Can be either:
2020-12-26 23:31:41 +01:00
* `'attached'` - wait for element to be present in DOM.
* `'detached'` - wait for element to not be present in DOM.
* `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden` . Note that element without
any content or with `display:none` has an empty bounding box and is not considered visible.
* `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden` .
This is opposite to the `'visible'` option.
2020-12-03 18:11:48 +01:00
2021-02-19 21:19:34 +01:00
## js-python-wait-for-function-polling
* langs: js, python
- `polling` < [float]|"raf">
If [`option: polling`] is `'raf'` , then [`param: expression`] is constantly executed in `requestAnimationFrame`
callback. If [`option: polling`] is a number, then it is treated as an interval in milliseconds at which the function
would be executed. Defaults to `raf` .
## csharp-java-wait-for-function-polling
* langs: csharp, java
- `pollingInterval` < [float]>
If specified, then it is treated as an interval in milliseconds at which the function would be executed. By default if the option is not specified [`param: expression`] is executed in `requestAnimationFrame` callback.
2021-02-02 19:46:36 +01:00
## browser-option-ignoredefaultargs
* langs: js, python
- `ignoreDefaultArgs` < [boolean]|[Array]< [string]>>
If `true` , Playwright does not pass its own configurations args and only uses the ones from [`option: args`]. If an
array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false` .
## csharp-java-browser-option-ignoredefaultargs
* langs: csharp, java
- `ignoreDefaultArgs` < [Array]< [string]>>
If `true` , Playwright does not pass its own configurations args and only uses the ones from [`option: args`].
Dangerous option; use with care.
## csharp-java-browser-option-ignorealldefaultargs
* langs: csharp, java
- `ignoreAllDefaultArgs` < [boolean]>
If `true` , Playwright does not pass its own configurations args and only uses the ones from [`option: args`].
Dangerous option; use with care. Defaults to `false` .
2021-01-26 01:53:47 +01:00
## browser-option-proxy
- `proxy` < [Object]>
- `server` < [string]> Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example
`http://myproxy.com:3128` or `socks5://myproxy.com:3128` . Short form `myproxy.com:3128` is considered an HTTP
proxy.
2022-04-07 04:02:10 +02:00
- `bypass` ?< [string]> Optional comma-separated domains to bypass proxy, for example `".com, chromium.org,
2021-01-26 01:53:47 +01:00
.domain.com"`.
2022-04-07 04:02:10 +02:00
- `username` ?< [string]> Optional username to use if HTTP proxy requires authentication.
- `password` ?< [string]> Optional password to use if HTTP proxy requires authentication.
2021-01-26 01:53:47 +01:00
Network proxy settings.
2021-02-02 19:57:22 +01:00
## csharp-java-browser-option-env
* langs: csharp, java
- `env` < [Object]< [string], [string]>>
Specify environment variables that will be visible to the browser. Defaults to `process.env` .
## js-python-browser-option-env
* langs: js, python
- `env` < [Object]< [string], [string]|[float]|[boolean]>>
Specify environment variables that will be visible to the browser. Defaults to `process.env` .
2021-02-03 02:48:32 +01:00
## js-python-context-option-storage-state
* langs: js, python
2021-01-06 02:05:43 +01:00
- `storageState` < [path]|[Object]>
2023-05-13 04:15:51 +02:00
- `cookies` < [Array]< [Object]>> Cookies to set for context
2021-01-11 03:18:35 +01:00
- `name` < [string]>
- `value` < [string]>
2023-05-13 04:15:51 +02:00
- `domain` < [string]> Domain and path are required. For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com"
- `path` < [string]> Domain and path are required
2021-10-06 18:02:41 +02:00
- `expires` < [float]> Unix time in seconds.
- `httpOnly` < [boolean]>
- `secure` < [boolean]>
- `sameSite` < [SameSiteAttribute]< "Strict"|"Lax"|"None">> sameSite flag
- `origins` < [Array]< [Object]>> localStorage to set for context
2020-12-03 18:11:48 +01:00
- `origin` < [string]>
- `localStorage` < [Array]< [Object]>>
- `name` < [string]>
- `value` < [string]>
2023-04-18 19:04:13 +02:00
Learn more about [storage state and auth ](../auth.md ).
2023-05-13 04:15:51 +02:00
Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [`method: BrowserContext.storageState`].
2020-12-04 01:02:34 +01:00
2021-02-03 02:48:32 +01:00
## csharp-java-context-option-storage-state
* langs: csharp, java
- `storageState` < [string]>
Populates context with given storage state. This option can be used to initialize context with logged-in information
obtained via [`method: BrowserContext.storageState`].
## csharp-java-context-option-storage-state-path
* langs: csharp, java
- `storageStatePath` < [path]>
Populates context with given storage state. This option can be used to initialize context with logged-in information
obtained via [`method: BrowserContext.storageState`]. Path to the file with saved storage state.
2021-09-30 23:14:29 +02:00
## storagestate-option-path
- `path` < [path]>
The file path to save the storage state to. If [`option: path`] is a relative path, then it is resolved relative to
current working directory. If no path is provided, storage
state is still returned, but won't be saved to the disk.
2020-12-04 01:02:34 +01:00
## context-option-acceptdownloads
- `acceptDownloads` < [boolean]>
2021-12-06 18:25:24 +01:00
Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted.
2020-12-04 01:02:34 +01:00
## context-option-ignorehttpserrors
- `ignoreHTTPSErrors` < [boolean]>
2021-09-22 20:03:39 +02:00
Whether to ignore HTTPS errors when sending network requests. Defaults to `false` .
2020-12-04 01:02:34 +01:00
## context-option-bypasscsp
- `bypassCSP` < [boolean]>
2023-05-31 02:19:48 +02:00
Toggles bypassing page's Content-Security-Policy. Defaults to `false` .
2020-12-04 01:02:34 +01:00
2021-07-06 21:16:37 +02:00
## context-option-baseURL
- `baseURL` < [string]>
2023-05-31 02:19:48 +02:00
When using [`method: Page.goto`], [`method: Page.route`], [`method: Page.waitForURL`], [`method: Page.waitForRequest`], or [`method: Page.waitForResponse`] it takes the base URL in consideration by using the [`URL()` ](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL ) constructor for building the corresponding URL. Unset by default. Examples:
2021-07-06 21:16:37 +02:00
* baseURL: `http://localhost:3000` and navigating to `/bar.html` results in `http://localhost:3000/bar.html`
* baseURL: `http://localhost:3000/foo/` and navigating to `./bar.html` results in `http://localhost:3000/foo/bar.html`
2022-01-11 16:50:58 +01:00
* baseURL: `http://localhost:3000/foo` (without trailing slash) and navigating to `./bar.html` results in `http://localhost:3000/bar.html`
2021-07-06 21:16:37 +02:00
2020-12-04 01:02:34 +01:00
## context-option-viewport
2021-05-05 22:13:18 +02:00
* langs: js, java
2021-02-10 01:50:32 +01:00
- alias-java: viewportSize
2020-12-04 01:02:34 +01:00
- `viewport` < [null]|[Object]>
2021-01-05 18:42:49 +01:00
- `width` < [int]> page width in pixels.
- `height` < [int]> page height in pixels.
2020-12-04 01:02:34 +01:00
2023-07-27 01:15:07 +02:00
Emulates consistent viewport for each page. Defaults to an 1280x720 viewport.
2023-04-18 19:04:13 +02:00
Use `null` to disable the consistent viewport emulation. Learn more about [viewport emulation ](../emulation#viewport ).
2023-01-26 02:48:18 +01:00
:::note
The `null` value opts out from the default presets, makes viewport depend on the
host window size defined by the operating system. It makes the execution of the
tests non-deterministic.
:::
2021-03-29 23:10:58 +02:00
2021-05-05 22:13:18 +02:00
## csharp-context-option-viewport
* langs: csharp
- alias-csharp: viewportSize
- `viewport` < [null]|[Object]>
- `width` < [int]> page width in pixels.
- `height` < [int]> page height in pixels.
2023-01-26 02:48:18 +01:00
Emulates consistent viewport for each page. Defaults to an 1280x720 viewport.
2023-04-18 19:04:13 +02:00
Use `ViewportSize.NoViewport` to disable the consistent viewport emulation. Learn more about [viewport emulation ](../emulation.md#viewport ).
2023-01-26 02:48:18 +01:00
:::note
The `ViewportSize.NoViewport` value opts out from the default presets,
makes viewport depend on the host window size defined by the operating system.
It makes the execution of the tests non-deterministic.
:::
2021-05-05 22:13:18 +02:00
2021-03-29 23:10:58 +02:00
## context-option-screen
* langs:
- alias-java: screenSize
- alias-csharp: screenSize
- `screen` < [Object]>
- `width` < [int]> page width in pixels.
- `height` < [int]> page height in pixels.
Emulates consistent window screen size available inside web page via `window.screen` . Is only used when the
[`option: viewport`] is set.
2020-12-04 01:02:34 +01:00
2021-10-07 21:42:26 +02:00
## fetch-param-url
- `url` < [string]>
Target URL.
2024-08-12 23:22:03 +02:00
## js-fetch-option-params
* langs: js
2024-10-14 16:32:11 +02:00
- `params` < [Object]< [string], [string]|[float]|[boolean]>|[URLSearchParams]|[string]>
2024-08-12 23:22:03 +02:00
Query parameters to be sent with the URL.
## python-fetch-option-params
* langs: python
2024-09-09 15:49:59 +02:00
- `params` < [Object]< [string], [string]|[float]|[boolean]>|[string]>
2021-10-07 21:42:26 +02:00
2021-11-09 23:00:58 +01:00
Query parameters to be sent with the URL.
2021-10-07 21:42:26 +02:00
2022-05-23 21:12:57 +02:00
## csharp-fetch-option-params
* langs: csharp
- `params` < [Object]< [string], [Serializable]>>
Query parameters to be sent with the URL.
2024-09-09 15:49:59 +02:00
## csharp-fetch-option-paramsString
* langs: csharp
- `paramsString` < [string]>
Query parameters to be sent with the URL.
## java-fetch-params
2021-11-20 01:40:35 +01:00
* langs: java
2022-04-11 19:01:32 +02:00
- `options` ?< [RequestOptions]>
2021-11-20 01:40:35 +01:00
Optional request parameters.
2022-09-09 22:25:36 +02:00
## js-python-csharp-fetch-option-headers
2022-05-23 21:12:57 +02:00
* langs: js, python, csharp
2021-10-07 21:42:26 +02:00
- `headers` < [Object]< [string], [string]>>
2023-02-02 01:55:03 +01:00
Allows to set HTTP headers. These headers will apply to the fetched request as well as any redirects initiated by it.
2021-10-07 21:42:26 +02:00
2022-09-09 22:25:36 +02:00
## js-python-csharp-fetch-option-timeout
2022-05-23 21:12:57 +02:00
* langs: js, python, csharp
2021-10-07 21:42:26 +02:00
- `timeout` < [float]>
Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
2022-09-09 22:25:36 +02:00
## js-python-csharp-fetch-option-failonstatuscode
2022-05-23 21:12:57 +02:00
* langs: js, python, csharp
2021-10-07 21:42:26 +02:00
- `failOnStatusCode` < [boolean]>
Whether to throw on response codes other than 2xx and 3xx. By default response object is returned
for all status codes.
2024-09-13 13:21:02 +02:00
## js-fetch-option-form
* langs: js
- `form` < [Object]< [string], [string]|[float]|[boolean]>|[FormData]>
Provides an object that will be serialized as html form using `application/x-www-form-urlencoded` encoding and sent as
this request body. If this parameter is specified `content-type` header will be set to `application/x-www-form-urlencoded`
unless explicitly provided.
## python-fetch-option-form
* langs: python
2021-10-01 21:11:33 +02:00
- `form` < [Object]< [string], [string]|[float]|[boolean]>>
Provides an object that will be serialized as html form using `application/x-www-form-urlencoded` encoding and sent as
this request body. If this parameter is specified `content-type` header will be set to `application/x-www-form-urlencoded`
unless explicitly provided.
2022-05-23 21:12:57 +02:00
## csharp-fetch-option-form
* langs: csharp
- `form` < [FormData]>
Provides an object that will be serialized as html form using `application/x-www-form-urlencoded` encoding and sent as
this request body. If this parameter is specified `content-type` header will be set to `application/x-www-form-urlencoded`
unless explicitly provided.
An instance of [FormData] can be created via [`method: APIRequestContext.createFormData`].
2024-04-24 02:05:27 +02:00
## js-fetch-option-multipart
* langs: js
- `multipart` < [FormData]|[Object]< [string], [string]|[float]|[boolean]|[ReadStream]|[Object]>>
2021-10-01 21:11:33 +02:00
- `name` < [string]> File name
- `mimeType` < [string]> File type
- `buffer` < [Buffer]> File content
Provides an object that will be serialized as html form using `multipart/form-data` encoding and sent as
this request body. If this parameter is specified `content-type` header will be set to `multipart/form-data`
unless explicitly provided. File values can be passed either as [`fs.ReadStream` ](https://nodejs.org/api/fs.html#fs_class_fs_readstream )
2024-03-26 20:36:35 +01:00
or as file-like object containing file name, mime-type and its content.
2021-10-01 21:11:33 +02:00
2024-04-24 02:05:27 +02:00
## python-fetch-option-multipart
* langs: python
- `multipart` < [Object]< [string], [string]|[float]|[boolean]|[ReadStream]|[Object]>>
- `name` < [string]> File name
- `mimeType` < [string]> File type
- `buffer` < [Buffer]> File content
Provides an object that will be serialized as html form using `multipart/form-data` encoding and sent as
this request body. If this parameter is specified `content-type` header will be set to `multipart/form-data`
unless explicitly provided. File values can be passed as file-like object containing file name, mime-type and its content.
2022-05-23 21:12:57 +02:00
## csharp-fetch-option-multipart
* langs: csharp
- `multipart` < [FormData]>
Provides an object that will be serialized as html form using `multipart/form-data` encoding and sent as
this request body. If this parameter is specified `content-type` header will be set to `multipart/form-data`
2024-04-24 02:05:27 +02:00
unless explicitly provided. File values can be passed as file-like object containing file name, mime-type and its content.
2022-05-23 21:12:57 +02:00
An instance of [FormData] can be created via [`method: APIRequestContext.createFormData`].
2022-09-09 22:25:36 +02:00
## js-python-csharp-fetch-option-data
2022-05-23 21:12:57 +02:00
* langs: js, python, csharp
2021-10-01 21:11:33 +02:00
- `data` < [string]|[Buffer]|[Serializable]>
Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
2022-12-13 23:01:39 +01:00
and `content-type` header will be set to `application/json` if not explicitly set. Otherwise the `content-type` header will be
set to `application/octet-stream` if not explicitly set.
2022-09-09 22:25:36 +02:00
## js-python-csharp-fetch-option-ignorehttpserrors
2022-05-23 21:12:57 +02:00
* langs: js, python, csharp
2021-11-20 01:40:35 +01:00
- `ignoreHTTPSErrors` < [boolean]>
Whether to ignore HTTPS errors when sending network requests. Defaults to `false` .
2021-10-01 21:11:33 +02:00
2022-09-09 22:25:36 +02:00
## js-python-csharp-fetch-option-maxredirects
* langs: js, python, csharp
2022-09-09 21:14:42 +02:00
- `maxRedirects` < [int]>
2022-09-09 22:25:36 +02:00
Maximum number of request redirects that will be followed automatically. An error will be thrown if the number is exceeded.
Defaults to `20` . Pass `0` to not follow redirects.
2022-09-09 21:14:42 +02:00
2024-06-20 03:10:14 +02:00
## js-python-csharp-fetch-option-maxretries
* langs: js, python, csharp
- `maxRetries` < [int]>
2024-07-23 17:27:27 +02:00
Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not retry based on HTTP response codes. An error will be thrown if the limit is exceeded. Defaults to `0` - no retries.
2024-06-20 03:10:14 +02:00
2021-01-29 02:51:41 +01:00
## evaluate-expression
- `expression` < [string]>
2022-10-20 22:35:17 +02:00
JavaScript expression to be evaluated in the browser context. If the expression evaluates
2022-09-20 20:31:56 +02:00
to a function, the function is automatically invoked.
2021-01-29 02:51:41 +01:00
## js-evaluate-pagefunction
* langs: js
- `pageFunction` < [function]|[string]>
2021-02-01 20:43:26 +01:00
Function to be evaluated in the page context.
2021-01-29 02:51:41 +01:00
## js-evalonselector-pagefunction
* langs: js
2023-02-11 00:14:28 +01:00
- `pageFunction` < [function]\([Element]\)|[string]>
2021-01-29 02:51:41 +01:00
2021-02-01 20:43:26 +01:00
Function to be evaluated in the page context.
2021-01-29 02:51:41 +01:00
## js-evalonselectorall-pagefunction
* langs: js
2023-02-11 00:14:28 +01:00
- `pageFunction` < [function]\([Array]< [Element]>\)|[string]>
2021-01-29 02:51:41 +01:00
2021-02-01 20:43:26 +01:00
Function to be evaluated in the page context.
2021-01-29 02:51:41 +01:00
## js-worker-evaluate-workerfunction
* langs: js
- `pageFunction` < [function]|[string]>
2021-02-01 20:43:26 +01:00
Function to be evaluated in the worker context.
## js-electron-evaluate-workerfunction
* langs: js
- `pageFunction` < [function]|[Electron]>
2023-02-27 21:49:25 +01:00
Function to be evaluated in the main Electron process.
2021-01-29 02:51:41 +01:00
2021-01-11 03:18:35 +01:00
## python-context-option-viewport
* langs: python
- `viewport` < [null]|[Object]>
- `width` < [int]> page width in pixels.
- `height` < [int]> page height in pixels.
2023-04-18 19:04:13 +02:00
Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `no_viewport` disables the fixed viewport. Learn more about [viewport emulation ](../emulation.md#viewport ).
2021-01-11 03:18:35 +01:00
## python-context-option-no-viewport
* langs: python
- `noViewport` < [boolean]>
2021-01-12 21:14:27 +01:00
Does not enforce fixed viewport, allows resizing window in the headed mode.
2021-01-11 03:18:35 +01:00
2024-07-12 11:42:24 +02:00
## context-option-clientCertificates
- `clientCertificates` < [Array]< [Object]>>
2024-07-24 19:13:03 +02:00
- `origin` < [string]> Exact origin that the certificate is valid for. Origin includes `https` protocol, a hostname and optionally a port.
2024-07-30 19:09:20 +02:00
- `certPath` ?< [path]> Path to the file with the certificate in PEM format.
2024-08-19 09:24:32 +02:00
- `cert` ?< [Buffer]> Direct value of the certificate in PEM format.
2024-07-30 19:09:20 +02:00
- `keyPath` ?< [path]> Path to the file with the private key in PEM format.
2024-08-19 09:24:32 +02:00
- `key` ?< [Buffer]> Direct value of the private key in PEM format.
2024-07-30 19:09:20 +02:00
- `pfxPath` ?< [path]> Path to the PFX or PKCS12 encoded private key and certificate chain.
2024-08-19 09:24:32 +02:00
- `pfx` ?< [Buffer]> Direct value of the PFX or PKCS12 encoded private key and certificate chain.
2024-07-23 22:56:36 +02:00
- `passphrase` ?< [string]> Passphrase for the private key (PEM or PFX).
TLS Client Authentication allows the server to request a client certificate and verify it.
**Details**
2024-08-19 09:24:32 +02:00
An array of client certificates to be used. Each certificate object must have either both `certPath` and `keyPath` , a single `pfxPath` , or their corresponding direct value equivalents (`cert` and `key` , or `pfx` ). Optionally, `passphrase` property should be provided if the certificate is encrypted. The `origin` property should be provided with an exact match to the request origin that the certificate is valid for.
2024-07-12 11:42:24 +02:00
:::note
When using WebKit on macOS, accessing `localhost` will not pick up client certificates. You can make it work by replacing `localhost` with `local.playwright` .
:::
2020-12-04 01:02:34 +01:00
## context-option-useragent
- `userAgent` < [string]>
Specific user agent to use in this context.
## context-option-devicescalefactor
2021-01-05 18:42:49 +01:00
- `deviceScaleFactor` < [float]>
2020-12-04 01:02:34 +01:00
2023-04-18 19:04:13 +02:00
Specify device scale factor (can be thought of as dpr). Defaults to `1` . Learn more about [emulating devices with device scale factor ](../emulation.md#devices ).
2020-12-04 01:02:34 +01:00
## context-option-ismobile
- `isMobile` < [boolean]>
2023-07-27 01:15:07 +02:00
Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation ](../emulation.md#ismobile ).
2020-12-04 01:02:34 +01:00
## context-option-hastouch
- `hasTouch` < [boolean]>
2023-04-18 19:04:13 +02:00
Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation ](../emulation.md#devices ).
2020-12-04 01:02:34 +01:00
## context-option-javascriptenabled
- `javaScriptEnabled` < [boolean]>
2023-04-18 19:04:13 +02:00
Whether or not to enable JavaScript in the context. Defaults to `true` . Learn more about [disabling JavaScript ](../emulation.md#javascript-enabled ).
2020-12-04 01:02:34 +01:00
## context-option-timezoneid
- `timezoneId` < [string]>
2020-12-28 16:03:09 +01:00
Changes the timezone of the context. See [ICU's metaZones.txt ](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1 )
2023-05-31 02:19:48 +02:00
for a list of supported timezone IDs. Defaults to the system timezone.
2020-12-04 01:02:34 +01:00
## context-option-geolocation
2020-12-03 18:11:48 +01:00
- `geolocation` < [Object]>
2021-01-05 18:42:49 +01:00
- `latitude` < [float]> Latitude between -90 and 90.
- `longitude` < [float]> Longitude between -180 and 180.
2022-04-07 04:02:10 +02:00
- `accuracy` ?< [float]> Non-negative accuracy value. Defaults to `0` .
2020-12-04 01:02:34 +01:00
## context-option-locale
- `locale` < [string]>
2023-05-31 02:19:48 +02:00
Specify user locale, for example `en-GB` , `de-DE` , etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules. Defaults to the system default locale. Learn more about emulation in our [emulation guide ](../emulation.md#locale--timezone ).
2020-12-04 01:02:34 +01:00
## context-option-permissions
- `permissions` < [Array]< [string]>>
A list of permissions to grant to all pages in this context. See
2023-05-31 02:19:48 +02:00
[`method: BrowserContext.grantPermissions`] for more details. Defaults to none.
2020-12-04 01:02:34 +01:00
## context-option-extrahttpheaders
- `extraHTTPHeaders` < [Object]< [string], [string]>>
2023-05-31 02:19:48 +02:00
An object containing additional HTTP headers to be sent with every request. Defaults to none.
2020-12-04 01:02:34 +01:00
## context-option-offline
- `offline` < [boolean]>
2023-04-18 19:04:13 +02:00
Whether to emulate network being offline. Defaults to `false` . Learn more about [network emulation ](../emulation.md#offline ).
2020-12-04 01:02:34 +01:00
## context-option-httpcredentials
- `httpCredentials` < [Object]>
2020-12-03 18:11:48 +01:00
- `username` < [string]>
- `password` < [string]>
2023-03-27 17:52:00 +02:00
- `origin` ?< [string]> Restrain sending http credentials on specific origin (scheme://host:port).
2024-05-30 19:19:56 +02:00
- `send` ?< [HttpCredentialsSend]< "unauthorized"|"always">> This option only applies to the requests sent from corresponding [APIRequestContext] and does not affect requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'` .
2020-12-04 01:02:34 +01:00
Credentials for [HTTP authentication ](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication ).
2023-03-27 17:52:00 +02:00
If no origin is specified, the username and password are sent to any servers upon unauthorized responses.
2020-12-04 01:02:34 +01:00
## context-option-colorscheme
2022-11-03 20:38:02 +01:00
* langs: js, java
2022-10-31 17:09:52 +01:00
- `colorScheme` < null |[ ColorScheme ]<" light "|" dark "|" no-preference " > >
2020-12-04 01:02:34 +01:00
2024-10-04 16:49:32 +02:00
Emulates [prefers-colors-scheme ](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme ) media feature, supported values are `'light'` and `'dark'` . See
2022-10-31 17:09:52 +01:00
[`method: Page.emulateMedia`] for more details. Passing `null` resets emulation to system defaults. Defaults to `'light'` .
2022-11-03 20:38:02 +01:00
## context-option-colorscheme-csharp-python
* langs: csharp, python
2022-10-31 17:09:52 +01:00
- `colorScheme` < [ColorScheme]< "light"|"dark"|"no-preference"|"null">>
2024-10-04 16:49:32 +02:00
Emulates [prefers-colors-scheme ](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme ) media feature, supported values are `'light'` and `'dark'` . See
2022-10-31 17:09:52 +01:00
[`method: Page.emulateMedia`] for more details. Passing `'null'` resets emulation to system defaults. Defaults to `'light'` .
2020-12-04 01:02:34 +01:00
2021-05-22 01:56:09 +02:00
## context-option-reducedMotion
2022-11-03 20:38:02 +01:00
* langs: js, java
2022-10-31 17:09:52 +01:00
- `reducedMotion` < null |[ ReducedMotion ]<" reduce "|" no-preference " > >
2021-05-22 01:56:09 +02:00
2022-10-31 17:09:52 +01:00
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'` , `'no-preference'` . See [`method: Page.emulateMedia`] for more details. Passing `null` resets emulation to system defaults. Defaults to `'no-preference'` .
2022-11-03 20:38:02 +01:00
## context-option-reducedMotion-csharp-python
* langs: csharp, python
2022-10-31 17:09:52 +01:00
- `reducedMotion` < [ReducedMotion]< "reduce"|"no-preference"|"null">>
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'` , `'no-preference'` . See [`method: Page.emulateMedia`] for more details. Passing `'null'` resets emulation to system defaults. Defaults to `'no-preference'` .
2021-05-22 01:56:09 +02:00
2021-09-03 21:48:06 +02:00
## context-option-forcedColors
2022-11-03 20:38:02 +01:00
* langs: js, java
2022-10-31 17:09:52 +01:00
- `forcedColors` < null |[ ForcedColors ]<" active "|" none " > >
Emulates `'forced-colors'` media feature, supported values are `'active'` , `'none'` . See [`method: Page.emulateMedia`] for more details. Passing `null` resets emulation to system defaults. Defaults to `'none'` .
2022-11-03 20:38:02 +01:00
## context-option-forcedColors-csharp-python
* langs: csharp, python
2022-10-31 17:09:52 +01:00
- `forcedColors` < [ForcedColors]< "active"|"none"|"null">>
2021-09-03 21:48:06 +02:00
2022-10-31 17:09:52 +01:00
Emulates `'forced-colors'` media feature, supported values are `'active'` , `'none'` . See [`method: Page.emulateMedia`] for more details. Passing `'null'` resets emulation to system defaults. Defaults to `'none'` .
2021-09-03 21:48:06 +02:00
2020-12-04 01:02:34 +01:00
## context-option-logger
2021-01-08 01:12:25 +01:00
* langs: js
2020-12-04 01:02:34 +01:00
- `logger` < [Logger]>
Logger sink for Playwright logging.
## context-option-videospath
2021-01-12 21:14:27 +01:00
* langs: js
2022-11-23 17:40:47 +01:00
* deprecated: Use [`option: recordVideo`] instead.
2021-01-05 18:42:49 +01:00
- `videosPath` < [path]>
2020-12-04 01:02:34 +01:00
## context-option-videosize
2021-01-12 21:14:27 +01:00
* langs: js
2022-11-23 17:40:47 +01:00
* deprecated: Use [`option: recordVideo`] instead.
2020-12-04 01:02:34 +01:00
- `videoSize` < [Object]>
2021-01-05 18:42:49 +01:00
- `width` < [int]> Video frame width.
- `height` < [int]> Video frame height.
2020-12-04 01:02:34 +01:00
## context-option-recordhar
2021-02-10 20:41:55 +01:00
* langs: js
2020-12-04 01:02:34 +01:00
- `recordHar` < [Object]>
2022-04-07 04:02:10 +02:00
- `omitContent` ?< [boolean]> Optional setting to control whether to omit request content from the HAR. Defaults to
2022-06-17 01:33:32 +02:00
`false` . Deprecated, use `content` policy instead.
2022-09-21 13:58:34 +02:00
- `content` ?< [HarContentPolicy]< "omit"|"embed"|"attach">> Optional setting to control resource content management. If `omit` is specified, content is not persisted. If `attach` is specified, resources are persisted as separate files or entries in the ZIP archive. If `embed` is specified, content is stored inline the HAR file as per HAR specification. Defaults to `attach` for `.zip` output files and to `embed` for all other file extensions.
2022-06-29 00:09:36 +02:00
- `path` < [path]> Path on the filesystem to write the HAR file to. If the file name ends with `.zip` , `content: 'attach'` is used by default.
2022-06-22 23:44:12 +02:00
- `mode` ?< [HarMode]< "full"|"minimal">> When set to `minimal` , only record information necessary for routing from HAR. This omits sizes, timing, page, cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to `full` .
2024-09-26 10:08:16 +02:00
- `urlFilter` ?< [string]|[RegExp]> A glob or regex pattern to filter requests that are stored in the HAR. When a [`option: Browser.newContext.baseURL`] via the context options was provided and the passed URL is a path, it gets merged via the [`new URL()` ](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL ) constructor. Defaults to none.
2020-12-04 01:02:34 +01:00
Enables [HAR ](http://www.softwareishard.com/blog/har-12-spec ) recording for all pages into `recordHar.path` file. If not
2020-12-29 08:42:51 +01:00
specified, the HAR is not recorded. Make sure to await [`method: BrowserContext.close`] for the HAR to be
2020-12-04 01:02:34 +01:00
saved.
2021-02-10 02:33:28 +01:00
## context-option-recordhar-path
* langs: csharp, java, python
- alias-python: record_har_path
- `recordHarPath` < [path]>
2021-01-11 03:18:35 +01:00
2021-03-23 21:13:15 +01:00
Enables [HAR ](http://www.softwareishard.com/blog/har-12-spec ) recording for all pages into the
specified HAR file on the filesystem. If not specified, the HAR is not recorded. Make sure to
call [`method: BrowserContext.close`] for the HAR to be saved.
2021-01-11 03:18:35 +01:00
2021-02-10 02:33:28 +01:00
## context-option-recordhar-omit-content
* langs: csharp, java, python
- alias-python: record_har_omit_content
2022-04-11 19:01:32 +02:00
- `recordHarOmitContent` ?< [boolean]>
2021-01-11 03:18:35 +01:00
2021-02-10 02:33:28 +01:00
Optional setting to control whether to omit request content from the HAR. Defaults to `false` .
2021-01-11 03:18:35 +01:00
2022-06-24 03:55:15 +02:00
## context-option-recordhar-content
* langs: csharp, java, python
- alias-python: record_har_content
- `recordHarContent` ?< [HarContentPolicy]< "omit"|"embed"|"attach">>
2022-09-21 13:58:34 +02:00
Optional setting to control resource content management. If `omit` is specified, content is not persisted. If `attach` is specified, resources are persisted as separate files and all of these files are archived along with the HAR file. Defaults to `embed` , which stores content inline the HAR file as per HAR specification.
2022-06-24 03:55:15 +02:00
## context-option-recordhar-mode
* langs: csharp, java, python
- alias-python: record_har_mode
- `recordHarMode` ?< [HarMode]< "full"|"minimal">>
When set to `minimal` , only record information necessary for routing from HAR. This omits sizes, timing, page, cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to `full` .
2022-06-16 00:40:21 +02:00
## context-option-recordhar-url-filter
* langs: csharp, java, python
- alias-python: record_har_url_filter
- `recordHarUrlFilter` ?< [string]|[RegExp]>
2020-12-04 01:02:34 +01:00
## context-option-recordvideo
2021-02-10 01:44:50 +01:00
* langs: js
2020-12-04 01:02:34 +01:00
- `recordVideo` < [Object]>
2021-01-05 18:42:49 +01:00
- `dir` < [path]> Path to the directory to put videos into.
2022-04-07 04:02:10 +02:00
- `size` ?< [Object]> Optional dimensions of the recorded videos. If not specified the size will be equal to `viewport`
2021-02-10 01:44:50 +01:00
scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450.
Actual picture of each page will be scaled down if necessary to fit the specified size.
2021-01-05 18:42:49 +01:00
- `width` < [int]> Video frame width.
- `height` < [int]> Video frame height.
2020-12-03 18:11:48 +01:00
2020-12-04 01:02:34 +01:00
Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make
2020-12-29 08:42:51 +01:00
sure to await [`method: BrowserContext.close`] for videos to be saved.
2020-12-04 01:02:34 +01:00
2021-02-10 02:33:28 +01:00
## context-option-recordvideo-dir
2021-02-10 01:44:50 +01:00
* langs: csharp, java, python
- alias-python: record_video_dir
- `recordVideoDir` < [path]>
2021-01-11 03:18:35 +01:00
2021-03-23 21:13:15 +01:00
Enables video recording for all pages into the specified directory. If not specified videos are
not recorded. Make sure to call [`method: BrowserContext.close`] for videos to be saved.
2021-01-11 03:18:35 +01:00
2021-02-10 02:33:28 +01:00
## context-option-recordvideo-size
2021-02-10 01:44:50 +01:00
* langs: csharp, java, python
- alias-python: record_video_size
- `recordVideoSize` < [Object]>
2021-01-11 03:18:35 +01:00
- `width` < [int]> Video frame width.
- `height` < [int]> Video frame height.
2021-02-10 01:44:50 +01:00
Dimensions of the recorded videos. If not specified the size will be equal to `viewport`
scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450.
Actual picture of each page will be scaled down if necessary to fit the specified size.
2021-01-11 03:18:35 +01:00
2020-12-04 01:02:34 +01:00
## context-option-proxy
- `proxy` < [Object]>
- `server` < [string]> Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example
`http://myproxy.com:3128` or `socks5://myproxy.com:3128` . Short form `myproxy.com:3128` is considered an HTTP proxy.
2022-04-07 04:02:10 +02:00
- `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.
2020-12-04 01:02:34 +01:00
2023-05-31 02:19:48 +02:00
Network proxy settings to use with this context. Defaults to none.
2021-04-30 00:02:48 +02:00
2021-08-18 21:51:45 +02:00
## context-option-strict
- `strictSelectors` < [boolean]>
2022-12-13 00:09:44 +01:00
If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations
2021-08-18 21:51:45 +02:00
on selectors that imply single target DOM element will throw when more than one element matches the selector.
2023-05-31 02:19:48 +02:00
This option does not affect any Locator APIs (Locators are always strict). Defaults to `false` .
2021-08-18 21:51:45 +02:00
See [Locator] to learn more about the strict mode.
2022-06-09 00:27:51 +02:00
## context-option-service-worker-policy
- `serviceWorkers` < [ServiceWorkerPolicy]< "allow"|"block">>
2022-06-14 00:18:24 +02:00
Whether to allow sites to register Service workers. Defaults to `'allow'` .
* `'allow'` : [Service Workers ](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API ) can be registered.
* `'block'` : Playwright will block all registration of Service Workers.
2022-06-09 00:27:51 +02:00
2024-08-06 06:14:35 +02:00
## remove-all-listeners-options-behavior
* langs: js
* since: v1.47
- `behavior` < [RemoveAllListenersBehavior]< "wait"|"ignoreErrors"|"default">>
Specifies whether to wait for already running listeners and what to do if they throw errors:
* `'default'` - do not wait for current listener calls (if any) to finish, if the listener throws, it may result in unhandled error
* `'wait'` - wait for current listener calls (if any) to finish
* `'ignoreErrors'` - do not wait for current listener calls (if any) to finish, all errors thrown by the listeners after removal are silently caught
2023-12-14 22:48:17 +01:00
## unroute-all-options-behavior
2023-12-15 21:09:26 +01:00
* langs: js, csharp, python
2023-12-14 22:48:17 +01:00
* since: v1.41
2023-12-15 18:00:12 +01:00
- `behavior` < [UnrouteBehavior]< "wait"|"ignoreErrors"|"default">>
2023-12-14 22:48:17 +01:00
2024-05-08 20:40:03 +02:00
Specifies whether to wait for already running handlers and what to do if they throw errors:
2023-12-14 22:48:17 +01:00
* `'default'` - do not wait for current handler calls (if any) to finish, if unrouted handler throws, it may result in unhandled error
* `'wait'` - wait for current handler calls (if any) to finish
* `'ignoreErrors'` - do not wait for current handler calls (if any) to finish, all errors thrown by the handlers after unrouting are silently caught
2022-06-09 00:27:51 +02:00
2024-08-06 06:14:35 +02:00
2021-01-08 01:12:25 +01:00
## select-options-values
2021-05-20 01:13:17 +02:00
* langs: java, js, csharp
2021-01-08 01:12:25 +01:00
- `values` < [null]|[string]|[ElementHandle]|[Array]< [string]>|[Object]|[Array]< [ElementHandle]>|[Array]< [Object]>>
2022-04-07 04:02:10 +02:00
- `value` ?< [string]> Matches by `option.value` . Optional.
- `label` ?< [string]> Matches by `option.label` . Optional.
- `index` ?< [int]> Matches by the index. Optional.
2021-01-08 01:12:25 +01:00
Options to select. If the `<select>` has the `multiple` attribute, all matching options are selected, otherwise only the
2022-12-07 18:04:32 +01:00
first option matching one of the passed options is selected. String values are matching both values and labels. Option
2021-01-08 01:12:25 +01:00
is considered matching if all specified properties match.
2021-01-11 06:00:52 +01:00
## wait-for-navigation-url
- `url` < [string]|[RegExp]|[function]\([URL]\):[boolean]>
2021-09-17 10:34:49 +02:00
A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if
2022-04-06 12:00:51 +02:00
the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
2021-09-17 10:34:49 +02:00
equal to the string.
2021-01-11 06:00:52 +01:00
## wait-for-event-event
2021-05-22 16:58:02 +02:00
* langs: js, python, java
2021-01-11 06:00:52 +01:00
- `event` < [string]>
2021-01-12 21:14:27 +01:00
Event name, same one typically passed into `*.on(event)` .
2021-01-11 06:00:52 +01:00
## wait-for-load-state-state
2022-04-07 04:02:10 +02:00
- `state` ?< [LoadState]< "load"|"domcontentloaded"|"networkidle">>
2021-01-11 06:00:52 +01:00
Optional load state to wait for, defaults to `load` . If the state has been already reached while loading current document, the
method resolves immediately. Can be one of:
* `'load'` - wait for the `load` event to be fired.
* `'domcontentloaded'` - wait for the `DOMContentLoaded` event to be fired.
2023-04-06 22:00:34 +02:00
* `'networkidle'` - **DISCOURAGED** wait until there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
2021-01-11 06:00:52 +01:00
2021-02-05 06:15:14 +01:00
## java-wait-for-event-callback
* langs: java
- `callback` < [Runnable]>
Callback that performs the action triggering the event.
2021-05-27 00:11:31 +02:00
## csharp-wait-for-event-action
* langs: csharp
- `action` < [Func< Task > ]>
Action that triggers the event.
2021-01-08 01:12:25 +01:00
## python-select-options-element
* langs: python
2022-04-07 04:02:10 +02:00
- `element` ?< [ElementHandle]|[Array]< [ElementHandle]>>
2021-01-08 01:12:25 +01:00
Option elements to select. Optional.
## python-select-options-index
* langs: python
2022-04-07 04:02:10 +02:00
- `index` ?< [int]|[Array]< [int]>>
2021-01-08 01:12:25 +01:00
Options to select by index. Optional.
## python-select-options-value
* langs: python
2022-04-07 04:02:10 +02:00
- `value` ?< [string]|[Array]< [string]>>
2021-01-08 01:12:25 +01:00
Options to select by value. If the `<select>` has the `multiple` attribute, all given options are selected, otherwise
only the first option matching one of the passed options is selected. Optional.
## python-select-options-label
* langs: python
2022-04-07 04:02:10 +02:00
- `label` ?< [string]|[Array]< [string]>>
2021-01-08 01:12:25 +01:00
Options to select by label. If the `<select>` has the `multiple` attribute, all given options are selected, otherwise
only the first option matching one of the passed options is selected. Optional.
2021-05-20 00:49:44 +02:00
## wait-for-event-predicate
2021-01-12 21:14:27 +01:00
- `predicate` < [function]>
2021-01-09 00:00:14 +01:00
Receives the event data and resolves to truthy value when the waiting should resolve.
2021-02-05 06:15:14 +01:00
## wait-for-event-timeout
* langs: csharp, java, python
2021-01-09 00:00:14 +01:00
- `timeout` < [float]>
Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
The default value can be changed by using the [`method: BrowserContext.setDefaultTimeout`].
2021-02-11 19:31:57 +01:00
## android-timeout
* langs: js
- `timeout` < [float]>
Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
using the [`method: AndroidDevice.setDefaultTimeout`] method.
2022-03-02 21:43:16 +01:00
## js-assertions-timeout
2021-11-24 21:58:35 +01:00
* langs: js
- `timeout` < [float]>
2023-05-30 18:13:14 +02:00
Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect` .
2022-03-02 21:43:16 +01:00
## csharp-java-python-assertions-timeout
* langs: java, python, csharp
- `timeout` < [float]>
2023-05-30 18:13:14 +02:00
Time to retry the assertion for in milliseconds. Defaults to `5000` .
2021-11-24 21:58:35 +01:00
2024-04-18 21:28:55 +02:00
## assertions-ignore-case
- `ignoreCase` < [boolean]>
Whether to perform case-insensitive match. [`option: ignoreCase`] option takes precedence over the corresponding regular expression flag if specified.
2022-03-04 08:17:31 +01:00
## assertions-max-diff-pixels
2022-02-28 21:25:59 +01:00
* langs: js
2022-03-04 08:17:31 +01:00
- `maxDiffPixels` < [int]>
2022-03-02 21:43:16 +01:00
2022-05-29 18:46:06 +02:00
An acceptable amount of pixels that could be different. Default is configurable with `TestConfig.expect` . Unset by default.
2022-02-28 21:25:59 +01:00
2022-03-04 08:17:31 +01:00
## assertions-max-diff-pixel-ratio
2022-02-28 21:25:59 +01:00
* langs: js
2022-03-04 08:17:31 +01:00
- `maxDiffPixelRatio` < [float]>
2022-03-02 21:43:16 +01:00
2022-03-05 02:30:43 +01:00
An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` . Default is configurable with `TestConfig.expect` . Unset by default.
2022-02-28 21:25:59 +01:00
## assertions-threshold
* langs: js
2022-03-02 21:43:16 +01:00
- `threshold` < [float]>
2021-10-23 01:56:58 +02:00
2022-12-07 02:03:13 +01:00
An acceptable perceived color difference in the [YIQ color space ](https://en.wikipedia.org/wiki/YIQ )
between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with
2023-02-13 20:11:44 +01:00
`TestConfig.expect` . Defaults to `0.2` .
2021-10-23 01:56:58 +02:00
2022-07-06 02:24:50 +02:00
## shared-context-params-list-v1.8
2020-12-04 01:02:34 +01:00
- %%-context-option-acceptdownloads-%%
- %%-context-option-ignorehttpserrors-%%
- %%-context-option-bypasscsp-%%
2021-07-06 21:16:37 +02:00
- %%-context-option-baseURL-%%
2020-12-04 01:02:34 +01:00
- %%-context-option-viewport-%%
2021-05-05 22:13:18 +02:00
- %%-csharp-context-option-viewport-%%
2021-01-11 03:18:35 +01:00
- %%-python-context-option-viewport-%%
2021-03-29 23:10:58 +02:00
- %%-context-option-screen-%%
2021-01-11 03:18:35 +01:00
- %%-python-context-option-no-viewport-%%
2020-12-04 01:02:34 +01:00
- %%-context-option-useragent-%%
- %%-context-option-devicescalefactor-%%
- %%-context-option-ismobile-%%
- %%-context-option-hastouch-%%
- %%-context-option-javascriptenabled-%%
- %%-context-option-timezoneid-%%
- %%-context-option-geolocation-%%
- %%-context-option-locale-%%
- %%-context-option-permissions-%%
- %%-context-option-extrahttpheaders-%%
- %%-context-option-offline-%%
- %%-context-option-httpcredentials-%%
- %%-context-option-colorscheme-%%
2022-11-03 20:38:02 +01:00
- %%-context-option-colorscheme-csharp-python-%%
2021-05-22 01:56:09 +02:00
- %%-context-option-reducedMotion-%%
2022-11-03 20:38:02 +01:00
- %%-context-option-reducedMotion-csharp-python-%%
2021-09-03 21:48:06 +02:00
- %%-context-option-forcedColors-%%
2022-11-03 20:38:02 +01:00
- %%-context-option-forcedColors-csharp-python-%%
2020-12-04 01:02:34 +01:00
- %%-context-option-logger-%%
- %%-context-option-videospath-%%
- %%-context-option-videosize-%%
- %%-context-option-recordhar-%%
2021-02-10 02:33:28 +01:00
- %%-context-option-recordhar-path-%%
- %%-context-option-recordhar-omit-content-%%
2022-06-24 03:55:15 +02:00
- %%-context-option-recordhar-content-%%
- %%-context-option-recordhar-mode-%%
2022-06-16 00:40:21 +02:00
- %%-context-option-recordhar-url-filter-%%
2020-12-04 01:02:34 +01:00
- %%-context-option-recordvideo-%%
2021-02-10 02:33:28 +01:00
- %%-context-option-recordvideo-dir-%%
- %%-context-option-recordvideo-size-%%
2021-08-18 21:51:45 +02:00
- %%-context-option-strict-%%
2022-06-09 00:27:51 +02:00
- %%-context-option-service-worker-policy-%%
2021-05-13 01:16:36 +02:00
## browser-option-args
- `args` < [Array]< [string]>>
2023-12-14 23:37:31 +01:00
:::warning
Use custom browser args at your own risk, as some of them may break Playwright functionality.
:::
2021-05-13 01:16:36 +02:00
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
2023-12-14 23:37:31 +01:00
[here ](https://peter.sh/experiments/chromium-command-line-switches/ ).
2021-05-13 01:16:36 +02:00
## browser-option-channel
2021-05-25 23:33:27 +02:00
- `channel` < [string]>
2022-03-25 19:30:45 +01:00
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using [Google Chrome and Microsoft Edge ](../browsers.md#google-chrome--microsoft-edge ).
2021-05-13 01:16:36 +02:00
## browser-option-chromiumsandbox
- `chromiumSandbox` < [boolean]>
2021-05-20 00:16:55 +02:00
Enable Chromium sandboxing. Defaults to `false` .
2021-05-13 01:16:36 +02:00
## browser-option-downloadspath
- `downloadsPath` < [path]>
If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is
2021-08-19 22:34:17 +02:00
deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in
is closed.
2021-05-13 01:16:36 +02:00
## browser-option-executablepath
- `executablePath` < [path]>
Path to a browser executable to run instead of the bundled one. If [`option: executablePath`] is a relative path, then
it is resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium,
Firefox or WebKit, use at your own risk.
## browser-option-handlesigint
- `handleSIGINT` < [boolean]>
Close the browser process on Ctrl-C. Defaults to `true` .
## browser-option-handlesigterm
- `handleSIGTERM` < [boolean]>
Close the browser process on SIGTERM. Defaults to `true` .
## browser-option-handlesighup
- `handleSIGHUP` < [boolean]>
Close the browser process on SIGHUP. Defaults to `true` .
## browser-option-headless
- `headless` < [boolean]>
Whether to run browser in headless mode. More details for
[Chromium ](https://developers.google.com/web/updates/2017/04/headless-chrome ) and
[Firefox ](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode ). Defaults to `true` unless the
2024-09-26 10:08:16 +02:00
[`option: BrowserType.launch.devtools`] option is `true` .
2021-05-13 01:16:36 +02:00
## js-python-browser-option-firefoxuserprefs
* langs: js, python
- `firefoxUserPrefs` < [Object]< [string], [string]|[float]|[boolean]>>
Firefox user preferences. Learn more about the Firefox user preferences at
[`about:config` ](https://support.mozilla.org/en-US/kb/about-config-editor-firefox ).
## csharp-java-browser-option-firefoxuserprefs
* langs: csharp, java
- `firefoxUserPrefs` < [Object]< [string], [any]>>
Firefox user preferences. Learn more about the Firefox user preferences at
[`about:config` ](https://support.mozilla.org/en-US/kb/about-config-editor-firefox ).
## browser-option-logger
* langs: js
- `logger` < [Logger]>
Logger sink for Playwright logging.
## browser-option-timeout
- `timeout` < [float]>
Maximum time in milliseconds to wait for the browser instance to start. Defaults to `30000` (30 seconds). Pass `0` to
disable timeout.
2021-06-03 07:00:34 +02:00
## browser-option-tracesdir
- `tracesDir` < [path]>
2021-05-13 01:16:36 +02:00
If specified, traces are saved into this directory.
## browser-option-devtools
2024-03-25 19:22:15 +01:00
* deprecated: Use [debugging tools ](../debug.md ) instead.
2021-05-13 01:16:36 +02:00
- `devtools` < [boolean]>
2024-03-25 19:22:15 +01:00
**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true` , the
2021-05-13 01:16:36 +02:00
[`option: headless`] option will be set `false` .
## browser-option-slowmo
- `slowMo` < [float]>
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
2022-07-06 02:24:50 +02:00
## shared-browser-options-list-v1.8
2021-05-13 01:16:36 +02:00
- %%-browser-option-args-%%
- %%-browser-option-channel-%%
- %%-browser-option-chromiumsandbox-%%
- %%-browser-option-devtools-%%
- %%-browser-option-downloadspath-%%
- %%-csharp-java-browser-option-env-%%
- %%-js-python-browser-option-env-%%
- %%-browser-option-executablepath-%%
- %%-browser-option-handlesigint-%%
- %%-browser-option-handlesigterm-%%
- %%-browser-option-handlesighup-%%
- %%-browser-option-headless-%%
- %%-browser-option-ignoredefaultargs-%%
- %%-browser-option-proxy-%%
- %%-browser-option-timeout-%%
2021-06-03 07:00:34 +02:00
- %%-browser-option-tracesdir-%%
2021-12-15 00:37:31 +01:00
## locator-option-has-text
- `hasText` < [string]|[RegExp]>
2022-04-04 22:18:03 +02:00
Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a [string], matching is case-insensitive and searches for a substring.
2021-12-15 00:37:31 +01:00
For example, `"Playwright"` matches `<article><div>Playwright</div></article>` .
2022-02-03 01:55:50 +01:00
## locator-option-has
- `has` < [Locator]>
2023-12-12 02:35:29 +01:00
Narrows down the results of the method to those which contain elements matching this relative locator.
2022-02-03 01:55:50 +01:00
For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>` .
2023-12-12 02:35:29 +01:00
Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the document root. For example, you can find `content` that has `div` in `<article><content><div>Playwright</div></content></article>` . However, looking for `content` that has `article div` will fail, because the inner locator must be relative and should not use any elements outside the `content` .
2022-02-03 01:55:50 +01:00
Note that outer and inner locators must belong to the same frame. Inner locator must not contain [FrameLocator]s.
2023-04-05 21:45:46 +02:00
## locator-option-has-not
- `hasNot` < [Locator]>
Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the outer one.
For example, `article` that does not have `div` matches `<article><span>Playwright</span></article>` .
Note that outer and inner locators must belong to the same frame. Inner locator must not contain [FrameLocator]s.
2023-04-05 23:13:28 +02:00
## locator-option-has-not-text
- `hasNotText` < [string]|[RegExp]>
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When passed a [string], matching is case-insensitive and searches for a substring.
2022-07-06 02:24:50 +02:00
## locator-options-list-v1.14
2021-12-15 00:37:31 +01:00
- %%-locator-option-has-text-%%
2022-02-03 01:55:50 +01:00
- %%-locator-option-has-%%
2022-02-10 21:31:17 +01:00
2022-03-04 20:02:59 +01:00
## screenshot-option-animations
2022-03-11 02:15:36 +01:00
- `animations` < [ScreenshotAnimations]< "disabled"|"allow">>
2022-02-10 21:31:17 +01:00
2022-03-04 20:02:59 +01:00
When set to `"disabled"` , stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:
* finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* infinite animations are canceled to initial state, and then played over after the screenshot.
2022-02-10 21:31:17 +01:00
2022-03-11 02:15:36 +01:00
Defaults to `"allow"` that leaves animations untouched.
2022-05-16 21:26:23 +02:00
## screenshot-option-animations-default-disabled
- `animations` < [ScreenshotAnimations]< "disabled"|"allow">>
When set to `"disabled"` , stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:
* finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* infinite animations are canceled to initial state, and then played over after the screenshot.
Defaults to `"disabled"` that disables animations.
2022-02-10 21:31:17 +01:00
## screenshot-option-omit-background
- `omitBackground` < [boolean]>
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
Defaults to `false` .
## screenshot-option-quality
- `quality` < [int]>
The quality of the image, between 0-100. Not applicable to `png` images.
## screenshot-option-path
- `path` < [path]>
The file path to save the image to. The screenshot type will be inferred from file extension. If [`option: path`] is a
relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be
saved to the disk.
## screenshot-option-type
- `type` < [ScreenshotType]< "png"|"jpeg">>
Specify screenshot type, defaults to `png` .
2022-02-15 16:05:05 +01:00
## screenshot-option-mask
- `mask` < [Array]< [Locator]>>
2022-08-09 15:47:17 +02:00
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with
2023-06-07 02:15:55 +02:00
a pink box `#FF00FF` (customized by [`option: maskColor`]) that completely covers its bounding box.
2022-02-15 16:05:05 +01:00
2023-05-23 03:44:44 +02:00
## screenshot-option-mask-color
2023-06-07 02:15:55 +02:00
* since: v1.35
2023-05-23 03:44:44 +02:00
- `maskColor` < [string]>
Specify the color of the overlay box for masked elements, in [CSS color format ](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value ). Default color is pink `#FF00FF` .
2022-02-28 21:25:59 +01:00
## screenshot-option-full-page
- `fullPage` < [boolean]>
When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
`false` .
## screenshot-option-clip
- `clip` < [Object]>
- `x` < [float]> x-coordinate of top-left corner of clip area
- `y` < [float]> y-coordinate of top-left corner of clip area
- `width` < [float]> width of clipping area
- `height` < [float]> height of clipping area
2023-05-13 04:15:51 +02:00
An object which specifies clipping of the resulting image.
2022-02-28 21:25:59 +01:00
2022-04-01 21:28:40 +02:00
## screenshot-option-scale
- `scale` < [ScreenshotScale]< "css"|"device">>
2022-03-10 22:07:10 +01:00
2022-10-20 22:46:37 +02:00
When set to `"css"` , screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenshots of high-dpi devices will be twice as large or even larger.
2022-05-16 21:26:23 +02:00
Defaults to `"device"` .
## screenshot-option-scale-default-css
- `scale` < [ScreenshotScale]< "css"|"device">>
2022-10-20 22:46:37 +02:00
When set to `"css"` , screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenshots of high-dpi devices will be twice as large or even larger.
2022-05-16 21:26:23 +02:00
Defaults to `"css"` .
2022-03-11 01:54:36 +01:00
2022-03-30 02:48:13 +02:00
## screenshot-option-caret
- `caret` < [ScreenshotCaret]< "hide"|"initial">>
When set to `"hide"` , screenshot will hide text caret. When set to `"initial"` , text caret behavior will not be changed. Defaults to `"hide"` .
2023-12-01 02:42:45 +01:00
## screenshot-option-style
- `style` < string >
2023-12-14 17:19:24 +01:00
Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements invisible
2023-12-01 02:42:45 +01:00
or change their properties to help you creating repeatable screenshots. This stylesheet pierces the Shadow DOM and applies
to the inner frames.
2023-12-14 17:19:24 +01:00
## screenshot-option-style-path
- `stylePath` < [string]|[Array]< [string]>>
File name containing the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements invisible or change their properties to help you creating repeatable screenshots. This stylesheet pierces the Shadow DOM and applies to the inner frames.
2022-07-06 02:24:50 +02:00
## screenshot-options-common-list-v1.8
2022-03-04 20:02:59 +01:00
- %%-screenshot-option-animations-%%
2022-02-10 21:31:17 +01:00
- %%-screenshot-option-omit-background-%%
- %%-screenshot-option-quality-%%
- %%-screenshot-option-path-%%
2022-04-01 21:28:40 +02:00
- %%-screenshot-option-scale-%%
2022-03-30 02:48:13 +02:00
- %%-screenshot-option-caret-%%
2022-02-10 21:31:17 +01:00
- %%-screenshot-option-type-%%
2022-02-15 16:05:05 +01:00
- %%-screenshot-option-mask-%%
2022-09-27 19:29:34 +02:00
2022-09-28 06:06:07 +02:00
## locator-get-by-test-id-test-id
* since: v1.27
2022-12-13 17:43:13 +01:00
- `testId` < [string]|[RegExp]>
2022-09-28 06:06:07 +02:00
Id to locate the element by.
2022-09-28 01:13:56 +02:00
## locator-get-by-text-text
* since: v1.27
- `text` < [string]|[RegExp]>
2022-09-28 06:06:07 +02:00
Text to locate the element for.
2022-09-28 01:13:56 +02:00
## locator-get-by-text-exact
* since: v1.27
- `exact` < [boolean]>
2022-10-27 19:27:18 +02:00
Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.
2022-09-28 06:06:07 +02:00
2024-04-26 00:26:10 +02:00
## get-by-role-to-have-role-role
2022-10-10 19:57:55 +02:00
- `role` < [AriaRole]< "alert"|"alertdialog"|"application"|"article"|"banner"|"blockquote"|"button"|"caption"|"cell"|"checkbox"|"code"|"columnheader"|"combobox"|"complementary"|"contentinfo"|"definition"|"deletion"|"dialog"|"directory"|"document"|"emphasis"|"feed"|"figure"|"form"|"generic"|"grid"|"gridcell"|"group"|"heading"|"img"|"insertion"|"link"|"list"|"listbox"|"listitem"|"log"|"main"|"marquee"|"math"|"meter"|"menu"|"menubar"|"menuitem"|"menuitemcheckbox"|"menuitemradio"|"navigation"|"none"|"note"|"option"|"paragraph"|"presentation"|"progressbar"|"radio"|"radiogroup"|"region"|"row"|"rowgroup"|"rowheader"|"scrollbar"|"search"|"searchbox"|"separator"|"slider"|"spinbutton"|"status"|"strong"|"subscript"|"superscript"|"switch"|"tab"|"table"|"tablist"|"tabpanel"|"term"|"textbox"|"time"|"timer"|"toolbar"|"tooltip"|"tree"|"treegrid"|"treeitem">>
2022-09-28 01:13:56 +02:00
2022-09-28 06:06:07 +02:00
Required aria role.
2022-09-28 01:13:56 +02:00
## locator-get-by-role-option-checked
* since: v1.27
- `checked` < [boolean]>
2022-11-12 00:58:36 +01:00
An attribute that is usually set by `aria-checked` or native `<input type=checkbox>` controls.
2022-09-28 01:13:56 +02:00
Learn more about [`aria-checked` ](https://www.w3.org/TR/wai-aria-1.2/#aria-checked ).
## locator-get-by-role-option-disabled
* since: v1.27
- `disabled` < [boolean]>
2022-11-12 00:58:36 +01:00
An attribute that is usually set by `aria-disabled` or `disabled` .
2022-09-28 01:13:56 +02:00
:::note
Unlike most other attributes, `disabled` is inherited through the DOM hierarchy.
Learn more about [`aria-disabled` ](https://www.w3.org/TR/wai-aria-1.2/#aria-disabled ).
:::
## locator-get-by-role-option-expanded
* since: v1.27
- `expanded` < [boolean]>
2022-11-12 00:58:36 +01:00
An attribute that is usually set by `aria-expanded` .
2022-09-28 01:13:56 +02:00
2022-11-12 00:58:36 +01:00
Learn more about [`aria-expanded` ](https://www.w3.org/TR/wai-aria-1.2/#aria-expanded ).
2022-09-28 01:13:56 +02:00
## locator-get-by-role-option-includeHidden
* since: v1.27
- `includeHidden` < [boolean]>
2022-11-12 00:58:36 +01:00
Option that controls whether hidden elements are matched. By default, only non-hidden elements, as [defined by ARIA ](https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion ), are matched by role selector.
2022-09-28 01:13:56 +02:00
Learn more about [`aria-hidden` ](https://www.w3.org/TR/wai-aria-1.2/#aria-hidden ).
## locator-get-by-role-option-level
* since: v1.27
- `level` < [int]>
A number attribute that is usually present for roles `heading` , `listitem` , `row` , `treeitem` , with default values for `<h1>-<h6>` elements.
Learn more about [`aria-level` ](https://www.w3.org/TR/wai-aria-1.2/#aria-level ).
## locator-get-by-role-option-name
* since: v1.27
- `name` < [string]|[RegExp]>
2022-11-12 00:58:36 +01:00
Option to match the [accessible name ](https://w3c.github.io/accname/#dfn-accessible-name ). By default, matching is case-insensitive and searches for a substring, use [`option: exact`] to control this behavior.
2022-09-28 01:13:56 +02:00
Learn more about [accessible name ](https://w3c.github.io/accname/#dfn-accessible-name ).
2022-11-12 00:58:36 +01:00
## locator-get-by-role-option-exact
* since: v1.28
- `exact` < [boolean]>
Whether [`option: name`] is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when [`option: name`] is a regular expression. Note that exact match still trims whitespace.
2022-09-28 01:13:56 +02:00
## locator-get-by-role-option-pressed
* since: v1.27
- `pressed` < [boolean]>
2022-11-12 00:58:36 +01:00
An attribute that is usually set by `aria-pressed` .
2022-09-28 01:13:56 +02:00
Learn more about [`aria-pressed` ](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed ).
## locator-get-by-role-option-selected
* since: v1.27
- `selected` < boolean >
2022-11-12 00:58:36 +01:00
An attribute that is usually set by `aria-selected` .
2022-09-28 01:13:56 +02:00
Learn more about [`aria-selected` ](https://www.w3.org/TR/wai-aria-1.2/#aria-selected ).
## locator-get-by-role-option-list-v1.27
- %%-locator-get-by-role-option-checked-%%
- %%-locator-get-by-role-option-disabled-%%
- %%-locator-get-by-role-option-expanded-%%
- %%-locator-get-by-role-option-includeHidden-%%
- %%-locator-get-by-role-option-level-%%
- %%-locator-get-by-role-option-name-%%
- %%-locator-get-by-role-option-pressed-%%
- %%-locator-get-by-role-option-selected-%%
2022-09-27 19:29:34 +02:00
## template-locator-locator
2023-03-30 23:41:30 +02:00
The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options, similar to [`method: Locator.filter`] method.
2022-09-28 01:13:56 +02:00
[Learn more about locators ](../locators.md ).
## template-locator-root-locator
The method returns an element locator that can be used to perform actions on this page / frame.
Locator is resolved to the element immediately before performing an action, so a series of actions on the same locator can in fact be performed on different DOM elements. That would happen if the DOM structure between those actions has changed.
[Learn more about locators ](../locators.md ).
2022-09-28 06:06:07 +02:00
## template-locator-get-by-test-id
2023-01-09 22:06:25 +01:00
Locate element by the test id.
**Usage**
Consider the following DOM structure.
```html
< button data-testid = "directions" > Itinéraire< / button >
```
You can locate the element by it's test id:
```js
await page.getByTestId('directions').click();
```
```java
page.getByTestId("directions").click();
```
```python async
await page.get_by_test_id("directions").click()
```
```python sync
page.get_by_test_id("directions").click()
```
```csharp
await page.GetByTestId("directions").ClickAsync();
```
**Details**
By default, the `data-testid` attribute is used as a test id. Use [`method: Selectors.setTestIdAttribute`] to configure a different test id attribute if necessary.
2022-09-28 06:06:07 +02:00
2022-10-20 19:54:57 +02:00
```js
// Set custom test id attribute from @playwright/test config:
2023-06-27 11:53:53 +02:00
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
testIdAttribute: 'data-pw'
},
});
2022-10-20 19:54:57 +02:00
```
2022-09-28 01:13:56 +02:00
## template-locator-get-by-text
2023-01-09 22:06:25 +01:00
Allows locating elements that contain given text.
2023-03-30 23:41:30 +02:00
See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter by the text content.
2023-01-09 22:06:25 +01:00
**Usage**
Consider the following DOM structure:
2022-10-27 19:27:18 +02:00
```html
< div > Hello < span > world< / span > < / div >
< div > Hello< / div >
```
You can locate by text substring, exact string, or a regular expression:
```js
// Matches < span >
2023-06-27 11:53:53 +02:00
page.getByText('world');
2022-10-27 19:27:18 +02:00
// Matches first < div >
2023-06-27 11:53:53 +02:00
page.getByText('Hello world');
2022-10-27 19:27:18 +02:00
// Matches second < div >
2023-06-27 11:53:53 +02:00
page.getByText('Hello', { exact: true });
2022-10-27 19:27:18 +02:00
// Matches both < div > s
2023-06-27 11:53:53 +02:00
page.getByText(/Hello/);
2022-10-27 19:27:18 +02:00
// Matches second < div >
2023-06-27 11:53:53 +02:00
page.getByText(/^hello$/i);
2022-10-27 19:27:18 +02:00
```
```python async
# Matches <span>
page.get_by_text("world")
# Matches first <div>
page.get_by_text("Hello world")
# Matches second <div>
page.get_by_text("Hello", exact=True)
# Matches both <div>s
page.get_by_text(re.compile("Hello"))
# Matches second <div>
page.get_by_text(re.compile("^hello$", re.IGNORECASE))
```
```python sync
# Matches <span>
page.get_by_text("world")
# Matches first <div>
page.get_by_text("Hello world")
# Matches second <div>
page.get_by_text("Hello", exact=True)
# Matches both <div>s
page.get_by_text(re.compile("Hello"))
# Matches second <div>
page.get_by_text(re.compile("^hello$", re.IGNORECASE))
```
```java
// Matches < span >
2024-10-04 11:34:04 +02:00
page.getByText("world");
2022-10-27 19:27:18 +02:00
// Matches first < div >
2024-10-04 11:34:04 +02:00
page.getByText("Hello world");
2022-10-27 19:27:18 +02:00
// Matches second < div >
2024-10-04 11:34:04 +02:00
page.getByText("Hello", new Page.GetByTextOptions().setExact(true));
2022-10-27 19:27:18 +02:00
// Matches both < div > s
2024-10-04 11:34:04 +02:00
page.getByText(Pattern.compile("Hello"));
2022-10-27 19:27:18 +02:00
// Matches second < div >
2024-10-04 11:34:04 +02:00
page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE));
2022-10-27 19:27:18 +02:00
```
```csharp
// Matches < span >
2023-06-26 18:21:14 +02:00
page.GetByText("world");
2022-10-27 19:27:18 +02:00
// Matches first < div >
2023-06-26 18:21:14 +02:00
page.GetByText("Hello world");
2022-10-27 19:27:18 +02:00
// Matches second < div >
2023-06-26 18:21:14 +02:00
page.GetByText("Hello", new() { Exact = true });
2022-10-27 19:27:18 +02:00
// Matches both < div > s
2023-06-26 18:21:14 +02:00
page.GetByText(new Regex("Hello"));
2022-10-27 19:27:18 +02:00
// Matches second < div >
2023-06-26 18:21:14 +02:00
page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));
2022-10-27 19:27:18 +02:00
```
2023-01-09 22:06:25 +01:00
**Details**
2022-10-27 19:27:18 +02:00
Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For example, locating by text `"Log in"` matches `<input type=button value="Log in">` .
2022-09-28 01:13:56 +02:00
2022-09-30 06:45:44 +02:00
## template-locator-get-by-alt-text
2023-01-09 22:06:25 +01:00
Allows locating elements by their alt text.
**Usage**
For example, this method will find the image by alt text "Playwright logo":
2022-09-30 06:45:44 +02:00
```html
2023-01-09 22:06:25 +01:00
< img alt = 'Playwright logo' >
```
```js
await page.getByAltText('Playwright logo').click();
```
```java
page.getByAltText("Playwright logo").click();
```
```python async
await page.get_by_alt_text("Playwright logo").click()
```
```python sync
page.get_by_alt_text("Playwright logo").click()
```
```csharp
await page.GetByAltText("Playwright logo").ClickAsync();
2022-09-30 06:45:44 +02:00
```
2022-09-29 20:06:58 +02:00
## template-locator-get-by-label-text
2023-03-17 20:48:07 +01:00
Allows locating input elements by the text of the associated `<label>` or `aria-labelledby` element, or by the `aria-label` attribute.
2023-01-09 22:06:25 +01:00
**Usage**
2023-03-17 20:48:07 +01:00
For example, this method will find inputs by label "Username" and "Password" in the following DOM:
2022-09-29 20:06:58 +02:00
```html
2023-03-17 20:48:07 +01:00
< input aria-label = "Username" >
2022-09-29 20:06:58 +02:00
< label for = "password-input" > Password:< / label >
< input id = "password-input" >
```
2022-09-30 06:45:44 +02:00
2023-01-09 22:06:25 +01:00
```js
2023-03-17 20:48:07 +01:00
await page.getByLabel('Username').fill('john');
2023-01-09 22:06:25 +01:00
await page.getByLabel('Password').fill('secret');
```
```java
2023-03-17 20:48:07 +01:00
page.getByLabel("Username").fill("john");
2023-01-09 22:06:25 +01:00
page.getByLabel("Password").fill("secret");
```
```python async
2023-03-17 20:48:07 +01:00
await page.get_by_label("Username").fill("john")
2023-01-09 22:06:25 +01:00
await page.get_by_label("Password").fill("secret")
```
```python sync
2023-03-17 20:48:07 +01:00
page.get_by_label("Username").fill("john")
2023-01-09 22:06:25 +01:00
page.get_by_label("Password").fill("secret")
```
```csharp
2023-03-17 20:48:07 +01:00
await page.GetByLabel("Username").FillAsync("john");
2023-01-09 22:06:25 +01:00
await page.GetByLabel("Password").FillAsync("secret");
```
2022-09-30 03:12:49 +02:00
## template-locator-get-by-placeholder-text
2023-01-09 22:06:25 +01:00
Allows locating input elements by the placeholder text.
**Usage**
For example, consider the following DOM structure.
2022-09-30 03:12:49 +02:00
```html
2023-01-09 22:06:25 +01:00
< input type = "email" placeholder = "name@example.com" / >
```
You can fill the input after locating it by the placeholder text:
```js
await page
2023-06-27 11:53:53 +02:00
.getByPlaceholder('name@example.com')
.fill('playwright@microsoft.com');
2023-01-09 22:06:25 +01:00
```
```java
page.getByPlaceholder("name@example.com").fill("playwright@microsoft.com");
```
```python async
await page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
```
```python sync
page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
```
```csharp
await page
.GetByPlaceholder("name@example.com")
.FillAsync("playwright@microsoft.com");
2022-09-30 03:12:49 +02:00
```
2022-09-29 20:06:58 +02:00
2022-09-28 01:13:56 +02:00
## template-locator-get-by-role
2023-01-09 22:06:25 +01:00
Allows locating elements by their [ARIA role ](https://www.w3.org/TR/wai-aria-1.2/#roles ), [ARIA attributes ](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes ) and [accessible name ](https://w3c.github.io/accname/#dfn-accessible-name ).
**Usage**
Consider the following DOM structure.
```html
< h3 > Sign up< / h3 >
< label >
< input type = "checkbox" / > Subscribe
< / label >
< br / >
< button > Submit< / button >
```
You can locate each element by it's implicit role:
```js
await expect(page.getByRole('heading', { name: 'Sign up' })).toBeVisible();
await page.getByRole('checkbox', { name: 'Subscribe' }).check();
await page.getByRole('button', { name: /submit/i }).click();
```
```python async
await expect(page.get_by_role("heading", name="Sign up")).to_be_visible()
await page.get_by_role("checkbox", name="Subscribe").check()
2022-09-28 01:13:56 +02:00
2023-01-09 22:06:25 +01:00
await page.get_by_role("button", name=re.compile("submit", re.IGNORECASE)).click()
```
```python sync
expect(page.get_by_role("heading", name="Sign up")).to_be_visible()
page.get_by_role("checkbox", name="Subscribe").check()
page.get_by_role("button", name=re.compile("submit", re.IGNORECASE)).click()
```
```java
assertThat(page
.getByRole(AriaRole.HEADING,
new Page.GetByRoleOptions().setName("Sign up")))
.isVisible();
page.getByRole(AriaRole.CHECKBOX,
new Page.GetByRoleOptions().setName("Subscribe"))
.check();
page.getByRole(AriaRole.BUTTON,
new Page.GetByRoleOptions().setName(
Pattern.compile("submit", Pattern.CASE_INSENSITIVE)))
.click();
```
```csharp
2023-11-07 09:28:18 +01:00
await Expect(Page
2023-01-09 22:06:25 +01:00
.GetByRole(AriaRole.Heading, new() { Name = "Sign up" }))
.ToBeVisibleAsync();
await page
.GetByRole(AriaRole.Checkbox, new() { Name = "Subscribe" })
.CheckAsync();
await page
.GetByRole(AriaRole.Button, new() {
NameRegex = new Regex("submit", RegexOptions.IgnoreCase)
})
.ClickAsync();
```
**Details**
Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
Many html elements have an implicitly [defined role ](https://w3c.github.io/html-aam/#html-element-role-mappings ) that is recognized by the role selector. You can find all the [supported roles here ](https://www.w3.org/TR/wai-aria-1.2/#role_definitions ). ARIA guidelines **do not recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
2022-09-28 01:13:56 +02:00
2022-09-30 06:45:44 +02:00
## template-locator-get-by-title
2023-01-09 22:06:25 +01:00
Allows locating elements by their title attribute.
**Usage**
Consider the following DOM structure.
2022-09-30 06:45:44 +02:00
```html
2023-01-09 22:06:25 +01:00
< span title = 'Issues count' > 25 issues< / span >
```
You can check the issues count after locating it by the title text:
```js
await expect(page.getByTitle('Issues count')).toHaveText('25 issues');
```
```java
assertThat(page.getByTitle("Issues count")).hasText("25 issues");
```
```python async
await expect(page.get_by_title("Issues count")).to_have_text("25 issues")
```
```python sync
expect(page.get_by_title("Issues count")).to_have_text("25 issues")
```
```csharp
2023-11-07 09:28:18 +01:00
await Expect(Page.GetByTitle("Issues count")).toHaveText("25 issues");
2022-09-30 06:45:44 +02:00
```
2022-11-10 00:29:07 +01:00
2022-11-10 20:37:41 +01:00
## test-config-snapshot-path-template
2022-11-10 00:29:07 +01:00
- `type` ?< [string]>
2022-11-10 20:37:41 +01:00
* langs: js
2022-11-10 00:29:07 +01:00
2022-11-30 01:57:03 +01:00
This option configures a template controlling location of snapshots generated by [`method: PageAssertions.toHaveScreenshot#1`] and [`method: SnapshotAssertions.toMatchSnapshot#1`].
2022-11-10 00:29:07 +01:00
2023-01-06 19:26:23 +01:00
**Usage**
2023-05-10 18:38:12 +02:00
```js title="playwright.config.ts"
2023-01-12 22:12:02 +01:00
import { defineConfig } from '@playwright/test';
2022-11-10 00:29:07 +01:00
2023-01-12 22:12:02 +01:00
export default defineConfig({
2022-11-10 00:29:07 +01:00
testDir: './tests',
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',
2023-01-12 22:12:02 +01:00
});
2022-11-10 00:29:07 +01:00
```
2023-01-06 19:26:23 +01:00
**Details**
2022-11-10 00:29:07 +01:00
The value might include some "tokens" that will be replaced with actual values during test execution.
Consider the following file structure:
2023-06-29 18:26:19 +02:00
```txt
2022-11-10 00:29:07 +01:00
playwright.config.ts
tests/
└── page/
└── page-click.spec.ts
```
And the following `page-click.spec.ts` that uses `toHaveScreenshot()` call:
2023-05-10 23:30:51 +02:00
```js title="page-click.spec.ts"
2022-11-10 00:29:07 +01:00
import { test, expect } from '@playwright/test';
2022-11-11 02:23:57 +01:00
test.describe('suite', () => {
test('test should work', async ({ page }) => {
await expect(page).toHaveScreenshot(['foo', 'bar', 'baz.png']);
});
2022-11-10 00:29:07 +01:00
});
```
The list of supported tokens:
2024-04-25 00:18:43 +02:00
* `{arg}` - Relative snapshot path **without extension** . These come from the arguments passed to the `toHaveScreenshot()` and `toMatchSnapshot()` calls; if called without arguments, this will be an auto-generated snapshot name.
* Value: `foo/bar/baz`
* `{ext}` - snapshot extension (with dots)
* Value: `.png`
2022-11-10 00:29:07 +01:00
* `{platform}` - The value of `process.platform` .
2022-11-11 02:23:57 +01:00
* `{projectName}` - Project's file-system-sanitized name, if any.
* Value: `''` (empty string).
2024-04-25 00:18:43 +02:00
* `{snapshotDir}` - Project's [`property: TestConfig.snapshotDir`].
* Value: `/home/playwright/tests` (since `snapshotDir` is not provided in config, it defaults to `testDir` )
* `{testDir}` - Project's [`property: TestConfig.testDir`].
* Value: `/home/playwright/tests` (absolute path is since `testDir` is resolved relative to directory with config)
2022-11-10 00:29:07 +01:00
* `{testFileDir}` - Directories in relative path from `testDir` to **test file** .
2022-11-11 02:23:57 +01:00
* Value: `page`
2022-11-10 00:29:07 +01:00
* `{testFileName}` - Test file name with extension.
2022-11-11 02:23:57 +01:00
* Value: `page-click.spec.ts`
2022-11-10 00:29:07 +01:00
* `{testFilePath}` - Relative path from `testDir` to **test file**
2022-11-11 02:23:57 +01:00
* Value: `page/page-click.spec.ts`
* `{testName}` - File-system-sanitized test title, including parent describes but excluding file name.
* Value: `suite-test-should-work`
2022-11-10 00:29:07 +01:00
Each token can be preceded with a single character that will be used **only if** this token has non-empty value.
Consider the following config:
2023-05-10 18:38:12 +02:00
```js title="playwright.config.ts"
2023-01-12 22:12:02 +01:00
import { defineConfig } from '@playwright/test';
2022-11-10 00:29:07 +01:00
2023-01-12 22:12:02 +01:00
export default defineConfig({
2022-11-10 00:29:07 +01:00
snapshotPathTemplate: '__screenshots__{/projectName}/{testFilePath}/{arg}{ext}',
testMatch: 'example.spec.ts',
projects: [
{ use: { browserName: 'firefox' } },
{ name: 'chromium', use: { browserName: 'chromium' } },
],
2023-01-12 22:12:02 +01:00
});
2022-11-10 00:29:07 +01:00
```
In this config:
1. First project **does not** have a name, so its snapshots will be stored in `<configDir>/__screenshots__/example.spec.ts/...` .
1. Second project **does** have a name, so its snapshots will be stored in `<configDir>/__screenshots__/chromium/example.spec.ts/..` .
1. Since `snapshotPathTemplate` resolves to relative path, it will be resolved relative to `configDir` .
2022-11-10 20:37:41 +01:00
1. Forward slashes `"/"` can be used as path separators on any platform.
2022-11-10 00:29:07 +01:00