This commit is contained in:
Pavel Feldman 2022-07-05 16:24:50 -08:00 коммит произвёл GitHub
Родитель ee82837fb5
Коммит 6181b0dcaf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
73 изменённых файлов: 2453 добавлений и 58 удалений

Просмотреть файл

@ -1,4 +1,5 @@
# class: Accessibility
* since: v1.8
* langs: csharp, js, python
The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by
@ -16,6 +17,7 @@ assistive technologies themselves. By default, Playwright tries to approximate t
"interesting" nodes of the tree.
## async method: Accessibility.snapshot
* since: v1.8
- returns: <[null]|[Object]>
- `role` <[string]> The [role](https://www.w3.org/TR/wai-aria/#usage_intro).
- `name` <[string]> A human readable name for the node.
@ -141,19 +143,23 @@ if node:
```
## async method: Accessibility.snapshot
* since: v1.8
* langs: java
- returns: <[null]|[string]>
## async method: Accessibility.snapshot
* since: v1.8
* langs: csharp
- returns: <[null]|[JsonElement]>
### option: Accessibility.snapshot.interestingOnly
* since: v1.8
- `interestingOnly` <[boolean]>
Prune uninteresting nodes from the tree. Defaults to `true`.
### option: Accessibility.snapshot.root
* since: v1.8
- `root` <[ElementHandle]>
The root DOM element for the snapshot. Defaults to the whole page.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Android
* since: v1.9
* langs: js
Playwright has **experimental** support for Android automation. This includes Chrome for Android and Android WebView.
@ -78,30 +79,36 @@ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
```
## async method: Android.devices
* since: v1.9
- returns: <[Array]<[AndroidDevice]>>
Returns the list of detected Android devices.
### option: Android.devices.host
* since: v1.22
- `host` <[string]>
Optional host to establish ADB server connection. Default to `127.0.0.1`.
### option: Android.devices.port
* since: v1.20
- `port` <[int]>
Optional port to establish ADB server connection. Default to `5037`.
### option: Android.devices.omitDriverInstall
* since: v1.21
- `omitDriverInstall` <[boolean]>
Prevents automatic playwright driver installation on attach. Assumes that the drivers have been installed already.
## method: Android.setDefaultTimeout
* since: v1.9
This setting will change the default maximum time for all the methods accepting [`param: timeout`] option.
### param: Android.setDefaultTimeout.timeout
* since: v1.9
- `timeout` <[float]>
Maximum time in milliseconds

Просмотреть файл

@ -1,27 +1,33 @@
# class: AndroidDevice
* since: v1.9
* langs: js
[AndroidDevice] represents a connected device, either real hardware or emulated. Devices can be obtained using [`method: Android.devices`].
## event: AndroidDevice.webView
* since: v1.9
- argument: <[AndroidWebView]>
Emitted when a new WebView instance is detected.
## async method: AndroidDevice.close
* since: v1.9
Disconnects from the device.
## async method: AndroidDevice.drag
* since: v1.9
Drags the widget defined by [`param: selector`] towards [`param: dest`] point.
### param: AndroidDevice.drag.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to drag.
### param: AndroidDevice.drag.dest
* since: v1.9
- `dest` <[Object]>
- `x` <[float]>
- `y` <[float]>
@ -29,196 +35,242 @@ Selector to drag.
Point to drag to.
### option: AndroidDevice.drag.speed
* since: v1.9
- `speed` <[float]>
Optional speed of the drag in pixels per second.
### option: AndroidDevice.drag.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.fill
* since: v1.9
Fills the specific [`param: selector`] input box with [`param: text`].
### param: AndroidDevice.fill.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to fill.
### param: AndroidDevice.fill.text
* since: v1.9
- `text` <[string]>
Text to be filled in the input box.
### option: AndroidDevice.fill.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.fling
* since: v1.9
Flings the widget defined by [`param: selector`] in the specified [`param: direction`].
### param: AndroidDevice.fling.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to fling.
### param: AndroidDevice.fling.direction
* since: v1.9
- `direction` <[AndroidFlingDirection]<"down"|"up"|"left"|"right">>
Fling direction.
### option: AndroidDevice.fling.speed
* since: v1.9
- `speed` <[float]>
Optional speed of the fling in pixels per second.
### option: AndroidDevice.fling.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.info
* since: v1.9
- returns: <[AndroidElementInfo]>
Returns information about a widget defined by [`param: selector`].
### param: AndroidDevice.info.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to return information about.
## property: AndroidDevice.input
* since: v1.9
- type: <[AndroidInput]>
## async method: AndroidDevice.installApk
* since: v1.9
Installs an apk on the device.
### param: AndroidDevice.installApk.file
* since: v1.9
- `file` <[string]|[Buffer]>
Either a path to the apk file, or apk file content.
### option: AndroidDevice.installApk.args
* since: v1.9
- `args` <[Array]<[string]>>
Optional arguments to pass to the `shell:cmd package install` call. Defaults to `-r -t -S`.
## async method: AndroidDevice.launchBrowser
* since: v1.9
- returns: <[BrowserContext]>
Launches Chrome browser on the device, and returns its persistent context.
### option: AndroidDevice.launchBrowser.pkg
* since: v1.9
- `command` <[string]>
Optional package name to launch instead of default Chrome for Android.
### option: AndroidDevice.launchBrowser.-inline- = %%-shared-context-params-list-%%
### option: AndroidDevice.launchBrowser.-inline- = %%-shared-context-params-list-v1.8-%%
* since: v1.9
## async method: AndroidDevice.longTap
* since: v1.9
Performs a long tap on the widget defined by [`param: selector`].
### param: AndroidDevice.longTap.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to tap on.
### option: AndroidDevice.longTap.timeout = %%-android-timeout-%%
* since: v1.9
## method: AndroidDevice.model
* since: v1.9
- returns: <[string]>
Device model.
## async method: AndroidDevice.open
* since: v1.9
- returns: <[AndroidSocket]>
Launches a process in the shell on the device and returns a socket to communicate with the launched process.
### param: AndroidDevice.open.command
* since: v1.9
- `command` <[string]> Shell command to execute.
## async method: AndroidDevice.pinchClose
* since: v1.9
Pinches the widget defined by [`param: selector`] in the closing direction.
### param: AndroidDevice.pinchClose.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to pinch close.
### param: AndroidDevice.pinchClose.percent
* since: v1.9
- `percent` <[float]>
The size of the pinch as a percentage of the widget's size.
### option: AndroidDevice.pinchClose.speed
* since: v1.9
- `speed` <[float]>
Optional speed of the pinch in pixels per second.
### option: AndroidDevice.pinchClose.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.pinchOpen
* since: v1.9
Pinches the widget defined by [`param: selector`] in the open direction.
### param: AndroidDevice.pinchOpen.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to pinch open.
### param: AndroidDevice.pinchOpen.percent
* since: v1.9
- `percent` <[float]>
The size of the pinch as a percentage of the widget's size.
### option: AndroidDevice.pinchOpen.speed
* since: v1.9
- `speed` <[float]>
Optional speed of the pinch in pixels per second.
### option: AndroidDevice.pinchOpen.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.press
* since: v1.9
Presses the specific [`param: key`] in the widget defined by [`param: selector`].
### param: AndroidDevice.press.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to press the key in.
### param: AndroidDevice.press.key
* since: v1.9
- `key` <[AndroidKey]>
The key to press.
### option: AndroidDevice.press.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.push
* since: v1.9
Copies a file to the device.
### param: AndroidDevice.push.file
* since: v1.9
- `file` <[string]|[Buffer]>
Either a path to the file, or file content.
### param: AndroidDevice.push.path
* since: v1.9
- `path` <[string]>
Path to the file on the device.
### option: AndroidDevice.push.mode
* since: v1.9
- `mode` <[int]>
Optional file mode, defaults to `644` (`rw-r--r--`).
## async method: AndroidDevice.screenshot
* since: v1.9
- returns: <[Buffer]>
Returns the buffer with the captured screenshot of the device.
### option: AndroidDevice.screenshot.path
* since: v1.9
- `path` <[path]>
The file path to save the image to. If [`option: path`] is a
@ -226,108 +278,132 @@ relative path, then it is resolved relative to the current working directory. If
saved to the disk.
## async method: AndroidDevice.scroll
* since: v1.9
Scrolls the widget defined by [`param: selector`] in the specified [`param: direction`].
### param: AndroidDevice.scroll.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to scroll.
### param: AndroidDevice.scroll.direction
* since: v1.9
- `direction` <[AndroidScrollDirection]<"down"|"up"|"left"|"right">>
Scroll direction.
### param: AndroidDevice.scroll.percent
* since: v1.9
- `percent` <[float]>
Distance to scroll as a percentage of the widget's size.
### option: AndroidDevice.scroll.speed
* since: v1.9
- `speed` <[float]>
Optional speed of the scroll in pixels per second.
### option: AndroidDevice.scroll.timeout = %%-android-timeout-%%
* since: v1.9
## method: AndroidDevice.serial
* since: v1.9
- returns: <[string]>
Device serial number.
## method: AndroidDevice.setDefaultTimeout
* since: v1.9
This setting will change the default maximum time for all the methods accepting [`param: timeout`] option.
### param: AndroidDevice.setDefaultTimeout.timeout
* since: v1.9
- `timeout` <[float]>
Maximum time in milliseconds
## async method: AndroidDevice.shell
* since: v1.9
- returns: <[Buffer]>
Executes a shell command on the device and returns its output.
### param: AndroidDevice.shell.command
* since: v1.9
- `command` <[string]>
Shell command to execute.
## async method: AndroidDevice.swipe
* since: v1.9
Swipes the widget defined by [`param: selector`] in the specified [`param: direction`].
### param: AndroidDevice.swipe.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to swipe.
### param: AndroidDevice.swipe.direction
* since: v1.9
- `direction` <[AndroidSwipeDirection]<"down"|"up"|"left"|"right">>
Swipe direction.
### param: AndroidDevice.swipe.percent
* since: v1.9
- `percent` <[float]>
Distance to swipe as a percentage of the widget's size.
### option: AndroidDevice.swipe.speed
* since: v1.9
- `speed` <[float]>
Optional speed of the swipe in pixels per second.
### option: AndroidDevice.swipe.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.tap
* since: v1.9
Taps on the widget defined by [`param: selector`].
### param: AndroidDevice.tap.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to tap on.
### option: AndroidDevice.tap.duration
* since: v1.9
- `duration` <[float]>
Optional duration of the tap in milliseconds.
### option: AndroidDevice.tap.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.wait
* since: v1.9
Waits for the specific [`param: selector`] to either appear or disappear, depending on the [`option: state`].
### param: AndroidDevice.wait.selector
* since: v1.9
- `selector` <[AndroidSelector]>
Selector to wait for.
### option: AndroidDevice.wait.state
* since: v1.9
- `state` <[AndroidDeviceState]<"gone">>
Optional state. Can be either:
@ -335,15 +411,19 @@ Optional state. Can be either:
* `'gone'` - wait for element to not be present.
### option: AndroidDevice.wait.timeout = %%-android-timeout-%%
* since: v1.9
## async method: AndroidDevice.waitForEvent
* since: v1.9
- returns: <[any]>
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value.
### param: AndroidDevice.waitForEvent.event = %%-wait-for-event-event-%%
* since: v1.9
### param: AndroidDevice.waitForEvent.optionsOrPredicate
* since: v1.9
- `optionsOrPredicate` ?<[function]|[Object]>
- `predicate` <[function]> receives the event data and resolves to truthy value when the waiting should resolve.
- `timeout` ?<[float]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to
@ -352,18 +432,22 @@ Waits for event to fire and passes its value into the predicate function. Return
Either a predicate that receives an event or an options object. Optional.
## async method: AndroidDevice.webView
* since: v1.9
- returns: <[AndroidWebView]>
This method waits until [AndroidWebView] matching the [`option: selector`] is opened and returns it. If there is already an open [AndroidWebView] matching the [`option: selector`], returns immediately.
### param: AndroidDevice.webView.selector
* since: v1.9
- `selector` <[Object]>
- `pkg` ?<[string]> Optional Package identifier.
- `socketName` ?<[string]> Optional webview socket name.
### option: AndroidDevice.webView.timeout = %%-android-timeout-%%
* since: v1.9
## method: AndroidDevice.webViews
* since: v1.9
- returns: <[Array]<[AndroidWebView]>>
Currently open WebViews.

Просмотреть файл

@ -1,11 +1,14 @@
# class: AndroidInput
* since: v1.9
* langs: js
## async method: AndroidInput.drag
* since: v1.9
Performs a drag between [`param: from`] and [`param: to`] points.
### param: AndroidInput.drag.from
* since: v1.9
- `from` <[Object]>
- `x` <[float]>
- `y` <[float]>
@ -13,6 +16,7 @@ Performs a drag between [`param: from`] and [`param: to`] points.
The start point of the drag.
### param: AndroidInput.drag.to
* since: v1.9
- `to` <[Object]>
- `x` <[float]>
- `y` <[float]>
@ -20,25 +24,30 @@ The start point of the drag.
The end point of the drag.
### param: AndroidInput.drag.steps
* since: v1.9
- `steps` <[int]>
The number of steps in the drag. Each step takes 5 milliseconds to complete.
## async method: AndroidInput.press
* since: v1.9
Presses the [`param: key`].
### param: AndroidInput.press.key
* since: v1.9
- `key` <[AndroidKey]>
Key to press.
## async method: AndroidInput.swipe
* since: v1.9
Swipes following the path defined by [`param: segments`].
### param: AndroidInput.swipe.from
* since: v1.9
- `from` <[Object]>
- `x` <[float]>
- `y` <[float]>
@ -46,6 +55,7 @@ Swipes following the path defined by [`param: segments`].
The point to start swiping from.
### param: AndroidInput.swipe.segments
* since: v1.9
- `segments` <[Array]<[Object]>>
- `x` <[float]>
- `y` <[float]>
@ -53,15 +63,18 @@ The point to start swiping from.
Points following the [`param: from`] point in the swipe gesture.
### param: AndroidInput.swipe.steps
* since: v1.9
- `steps` <[int]>
The number of steps for each segment. Each step takes 5 milliseconds to complete, so 100 steps means half a second per each segment.
## async method: AndroidInput.tap
* since: v1.9
Taps at the specified [`param: point`].
### param: AndroidInput.tap.point
* since: v1.9
- `point` <[Object]>
- `x` <[float]>
- `y` <[float]>
@ -69,10 +82,12 @@ Taps at the specified [`param: point`].
The point to tap at.
## async method: AndroidInput.type
* since: v1.9
Types [`param: text`] into currently focused widget.
### param: AndroidInput.type.text
* since: v1.9
- `text` <[string]>
Text to type.

Просмотреть файл

@ -1,26 +1,32 @@
# class: AndroidSocket
* since: v1.9
* langs: js
[AndroidSocket] is a way to communicate with a process launched on the [AndroidDevice]. Use [`method: AndroidDevice.open`] to open a socket.
## event: AndroidSocket.close
* since: v1.9
Emitted when the socket is closed.
## event: AndroidSocket.data
* since: v1.9
- argument: <[Buffer]>
Emitted when data is available to read from the socket.
## async method: AndroidSocket.close
* since: v1.9
Closes the socket.
## async method: AndroidSocket.write
* since: v1.9
Writes some [`param: data`] to the socket.
### param: AndroidSocket.write.data
* since: v1.9
- `data` <[Buffer]>
Data to write.

Просмотреть файл

@ -1,23 +1,28 @@
# class: AndroidWebView
* since: v1.9
* langs: js
[AndroidWebView] represents a WebView open on the [AndroidDevice]. WebView is usually obtained using [`method: AndroidDevice.webView`].
## event: AndroidWebView.close
* since: v1.9
Emitted when the WebView is closed.
## async method: AndroidWebView.page
* since: v1.9
- returns: <[Page]>
Connects to the WebView and returns a regular Playwright [Page] to interact with.
## method: AndroidWebView.pid
* since: v1.9
- returns: <[int]>
WebView process PID.
## method: AndroidWebView.pkg
* since: v1.9
- returns: <[string]>
WebView package identifier.

Просмотреть файл

@ -1,4 +1,5 @@
# class: APIRequest
* since: v1.16
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
@ -6,17 +7,24 @@ of this class can be obtained via [`property: Playwright.request`]. For more inf
see [APIRequestContext].
## async method: APIRequest.newContext
* since: v1.16
- returns: <[APIRequestContext]>
Creates new instances of [APIRequestContext].
### option: APIRequest.newContext.useragent = %%-context-option-useragent-%%
* since: v1.16
### option: APIRequest.newContext.extraHTTPHeaders = %%-context-option-extrahttpheaders-%%
* since: v1.16
### option: APIRequest.newContext.httpCredentials = %%-context-option-httpcredentials-%%
* since: v1.16
### option: APIRequest.newContext.proxy = %%-browser-option-proxy-%%
* since: v1.16
### option: APIRequest.newContext.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
* since: v1.16
### option: APIRequest.newContext.timeout
* since: v1.16
- `timeout` <[float]>
Maximum time in milliseconds to wait for the response. Defaults to
@ -24,6 +32,7 @@ Maximum time in milliseconds to wait for the response. Defaults to
### option: APIRequest.newContext.baseURL
* since: v1.16
- `baseURL` <[string]>
Methods like [`method: APIRequestContext.get`] take the base URL into consideration by using the [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. Examples:
@ -32,6 +41,7 @@ Methods like [`method: APIRequestContext.get`] take the base URL into considerat
* baseURL: `http://localhost:3000/foo` (without trailing slash) and navigating to `./bar.html` results in `http://localhost:3000/bar.html`
### option: APIRequest.newContext.storageState
* since: v1.16
* langs: js, python
- `storageState` <[path]|[Object]>
- `cookies` <[Array]<[Object]>>
@ -55,6 +65,7 @@ file with saved storage, or the value returned by one of [`method: BrowserContex
[`method: APIRequestContext.storageState`] methods.
### option: APIRequest.newContext.storageState
* since: v1.16
* langs: java, csharp
- `storageState` <[string]>
@ -64,3 +75,4 @@ file with saved storage, or the value returned by one of [`method: BrowserContex
[`method: APIRequestContext.storageState`] methods.
### option: APIRequest.newContext.storageStatePath = %%-csharp-java-context-option-storage-state-path-%%
* since: v1.18

Просмотреть файл

@ -1,4 +1,5 @@
# class: APIRequestContext
* since: v1.16
This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
environment or the service to your e2e test.
@ -120,12 +121,14 @@ with sync_playwright() as p:
```
## method: APIRequestContext.createFormData
* since: v1.23
* langs: csharp
- returns: <[FormData]>
Creates a new [FormData] instance which is used for providing form and multipart data when making HTTP requests.
## async method: APIRequestContext.delete
* since: v1.16
- returns: <[APIResponse]>
Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response.
@ -133,40 +136,60 @@ The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.
### param: APIRequestContext.delete.url = %%-fetch-param-url-%%
* since: v1.16
### param: APIRequestContext.delete.params = %%-java-csharp-fetch-params-%%
* since: v1.18
### option: APIRequestContext.delete.params = %%-js-python-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.delete.params = %%-csharp-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.delete.headers = %%-js-python-fetch-option-headers-%%
* since: v1.16
### option: APIRequestContext.delete.data = %%-js-python-fetch-option-data-%%
* since: v1.17
### option: APIRequestContext.delete.form = %%-js-python-fetch-option-form-%%
* since: v1.17
### option: APIRequestContext.delete.form = %%-csharp-fetch-option-form-%%
* since: v1.17
### option: APIRequestContext.delete.multipart = %%-js-python-fetch-option-multipart-%%
* since: v1.17
### option: APIRequestContext.delete.multipart = %%-csharp-fetch-option-multipart-%%
* since: v1.17
### option: APIRequestContext.delete.timeout = %%-js-python-fetch-option-timeout-%%
* since: v1.16
### option: APIRequestContext.delete.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
* since: v1.16
### option: APIRequestContext.delete.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
* since: v1.16
## async method: APIRequestContext.dispose
* since: v1.16
All responses returned by [`method: APIRequestContext.get`] and similar methods are stored in the memory, so that you can later call [`method: APIResponse.body`]. This method
discards all stored responses, and makes [`method: APIResponse.body`] throw "Response disposed" error.
## async method: APIRequestContext.fetch
* since: v1.16
- returns: <[APIResponse]>
Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.
### param: APIRequestContext.fetch.urlOrRequest
* since: v1.16
- `urlOrRequest` <[string]|[Request]>
Target URL or Request to get all parameters from.
### param: APIRequestContext.fetch.params = %%-java-csharp-fetch-params-%%
* since: v1.18
### option: APIRequestContext.fetch.params = %%-js-python-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.fetch.params = %%-csharp-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.fetch.method
* since: v1.16
* langs: js, python, csharp
- `method` <[string]>
@ -174,16 +197,26 @@ If set changes the fetch method (e.g. [PUT](https://developer.mozilla.org/en-US/
[POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST)). If not specified, GET method is used.
### option: APIRequestContext.fetch.headers = %%-js-python-fetch-option-headers-%%
* since: v1.16
### option: APIRequestContext.fetch.data = %%-js-python-fetch-option-data-%%
* since: v1.16
### option: APIRequestContext.fetch.form = %%-js-python-fetch-option-form-%%
* since: v1.16
### option: APIRequestContext.fetch.form = %%-csharp-fetch-option-form-%%
* since: v1.16
### option: APIRequestContext.fetch.multipart = %%-js-python-fetch-option-multipart-%%
* since: v1.16
### option: APIRequestContext.fetch.multipart = %%-csharp-fetch-option-multipart-%%
* since: v1.16
### option: APIRequestContext.fetch.timeout = %%-js-python-fetch-option-timeout-%%
* since: v1.16
### option: APIRequestContext.fetch.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
* since: v1.16
### option: APIRequestContext.fetch.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
* since: v1.16
## async method: APIRequestContext.get
* since: v1.16
- returns: <[APIResponse]>
Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response.
@ -191,15 +224,24 @@ The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.
### param: APIRequestContext.get.url = %%-fetch-param-url-%%
* since: v1.16
### param: APIRequestContext.get.params = %%-java-csharp-fetch-params-%%
* since: v1.18
### option: APIRequestContext.get.params = %%-js-python-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.get.params = %%-csharp-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.get.headers = %%-js-python-fetch-option-headers-%%
* since: v1.16
### option: APIRequestContext.get.timeout = %%-js-python-fetch-option-timeout-%%
* since: v1.16
### option: APIRequestContext.get.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
* since: v1.16
### option: APIRequestContext.get.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
* since: v1.16
## async method: APIRequestContext.head
* since: v1.16
- returns: <[APIResponse]>
Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
@ -207,15 +249,24 @@ The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.
### param: APIRequestContext.head.url = %%-fetch-param-url-%%
* since: v1.16
### param: APIRequestContext.head.params = %%-java-csharp-fetch-params-%%
* since: v1.18
### option: APIRequestContext.head.params = %%-js-python-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.head.params = %%-csharp-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.head.headers = %%-js-python-fetch-option-headers-%%
* since: v1.16
### option: APIRequestContext.head.timeout = %%-js-python-fetch-option-timeout-%%
* since: v1.16
### option: APIRequestContext.head.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
* since: v1.16
### option: APIRequestContext.head.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
* since: v1.16
## async method: APIRequestContext.patch
* since: v1.16
- returns: <[APIResponse]>
Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
@ -223,20 +274,34 @@ The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.
### param: APIRequestContext.patch.url = %%-fetch-param-url-%%
* since: v1.16
### param: APIRequestContext.patch.params = %%-java-csharp-fetch-params-%%
* since: v1.18
### option: APIRequestContext.patch.params = %%-js-python-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.patch.params = %%-csharp-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.patch.headers = %%-js-python-fetch-option-headers-%%
* since: v1.16
### option: APIRequestContext.patch.data = %%-js-python-fetch-option-data-%%
* since: v1.16
### option: APIRequestContext.patch.form = %%-js-python-fetch-option-form-%%
* since: v1.16
### option: APIRequestContext.patch.form = %%-csharp-fetch-option-form-%%
* since: v1.16
### option: APIRequestContext.patch.multipart = %%-js-python-fetch-option-multipart-%%
* since: v1.16
### option: APIRequestContext.patch.multipart = %%-csharp-fetch-option-multipart-%%
* since: v1.16
### option: APIRequestContext.patch.timeout = %%-js-python-fetch-option-timeout-%%
* since: v1.16
### option: APIRequestContext.patch.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
* since: v1.16
### option: APIRequestContext.patch.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
* since: v1.16
## async method: APIRequestContext.post
* since: v1.16
- returns: <[APIResponse]>
Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
@ -244,20 +309,34 @@ The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.
### param: APIRequestContext.post.url = %%-fetch-param-url-%%
* since: v1.16
### param: APIRequestContext.post.params = %%-java-csharp-fetch-params-%%
* since: v1.18
### option: APIRequestContext.post.params = %%-js-python-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.post.params = %%-csharp-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.post.headers = %%-js-python-fetch-option-headers-%%
* since: v1.16
### option: APIRequestContext.post.data = %%-js-python-fetch-option-data-%%
* since: v1.16
### option: APIRequestContext.post.form = %%-js-python-fetch-option-form-%%
* since: v1.16
### option: APIRequestContext.post.form = %%-csharp-fetch-option-form-%%
* since: v1.16
### option: APIRequestContext.post.multipart = %%-js-python-fetch-option-multipart-%%
* since: v1.16
### option: APIRequestContext.post.multipart = %%-csharp-fetch-option-multipart-%%
* since: v1.16
### option: APIRequestContext.post.timeout = %%-js-python-fetch-option-timeout-%%
* since: v1.16
### option: APIRequestContext.post.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
* since: v1.16
### option: APIRequestContext.post.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
* since: v1.16
## async method: APIRequestContext.put
* since: v1.16
- returns: <[APIResponse]>
Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response.
@ -265,20 +344,34 @@ The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects.
### param: APIRequestContext.put.url = %%-fetch-param-url-%%
* since: v1.16
### param: APIRequestContext.put.params = %%-java-csharp-fetch-params-%%
* since: v1.18
### option: APIRequestContext.put.params = %%-js-python-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.put.params = %%-csharp-fetch-option-params-%%
* since: v1.16
### option: APIRequestContext.put.headers = %%-js-python-fetch-option-headers-%%
* since: v1.16
### option: APIRequestContext.put.data = %%-js-python-fetch-option-data-%%
* since: v1.16
### option: APIRequestContext.put.form = %%-js-python-fetch-option-form-%%
* since: v1.16
### option: APIRequestContext.put.form = %%-csharp-fetch-option-form-%%
* since: v1.16
### option: APIRequestContext.put.multipart = %%-js-python-fetch-option-multipart-%%
* since: v1.16
### option: APIRequestContext.put.multipart = %%-csharp-fetch-option-multipart-%%
* since: v1.16
### option: APIRequestContext.put.timeout = %%-js-python-fetch-option-timeout-%%
* since: v1.16
### option: APIRequestContext.put.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
* since: v1.16
### option: APIRequestContext.put.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
* since: v1.16
## async method: APIRequestContext.storageState
* since: v1.16
- returns: <[Object]>
- `cookies` <[Array]<[Object]>>
- `name` <[string]>
@ -298,7 +391,9 @@ context cookies from the response. The method will automatically follow redirect
Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to the constructor.
## async method: APIRequestContext.storageState
* since: v1.16
* langs: java, csharp
- returns: <[string]>
### option: APIRequestContext.storageState.path = %%-storagestate-option-path-%%
* since: v1.16

Просмотреть файл

@ -1,4 +1,5 @@
# class: APIResponse
* since: v1.16
[APIResponse] class represents responses returned by [`method: APIRequestContext.get`] and similar methods.
@ -37,20 +38,24 @@ with sync_playwright() as p:
```
## async method: APIResponse.body
* since: v1.16
- returns: <[Buffer]>
Returns the buffer with response body.
## async method: APIResponse.dispose
* since: v1.16
Disposes the body of this response. If not called then the body will stay in memory until the context closes.
## method: APIResponse.headers
* since: v1.16
- returns: <[Object]<[string], [string]>>
An object with all the response HTTP headers associated with this response.
## method: APIResponse.headersArray
* since: v1.16
- returns: <[Array]<[Object]>>
- `name` <[string]> Name of the header.
- `value` <[string]> Value of the header.
@ -59,6 +64,7 @@ An array with all the request HTTP headers associated with this response. Header
Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
## async method: APIResponse.json
* since: v1.16
* langs: js, python
- returns: <[Serializable]>
@ -67,6 +73,7 @@ Returns the JSON representation of response body.
This method will throw if the response body is not parsable via `JSON.parse`.
## async method: APIResponse.json
* since: v1.16
* langs: csharp
- returns: <[null]|[JsonElement]>
@ -75,26 +82,31 @@ Returns the JSON representation of response body.
This method will throw if the response body is not parsable via `JSON.parse`.
## method: APIResponse.ok
* since: v1.16
- returns: <[boolean]>
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
## method: APIResponse.status
* since: v1.16
- returns: <[int]>
Contains the status code of the response (e.g., 200 for a success).
## method: APIResponse.statusText
* since: v1.16
- returns: <[string]>
Contains the status text of the response (e.g. usually an "OK" for a success).
## async method: APIResponse.text
* since: v1.16
- returns: <[string]>
Returns the text representation of response body.
## method: APIResponse.url
* since: v1.16
- returns: <[string]>
Contains the URL of the response.

Просмотреть файл

@ -1,4 +1,5 @@
# class: APIResponseAssertions
* since: v1.18
* langs: js, java, python
The [APIResponseAssertions] class provides assertion methods that can be used to make assertions about the [APIResponse] in the tests. A new instance of [APIResponseAssertions] is created by calling [`method: PlaywrightAssertions.expectAPIResponse`]:
@ -48,6 +49,7 @@ def test_navigates_to_login_page(page: Page) -> None:
## property: APIResponseAssertions.not
* since: v1.20
* langs: java, js
- returns: <[APIResponseAssertions]>
@ -62,11 +64,13 @@ assertThat(response).not().isOK();
```
## async method: APIResponseAssertions.NotToBeOK
* since: v1.19
* langs: python
The opposite of [`method: APIResponseAssertions.toBeOK`].
## async method: APIResponseAssertions.toBeOK
* since: v1.18
* langs:
- alias-java: isOK

Просмотреть файл

@ -1,4 +1,5 @@
# class: Browser
* since: v1.8
* extends: [EventEmitter]
A Browser is created via [`method: BrowserType.launch`]. An example of using a [Browser] to create a [Page]:
@ -73,6 +74,7 @@ await browser.CloseAsync();
```
## event: Browser.disconnected
* since: v1.8
- argument: <[Browser]>
Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
@ -80,11 +82,13 @@ Emitted when Browser gets disconnected from the browser application. This might
* The [`method: Browser.close`] method was called.
## method: Browser.browserType
* since: v1.23
- returns: <[BrowserType]>
Get the browser type (chromium, firefox or webkit) that the browser belongs to.
## async method: Browser.close
* since: v1.8
In case this browser is obtained using [`method: BrowserType.launch`], closes the browser and all of its pages (if any
were opened).
@ -99,6 +103,7 @@ This is similar to force quitting the browser. Therefore, you should call [`meth
The [Browser] object itself is considered to be disposed and cannot be used anymore.
## method: Browser.contexts
* since: v1.8
- returns: <[Array]<[BrowserContext]>>
Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.
@ -141,11 +146,13 @@ System.Console.WriteLine(browser.Contexts.Count); // prints "1"
```
## method: Browser.isConnected
* since: v1.8
- returns: <[boolean]>
Indicates that the browser is connected.
## async method: Browser.newBrowserCDPSession
* since: v1.11
* langs: js, python
- returns: <[CDPSession]>
@ -156,6 +163,7 @@ CDP Sessions are only supported on Chromium-based browsers.
Returns the newly created browser session.
## async method: Browser.newContext
* since: v1.8
- returns: <[BrowserContext]>
Creates a new browser context. It won't share cookies/cache with other browser contexts.
@ -233,17 +241,23 @@ await context.CloseAsync();
await browser.CloseAsync();
```
### option: Browser.newContext.-inline- = %%-shared-context-params-list-%%
### option: Browser.newContext.-inline- = %%-shared-context-params-list-v1.8-%%
* since: v1.8
### option: Browser.newContext.proxy = %%-context-option-proxy-%%
* since: v1.8
### option: Browser.newContext.storageState = %%-js-python-context-option-storage-state-%%
* since: v1.8
### option: Browser.newContext.storageState = %%-csharp-java-context-option-storage-state-%%
* since: v1.8
### option: Browser.newContext.storageStatePath = %%-csharp-java-context-option-storage-state-path-%%
* since: v1.9
## async method: Browser.newPage
* since: v1.8
- returns: <[Page]>
Creates a new page in a new browser context. Closing this page will close the context as well.
@ -252,17 +266,23 @@ This is a convenience API that should only be used for the single-page scenarios
testing frameworks should explicitly create [`method: Browser.newContext`] followed by the
[`method: BrowserContext.newPage`] to control their exact life times.
### option: Browser.newPage.-inline- = %%-shared-context-params-list-%%
### option: Browser.newPage.-inline- = %%-shared-context-params-list-v1.8-%%
* since: v1.8
### option: Browser.newPage.proxy = %%-context-option-proxy-%%
* since: v1.8
### option: Browser.newPage.storageState = %%-js-python-context-option-storage-state-%%
* since: v1.8
### option: Browser.newPage.storageState = %%-csharp-java-context-option-storage-state-%%
* since: v1.8
### option: Browser.newPage.storageStatePath = %%-csharp-java-context-option-storage-state-path-%%
* since: v1.9
## async method: Browser.startTracing
* since: v1.11
* langs: java, js, python
:::note
@ -298,26 +318,31 @@ browser.stop_tracing()
```
### param: Browser.startTracing.page
* since: v1.11
- `page` ?<[Page]>
Optional, if specified, tracing includes screenshots of the given page.
### option: Browser.startTracing.path
* since: v1.11
- `path` <[path]>
A path to write the trace file to.
### option: Browser.startTracing.screenshots
* since: v1.11
- `screenshots` <[boolean]>
captures screenshots in the trace.
### option: Browser.startTracing.categories
* since: v1.11
- `categories` <[Array]<[string]>>
specify custom categories to use instead of default.
## async method: Browser.stopTracing
* since: v1.11
* langs: java, js, python
- returns: <[Buffer]>
@ -328,6 +353,7 @@ This API controls [Chromium Tracing](https://www.chromium.org/developers/how-tos
Returns the buffer with trace data.
## method: Browser.version
* since: v1.8
- returns: <[string]>
Returns the browser version.

Просмотреть файл

@ -1,4 +1,5 @@
# class: BrowserContext
* since: v1.8
* extends: [EventEmitter]
BrowserContexts provide a way to operate multiple independent browser sessions.
@ -62,6 +63,7 @@ await context.CloseAsync();
```
## event: BrowserContext.backgroundPage
* since: v1.11
* langs: js, python
- argument: <[Page]>
@ -85,6 +87,7 @@ background_page = context.wait_for_event("backgroundpage")
```
## event: BrowserContext.close
* since: v1.8
- argument: <[BrowserContext]>
Emitted when Browser context gets closed. This might happen because of one of the following:
@ -93,6 +96,7 @@ Emitted when Browser context gets closed. This might happen because of one of th
* The [`method: Browser.close`] method was called.
## event: BrowserContext.page
* since: v1.8
- argument: <[Page]>
The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will
@ -145,6 +149,7 @@ cases).
:::
## event: BrowserContext.request
* since: v1.12
- argument: <[Request]>
Emitted when a request is issued from any pages created through this context.
@ -155,6 +160,7 @@ In order to intercept and mutate requests, see [`method: BrowserContext.route`]
or [`method: Page.route`].
## event: BrowserContext.requestFailed
* since: v1.12
- argument: <[Request]>
Emitted when a request fails, for example by timing out. To only listen for
@ -166,6 +172,7 @@ with [`event: BrowserContext.requestFinished`] event and not with [`event: Brows
:::
## event: BrowserContext.requestFinished
* since: v1.12
- argument: <[Request]>
Emitted when a request finishes successfully after downloading the response body. For a successful response, the
@ -173,6 +180,7 @@ sequence of events is `request`, `response` and `requestfinished`. To listen for
successful requests from a particular page, use [`event: Page.requestFinished`].
## event: BrowserContext.response
* since: v1.12
- argument: <[Response]>
Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events
@ -180,6 +188,7 @@ is `request`, `response` and `requestfinished`. To listen for response events
from a particular page, use [`event: Page.response`].
## event: BrowserContext.serviceWorker
* since: v1.11
* langs: js, python
- argument: <[Worker]>
@ -190,6 +199,7 @@ Service workers are only supported on Chromium-based browsers.
Emitted when new service worker is created in the context.
## async method: BrowserContext.addCookies
* since: v1.8
Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
obtained via [`method: BrowserContext.cookies`].
@ -215,6 +225,7 @@ await context.AddCookiesAsync(new[] { cookie1, cookie2 });
```
### param: BrowserContext.addCookies.cookies
* since: v1.8
- `cookies` <[Array]<[Object]>>
- `name` <[string]>
- `value` <[string]>
@ -227,6 +238,7 @@ await context.AddCookiesAsync(new[] { cookie1, cookie2 });
- `sameSite` ?<[SameSiteAttribute]<"Strict"|"Lax"|"None">> Optional.
## async method: BrowserContext.addInitScript
* since: v1.8
Adds a script which would be evaluated in one of the following scenarios:
* Whenever a page is created in the browser context or is navigated.
@ -275,6 +287,7 @@ The order of evaluation of multiple scripts installed via [`method: BrowserConte
:::
### param: BrowserContext.addInitScript.script
* since: v1.8
* langs: js
- `script` <[function]|[string]|[Object]>
- `path` ?<[path]> Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the
@ -284,18 +297,21 @@ The order of evaluation of multiple scripts installed via [`method: BrowserConte
Script to be evaluated in all pages in the browser context.
### param: BrowserContext.addInitScript.script
* since: v1.8
* langs: csharp, java
- `script` <[string]|[path]>
Script to be evaluated in all pages in the browser context.
### param: BrowserContext.addInitScript.arg
* since: v1.8
* langs: js
- `arg` ?<[Serializable]>
Optional argument to pass to [`param: script`] (only supported when passing a function).
## method: BrowserContext.backgroundPages
* since: v1.11
* langs: js, python
- returns: <[Array]<[Page]>>
@ -306,15 +322,18 @@ Background pages are only supported on Chromium-based browsers.
All existing background pages in the context.
## method: BrowserContext.browser
* since: v1.8
- returns: <[null]|[Browser]>
Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
## async method: BrowserContext.clearCookies
* since: v1.8
Clears context cookies.
## async method: BrowserContext.clearPermissions
* since: v1.8
Clears all permission overrides for the browser context.
@ -356,6 +375,7 @@ await context.ClearPermissionsAsync();
```
## async method: BrowserContext.close
* since: v1.8
Closes the browser context. All the pages that belong to the browser context will be closed.
@ -364,6 +384,7 @@ The default browser context cannot be closed.
:::
## async method: BrowserContext.cookies
* since: v1.8
- returns: <[Array]<[Object]>>
- `name` <[string]>
- `value` <[string]>
@ -378,11 +399,13 @@ If no URLs are specified, this method returns all cookies. If URLs are specified
are returned.
### param: BrowserContext.cookies.urls
* since: v1.8
- `urls` ?<[string]|[Array]<[string]>>
Optional list of URLs.
## async method: BrowserContext.exposeBinding
* since: v1.8
The method adds a function called [`param: name`] on the `window` object of every frame in every page in the context.
When called, the function executes [`param: callback`] and returns a [Promise] which resolves to the return value of
@ -588,22 +611,26 @@ Assert.AreEqual("Click me", await result.Task);
```
### param: BrowserContext.exposeBinding.name
* since: v1.8
- `name` <[string]>
Name of the function on the window object.
### param: BrowserContext.exposeBinding.callback
* since: v1.8
- `callback` <[function]>
Callback function that will be called in the Playwright's context.
### option: BrowserContext.exposeBinding.handle
* since: v1.8
- `handle` <[boolean]>
Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is
supported. When passing by value, multiple arguments are supported.
## async method: BrowserContext.exposeFunction
* since: v1.8
The method adds a function called [`param: name`] on the `window` object of every frame in every page in the context.
When called, the function executes [`param: callback`] and returns a [Promise] which resolves to the return value of
@ -776,21 +803,25 @@ class BrowserContextExamples
```
### param: BrowserContext.exposeFunction.name
* since: v1.8
- `name` <[string]>
Name of the function on the window object.
### param: BrowserContext.exposeFunction.callback
* since: v1.8
- `callback` <[function]>
Callback function that will be called in the Playwright's context.
## async method: BrowserContext.grantPermissions
* since: v1.8
Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
specified.
### param: BrowserContext.grantPermissions.permissions
* since: v1.8
- `permissions` <[Array]<[string]>>
A permission or an array of permissions to grant. Permissions can be one of the following values:
@ -811,11 +842,13 @@ A permission or an array of permissions to grant. Permissions can be one of the
* `'payment-handler'`
### option: BrowserContext.grantPermissions.origin
* since: v1.8
- `origin` <[string]>
The [origin] to grant permissions to, e.g. "https://example.com".
## async method: BrowserContext.newCDPSession
* since: v1.11
* langs: js, python
- returns: <[CDPSession]>
@ -826,22 +859,26 @@ CDP sessions are only supported on Chromium-based browsers.
Returns the newly created session.
### param: BrowserContext.newCDPSession.page
* since: v1.11
- `page` <[Page]|[Frame]>
Target to create new session for. For backwards-compatibility, this parameter is
named `page`, but it can be a `Page` or `Frame` type.
## async method: BrowserContext.newPage
* since: v1.8
- returns: <[Page]>
Creates a new page in the browser context.
## method: BrowserContext.pages
* since: v1.8
- returns: <[Array]<[Page]>>
Returns all open pages in the context.
## property: BrowserContext.request
* since: v1.16
* langs:
- alias-csharp: APIRequest
- type: <[APIRequestContext]>
@ -849,6 +886,7 @@ Returns all open pages in the context.
API testing helper associated with this context. Requests made with this API will use context cookies.
## async method: BrowserContext.route
* since: v1.8
Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
@ -1002,6 +1040,7 @@ Enabling routing disables http cache.
:::
### param: BrowserContext.route.url
* since: v1.8
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>
A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
@ -1009,34 +1048,40 @@ When a [`option: baseURL`] via the context options was provided and the passed U
it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
### param: BrowserContext.route.handler
* since: v1.8
* langs: js, python
- `handler` <[function]\([Route], [Request]\)>
handler function to route the request.
### param: BrowserContext.route.handler
* since: v1.8
* langs: csharp, java
- `handler` <[function]\([Route]\)>
handler function to route the request.
### option: BrowserContext.route.times
* since: v1.15
- `times` <[int]>
How often a route should be used. By default it will be used every time.
## async method: BrowserContext.routeFromHAR
* since: v1.23
If specified the network requests that are made in the context will be served from the HAR file. Read more about [Replaying from HAR](../network.md#replaying-from-har).
Playwright will not serve requests intercepted by Service Worker from the HAR file. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting [`option: Browser.newContext.serviceWorkers`] to `'block'`.
### param: BrowserContext.routeFromHAR.har
* since: v1.23
- `har` <[path]>
Path to a [HAR](http://www.softwareishard.com/blog/har-12-spec) file with prerecorded network data. If `path` is a relative path, then it is resolved relative to the current working directory.
### option: BrowserContext.routeFromHAR.notFound
* since: v1.23
- `notFound` ?<[HarNotFound]<"abort"|"fallback">>
* If set to 'abort' any request not found in the HAR file will be aborted.
@ -1045,16 +1090,19 @@ Path to a [HAR](http://www.softwareishard.com/blog/har-12-spec) file with prerec
Defaults to abort.
### option: BrowserContext.routeFromHAR.update
* since: v1.23
- `update` ?<boolean>
If specified, updates the given HAR with the actual network information instead of serving from file.
### option: BrowserContext.routeFromHAR.url
* since: v1.23
- `url` <[string]|[RegExp]>
A glob pattern, regular expression or predicate to match the request URL. Only requests with URL matching the pattern will be served from the HAR file. If not specified, all requests are served from the HAR file.
## method: BrowserContext.serviceWorkers
* since: v1.11
* langs: js, python
- returns: <[Array]<[Worker]>>
@ -1065,6 +1113,7 @@ Service workers are only supported on Chromium-based browsers.
All existing service workers in the context.
## method: BrowserContext.setDefaultNavigationTimeout
* since: v1.8
This setting will change the default maximum navigation time for the following methods and related shortcuts:
* [`method: Page.goBack`]
@ -1080,11 +1129,13 @@ This setting will change the default maximum navigation time for the following m
:::
### param: BrowserContext.setDefaultNavigationTimeout.timeout
* since: v1.8
- `timeout` <[float]>
Maximum navigation time in milliseconds
## method: BrowserContext.setDefaultTimeout
* since: v1.8
This setting will change the default maximum time for all the methods accepting [`param: timeout`] option.
@ -1094,11 +1145,13 @@ This setting will change the default maximum time for all the methods accepting
:::
### param: BrowserContext.setDefaultTimeout.timeout
* since: v1.8
- `timeout` <[float]>
Maximum time in milliseconds
## async method: BrowserContext.setExtraHTTPHeaders
* since: v1.8
The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged
with page-specific extra HTTP headers set with [`method: Page.setExtraHTTPHeaders`]. If page overrides a particular
@ -1109,11 +1162,13 @@ header, page-specific header value will be used instead of the browser context h
:::
### param: BrowserContext.setExtraHTTPHeaders.headers
* since: v1.8
- `headers` <[Object]<[string], [string]>>
An object containing additional HTTP headers to be sent with every request. All header values must be strings.
## async method: BrowserContext.setGeolocation
* since: v1.8
Sets the context's geolocation. Passing `null` or `undefined` emulates position unavailable.
@ -1147,29 +1202,35 @@ its geolocation.
:::
### param: BrowserContext.setGeolocation.geolocation
* since: v1.8
- `geolocation` <[null]|[Object]>
- `latitude` <[float]> Latitude between -90 and 90.
- `longitude` <[float]> Longitude between -180 and 180.
- `accuracy` ?<[float]> Non-negative accuracy value. Defaults to `0`.
## async method: BrowserContext.setHTTPCredentials
* since: v1.8
* langs: js
**DEPRECATED** Browsers may cache credentials after successful authentication. Create a new browser context instead.
### param: BrowserContext.setHTTPCredentials.httpCredentials
* since: v1.8
- `httpCredentials` <[null]|[Object]>
- `username` <[string]>
- `password` <[string]>
## async method: BrowserContext.setOffline
* since: v1.8
### param: BrowserContext.setOffline.offline
* since: v1.8
- `offline` <[boolean]>
Whether to emulate network being offline for the browser context.
## async method: BrowserContext.storageState
* since: v1.8
- returns: <[Object]>
- `cookies` <[Array]<[Object]>>
- `name` <[string]>
@ -1189,38 +1250,46 @@ Whether to emulate network being offline for the browser context.
Returns storage state for this browser context, contains current cookies and local storage snapshot.
## async method: BrowserContext.storageState
* since: v1.8
* langs: csharp, java
- returns: <[string]>
### option: BrowserContext.storageState.path = %%-storagestate-option-path-%%
* since: v1.8
## property: BrowserContext.tracing
* since: v1.12
- type: <[Tracing]>
## async method: BrowserContext.unroute
* since: v1.8
Removes a route created with [`method: BrowserContext.route`]. When [`param: handler`] is not specified, removes all
routes for the [`param: url`].
### param: BrowserContext.unroute.url
* since: v1.8
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>
A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with
[`method: BrowserContext.route`].
### param: BrowserContext.unroute.handler
* since: v1.8
* langs: js, python
- `handler` ?<[function]\([Route], [Request]\)>
Optional handler function used to register a routing with [`method: BrowserContext.route`].
### param: BrowserContext.unroute.handler
* since: v1.8
* langs: csharp, java
- `handler` ?<[function]\([Route]\)>
Optional handler function used to register a routing with [`method: BrowserContext.route`].
## async method: BrowserContext.waitForEvent
* since: v1.8
* langs: js, python
- alias-python: expect_event
- returns: <[any]>
@ -1259,11 +1328,13 @@ var page = await context.RunAndWaitForPageAsync(async () =>
```
### param: BrowserContext.waitForEvent.event
* since: v1.8
- `event` <[string]>
Event name, same one would pass into `browserContext.on(event)`.
### param: BrowserContext.waitForEvent.optionsOrPredicate
* since: v1.8
* langs: js
- `optionsOrPredicate` ?<[function]|[Object]>
- `predicate` <[function]> receives the event data and resolves to truthy value when the waiting should resolve.
@ -1273,6 +1344,7 @@ Event name, same one would pass into `browserContext.on(event)`.
Either a predicate that receives an event or an options object. Optional.
## async method: BrowserContext.waitForPage
* since: v1.9
* langs: java, python, csharp
- alias-python: expect_page
- alias-csharp: RunAndWaitForPage
@ -1283,14 +1355,17 @@ Performs action and waits for a new [Page] to be created in the context. If pred
Will throw an error if the context closes before new [Page] is created.
### option: BrowserContext.waitForPage.predicate =
* since: v1.9
* langs: csharp, java, python
- `predicate` <[function]\([Page]\):[boolean]>
Receives the [Page] object and resolves to truthy value when the waiting should resolve.
### option: BrowserContext.waitForPage.timeout = %%-wait-for-event-timeout-%%
* since: v1.9
## async method: BrowserContext.waitForEvent2
* since: v1.8
* langs: python
- alias-python: wait_for_event
- returns: <[any]>
@ -1304,5 +1379,8 @@ event's value into the `predicate` function and waits for `predicate(event)` to
Will throw an error if the browser context is closed before the `event` is fired.
### param: BrowserContext.waitForEvent2.event = %%-wait-for-event-event-%%
* since: v1.8
### option: BrowserContext.waitForEvent2.predicate = %%-wait-for-event-predicate-%%
* since: v1.8
### option: BrowserContext.waitForEvent2.timeout = %%-wait-for-event-timeout-%%
* since: v1.8

Просмотреть файл

@ -1,24 +1,30 @@
# class: BrowserServer
* since: v1.8
* langs: js
## event: BrowserServer.close
* since: v1.8
Emitted when the browser server closes.
## async method: BrowserServer.close
* since: v1.8
Closes the browser gracefully and makes sure the process is terminated.
## async method: BrowserServer.kill
* since: v1.8
Kills the browser process and waits for the process to exit.
## method: BrowserServer.process
* since: v1.8
- returns: <[ChildProcess]>
Spawned browser application process.
## method: BrowserServer.wsEndpoint
* since: v1.8
- returns: <[string]>
Browser websocket url.

Просмотреть файл

@ -1,4 +1,5 @@
# class: BrowserType
* since: v1.8
BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a
typical example of using Playwright to drive automation:
@ -85,39 +86,46 @@ class BrowserTypeExamples
```
## async method: BrowserType.connect
* since: v1.8
- returns: <[Browser]>
This method attaches Playwright to an existing browser instance.
### param: BrowserType.connect.wsEndpoint
* since: v1.10
- `wsEndpoint` <[string]>
A browser websocket endpoint to connect to.
### option: BrowserType.connect.headers
* since: v1.11
- `headers` <[Object]<[string], [string]>>
Additional HTTP headers to be sent with web socket connect request. Optional.
### option: BrowserType.connect.slowMo
* since: v1.10
- `slowMo` <[float]>
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you
can see what is going on. Defaults to 0.
### option: BrowserType.connect.logger
* since: v1.14
* langs: js
- `logger` <[Logger]>
Logger sink for Playwright logging. Optional.
### option: BrowserType.connect.timeout
* since: v1.10
- `timeout` <[float]>
Maximum time in milliseconds to wait for the connection to be established. Defaults to
`0` (no timeout).
## async method: BrowserType.connectOverCDP
* since: v1.9
- returns: <[Browser]>
This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
@ -129,45 +137,53 @@ Connecting over the Chrome DevTools Protocol is only supported for Chromium-base
:::
### param: BrowserType.connectOverCDP.endpointURL
* since: v1.11
- `endpointURL` <[string]>
A CDP websocket endpoint or http url to connect to. For example `http://localhost:9222/` or `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.
### option: BrowserType.connectOverCDP.endpointURL
* since: v1.14
* langs: js
- `endpointURL` <[string]>
Deprecated, use the first argument instead. Optional.
### option: BrowserType.connectOverCDP.headers
* since: v1.11
- `headers` <[Object]<[string], [string]>>
Additional HTTP headers to be sent with connect request. Optional.
### option: BrowserType.connectOverCDP.slowMo
* since: v1.11
- `slowMo` <[float]>
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you
can see what is going on. Defaults to 0.
### option: BrowserType.connectOverCDP.logger
* since: v1.14
* langs: js
- `logger` <[Logger]>
Logger sink for Playwright logging. Optional.
### option: BrowserType.connectOverCDP.timeout
* since: v1.11
- `timeout` <[float]>
Maximum time in milliseconds to wait for the connection to be established. Defaults to
`30000` (30 seconds). Pass `0` to disable timeout.
## method: BrowserType.executablePath
* since: v1.8
- returns: <[string]>
A path where Playwright expects to find a bundled browser executable.
## async method: BrowserType.launch
* since: v1.8
- returns: <[Browser]>
Returns the browser instance.
@ -216,16 +232,24 @@ option with extreme caution.
[This article](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md)
describes some differences for Linux users.
### option: BrowserType.launch.-inline- = %%-shared-browser-options-list-%%
### option: BrowserType.launch.-inline- = %%-shared-browser-options-list-v1.8-%%
* since: v1.8
### option: BrowserType.launch.firefoxUserPrefs = %%-js-python-browser-option-firefoxuserprefs-%%
* since: v1.8
### option: BrowserType.launch.firefoxUserPrefs2 = %%-csharp-java-browser-option-firefoxuserprefs-%%
* since: v1.8
### option: BrowserType.launch.logger = %%-browser-option-logger-%%
* since: v1.8
### option: BrowserType.launch.slowMo = %%-browser-option-slowmo-%%
* since: v1.8
### option: BrowserType.launch.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%%
* since: v1.8
### option: BrowserType.launch.ignoreAllDefaultArgs = %%-csharp-java-browser-option-ignorealldefaultargs-%%
* since: v1.9
## async method: BrowserType.launchPersistentContext
* since: v1.8
- returns: <[BrowserContext]>
Returns the persistent browser context instance.
@ -234,6 +258,7 @@ Launches browser that uses persistent storage located at [`param: userDataDir`]
this context will automatically close the browser.
### param: BrowserType.launchPersistentContext.userDataDir
* since: v1.8
- `userDataDir` <[path]>
Path to a User Data Directory, which stores browser session data like cookies and local storage. More details for
@ -242,13 +267,19 @@ Path to a User Data Directory, which stores browser session data like cookies an
Note that Chromium's user data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`. Pass an empty string to
use a temporary directory instead.
### option: BrowserType.launchPersistentContext.-inline- = %%-shared-browser-options-list-%%
### option: BrowserType.launchPersistentContext.-inline- = %%-shared-browser-options-list-v1.8-%%
* since: v1.8
### option: BrowserType.launchPersistentContext.slowMo = %%-browser-option-slowmo-%%
* since: v1.8
### option: BrowserType.launchPersistentContext.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%%
* since: v1.8
### option: BrowserType.launchPersistentContext.ignoreAllDefaultArgs = %%-csharp-java-browser-option-ignorealldefaultargs-%%
### option: BrowserType.launchPersistentContext.-inline- = %%-shared-context-params-list-%%
* since: v1.9
### option: BrowserType.launchPersistentContext.-inline- = %%-shared-context-params-list-v1.8-%%
* since: v1.8
## async method: BrowserType.launchServer
* since: v1.8
* langs: js
- returns: <[BrowserServer]>
@ -270,17 +301,23 @@ const { chromium } = require('playwright'); // Or 'webkit' or 'firefox'.
})();
```
### option: BrowserType.launchServer.-inline- = %%-shared-browser-options-list-%%
### option: BrowserType.launchServer.-inline- = %%-shared-browser-options-list-v1.8-%%
* since: v1.8
### option: BrowserType.launchServer.firefoxUserPrefs = %%-js-python-browser-option-firefoxuserprefs-%%
* since: v1.8
### option: BrowserType.launchServer.firefoxUserPrefs2 = %%-csharp-java-browser-option-firefoxuserprefs-%%
* since: v1.8
### option: BrowserType.launchServer.logger = %%-browser-option-logger-%%
* since: v1.8
### option: BrowserType.launchServer.port
* since: v1.8
- `port` <[int]>
Port to use for the web socket. Defaults to 0 that picks any available port.
### option: BrowserType.launchServer.wsPath
* since: v1.15
- `wsPath` <[string]>
Path at which to serve the Browser Server. For security, this defaults to an
@ -293,6 +330,7 @@ use an unguessable token when using this option.
:::
## method: BrowserType.name
* since: v1.8
- returns: <[string]>
Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`.

Просмотреть файл

@ -1,4 +1,5 @@
# class: CDPSession
* since: v1.8
* langs: js, python
* extends: [EventEmitter]
@ -46,19 +47,23 @@ client.send("Animation.setPlaybackRate", {
```
## async method: CDPSession.detach
* since: v1.8
Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to
send messages.
## async method: CDPSession.send
* since: v1.8
- returns: <[Object]>
### param: CDPSession.send.method
* since: v1.8
- `method` <[string]>
Protocol method name.
### param: CDPSession.send.params
* since: v1.8
- `params` ?<[Object]>
Optional method parameters.

Просмотреть файл

@ -1,4 +1,5 @@
# class: ConsoleMessage
* since: v1.8
[ConsoleMessage] objects are dispatched by page via the [`event: Page.console`] event.
For each console messages logged in the page there will be corresponding event in the Playwright
@ -106,11 +107,13 @@ await message.Args.ElementAt(1).JsonValueAsync<int>(); // 42
```
## method: ConsoleMessage.args
* since: v1.8
- returns: <[Array]<[JSHandle]>>
List of arguments passed to a `console` function call. See also [`event: Page.console`].
## method: ConsoleMessage.location
* since: v1.8
* langs: js, python
- returns: <[Object]>
- `url` <[string]> URL of the resource.
@ -118,17 +121,20 @@ List of arguments passed to a `console` function call. See also [`event: Page.co
- `columnNumber` <[int]> 0-based column number in the resource.
## method: ConsoleMessage.location
* since: v1.8
* langs: csharp, java
- returns: <[string]>
URL of the resource followed by 0-based line and column numbers in the resource formatted as `URL:line:column`.
## method: ConsoleMessage.text
* since: v1.8
- returns: <[string]>
The text of the console message.
## method: ConsoleMessage.type
* since: v1.8
- returns: <[string]>
One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,

Просмотреть файл

@ -1,4 +1,5 @@
# class: Coverage
* since: v1.11
* langs: js
Coverage gathers information about parts of JavaScript and CSS that were used by the page.
@ -30,15 +31,18 @@ const v8toIstanbul = require('v8-to-istanbul');
```
## async method: Coverage.startCSSCoverage
* since: v1.11
Returns coverage is started
### option: Coverage.startCSSCoverage.resetOnNavigation
* since: v1.11
- `resetOnNavigation` <[boolean]>
Whether to reset coverage on every navigation. Defaults to `true`.
## async method: Coverage.startJSCoverage
* since: v1.11
Returns coverage is started
@ -49,16 +53,19 @@ will have `__playwright_evaluation_script__` as their URL.
:::
### option: Coverage.startJSCoverage.resetOnNavigation
* since: v1.11
- `resetOnNavigation` <[boolean]>
Whether to reset coverage on every navigation. Defaults to `true`.
### option: Coverage.startJSCoverage.reportAnonymousScripts
* since: v1.11
- `reportAnonymousScripts` <[boolean]>
Whether anonymous scripts generated by the page should be reported. Defaults to `false`.
## async method: Coverage.stopCSSCoverage
* since: v1.11
- returns: <[Array]<[Object]>>
- `url` <[string]> StyleSheet URL
- `text` ?<[string]> StyleSheet content, if available.
@ -73,6 +80,7 @@ CSS Coverage doesn't include dynamically injected style tags without sourceURLs.
:::
## async method: Coverage.stopJSCoverage
* since: v1.11
- returns: <[Array]<[Object]>>
- `url` <[string]> Script URL
- `scriptId` <[string]> Script ID

Просмотреть файл

@ -1,4 +1,5 @@
# class: Dialog
* since: v1.8
[Dialog] objects are dispatched by page via the [`event: Page.dialog`] event.
@ -109,29 +110,35 @@ When listener is present, it **must** either [`method: Dialog.accept`] or [`meth
:::
## async method: Dialog.accept
* since: v1.8
Returns when the dialog has been accepted.
### param: Dialog.accept.promptText
* since: v1.8
- `promptText` ?<[string]>
A text to enter in prompt. Does not cause any effects if the dialog's `type` is not prompt. Optional.
## method: Dialog.defaultValue
* since: v1.8
- returns: <[string]>
If dialog is prompt, returns default prompt value. Otherwise, returns empty string.
## async method: Dialog.dismiss
* since: v1.8
Returns when the dialog has been dismissed.
## method: Dialog.message
* since: v1.8
- returns: <[string]>
A message displayed in the dialog.
## method: Dialog.type
* since: v1.8
- returns: <[string]>
Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prompt`.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Download
* since: v1.8
[Download] objects are dispatched by page via the [`event: Page.download`] event.
@ -61,31 +62,37 @@ Console.WriteLine(await download.PathAsync());
```
## async method: Download.cancel
* since: v1.13
Cancels a download. Will not fail if the download is already finished or canceled.
Upon successful cancellations, `download.failure()` would resolve to `'canceled'`.
## async method: Download.createReadStream
* since: v1.8
* langs: java, js, csharp
- returns: <[null]|[Readable]>
Returns readable stream for current download or `null` if download failed.
## async method: Download.delete
* since: v1.8
Deletes the downloaded file. Will wait for the download to finish if necessary.
## async method: Download.failure
* since: v1.8
- returns: <[null]|[string]>
Returns download error if any. Will wait for the download to finish if necessary.
## method: Download.page
* since: v1.12
- returns: <[Page]>
Get the page that the download belongs to.
## async method: Download.path
* since: v1.8
- returns: <[null]|[path]>
Returns path to the downloaded file in case of successful download. The method will
@ -95,16 +102,19 @@ Note that the download's file name is a random GUID, use [`method: Download.sugg
to get suggested file name.
## async method: Download.saveAs
* since: v1.8
Copy the download to a user-specified path. It is safe to call this method while the download
is still in progress. Will wait for the download to finish if necessary.
### param: Download.saveAs.path
* since: v1.8
- `path` <[path]>
Path where the download should be copied.
## method: Download.suggestedFilename
* since: v1.8
- returns: <[string]>
Returns suggested filename for this download. It is typically computed by the browser from the
@ -113,6 +123,7 @@ or the `download` attribute. See the spec on [whatwg](https://html.spec.whatwg.o
browsers can use different logic for computing it.
## method: Download.url
* since: v1.8
- returns: <[string]>
Returns downloaded url.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Electron
* since: v1.9
* langs: js
Playwright has **experimental** support for Electron automation. You can access electron namespace via:
@ -51,50 +52,72 @@ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
* v14+
## async method: Electron.launch
* since: v1.9
- returns: <[ElectronApplication]>
Launches electron application specified with the [`option: executablePath`].
### option: Electron.launch.executablePath
* since: v1.9
- `executablePath` <[string]>
Launches given Electron application. If not specified, launches the default Electron
executable installed in this package, located at `node_modules/.bin/electron`.
### option: Electron.launch.args
* since: v1.9
- `args` <[Array]<[string]>>
Additional arguments to pass to the application when launching. You typically pass the main
script name here.
### option: Electron.launch.cwd
* since: v1.9
- `cwd` <[string]>
Current working directory to launch application from.
### option: Electron.launch.env
* since: v1.9
- `env` <[Object]<[string], [string]>>
Specifies environment variables that will be visible to Electron. Defaults to `process.env`.
### option: Electron.launch.timeout
* since: v1.15
- `timeout` <[float]>
Maximum time in milliseconds to wait for the application to start. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
### option: Electron.launch.acceptdownloads = %%-context-option-acceptdownloads-%%
* since: v1.12
### option: Electron.launch.bypassCSP = %%-context-option-bypasscsp-%%
* since: v1.12
### option: Electron.launch.colorScheme = %%-context-option-colorscheme-%%
* since: v1.12
### option: Electron.launch.extraHTTPHeaders = %%-context-option-extrahttpheaders-%%
* since: v1.12
### option: Electron.launch.geolocation = %%-context-option-geolocation-%%
* since: v1.12
### option: Electron.launch.httpcredentials = %%-context-option-httpcredentials-%%
* since: v1.12
### option: Electron.launch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
* since: v1.12
### option: Electron.launch.locale = %%-context-option-locale-%%
* since: v1.12
### option: Electron.launch.offline = %%-context-option-offline-%%
* since: v1.12
### option: Electron.launch.recordhar = %%-context-option-recordhar-%%
* since: v1.12
### option: Electron.launch.recordharpath = %%-context-option-recordhar-path-%%
* since: v1.12
### option: Electron.launch.recordHarOmitContent = %%-context-option-recordhar-omit-content-%%
* since: v1.12
### option: Electron.launch.recordvideo = %%-context-option-recordvideo-%%
* since: v1.12
### option: Electron.launch.recordvideodir = %%-context-option-recordvideo-dir-%%
* since: v1.12
### option: Electron.launch.recordvideosize = %%-context-option-recordvideo-size-%%
* since: v1.12
### option: Electron.launch.timezoneId = %%-context-option-timezoneid-%%
* since: v1.12

Просмотреть файл

@ -1,4 +1,5 @@
# class: ElectronApplication
* since: v1.9
* langs: js
Electron application representation. You can use [`method: Electron.launch`] to
@ -36,35 +37,42 @@ const { _electron: electron } = require('playwright');
```
## event: ElectronApplication.close
* since: v1.9
This event is issued when the application closes.
## event: ElectronApplication.window
* since: v1.9
- argument: <[Page]>
This event is issued for every window that is created **and loaded** in Electron. It contains a [Page] that can
be used for Playwright automation.
## async method: ElectronApplication.browserWindow
* since: v1.11
- returns: <[JSHandle]>
Returns the BrowserWindow object that corresponds to the given Playwright page.
### param: ElectronApplication.browserWindow.page
* since: v1.11
- `page` <[Page]>
Page to retrieve the window for.
## async method: ElectronApplication.close
* since: v1.9
Closes Electron application.
## method: ElectronApplication.context
* since: v1.9
- returns: <[BrowserContext]>
This method returns browser context that can be used for setting up context-wide routing, etc.
## async method: ElectronApplication.evaluate
* since: v1.9
- returns: <[Serializable]>
Returns the return value of [`param: expression`].
@ -77,13 +85,16 @@ If the function passed to the [`method: ElectronApplication.evaluate`] returns a
some additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
### param: ElectronApplication.evaluate.expression = %%-evaluate-expression-%%
* since: v1.9
### param: ElectronApplication.evaluate.arg
* since: v1.9
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: ElectronApplication.evaluateHandle
* since: v1.9
- returns: <[JSHandle]>
Returns the return value of [`param: expression`] as a [JSHandle].
@ -94,13 +105,16 @@ If the function passed to the [`method: ElectronApplication.evaluateHandle`] ret
[`method: ElectronApplication.evaluateHandle`] would wait for the promise to resolve and return its value.
### param: ElectronApplication.evaluateHandle.expression = %%-evaluate-expression-%%
* since: v1.9
### param: ElectronApplication.evaluateHandle.arg
* since: v1.9
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: ElectronApplication.firstWindow
* since: v1.9
- returns: <[Page]>
Convenience method that waits for the first application window to be opened.
@ -115,11 +129,13 @@ Typically your script will start with:
```
## method: ElectronApplication.process
* since: v1.21
- returns: <[ChildProcess]>
Returns the main process for this Electron Application.
## async method: ElectronApplication.waitForEvent
* since: v1.9
- returns: <[any]>
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the application is closed before the event is fired. Returns the event data value.
@ -132,8 +148,10 @@ const [window] = await Promise.all([
```
### param: ElectronApplication.waitForEvent.event = %%-wait-for-event-event-%%
* since: v1.9
### param: ElectronApplication.waitForEvent.optionsOrPredicate
* since: v1.9
* langs: js
- `optionsOrPredicate` ?<[function]|[Object]>
- `predicate` <[function]> receives the event data and resolves to truthy value when the waiting should resolve.
@ -143,6 +161,7 @@ const [window] = await Promise.all([
Either a predicate that receives an event or an options object. Optional.
## method: ElectronApplication.windows
* since: v1.9
- returns: <[Array]<[Page]>>
Convenience method that returns all the opened windows.

Просмотреть файл

@ -1,4 +1,5 @@
# class: ElementHandle
* since: v1.8
* extends: [JSHandle]
ElementHandle represents an in-page DOM element. ElementHandles can be created with the [`method: Page.querySelector`] method.
@ -106,6 +107,7 @@ await locator.ClickAsync();
```
## async method: ElementHandle.boundingBox
* since: v1.8
- returns: <[null]|[Object]>
- `x` <[float]> the x coordinate of the element in pixels.
- `y` <[float]> the y coordinate of the element in pixels.
@ -151,6 +153,7 @@ await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2);
```
## async method: ElementHandle.check
* since: v1.8
This method checks the element by performing the following steps:
1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
@ -167,16 +170,22 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### option: ElementHandle.check.position = %%-input-position-%%
* since: v1.11
### option: ElementHandle.check.force = %%-input-force-%%
* since: v1.8
### option: ElementHandle.check.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.check.timeout = %%-input-timeout-%%
* since: v1.8
### option: ElementHandle.check.trial = %%-input-trial-%%
* since: v1.11
## async method: ElementHandle.click
* since: v1.8
This method clicks the element by performing the following steps:
1. Wait for [actionability](../actionability.md) checks on the element, unless [`option: force`] option is set.
@ -190,29 +199,40 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### option: ElementHandle.click.button = %%-input-button-%%
* since: v1.8
### option: ElementHandle.click.clickCount = %%-input-click-count-%%
* since: v1.8
### option: ElementHandle.click.delay = %%-input-down-up-delay-%%
* since: v1.8
### option: ElementHandle.click.position = %%-input-position-%%
* since: v1.8
### option: ElementHandle.click.modifiers = %%-input-modifiers-%%
* since: v1.8
### option: ElementHandle.click.force = %%-input-force-%%
* since: v1.8
### option: ElementHandle.click.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.click.timeout = %%-input-timeout-%%
* since: v1.8
### option: ElementHandle.click.trial = %%-input-trial-%%
* since: v1.11
## async method: ElementHandle.contentFrame
* since: v1.8
- returns: <[null]|[Frame]>
Returns the content frame for element handles referencing iframe nodes, or `null` otherwise
## async method: ElementHandle.dblclick
* since: v1.8
* langs:
- alias-csharp: DblClickAsync
@ -233,22 +253,31 @@ When all steps combined have not finished during the specified [`option: timeout
:::
### option: ElementHandle.dblclick.button = %%-input-button-%%
* since: v1.8
### option: ElementHandle.dblclick.delay = %%-input-down-up-delay-%%
* since: v1.8
### option: ElementHandle.dblclick.position = %%-input-position-%%
* since: v1.8
### option: ElementHandle.dblclick.modifiers = %%-input-modifiers-%%
* since: v1.8
### option: ElementHandle.dblclick.force = %%-input-force-%%
* since: v1.8
### option: ElementHandle.dblclick.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.dblclick.timeout = %%-input-timeout-%%
* since: v1.8
### option: ElementHandle.dblclick.trial = %%-input-trial-%%
* since: v1.11
## async method: ElementHandle.dispatchEvent
* since: v1.8
The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
is dispatched. This is equivalent to calling
@ -325,16 +354,19 @@ await elementHandle.DispatchEventAsync("dragstart", new Dictionary<string, objec
```
### param: ElementHandle.dispatchEvent.type
* since: v1.8
- `type` <[string]>
DOM event type: `"click"`, `"dragstart"`, etc.
### param: ElementHandle.dispatchEvent.eventInit
* since: v1.8
- `eventInit` ?<[EvaluationArgument]>
Optional event-specific initialization properties.
## async method: ElementHandle.evalOnSelector
* since: v1.9
* langs:
- alias-python: eval_on_selector
- alias-js: $eval
@ -382,15 +414,19 @@ Assert.AreEqual("10", await tweetHandle.EvalOnSelectorAsync(".retweets", "node =
```
### param: ElementHandle.evalOnSelector.selector = %%-query-selector-%%
* since: v1.9
### param: ElementHandle.evalOnSelector.expression = %%-evaluate-expression-%%
* since: v1.9
### param: ElementHandle.evalOnSelector.arg
* since: v1.9
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: ElementHandle.evalOnSelectorAll
* since: v1.9
* langs:
- alias-python: eval_on_selector_all
- alias-js: $$eval
@ -440,15 +476,19 @@ Assert.AreEqual(new [] { "Hello!", "Hi!" }, await feedHandle.EvalOnSelectorAllAs
```
### param: ElementHandle.evalOnSelectorAll.selector = %%-query-selector-%%
* since: v1.9
### param: ElementHandle.evalOnSelectorAll.expression = %%-evaluate-expression-%%
* since: v1.9
### param: ElementHandle.evalOnSelectorAll.arg
* since: v1.9
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: ElementHandle.fill
* since: v1.8
This method waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
@ -457,29 +497,37 @@ If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` e
To send fine-grained keyboard events, use [`method: ElementHandle.type`].
### param: ElementHandle.fill.value
* since: v1.8
- `value` <[string]>
Value to set for the `<input>`, `<textarea>` or `[contenteditable]` element.
### option: ElementHandle.fill.force = %%-input-force-%%
* since: v1.13
### option: ElementHandle.fill.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.fill.timeout = %%-input-timeout-%%
* since: v1.8
## async method: ElementHandle.focus
* since: v1.8
Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
## async method: ElementHandle.getAttribute
* since: v1.8
- returns: <[null]|[string]>
Returns element attribute value.
### param: ElementHandle.getAttribute.name
* since: v1.8
- `name` <[string]>
Attribute name to get the value for.
## async method: ElementHandle.hover
* since: v1.8
This method hovers over the element by performing the following steps:
1. Wait for [actionability](../actionability.md) checks on the element, unless [`option: force`] option is set.
@ -493,26 +541,34 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### option: ElementHandle.hover.position = %%-input-position-%%
* since: v1.8
### option: ElementHandle.hover.modifiers = %%-input-modifiers-%%
* since: v1.8
### option: ElementHandle.hover.force = %%-input-force-%%
* since: v1.8
### option: ElementHandle.hover.timeout = %%-input-timeout-%%
* since: v1.8
### option: ElementHandle.hover.trial = %%-input-trial-%%
* since: v1.11
## async method: ElementHandle.innerHTML
* since: v1.8
- returns: <[string]>
Returns the `element.innerHTML`.
## async method: ElementHandle.innerText
* since: v1.8
- returns: <[string]>
Returns the `element.innerText`.
## async method: ElementHandle.inputValue
* since: v1.13
- returns: <[string]>
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
@ -520,43 +576,52 @@ Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` e
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
### option: ElementHandle.inputValue.timeout = %%-input-timeout-%%
* since: v1.13
## async method: ElementHandle.isChecked
* since: v1.8
- returns: <[boolean]>
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
## async method: ElementHandle.isDisabled
* since: v1.8
- returns: <[boolean]>
Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
## async method: ElementHandle.isEditable
* since: v1.8
- returns: <[boolean]>
Returns whether the element is [editable](../actionability.md#editable).
## async method: ElementHandle.isEnabled
* since: v1.8
- returns: <[boolean]>
Returns whether the element is [enabled](../actionability.md#enabled).
## async method: ElementHandle.isHidden
* since: v1.8
- returns: <[boolean]>
Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible).
## async method: ElementHandle.isVisible
* since: v1.8
- returns: <[boolean]>
Returns whether the element is [visible](../actionability.md#visible).
## async method: ElementHandle.ownerFrame
* since: v1.8
- returns: <[null]|[Frame]>
Returns the frame containing the given element.
## async method: ElementHandle.press
* since: v1.8
Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
@ -579,20 +644,25 @@ Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported a
modifier, modifier is pressed and being held while the subsequent key is being pressed.
### param: ElementHandle.press.key
* since: v1.8
- `key` <[string]>
Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
### option: ElementHandle.press.delay
* since: v1.8
- `delay` <[float]>
Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
### option: ElementHandle.press.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.press.timeout = %%-input-timeout-%%
* since: v1.8
## async method: ElementHandle.querySelector
* since: v1.9
* langs:
- alias-python: query_selector
- alias-js: $
@ -603,8 +673,10 @@ The method finds an element matching the specified selector in the `ElementHandl
returns `null`.
### param: ElementHandle.querySelector.selector = %%-query-selector-%%
* since: v1.9
## async method: ElementHandle.querySelectorAll
* since: v1.9
* langs:
- alias-python: query_selector_all
- alias-js: $$
@ -615,8 +687,10 @@ The method finds all elements matching the specified selector in the `ElementHan
returns empty array.
### param: ElementHandle.querySelectorAll.selector = %%-query-selector-%%
* since: v1.9
## async method: ElementHandle.screenshot
* since: v1.8
- returns: <[Buffer]>
This method captures a screenshot of the page, clipped to the size and position of this particular element. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable container, only the currently scrolled content will be visible on the screenshot.
@ -626,9 +700,11 @@ screenshot. If the element is detached from DOM, the method throws an error.
Returns the buffer with the captured screenshot.
### option: ElementHandle.screenshot.-inline- = %%-screenshot-options-common-list-%%
### option: ElementHandle.screenshot.-inline- = %%-screenshot-options-common-list-v1.8-%%
* since: v1.8
## async method: ElementHandle.scrollIntoViewIfNeeded
* since: v1.8
This method waits for [actionability](../actionability.md) checks, then tries to scroll element into view, unless it is
completely visible as defined by
@ -638,8 +714,10 @@ Throws when `elementHandle` does not point to an element
[connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
### option: ElementHandle.scrollIntoViewIfNeeded.timeout = %%-input-timeout-%%
* since: v1.8
## async method: ElementHandle.selectOption
* since: v1.8
- returns: <[Array]<[string]>>
This method waits for [actionability](../actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
@ -703,11 +781,16 @@ await handle.SelectOptionAsync(new[] {
```
### param: ElementHandle.selectOption.values = %%-select-options-values-%%
* since: v1.8
### option: ElementHandle.selectOption.force = %%-input-force-%%
* since: v1.13
### option: ElementHandle.selectOption.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.selectOption.timeout = %%-input-timeout-%%
* since: v1.8
## async method: ElementHandle.selectText
* since: v1.8
This method waits for [actionability](../actionability.md) checks, then focuses the element and selects all its text
content.
@ -715,9 +798,12 @@ content.
If the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the control instead.
### option: ElementHandle.selectText.force = %%-input-force-%%
* since: v1.13
### option: ElementHandle.selectText.timeout = %%-input-timeout-%%
* since: v1.8
## async method: ElementHandle.setChecked
* since: v1.15
This method checks or unchecks an element by performing the following steps:
1. Ensure that element is a checkbox or a radio input. If not, this method throws.
@ -733,13 +819,20 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### param: ElementHandle.setChecked.checked = %%-input-checked-%%
* since: v1.15
### option: ElementHandle.setChecked.force = %%-input-force-%%
* since: v1.15
### option: ElementHandle.setChecked.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.15
### option: ElementHandle.setChecked.position = %%-input-position-%%
* since: v1.15
### option: ElementHandle.setChecked.timeout = %%-input-timeout-%%
* since: v1.15
### option: ElementHandle.setChecked.trial = %%-input-trial-%%
* since: v1.15
## async method: ElementHandle.setInputFiles
* since: v1.8
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
are resolved relative to the current working directory. For empty array, clears the selected files.
@ -749,12 +842,16 @@ This method expects [ElementHandle] to point to an
### param: ElementHandle.setInputFiles.files = %%-input-files-%%
* since: v1.8
### option: ElementHandle.setInputFiles.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.setInputFiles.timeout = %%-input-timeout-%%
* since: v1.8
## async method: ElementHandle.tap
* since: v1.8
This method taps the element by performing the following steps:
1. Wait for [actionability](../actionability.md) checks on the element, unless [`option: force`] option is set.
@ -772,23 +869,31 @@ When all steps combined have not finished during the specified [`option: timeout
:::
### option: ElementHandle.tap.position = %%-input-position-%%
* since: v1.8
### option: ElementHandle.tap.modifiers = %%-input-modifiers-%%
* since: v1.8
### option: ElementHandle.tap.force = %%-input-force-%%
* since: v1.8
### option: ElementHandle.tap.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.tap.timeout = %%-input-timeout-%%
* since: v1.8
### option: ElementHandle.tap.trial = %%-input-trial-%%
* since: v1.11
## async method: ElementHandle.textContent
* since: v1.8
- returns: <[null]|[string]>
Returns the `node.textContent`.
## async method: ElementHandle.type
* since: v1.8
Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
@ -852,20 +957,25 @@ await elementHandle.PressAsync("Enter");
```
### param: ElementHandle.type.text
* since: v1.8
- `text` <[string]>
A text to type into a focused element.
### option: ElementHandle.type.delay
* since: v1.8
- `delay` <[float]>
Time to wait between key presses in milliseconds. Defaults to 0.
### option: ElementHandle.type.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.type.timeout = %%-input-timeout-%%
* since: v1.8
## async method: ElementHandle.uncheck
* since: v1.8
This method checks the element by performing the following steps:
1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
@ -882,16 +992,22 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### option: ElementHandle.uncheck.position = %%-input-position-%%
* since: v1.11
### option: ElementHandle.uncheck.force = %%-input-force-%%
* since: v1.8
### option: ElementHandle.uncheck.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: ElementHandle.uncheck.timeout = %%-input-timeout-%%
* since: v1.8
### option: ElementHandle.uncheck.trial = %%-input-trial-%%
* since: v1.11
## async method: ElementHandle.waitForElementState
* since: v1.8
Returns when the element satisfies the [`param: state`].
@ -909,13 +1025,16 @@ to pass. This method throws when the element is detached while waiting, unless w
If the element does not satisfy the condition for the [`option: timeout`] milliseconds, this method will throw.
### param: ElementHandle.waitForElementState.state
* since: v1.8
- `state` <[ElementState]<"visible"|"hidden"|"stable"|"enabled"|"disabled"|"editable">>
A state to wait for, see below for more details.
### option: ElementHandle.waitForElementState.timeout = %%-input-timeout-%%
* since: v1.8
## async method: ElementHandle.waitForSelector
* since: v1.8
- returns: <[null]|[ElementHandle]>
Returns element specified by selector when it satisfies [`option: state`] option. Returns `null` if waiting for `hidden`
@ -967,9 +1086,13 @@ This method does not work across navigations, use [`method: Page.waitForSelector
:::
### param: ElementHandle.waitForSelector.selector = %%-query-selector-%%
* since: v1.8
### option: ElementHandle.waitForSelector.state = %%-wait-for-selector-state-%%
* since: v1.8
### option: ElementHandle.waitForSelector.timeout = %%-input-timeout-%%
* since: v1.8
### option: ElementHandle.waitForSelector.strict = %%-input-strict-%%
* since: v1.15

Просмотреть файл

@ -1,4 +1,5 @@
# class: Error
* since: v1.11
* langs: python
* extends: [Exception]
@ -11,16 +12,19 @@ inherit from this class.
- [error.stack](./class-error.md#errorstack)
## property: Error.message
* since: v1.11
- returns: <[str]>
Message of the error.
## property: Error.name
* since: v1.11
- returns: ?<[str]>
Name of the error which got thrown inside the browser. Optional.
## property: Error.stack
* since: v1.11
- returns: ?<[str]>
Stack of the error which got thrown inside the browser. Optional.

Просмотреть файл

@ -1,4 +1,5 @@
# class: FileChooser
* since: v1.8
[FileChooser] objects are dispatched by the page in the [`event: Page.fileChooser`] event.
@ -42,27 +43,34 @@ await fileChooser.SetFilesAsync("temp.txt");
```
## method: FileChooser.element
* since: v1.8
- returns: <[ElementHandle]>
Returns input element associated with this file chooser.
## method: FileChooser.isMultiple
* since: v1.8
- returns: <[boolean]>
Returns whether this file chooser accepts multiple files.
## method: FileChooser.page
* since: v1.8
- returns: <[Page]>
Returns page this file chooser belongs to.
## async method: FileChooser.setFiles
* since: v1.8
Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then
they are resolved relative to the current working directory. For empty array, clears the selected files.
### param: FileChooser.setFiles.files = %%-input-files-%%
* since: v1.8
### option: FileChooser.setFiles.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: FileChooser.setFiles.timeout = %%-input-timeout-%%
* since: v1.8

Просмотреть файл

@ -1,4 +1,5 @@
# class: FormData
* since: v1.18
* langs: java, csharp
The [FormData] is used create form data that is sent via [APIRequestContext].
@ -14,22 +15,26 @@ page.request().post("http://localhost/submit", RequestOptions.create().setForm(f
```
## method: FormData.create
* since: v1.18
* langs: java
- returns: <[FormData]>
Creates new instance of [FormData].
## method: FormData.set
* since: v1.18
- returns: <[FormData]>
Sets a field on the form. File values can be passed either as `Path` or as `FilePayload`.
### param: FormData.set.name
* since: v1.18
- `name` <[string]>
Field name.
### param: FormData.set.value
* since: v1.18
- `value` <[string]|[boolean]|[int]|[Path]|[Object]>
- `name` <[string]> File name
- `mimeType` <[string]> File type
@ -38,6 +43,7 @@ Field name.
Field value.
### param: FormData.set.value
* since: v1.18
* langs: csharp
- `value` <[string]|[boolean]|[int]|[Object]>
- `name` <[string]> File name

Просмотреть файл

@ -1,4 +1,5 @@
# class: Frame
* since: v1.8
At every point of time, page exposes its current frame tree via the [`method: Page.mainFrame`] and
[`method: Frame.childFrames`] methods.
@ -124,6 +125,7 @@ class FrameExamples
```
## async method: Frame.addScriptTag
* since: v1.8
- returns: <[ElementHandle]>
Returns the added tag when the script's onload fires or when the script content was injected into frame.
@ -131,28 +133,33 @@ Returns the added tag when the script's onload fires or when the script content
Adds a `<script>` tag into the page with the desired url or content.
### option: Frame.addScriptTag.url
* since: v1.8
- `url` <[string]>
URL of a script to be added.
### option: Frame.addScriptTag.path
* since: v1.8
- `path` <[path]>
Path to the JavaScript file to be injected into frame. If `path` is a relative path, then it is resolved relative to the
current working directory.
### option: Frame.addScriptTag.content
* since: v1.8
- `content` <[string]>
Raw JavaScript content to be injected into frame.
### option: Frame.addScriptTag.type
* since: v1.8
- `type` <[string]>
Script type. Use 'module' in order to load a Javascript ES6 module. See
[script](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) for more details.
## async method: Frame.addStyleTag
* since: v1.8
- returns: <[ElementHandle]>
Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
@ -161,22 +168,26 @@ Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<s
content.
### option: Frame.addStyleTag.url
* since: v1.8
- `url` <[string]>
URL of the `<link>` tag.
### option: Frame.addStyleTag.path
* since: v1.8
- `path` <[path]>
Path to the CSS file to be injected into frame. If `path` is a relative path, then it is resolved relative to the
current working directory.
### option: Frame.addStyleTag.content
* since: v1.8
- `content` <[string]>
Raw CSS content to be injected into frame.
## async method: Frame.check
* since: v1.8
This method checks an element matching [`param: selector`] by performing the following steps:
1. Find an element matching [`param: selector`]. If there is none, wait until a matching element is attached to
@ -194,18 +205,27 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### param: Frame.check.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.check.force = %%-input-force-%%
* since: v1.8
### option: Frame.check.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.check.position = %%-input-position-%%
* since: v1.11
### option: Frame.check.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.check.timeout = %%-input-timeout-%%
* since: v1.8
### option: Frame.check.trial = %%-input-trial-%%
* since: v1.11
## method: Frame.childFrames
* since: v1.8
- returns: <[Array]<[Frame]>>
## async method: Frame.click
* since: v1.8
This method clicks an element matching [`param: selector`] by performing the following steps:
1. Find an element matching [`param: selector`]. If there is none, wait until a matching element is attached to
@ -220,24 +240,37 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### param: Frame.click.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.click.button = %%-input-button-%%
* since: v1.8
### option: Frame.click.clickCount = %%-input-click-count-%%
* since: v1.8
### option: Frame.click.delay = %%-input-down-up-delay-%%
* since: v1.8
### option: Frame.click.force = %%-input-force-%%
* since: v1.8
### option: Frame.click.modifiers = %%-input-modifiers-%%
* since: v1.8
### option: Frame.click.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.click.position = %%-input-position-%%
* since: v1.8
### option: Frame.click.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.click.timeout = %%-input-timeout-%%
* since: v1.8
### option: Frame.click.trial = %%-input-trial-%%
* since: v1.11
## async method: Frame.content
* since: v1.8
- returns: <[string]>
Gets the full HTML contents of the frame, including the doctype.
## async method: Frame.dblclick
* since: v1.8
* langs:
- alias-csharp: DblClickAsync
@ -259,18 +292,29 @@ When all steps combined have not finished during the specified [`option: timeout
:::
### param: Frame.dblclick.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.dblclick.button = %%-input-button-%%
* since: v1.8
### option: Frame.dblclick.force = %%-input-force-%%
* since: v1.8
### option: Frame.dblclick.delay = %%-input-down-up-delay-%%
* since: v1.8
### option: Frame.dblclick.modifiers = %%-input-modifiers-%%
* since: v1.8
### option: Frame.dblclick.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.dblclick.position = %%-input-position-%%
* since: v1.8
### option: Frame.dblclick.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.dblclick.timeout = %%-input-timeout-%%
* since: v1.8
### option: Frame.dblclick.trial = %%-input-trial-%%
* since: v1.11
## async method: Frame.dispatchEvent
* since: v1.8
The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
is dispatched. This is equivalent to calling
@ -345,37 +389,53 @@ await frame.DispatchEventAsync("#source", "dragstart", new { dataTransfer });
```
### param: Frame.dispatchEvent.selector = %%-input-selector-%%
* since: v1.8
### param: Frame.dispatchEvent.type
* since: v1.8
- `type` <[string]>
DOM event type: `"click"`, `"dragstart"`, etc.
### param: Frame.dispatchEvent.eventInit
* since: v1.8
- `eventInit` ?<[EvaluationArgument]>
Optional event-specific initialization properties.
### option: Frame.dispatchEvent.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.dispatchEvent.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.dragAndDrop
* since: v1.13
### param: Frame.dragAndDrop.source = %%-input-source-%%
* since: v1.13
### param: Frame.dragAndDrop.target = %%-input-target-%%
* since: v1.13
### option: Frame.dragAndDrop.force = %%-input-force-%%
* since: v1.13
### option: Frame.dragAndDrop.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.13
### option: Frame.dragAndDrop.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.dragAndDrop.timeout = %%-input-timeout-%%
* since: v1.13
### option: Frame.dragAndDrop.trial = %%-input-trial-%%
* since: v1.13
### option: Frame.dragAndDrop.sourcePosition = %%-input-source-position-%%
* since: v1.14
### option: Frame.dragAndDrop.targetPosition = %%-input-target-position-%%
* since: v1.14
## async method: Frame.evalOnSelector
* since: v1.9
* langs:
- alias-python: eval_on_selector
- alias-js: $eval
@ -428,15 +488,20 @@ var html = await frame.EvalOnSelectorAsync(".main-container", "(e, suffix) => e.
```
### param: Frame.evalOnSelector.selector = %%-query-selector-%%
* since: v1.9
### param: Frame.evalOnSelector.expression = %%-evaluate-expression-%%
* since: v1.9
### param: Frame.evalOnSelector.arg
* since: v1.9
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
### option: Frame.evalOnSelector.strict = %%-input-strict-%%
* since: v1.14
## async method: Frame.evalOnSelectorAll
* since: v1.9
* langs:
- alias-python: eval_on_selector_all
- alias-js: $$eval
@ -478,14 +543,18 @@ var divsCount = await frame.EvalOnSelectorAllAsync<bool>("div", "(divs, min) =>
```
### param: Frame.evalOnSelectorAll.selector = %%-query-selector-%%
* since: v1.9
### param: Frame.evalOnSelectorAll.expression = %%-evaluate-expression-%%
* since: v1.9
### param: Frame.evalOnSelectorAll.arg
* since: v1.9
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: Frame.evaluate
* since: v1.8
- returns: <[Serializable]>
Returns the return value of [`param: expression`].
@ -585,13 +654,16 @@ await bodyHandle.DisposeAsync();
```
### param: Frame.evaluate.expression = %%-evaluate-expression-%%
* since: v1.8
### param: Frame.evaluate.arg
* since: v1.8
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: Frame.evaluateHandle
* since: v1.8
- returns: <[JSHandle]>
Returns the return value of [`param: expression`] as a [JSHandle].
@ -687,13 +759,16 @@ await resultHandle.DisposeAsync();
```
### param: Frame.evaluateHandle.expression = %%-evaluate-expression-%%
* since: v1.8
### param: Frame.evaluateHandle.arg
* since: v1.8
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: Frame.fill
* since: v1.8
This method waits for an element matching [`param: selector`], waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
@ -702,28 +777,39 @@ If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` e
To send fine-grained keyboard events, use [`method: Frame.type`].
### param: Frame.fill.selector = %%-input-selector-%%
* since: v1.8
### param: Frame.fill.value
* since: v1.8
- `value` <[string]>
Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
### option: Frame.fill.force = %%-input-force-%%
* since: v1.13
### option: Frame.fill.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.fill.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.fill.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.focus
* since: v1.8
This method fetches an element with [`param: selector`] and focuses it. If there's no element matching
[`param: selector`], the method waits until a matching element appears in the DOM.
### param: Frame.focus.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.focus.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.focus.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.frameElement
* since: v1.8
- returns: <[ElementHandle]>
Returns the `frame` or `iframe` element handle which corresponds to this frame.
@ -765,6 +851,7 @@ Console.WriteLine(frame == contentFrame); // -> True
## method: Frame.frameLocator
* since: v1.17
- returns: <[FrameLocator]>
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
@ -797,24 +884,31 @@ await locator.ClickAsync();
```
### param: Frame.frameLocator.selector = %%-find-selector-%%
* since: v1.17
## async method: Frame.getAttribute
* since: v1.8
- returns: <[null]|[string]>
Returns element attribute value.
### param: Frame.getAttribute.selector = %%-input-selector-%%
* since: v1.8
### param: Frame.getAttribute.name
* since: v1.8
- `name` <[string]>
Attribute name to get the value for.
### option: Frame.getAttribute.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.getAttribute.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.goto
* since: v1.8
* langs:
- alias-java: navigate
- returns: <[null]|[Response]>
@ -844,21 +938,26 @@ Headless mode doesn't support navigation to a PDF document. See the
:::
### param: Frame.goto.url
* since: v1.8
- `url` <[string]>
URL to navigate frame to. The url should include scheme, e.g. `https://`.
### option: Frame.goto.waitUntil = %%-navigation-wait-until-%%
* since: v1.8
### option: Frame.goto.timeout = %%-navigation-timeout-%%
* since: v1.8
### option: Frame.goto.referer
* since: v1.8
- `referer` <[string]>
Referer header value. If provided it will take preference over the referer header value set by
[`method: Page.setExtraHTTPHeaders`].
## async method: Frame.hover
* since: v1.8
This method hovers over an element matching [`param: selector`] by performing the following steps:
1. Find an element matching [`param: selector`]. If there is none, wait until a matching element is attached to
@ -873,35 +972,51 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### param: Frame.hover.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.hover.position = %%-input-position-%%
* since: v1.8
### option: Frame.hover.modifiers = %%-input-modifiers-%%
* since: v1.8
### option: Frame.hover.force = %%-input-force-%%
* since: v1.8
### option: Frame.hover.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.hover.timeout = %%-input-timeout-%%
* since: v1.8
### option: Frame.hover.trial = %%-input-trial-%%
* since: v1.11
## async method: Frame.innerHTML
* since: v1.8
- returns: <[string]>
Returns `element.innerHTML`.
### param: Frame.innerHTML.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.innerHTML.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.innerHTML.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.innerText
* since: v1.8
- returns: <[string]>
Returns `element.innerText`.
### param: Frame.innerText.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.innerText.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.innerText.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.inputValue
* since: v1.13
- returns: <[string]>
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
@ -909,82 +1024,111 @@ Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` e
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
### param: Frame.inputValue.selector = %%-input-selector-%%
* since: v1.13
### option: Frame.inputValue.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.inputValue.timeout = %%-input-timeout-%%
* since: v1.13
## async method: Frame.isChecked
* since: v1.8
- returns: <[boolean]>
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
### param: Frame.isChecked.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.isChecked.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.isChecked.timeout = %%-input-timeout-%%
* since: v1.8
## method: Frame.isDetached
* since: v1.8
- returns: <[boolean]>
Returns `true` if the frame has been detached, or `false` otherwise.
## async method: Frame.isDisabled
* since: v1.8
- returns: <[boolean]>
Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
### param: Frame.isDisabled.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.isDisabled.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.isDisabled.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.isEditable
* since: v1.8
- returns: <[boolean]>
Returns whether the element is [editable](../actionability.md#editable).
### param: Frame.isEditable.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.isEditable.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.isEditable.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.isEnabled
* since: v1.8
- returns: <[boolean]>
Returns whether the element is [enabled](../actionability.md#enabled).
### param: Frame.isEnabled.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.isEnabled.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.isEnabled.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.isHidden
* since: v1.8
- returns: <[boolean]>
Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible). [`option: selector`] that does not match any elements is considered hidden.
### param: Frame.isHidden.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.isHidden.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.isHidden.timeout
* since: v1.8
- `timeout` <[float]>
**DEPRECATED** This option is ignored. [`method: Frame.isHidden`] does not wait for the element to become hidden and returns immediately.
## async method: Frame.isVisible
* since: v1.8
- returns: <[boolean]>
Returns whether the element is [visible](../actionability.md#visible). [`option: selector`] that does not match any elements is considered not visible.
### param: Frame.isVisible.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.isVisible.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.isVisible.timeout
* since: v1.8
- `timeout` <[float]>
**DEPRECATED** This option is ignored. [`method: Frame.isVisible`] does not wait for the element to become visible and returns immediately.
## method: Frame.locator
* since: v1.14
- returns: <[Locator]>
The method returns an element locator that can be used to perform actions in the frame.
@ -993,9 +1137,12 @@ Locator is resolved to the element immediately before performing an action, so a
[Learn more about locators](../locators.md).
### param: Frame.locator.selector = %%-find-selector-%%
### option: Frame.locator.-inline- = %%-locator-options-list-%%
* since: v1.14
### option: Frame.locator.-inline- = %%-locator-options-list-v1.14-%%
* since: v1.14
## method: Frame.name
* since: v1.8
- returns: <[string]>
Returns frame's name attribute as specified in the tag.
@ -1007,16 +1154,19 @@ This value is calculated once when the frame is created, and will not update if
:::
## method: Frame.page
* since: v1.8
- returns: <[Page]>
Returns the page containing this frame.
## method: Frame.parentFrame
* since: v1.8
- returns: <[null]|[Frame]>
Parent frame, if any. Detached frames and main frames return `null`.
## async method: Frame.press
* since: v1.8
[`param: key`] can specify the intended
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
@ -1037,22 +1187,29 @@ Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported a
modifier, modifier is pressed and being held while the subsequent key is being pressed.
### param: Frame.press.selector = %%-input-selector-%%
* since: v1.8
### param: Frame.press.key
* since: v1.8
- `key` <[string]>
Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
### option: Frame.press.delay
* since: v1.8
- `delay` <[float]>
Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
### option: Frame.press.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.press.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.press.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.querySelector
* since: v1.9
* langs:
- alias-python: query_selector
- alias-js: $
@ -1069,10 +1226,13 @@ The method finds an element matching the specified selector within the frame. Se
returns `null`.
### param: Frame.querySelector.selector = %%-query-selector-%%
* since: v1.9
### option: Frame.querySelector.strict = %%-input-strict-%%
* since: v1.14
## async method: Frame.querySelectorAll
* since: v1.9
* langs:
- alias-python: query_selector_all
- alias-js: $$
@ -1089,8 +1249,10 @@ The method finds all elements matching the specified selector within the frame.
returns empty array.
### param: Frame.querySelectorAll.selector = %%-query-selector-%%
* since: v1.9
## async method: Frame.selectOption
* since: v1.8
- returns: <[Array]<[string]>>
This method waits for an element matching [`param: selector`], waits for [actionability](../actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
@ -1149,14 +1311,21 @@ await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" })
```
### param: Frame.selectOption.selector = %%-query-selector-%%
* since: v1.8
### param: Frame.selectOption.values = %%-select-options-values-%%
* since: v1.8
### option: Frame.selectOption.force = %%-input-force-%%
* since: v1.13
### option: Frame.selectOption.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.selectOption.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.selectOption.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.setChecked
* since: v1.15
This method checks or unchecks an element matching [`param: selector`] by performing the following steps:
1. Find an element matching [`param: selector`]. If there is none, wait until a matching element is attached to
@ -1174,27 +1343,40 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### param: Frame.setChecked.selector = %%-input-selector-%%
* since: v1.15
### param: Frame.setChecked.checked = %%-input-checked-%%
* since: v1.15
### option: Frame.setChecked.force = %%-input-force-%%
* since: v1.15
### option: Frame.setChecked.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.15
### option: Frame.setChecked.position = %%-input-position-%%
* since: v1.15
### option: Frame.setChecked.strict = %%-input-strict-%%
* since: v1.15
### option: Frame.setChecked.timeout = %%-input-timeout-%%
* since: v1.15
### option: Frame.setChecked.trial = %%-input-trial-%%
* since: v1.15
## async method: Frame.setContent
* since: v1.8
### param: Frame.setContent.html
* since: v1.8
- `html` <[string]>
HTML markup to assign to the page.
### option: Frame.setContent.timeout = %%-navigation-timeout-%%
* since: v1.8
### option: Frame.setContent.waitUntil = %%-navigation-wait-until-%%
* since: v1.8
## async method: Frame.setInputFiles
* since: v1.8
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
are resolved relative to the current working directory. For empty array, clears the selected files.
@ -1203,12 +1385,18 @@ This method expects [`param: selector`] to point to an
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
### param: Frame.setInputFiles.selector = %%-input-selector-%%
* since: v1.8
### param: Frame.setInputFiles.files = %%-input-files-%%
* since: v1.8
### option: Frame.setInputFiles.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.setInputFiles.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.setInputFiles.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.tap
* since: v1.8
This method taps an element matching [`param: selector`] by performing the following steps:
1. Find an element matching [`param: selector`]. If there is none, wait until a matching element is attached to
@ -1227,31 +1415,45 @@ When all steps combined have not finished during the specified [`option: timeout
:::
### param: Frame.tap.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.tap.force = %%-input-force-%%
* since: v1.8
### option: Frame.tap.modifiers = %%-input-modifiers-%%
* since: v1.8
### option: Frame.tap.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.tap.position = %%-input-position-%%
* since: v1.8
### option: Frame.tap.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.tap.timeout = %%-input-timeout-%%
* since: v1.8
### option: Frame.tap.trial = %%-input-trial-%%
* since: v1.11
## async method: Frame.textContent
* since: v1.8
- returns: <[null]|[string]>
Returns `element.textContent`.
### param: Frame.textContent.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.textContent.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.textContent.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.title
* since: v1.8
- returns: <[string]>
Returns the page title.
## async method: Frame.type
* since: v1.8
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to
send fine-grained keyboard events. To fill values in form fields, use [`method: Frame.fill`].
@ -1286,22 +1488,29 @@ await frame.TypeAsync("#mytextarea", "world", delay: 100); // types slower, like
```
### param: Frame.type.selector = %%-input-selector-%%
* since: v1.8
### param: Frame.type.text
* since: v1.8
- `text` <[string]>
A text to type into a focused element.
### option: Frame.type.delay
* since: v1.8
- `delay` <[float]>
Time to wait between key presses in milliseconds. Defaults to 0.
### option: Frame.type.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.type.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.type.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.uncheck
* since: v1.8
This method checks an element matching [`param: selector`] by performing the following steps:
1. Find an element matching [`param: selector`]. If there is none, wait until a matching element is attached to
@ -1319,20 +1528,29 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### param: Frame.uncheck.selector = %%-input-selector-%%
* since: v1.8
### option: Frame.uncheck.force = %%-input-force-%%
* since: v1.8
### option: Frame.uncheck.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.8
### option: Frame.uncheck.position = %%-input-position-%%
* since: v1.11
### option: Frame.uncheck.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.uncheck.timeout = %%-input-timeout-%%
* since: v1.8
### option: Frame.uncheck.trial = %%-input-trial-%%
* since: v1.11
## method: Frame.url
* since: v1.8
- returns: <[string]>
Returns frame's url.
## async method: Frame.waitForFunction
* since: v1.8
- returns: <[JSHandle]>
Returns when the [`param: expression`] returns a truthy value, returns that value.
@ -1447,19 +1665,25 @@ await page.MainFrame.WaitForFunctionAsync("selector => !!document.querySelector(
```
### param: Frame.waitForFunction.expression = %%-evaluate-expression-%%
* since: v1.8
### param: Frame.waitForFunction.arg
* since: v1.8
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
### option: Frame.waitForFunction.polling = %%-js-python-wait-for-function-polling-%%
* since: v1.8
### option: Frame.waitForFunction.polling = %%-csharp-java-wait-for-function-polling-%%
* since: v1.8
### option: Frame.waitForFunction.timeout = %%-wait-for-timeout-%%
* since: v1.8
## async method: Frame.waitForLoadState
* since: v1.8
Waits for the required load state to be reached.
@ -1492,10 +1716,13 @@ await frame.WaitForLoadStateAsync(); // Defaults to LoadState.Load
```
### param: Frame.waitForLoadState.state = %%-wait-for-load-state-state-%%
* since: v1.8
### option: Frame.waitForLoadState.timeout = %%-navigation-timeout-%%
* since: v1.8
## async method: Frame.waitForNavigation
* since: v1.8
* langs:
* alias-python: expect_navigation
* alias-csharp: RunAndWaitForNavigation
@ -1551,12 +1778,16 @@ a navigation.
:::
### option: Frame.waitForNavigation.url = %%-wait-for-navigation-url-%%
* since: v1.8
### option: Frame.waitForNavigation.waitUntil = %%-navigation-wait-until-%%
* since: v1.8
### option: Frame.waitForNavigation.timeout = %%-navigation-timeout-%%
* since: v1.8
## async method: Frame.waitForSelector
* since: v1.8
- returns: <[null]|[ElementHandle]>
Returns when element specified by selector satisfies [`option: state`] option. Returns `null` if waiting for `hidden` or
@ -1670,11 +1901,16 @@ class FrameExamples
```
### param: Frame.waitForSelector.selector = %%-query-selector-%%
* since: v1.8
### option: Frame.waitForSelector.state = %%-wait-for-selector-state-%%
* since: v1.8
### option: Frame.waitForSelector.strict = %%-input-strict-%%
* since: v1.14
### option: Frame.waitForSelector.timeout = %%-input-timeout-%%
* since: v1.8
## async method: Frame.waitForTimeout
* since: v1.8
Waits for the given [`param: timeout`] in milliseconds.
@ -1682,11 +1918,13 @@ Note that `frame.waitForTimeout()` should only be used for debugging. Tests usin
be flaky. Use signals such as network events, selectors becoming visible and others instead.
### param: Frame.waitForTimeout.timeout
* since: v1.8
- `timeout` <[float]>
A timeout to wait for
## async method: Frame.waitForURL
* since: v1.11
Waits for the frame to navigate to the given URL.
@ -1716,5 +1954,8 @@ await frame.WaitForURLAsync("**/target.html");
```
### param: Frame.waitForURL.url = %%-wait-for-navigation-url-%%
* since: v1.11
### option: Frame.waitForURL.timeout = %%-navigation-timeout-%%
* since: v1.11
### option: Frame.waitForURL.waitUntil = %%-navigation-wait-until-%%
* since: v1.11

Просмотреть файл

@ -1,4 +1,5 @@
# class: FrameLocator
* since: v1.17
FrameLocator represents a view to the `iframe` on the page. It captures the logic sufficient to retrieve the `iframe` and locate elements in that iframe. FrameLocator can be created with either [`method: Page.frameLocator`] or [`method: Locator.frameLocator`] method.
@ -96,39 +97,48 @@ var frameLocator = locator.FrameLocator(":scope");
```
## method: FrameLocator.first
* since: v1.17
- returns: <[FrameLocator]>
Returns locator to the first matching frame.
## method: FrameLocator.frameLocator
* since: v1.17
- returns: <[FrameLocator]>
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
in that iframe.
### param: FrameLocator.frameLocator.selector = %%-find-selector-%%
* since: v1.17
## method: FrameLocator.last
* since: v1.17
- returns: <[FrameLocator]>
Returns locator to the last matching frame.
## method: FrameLocator.locator
* since: v1.17
- returns: <[Locator]>
The method finds an element matching the specified selector in the FrameLocator's subtree.
### param: FrameLocator.locator.selector = %%-find-selector-%%
### option: FrameLocator.locator.-inline- = %%-locator-options-list-%%
* since: v1.17
### option: FrameLocator.locator.-inline- = %%-locator-options-list-v1.14-%%
* since: v1.17
## method: FrameLocator.nth
* since: v1.17
- returns: <[FrameLocator]>
Returns locator to the n-th matching frame. It's zero based, `nth(0)` selects the first frame.
### param: FrameLocator.nth.index
* since: v1.17
- `index` <[int]>

Просмотреть файл

@ -1,4 +1,5 @@
# class: JSHandle
* since: v1.8
JSHandle represents an in-page JavaScript object. JSHandles can be created with the [`method: Page.evaluateHandle`]
method.
@ -35,15 +36,18 @@ JSHandle instances can be used as an argument in [`method: Page.evalOnSelector`]
[`method: Page.evaluateHandle`] methods.
## method: JSHandle.asElement
* since: v1.8
- returns: <[null]|[ElementHandle]>
Returns either `null` or the object handle itself, if the object handle is an instance of [ElementHandle].
## async method: JSHandle.dispose
* since: v1.8
The `jsHandle.dispose` method stops referencing the element handle.
## async method: JSHandle.evaluate
* since: v1.8
- returns: <[Serializable]>
Returns the return value of [`param: expression`].
@ -81,13 +85,16 @@ Assert.AreEqual("10 retweets", await tweetHandle.EvaluateAsync("node => node.inn
```
### param: JSHandle.evaluate.expression = %%-evaluate-expression-%%
* since: v1.8
### param: JSHandle.evaluate.arg
* since: v1.8
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: JSHandle.evaluateHandle
* since: v1.8
- returns: <[JSHandle]>
Returns the return value of [`param: expression`] as a [JSHandle].
@ -102,13 +109,16 @@ for the promise to resolve and return its value.
See [`method: Page.evaluateHandle`] for more details.
### param: JSHandle.evaluateHandle.expression = %%-evaluate-expression-%%
* since: v1.8
### param: JSHandle.evaluateHandle.arg
* since: v1.8
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: JSHandle.getProperties
* since: v1.8
- returns: <[Map]<[string], [JSHandle]>>
The method returns a map with **own property names** as keys and JSHandle instances for the property values.
@ -154,16 +164,19 @@ await handle.DisposeAsync();
```
## async method: JSHandle.getProperty
* since: v1.8
- returns: <[JSHandle]>
Fetches a single property from the referenced object.
### param: JSHandle.getProperty.propertyName
* since: v1.8
- `propertyName` <[string]>
property to get
## async method: JSHandle.jsonValue
* since: v1.8
- returns: <[Serializable]>
Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Keyboard
* since: v1.8
Keyboard provides an api for managing a virtual keyboard. The high level api is [`method: Keyboard.type`], which takes
raw characters and generates proper keydown, keypress/input, and keyup events on your page.
@ -138,6 +139,7 @@ await page.Keyboard.PressAsync("Meta+A");
```
## async method: Keyboard.down
* since: v1.8
Dispatches a `keydown` event.
@ -168,11 +170,13 @@ Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the t
:::
### param: Keyboard.down.key
* since: v1.8
- `key` <[string]>
Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
## async method: Keyboard.insertText
* since: v1.8
Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
@ -201,11 +205,13 @@ Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not
:::
### param: Keyboard.insertText.text
* since: v1.8
- `text` <[string]>
Sets input to the specified text value.
## async method: Keyboard.press
* since: v1.8
[`param: key`] can specify the intended
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
@ -287,16 +293,19 @@ await browser.CloseAsync();
Shortcut for [`method: Keyboard.down`] and [`method: Keyboard.up`].
### param: Keyboard.press.key
* since: v1.8
- `key` <[string]>
Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
### option: Keyboard.press.delay
* since: v1.8
- `delay` <[float]>
Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
## async method: Keyboard.type
* since: v1.8
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
@ -338,20 +347,24 @@ For characters that are not on a US keyboard, only an `input` event will be sent
:::
### param: Keyboard.type.text
* since: v1.8
- `text` <[string]>
A text to type into a focused element.
### option: Keyboard.type.delay
* since: v1.8
- `delay` <[float]>
Time to wait between key presses in milliseconds. Defaults to 0.
## async method: Keyboard.up
* since: v1.8
Dispatches a `keyup` event.
### param: Keyboard.up.key
* since: v1.8
- `key` <[string]>
Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Locator
* since: v1.14
Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent
a way to find element(s) on the page at any moment. Locator can be created with the [`method: Page.locator`] method.
@ -6,16 +7,19 @@ a way to find element(s) on the page at any moment. Locator can be created with
[Learn more about locators](../locators.md).
## async method: Locator.allInnerTexts
* since: v1.14
- returns: <[Array]<[string]>>
Returns an array of `node.innerText` values for all matching nodes.
## async method: Locator.allTextContents
* since: v1.14
- returns: <[Array]<[string]>>
Returns an array of `node.textContent` values for all matching nodes.
## async method: Locator.boundingBox
* since: v1.14
- returns: <[null]|[Object]>
- `x` <[float]> the x coordinate of the element in pixels.
- `y` <[float]> the y coordinate of the element in pixels.
@ -61,8 +65,10 @@ await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2);
```
### option: Locator.boundingBox.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.check
* since: v1.14
This method checks the element by performing the following steps:
1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
@ -79,12 +85,18 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### option: Locator.check.position = %%-input-position-%%
* since: v1.14
### option: Locator.check.force = %%-input-force-%%
* since: v1.14
### option: Locator.check.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.check.timeout = %%-input-timeout-%%
* since: v1.14
### option: Locator.check.trial = %%-input-trial-%%
* since: v1.14
## async method: Locator.click
* since: v1.14
This method clicks the element by performing the following steps:
1. Wait for [actionability](../actionability.md) checks on the element, unless [`option: force`] option is set.
@ -98,21 +110,32 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### option: Locator.click.button = %%-input-button-%%
* since: v1.14
### option: Locator.click.clickCount = %%-input-click-count-%%
* since: v1.14
### option: Locator.click.delay = %%-input-down-up-delay-%%
* since: v1.14
### option: Locator.click.position = %%-input-position-%%
* since: v1.14
### option: Locator.click.modifiers = %%-input-modifiers-%%
* since: v1.14
### option: Locator.click.force = %%-input-force-%%
* since: v1.14
### option: Locator.click.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.click.timeout = %%-input-timeout-%%
* since: v1.14
### option: Locator.click.trial = %%-input-trial-%%
* since: v1.14
## async method: Locator.count
* since: v1.14
- returns: <[int]>
Returns the number of elements matching given selector.
## async method: Locator.dblclick
* since: v1.14
* langs:
- alias-csharp: DblClickAsync
@ -133,15 +156,24 @@ When all steps combined have not finished during the specified [`option: timeout
:::
### option: Locator.dblclick.button = %%-input-button-%%
* since: v1.14
### option: Locator.dblclick.delay = %%-input-down-up-delay-%%
* since: v1.14
### option: Locator.dblclick.position = %%-input-position-%%
* since: v1.14
### option: Locator.dblclick.modifiers = %%-input-modifiers-%%
* since: v1.14
### option: Locator.dblclick.force = %%-input-force-%%
* since: v1.14
### option: Locator.dblclick.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.dblclick.timeout = %%-input-timeout-%%
* since: v1.14
### option: Locator.dblclick.trial = %%-input-trial-%%
* since: v1.14
## async method: Locator.dispatchEvent
* since: v1.14
The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
is dispatched. This is equivalent to calling
@ -218,43 +250,58 @@ await element.DispatchEventAsync("dragstart", new Dictionary<string, object>
```
### param: Locator.dispatchEvent.type
* since: v1.14
- `type` <[string]>
DOM event type: `"click"`, `"dragstart"`, etc.
### param: Locator.dispatchEvent.eventInit
* since: v1.14
- `eventInit` ?<[EvaluationArgument]>
Optional event-specific initialization properties.
### option: Locator.dispatchEvent.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.dragTo
* since: v1.18
### param: Locator.dragTo.target
* since: v1.18
- `target` <[Locator]>
Locator of the element to drag to.
### option: Locator.dragTo.force = %%-input-force-%%
* since: v1.18
### option: Locator.dragTo.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.18
### option: Locator.dragTo.timeout = %%-input-timeout-%%
* since: v1.18
### option: Locator.dragTo.trial = %%-input-trial-%%
* since: v1.18
### option: Locator.dragTo.sourcePosition = %%-input-source-position-%%
* since: v1.18
### option: Locator.dragTo.targetPosition = %%-input-target-position-%%
* since: v1.18
## async method: Locator.elementHandle
* since: v1.14
- returns: <[ElementHandle]>
Resolves given locator to the first matching DOM element. If no elements matching the query are visible, waits for them up to a given timeout. If multiple elements match the selector, throws.
### option: Locator.elementHandle.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.elementHandles
* since: v1.14
- returns: <[Array]<[ElementHandle]>>
Resolves given locator to all matching DOM elements.
## async method: Locator.evaluate
* since: v1.14
- returns: <[Serializable]>
Returns the return value of [`param: expression`].
@ -292,15 +339,19 @@ Assert.AreEqual("10 retweets", await tweets.EvaluateAsync("node => node.innerTex
```
### param: Locator.evaluate.expression = %%-evaluate-expression-%%
* since: v1.14
### param: Locator.evaluate.arg
* since: v1.14
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
### option: Locator.evaluate.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.evaluateAll
* since: v1.14
- returns: <[Serializable]>
The method finds all elements matching the specified locator and passes an array of matched elements as
@ -337,14 +388,17 @@ var divsCount = await elements.EvaluateAll<bool>("(divs, min) => divs.length >=
```
### param: Locator.evaluateAll.expression = %%-evaluate-expression-%%
* since: v1.14
### param: Locator.evaluateAll.arg
* since: v1.14
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: Locator.evaluateHandle
* since: v1.14
- returns: <[JSHandle]>
Returns the return value of [`param: expression`] as a [JSHandle].
@ -359,15 +413,19 @@ for the promise to resolve and return its value.
See [`method: Page.evaluateHandle`] for more details.
### param: Locator.evaluateHandle.expression = %%-evaluate-expression-%%
* since: v1.14
### param: Locator.evaluateHandle.arg
* since: v1.14
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
### option: Locator.evaluateHandle.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.fill
* since: v1.14
This method waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
@ -376,15 +434,20 @@ If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` e
To send fine-grained keyboard events, use [`method: Locator.type`].
### param: Locator.fill.value
* since: v1.14
- `value` <[string]>
Value to set for the `<input>`, `<textarea>` or `[contenteditable]` element.
### option: Locator.fill.force = %%-input-force-%%
* since: v1.14
### option: Locator.fill.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.fill.timeout = %%-input-timeout-%%
* since: v1.14
## method: Locator.filter
* since: v1.22
- returns: <[Locator]>
This method narrows existing locator according to the options, for example filters by text.
@ -435,21 +498,26 @@ await rowLocator
.ScreenshotAsync();
```
### option: Locator.filter.-inline- = %%-locator-options-list-%%
### option: Locator.filter.-inline- = %%-locator-options-list-v1.14-%%
* since: v1.22
## method: Locator.first
* since: v1.14
- returns: <[Locator]>
Returns locator to the first matching element.
## async method: Locator.focus
* since: v1.14
Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
### option: Locator.focus.timeout = %%-input-timeout-%%
* since: v1.14
## method: Locator.frameLocator
* since: v1.17
- returns: <[FrameLocator]>
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
@ -481,25 +549,31 @@ await locator.ClickAsync();
```
### param: Locator.frameLocator.selector = %%-find-selector-%%
* since: v1.17
## async method: Locator.getAttribute
* since: v1.14
- returns: <[null]|[string]>
Returns element attribute value.
### param: Locator.getAttribute.name
* since: v1.14
- `name` <[string]>
Attribute name to get the value for.
### option: Locator.getAttribute.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.highlight
* since: v1.20
Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses [`method: Locator.highlight`].
## async method: Locator.hover
* since: v1.14
This method hovers over the element by performing the following steps:
1. Wait for [actionability](../actionability.md) checks on the element, unless [`option: force`] option is set.
@ -513,26 +587,36 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### option: Locator.hover.position = %%-input-position-%%
* since: v1.14
### option: Locator.hover.modifiers = %%-input-modifiers-%%
* since: v1.14
### option: Locator.hover.force = %%-input-force-%%
* since: v1.14
### option: Locator.hover.timeout = %%-input-timeout-%%
* since: v1.14
### option: Locator.hover.trial = %%-input-trial-%%
* since: v1.14
## async method: Locator.innerHTML
* since: v1.14
- returns: <[string]>
Returns the `element.innerHTML`.
### option: Locator.innerHTML.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.innerText
* since: v1.14
- returns: <[string]>
Returns the `element.innerText`.
### option: Locator.innerText.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.inputValue
* since: v1.14
- returns: <[string]>
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
@ -540,82 +624,103 @@ Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` e
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
### option: Locator.inputValue.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.isChecked
* since: v1.14
- returns: <[boolean]>
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
### option: Locator.isChecked.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.isDisabled
* since: v1.14
- returns: <[boolean]>
Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
### option: Locator.isDisabled.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.isEditable
* since: v1.14
- returns: <[boolean]>
Returns whether the element is [editable](../actionability.md#editable).
### option: Locator.isEditable.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.isEnabled
* since: v1.14
- returns: <[boolean]>
Returns whether the element is [enabled](../actionability.md#enabled).
### option: Locator.isEnabled.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.isHidden
* since: v1.14
- returns: <[boolean]>
Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible).
### option: Locator.isHidden.timeout
* since: v1.14
- `timeout` <[float]>
**DEPRECATED** This option is ignored. [`method: Locator.isHidden`] does not wait for the element to become hidden and returns immediately.
## async method: Locator.isVisible
* since: v1.14
- returns: <[boolean]>
Returns whether the element is [visible](../actionability.md#visible).
### option: Locator.isVisible.timeout
* since: v1.14
- `timeout` <[float]>
**DEPRECATED** This option is ignored. [`method: Locator.isVisible`] does not wait for the element to become visible and returns immediately.
## method: Locator.last
* since: v1.14
- returns: <[Locator]>
Returns locator to the last matching element.
## method: Locator.locator
* since: v1.14
- returns: <[Locator]>
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.
### param: Locator.locator.selector = %%-find-selector-%%
### option: Locator.locator.-inline- = %%-locator-options-list-%%
* since: v1.14
### option: Locator.locator.-inline- = %%-locator-options-list-v1.14-%%
* since: v1.14
## method: Locator.nth
* since: v1.14
- returns: <[Locator]>
Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
### param: Locator.nth.index
* since: v1.14
- `index` <[int]>
## method: Locator.page
* since: v1.19
- returns: <[Page]>
A page this locator belongs to.
## async method: Locator.press
* since: v1.14
Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
@ -638,20 +743,25 @@ Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported a
modifier, modifier is pressed and being held while the subsequent key is being pressed.
### param: Locator.press.key
* since: v1.14
- `key` <[string]>
Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
### option: Locator.press.delay
* since: v1.14
- `delay` <[float]>
Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
### option: Locator.press.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.press.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.screenshot
* since: v1.14
- returns: <[Buffer]>
This method captures a screenshot of the page, clipped to the size and position of a particular element matching the locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable container, only the currently scrolled content will be visible on the screenshot.
@ -661,17 +771,21 @@ screenshot. If the element is detached from DOM, the method throws an error.
Returns the buffer with the captured screenshot.
### option: Locator.screenshot.-inline- = %%-screenshot-options-common-list-%%
### option: Locator.screenshot.-inline- = %%-screenshot-options-common-list-v1.8-%%
* since: v1.14
## async method: Locator.scrollIntoViewIfNeeded
* since: v1.14
This method waits for [actionability](../actionability.md) checks, then tries to scroll element into view, unless it is
completely visible as defined by
[IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
### option: Locator.scrollIntoViewIfNeeded.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.selectOption
* since: v1.14
- returns: <[Array]<[string]>>
This method waits for [actionability](../actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
@ -735,11 +849,16 @@ await element.SelectOptionAsync(new[] {
```
### param: Locator.selectOption.values = %%-select-options-values-%%
* since: v1.14
### option: Locator.selectOption.force = %%-input-force-%%
* since: v1.14
### option: Locator.selectOption.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.selectOption.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.selectText
* since: v1.14
This method waits for [actionability](../actionability.md) checks, then focuses the element and selects all its text
content.
@ -747,9 +866,12 @@ content.
If the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the control instead.
### option: Locator.selectText.force = %%-input-force-%%
* since: v1.14
### option: Locator.selectText.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.setChecked
* since: v1.15
This method checks or unchecks an element by performing the following steps:
1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
@ -765,13 +887,20 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### param: Locator.setChecked.checked = %%-input-checked-%%
* since: v1.15
### option: Locator.setChecked.force = %%-input-force-%%
* since: v1.15
### option: Locator.setChecked.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.15
### option: Locator.setChecked.position = %%-input-position-%%
* since: v1.15
### option: Locator.setChecked.timeout = %%-input-timeout-%%
* since: v1.15
### option: Locator.setChecked.trial = %%-input-trial-%%
* since: v1.15
## async method: Locator.setInputFiles
* since: v1.14
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
are resolved relative to the current working directory. For empty array, clears the selected files.
@ -780,10 +909,14 @@ This method expects [Locator] to point to an
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
### param: Locator.setInputFiles.files = %%-input-files-%%
* since: v1.14
### option: Locator.setInputFiles.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.setInputFiles.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.tap
* since: v1.14
This method taps the element by performing the following steps:
1. Wait for [actionability](../actionability.md) checks on the element, unless [`option: force`] option is set.
@ -801,20 +934,29 @@ When all steps combined have not finished during the specified [`option: timeout
:::
### option: Locator.tap.position = %%-input-position-%%
* since: v1.14
### option: Locator.tap.modifiers = %%-input-modifiers-%%
* since: v1.14
### option: Locator.tap.force = %%-input-force-%%
* since: v1.14
### option: Locator.tap.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.tap.timeout = %%-input-timeout-%%
* since: v1.14
### option: Locator.tap.trial = %%-input-trial-%%
* since: v1.14
## async method: Locator.textContent
* since: v1.14
- returns: <[null]|[string]>
Returns the `node.textContent`.
### option: Locator.textContent.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.type
* since: v1.14
Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
@ -878,19 +1020,24 @@ await element.PressAsync("Enter");
```
### param: Locator.type.text
* since: v1.14
- `text` <[string]>
A text to type into a focused element.
### option: Locator.type.delay
* since: v1.14
- `delay` <[float]>
Time to wait between key presses in milliseconds. Defaults to 0.
### option: Locator.type.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.type.timeout = %%-input-timeout-%%
* since: v1.14
## async method: Locator.uncheck
* since: v1.14
This method checks the element by performing the following steps:
1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
@ -907,12 +1054,18 @@ When all steps combined have not finished during the specified [`option: timeout
[TimeoutError]. Passing zero timeout disables this.
### option: Locator.uncheck.position = %%-input-position-%%
* since: v1.14
### option: Locator.uncheck.force = %%-input-force-%%
* since: v1.14
### option: Locator.uncheck.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.uncheck.timeout = %%-input-timeout-%%
* since: v1.14
### option: Locator.uncheck.trial = %%-input-trial-%%
* since: v1.14
## async method: Locator.waitFor
* since: v1.16
Returns when element specified by locator satisfies the [`option: state`] option.
@ -945,4 +1098,6 @@ orderSent.WaitForAsync();
```
### option: Locator.waitFor.state = %%-wait-for-selector-state-%%
* since: v1.16
### option: Locator.waitFor.timeout = %%-input-timeout-%%
* since: v1.16

Просмотреть файл

@ -1,4 +1,5 @@
# class: LocatorAssertions
* since: v1.17
The [LocatorAssertions] class provides assertion methods that can be used to make assertions about the [Locator] state in the tests. A new instance of [LocatorAssertions] is created by calling [`method: PlaywrightAssertions.expectLocator`]:
@ -66,6 +67,7 @@ public class ExampleTests : PageTest
```
## property: LocatorAssertions.not
* since: v1.20
* langs: java, js, csharp
- returns: <[LocatorAssertions]>
@ -84,236 +86,308 @@ await Expect(locator).Not.ToContainTextAsync("error");
```
## async method: LocatorAssertions.NotToBeChecked
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toBeChecked`].
### option: LocatorAssertions.NotToBeChecked.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToBeChecked.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToBeDisabled
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toBeDisabled`].
### option: LocatorAssertions.NotToBeDisabled.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToBeDisabled.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToBeEditable
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toBeEditable`].
### option: LocatorAssertions.NotToBeEditable.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToBeEditable.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToBeEmpty
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toBeEmpty`].
### option: LocatorAssertions.NotToBeEmpty.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToBeEmpty.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToBeEnabled
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toBeEnabled`].
### option: LocatorAssertions.NotToBeEnabled.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToBeEnabled.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToBeFocused
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toBeFocused`].
### option: LocatorAssertions.NotToBeFocused.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToBeFocused.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToBeHidden
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toBeHidden`].
### option: LocatorAssertions.NotToBeHidden.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToBeHidden.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToBeVisible
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toBeVisible`].
### option: LocatorAssertions.NotToBeVisible.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToBeVisible.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToContainText
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toContainText`].
### param: LocatorAssertions.NotToContainText.expected
* since: v1.18
- `expected` <[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Expected substring or RegExp or a list of those.
### option: LocatorAssertions.NotToContainText.ignoreCase
* since: v1.23
- `ignoreCase` <[boolean]>
Whether to perform case-insensitive match. [`option: ignoreCase`] option takes precedence over the corresponding regular expression flag if specified.
### option: LocatorAssertions.NotToContainText.useInnerText
* since: v1.18
- `useInnerText` <[boolean]>
Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
### option: LocatorAssertions.NotToContainText.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToContainText.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveAttribute
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toHaveAttribute`].
### param: LocatorAssertions.NotToHaveAttribute.name
* since: v1.18
- `name` <[string]>
Attribute name.
### param: LocatorAssertions.NotToHaveAttribute.value
* since: v1.18
- `value` <[string]|[RegExp]>
Expected attribute value.
### option: LocatorAssertions.NotToHaveAttribute.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToHaveAttribute.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveClass
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toHaveClass`].
### param: LocatorAssertions.NotToHaveClass.expected
* since: v1.18
- `expected` <[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Expected class or RegExp or a list of those.
### option: LocatorAssertions.NotToHaveClass.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToHaveClass.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveCount
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toHaveCount`].
### param: LocatorAssertions.NotToHaveCount.count
* since: v1.18
- `count` <[int]>
Expected count.
### option: LocatorAssertions.NotToHaveCount.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToHaveCount.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveCSS
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toHaveCSS`].
### param: LocatorAssertions.NotToHaveCSS.name
* since: v1.18
- `name` <[string]>
CSS property name.
### param: LocatorAssertions.NotToHaveCSS.value
* since: v1.18
- `value` <[string]|[RegExp]>
CSS property value.
### option: LocatorAssertions.NotToHaveCSS.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToHaveCSS.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveId
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toHaveId`].
### param: LocatorAssertions.NotToHaveId.id
* since: v1.18
- `id` <[string]|[RegExp]>
Element id.
### option: LocatorAssertions.NotToHaveId.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToHaveId.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveJSProperty
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toHaveJSProperty`].
### param: LocatorAssertions.NotToHaveJSProperty.name
* since: v1.18
- `name` <[string]>
Property name.
### param: LocatorAssertions.NotToHaveJSProperty.value
* since: v1.18
- `value` <[any]>
Property value.
### option: LocatorAssertions.NotToHaveJSProperty.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToHaveJSProperty.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveText
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toHaveText`].
### param: LocatorAssertions.NotToHaveText.expected
* since: v1.18
- `expected` <[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Expected substring or RegExp or a list of those.
### option: LocatorAssertions.NotToHaveText.ignoreCase
* since: v1.23
- `ignoreCase` <[boolean]>
Whether to perform case-insensitive match. [`option: ignoreCase`] option takes precedence over the corresponding regular expression flag if specified.
### option: LocatorAssertions.NotToHaveText.useInnerText
* since: v1.18
- `useInnerText` <[boolean]>
Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
### option: LocatorAssertions.NotToHaveText.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToHaveText.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveValue
* since: v1.20
* langs: python
The opposite of [`method: LocatorAssertions.toHaveValue`].
### param: LocatorAssertions.NotToHaveValue.value
* since: v1.18
- `value` <[string]|[RegExp]>
Expected value.
### option: LocatorAssertions.NotToHaveValue.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.NotToHaveValue.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.NotToHaveValues
* since: v1.23
* langs: python
The opposite of [`method: LocatorAssertions.toHaveValues`].
### param: LocatorAssertions.NotToHaveValues.values
* since: v1.23
- `values` <[Array]<[string]|[RegExp]>>
Expected options currently selected.
### option: LocatorAssertions.NotToHaveValues.timeout = %%-js-assertions-timeout-%%
* since: v1.23
### option: LocatorAssertions.NotToHaveValues.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.23
## async method: LocatorAssertions.toBeChecked
* since: v1.20
* langs:
- alias-java: isChecked
@ -348,13 +422,17 @@ await Expect(locator).ToBeCheckedAsync();
```
### option: LocatorAssertions.toBeChecked.checked
* since: v1.18
- `checked` <[boolean]>
### option: LocatorAssertions.toBeChecked.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toBeChecked.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toBeDisabled
* since: v1.20
* langs:
- alias-java: isDisabled
@ -393,10 +471,13 @@ await Expect(locator).ToBeDisabledAsync();
```
### option: LocatorAssertions.toBeDisabled.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toBeDisabled.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toBeEditable
* since: v1.20
* langs:
- alias-java: isEditable
@ -431,10 +512,13 @@ await Expect(locator).ToBeEditableAsync();
```
### option: LocatorAssertions.toBeEditable.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toBeEditable.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toBeEmpty
* since: v1.20
* langs:
- alias-java: isEmpty
@ -469,10 +553,13 @@ await Expect(locator).ToBeEmptyAsync();
```
### option: LocatorAssertions.toBeEmpty.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toBeEmpty.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toBeEnabled
* since: v1.20
* langs:
- alias-java: isEnabled
@ -507,10 +594,13 @@ await Expect(locator).toBeEnabledAsync();
```
### option: LocatorAssertions.toBeEnabled.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toBeEnabled.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toBeFocused
* since: v1.20
* langs:
- alias-java: isFocused
@ -545,10 +635,13 @@ await Expect(locator).ToBeFocusedAsync();
```
### option: LocatorAssertions.toBeFocused.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toBeFocused.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toBeHidden
* since: v1.20
* langs:
- alias-java: isHidden
@ -583,10 +676,13 @@ await Expect(locator).ToBeHiddenAsync();
```
### option: LocatorAssertions.toBeHidden.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toBeHidden.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toBeVisible
* since: v1.20
* langs:
- alias-java: isVisible
@ -621,9 +717,12 @@ await Expect(locator).ToBeVisibleAsync();
```
### option: LocatorAssertions.toBeVisible.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toBeVisible.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toContainText
* since: v1.20
* langs:
- alias-java: containsText
@ -696,32 +795,39 @@ await Expect(locator).ToContainTextAsync(new string[] { "Text 1", "Text 4", "Tex
```
### param: LocatorAssertions.toContainText.expected
* since: v1.18
* langs: python, js
- `expected` <[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Expected substring or RegExp or a list of those.
### param: LocatorAssertions.toContainText.expected
* since: v1.18
* langs: java, csharp
- `expected` <[string]|[RegExp]|[Array]<[string]>|[Array]<[RegExp]>>
Expected substring or RegExp or a list of those.
### option: LocatorAssertions.toContainText.ignoreCase
* since: v1.23
- `ignoreCase` <[boolean]>
Whether to perform case-insensitive match. [`option: ignoreCase`] option takes precedence over the corresponding regular expression flag if specified.
### option: LocatorAssertions.toContainText.useInnerText
* since: v1.18
- `useInnerText` <[boolean]>
Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
### option: LocatorAssertions.toContainText.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toContainText.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveAttribute
* since: v1.20
* langs:
- alias-java: hasAttribute
@ -756,19 +862,24 @@ await Expect(locator).ToHaveAttributeAsync("type", "text");
```
### param: LocatorAssertions.toHaveAttribute.name
* since: v1.18
- `name` <[string]>
Attribute name.
### param: LocatorAssertions.toHaveAttribute.value
* since: v1.18
- `value` <[string]|[RegExp]>
Expected attribute value.
### option: LocatorAssertions.toHaveAttribute.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toHaveAttribute.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveClass
* since: v1.20
* langs:
- alias-java: hasClass
@ -833,22 +944,27 @@ await Expect(locator).ToHaveClassAsync(new string[]{"component", "component sele
```
### param: LocatorAssertions.toHaveClass.expected
* since: v1.18
* langs: python, js
- `expected` <[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Expected class or RegExp or a list of those.
### param: LocatorAssertions.toHaveClass.expected
* since: v1.18
* langs: java, csharp
- `expected` <[string]|[RegExp]|[Array]<[string]>|[Array]<[RegExp]>>
Expected class or RegExp or a list of those.
### option: LocatorAssertions.toHaveClass.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toHaveClass.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveCount
* since: v1.20
* langs:
- alias-java: hasCount
@ -883,14 +999,18 @@ await Expect(locator).ToHaveCountAsync(3);
```
### param: LocatorAssertions.toHaveCount.count
* since: v1.18
- `count` <[int]>
Expected count.
### option: LocatorAssertions.toHaveCount.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toHaveCount.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveCSS
* since: v1.20
* langs:
- alias-java: hasCSS
@ -925,19 +1045,24 @@ await Expect(locator).ToHaveCSSAsync("display", "flex");
```
### param: LocatorAssertions.toHaveCSS.name
* since: v1.18
- `name` <[string]>
CSS property name.
### param: LocatorAssertions.toHaveCSS.value
* since: v1.18
- `value` <[string]|[RegExp]>
CSS property value.
### option: LocatorAssertions.toHaveCSS.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toHaveCSS.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveId
* since: v1.20
* langs:
- alias-java: hasId
@ -972,15 +1097,19 @@ await Expect(locator).ToHaveIdAsync("lastname");
```
### param: LocatorAssertions.toHaveId.id
* since: v1.18
- `id` <[string]|[RegExp]>
Element id.
### option: LocatorAssertions.toHaveId.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toHaveId.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveJSProperty
* since: v1.20
* langs:
- alias-java: hasJSProperty
@ -1016,20 +1145,25 @@ await Expect(locator).ToHaveJSPropertyAsync("loaded", true);
```
### param: LocatorAssertions.toHaveJSProperty.name
* since: v1.18
- `name` <[string]>
Property name.
### param: LocatorAssertions.toHaveJSProperty.value
* since: v1.18
- `value` <[any]>
Property value.
### option: LocatorAssertions.toHaveJSProperty.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toHaveJSProperty.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveScreenshot#1
* since: v1.23
* langs: js
This function will wait until two consecutive locator screenshots
@ -1041,22 +1175,33 @@ await expect(locator).toHaveScreenshot('image.png');
```
### param: LocatorAssertions.toHaveScreenshot#1.name
* since: v1.23
- `name` <[string]|[Array]<[string]>>
Snapshot name.
### option: LocatorAssertions.toHaveScreenshot#1.timeout = %%-js-assertions-timeout-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#1.animations = %%-screenshot-option-animations-default-disabled-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#1.caret = %%-screenshot-option-caret-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#1.mask = %%-screenshot-option-mask-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#1.omitBackground = %%-screenshot-option-omit-background-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#1.scale = %%-screenshot-option-scale-default-css-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#1.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#1.threshold = %%-assertions-threshold-%%
* since: v1.23
## async method: LocatorAssertions.toHaveScreenshot#2
* since: v1.23
* langs: js
This function will wait until two consecutive locator screenshots
@ -1068,18 +1213,28 @@ await expect(locator).toHaveScreenshot();
```
### option: LocatorAssertions.toHaveScreenshot#2.timeout = %%-js-assertions-timeout-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#2.animations = %%-screenshot-option-animations-default-disabled-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#2.caret = %%-screenshot-option-caret-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#2.mask = %%-screenshot-option-mask-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#2.omitBackground = %%-screenshot-option-omit-background-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#2.scale = %%-screenshot-option-scale-default-css-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#2.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#2.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
* since: v1.23
### option: LocatorAssertions.toHaveScreenshot#2.threshold = %%-assertions-threshold-%%
* since: v1.23
## async method: LocatorAssertions.toHaveText
* since: v1.20
* langs:
- alias-java: hasText
@ -1152,31 +1307,38 @@ await Expect(locator).toHaveTextAsync(new string[]{ "Text 1", "Text 2", "Text 3"
```
### param: LocatorAssertions.toHaveText.expected
* since: v1.18
* langs: python, js
- `expected` <[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Expected substring or RegExp or a list of those.
### param: LocatorAssertions.toHaveText.expected
* since: v1.18
* langs: java, csharp
- `expected` <[string]|[RegExp]|[Array]<[string]>|[Array]<[RegExp]>>
Expected substring or RegExp or a list of those.
### option: LocatorAssertions.toHaveText.ignoreCase
* since: v1.23
- `ignoreCase` <[boolean]>
Whether to perform case-insensitive match. [`option: ignoreCase`] option takes precedence over the corresponding regular expression flag if specified.
### option: LocatorAssertions.toHaveText.useInnerText
* since: v1.18
- `useInnerText` <[boolean]>
Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
### option: LocatorAssertions.toHaveText.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toHaveText.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveValue
* since: v1.20
* langs:
- alias-java: hasValue
@ -1213,14 +1375,18 @@ await Expect(locator).ToHaveValueAsync(new Regex("[0-9]"));
```
### param: LocatorAssertions.toHaveValue.value
* since: v1.18
- `value` <[string]|[RegExp]>
Expected value.
### option: LocatorAssertions.toHaveValue.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: LocatorAssertions.toHaveValue.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: LocatorAssertions.toHaveValues
* since: v1.23
* langs:
- alias-java: hasValues
@ -1272,16 +1438,20 @@ await Expect(locator).ToHaveValuesAsync(new Regex[] { new Regex("R"), new Regex(
```
### param: LocatorAssertions.toHaveValues.values
* since: v1.23
* langs: python, js
- `values` <[Array]<[string]|[RegExp]>>
Expected options currently selected.
### param: LocatorAssertions.toHaveValues.values
* since: v1.23
* langs: java, csharp
- `values` <[Array]<[string]>|[Array]<[RegExp]>>
Expected options currently selected.
### option: LocatorAssertions.toHaveValues.timeout = %%-js-assertions-timeout-%%
* since: v1.23
### option: LocatorAssertions.toHaveValues.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.23

Просмотреть файл

@ -1,4 +1,5 @@
# class: Logger
* since: v1.8
* langs: js
Playwright generates a lot of logs and they are accessible via the pluggable logger sink.
@ -18,39 +19,48 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
```
## method: Logger.isEnabled
* since: v1.8
- returns: <[boolean]>
Determines whether sink is interested in the logger with the given name and severity.
### param: Logger.isEnabled.name
* since: v1.8
- `name` <[string]>
logger name
### param: Logger.isEnabled.severity
* since: v1.8
- `severity` <[LogSeverity]<"verbose"|"info"|"warning"|"error">>
## method: Logger.log
* since: v1.8
### param: Logger.log.name
* since: v1.8
- `name` <[string]>
logger name
### param: Logger.log.severity
* since: v1.8
- `severity` <[LogSeverity]<"verbose"|"info"|"warning"|"error">>
### param: Logger.log.message
* since: v1.8
- `message` <[string]|[Error]>
log message format
### param: Logger.log.args
* since: v1.8
- `args` <[Array]<[Object]>>
message arguments
### param: Logger.log.hints
* since: v1.8
- `hints` <[Object]>
- `color` ?<[string]> Optional preferred logger color.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Mouse
* since: v1.8
The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
@ -58,22 +59,29 @@ await Page.Mouse.MoveAsync(0, 0);
await Page.Mouse.UpAsync();
```
## async method: Mouse.click
* since: v1.8
Shortcut for [`method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`].
### param: Mouse.click.x
* since: v1.8
- `x` <[float]>
### param: Mouse.click.y
* since: v1.8
- `y` <[float]>
### option: Mouse.click.button = %%-input-button-%%
* since: v1.8
### option: Mouse.click.clickCount = %%-input-click-count-%%
* since: v1.8
### option: Mouse.click.delay = %%-input-down-up-delay-%%
* since: v1.8
## async method: Mouse.dblclick
* since: v1.8
* langs:
- alias-csharp: DblClickAsync
@ -81,47 +89,62 @@ Shortcut for [`method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`
[`method: Mouse.up`].
### param: Mouse.dblclick.x
* since: v1.8
- `x` <[float]>
### param: Mouse.dblclick.y
* since: v1.8
- `y` <[float]>
### option: Mouse.dblclick.button = %%-input-button-%%
* since: v1.8
### option: Mouse.dblclick.delay = %%-input-down-up-delay-%%
* since: v1.8
## async method: Mouse.down
* since: v1.8
Dispatches a `mousedown` event.
### option: Mouse.down.button = %%-input-button-%%
* since: v1.8
### option: Mouse.down.clickCount = %%-input-click-count-%%
* since: v1.8
## async method: Mouse.move
* since: v1.8
Dispatches a `mousemove` event.
### param: Mouse.move.x
* since: v1.8
- `x` <[float]>
### param: Mouse.move.y
* since: v1.8
- `y` <[float]>
### option: Mouse.move.steps
* since: v1.8
- `steps` <[int]>
Defaults to 1. Sends intermediate `mousemove` events.
## async method: Mouse.up
* since: v1.8
Dispatches a `mouseup` event.
### option: Mouse.up.button = %%-input-button-%%
* since: v1.8
### option: Mouse.up.clickCount = %%-input-click-count-%%
* since: v1.8
## async method: Mouse.wheel
* since: v1.15
Dispatches a `wheel` event.
@ -131,11 +154,13 @@ wait for the scrolling to finish before returning.
:::
### param: Mouse.wheel.deltaX
* since: v1.15
- `deltaX` <[float]>
Pixels to scroll horizontally.
### param: Mouse.wheel.deltaY
* since: v1.15
- `deltaY` <[float]>
Pixels to scroll vertically.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,4 +1,5 @@
# class: PageAssertions
* since: v1.17
The [PageAssertions] class provides assertion methods that can be used to make assertions about the [Page] state in the tests. A new instance of [PageAssertions] is created by calling [`method: PlaywrightAssertions.expectPage`]:
@ -68,6 +69,7 @@ public class ExampleTests : PageTest
```
## property: PageAssertions.not
* since: v1.20
* langs: java, js, csharp
- returns: <[PageAssertions]>
@ -86,35 +88,44 @@ await Expect(page).Not.ToHaveURL("error");
```
## async method: PageAssertions.NotToHaveTitle
* since: v1.20
* langs: python
The opposite of [`method: PageAssertions.toHaveTitle`].
### param: PageAssertions.NotToHaveTitle.titleOrRegExp
* since: v1.18
- `titleOrRegExp` <[string]|[RegExp]>
Expected title or RegExp.
### option: PageAssertions.NotToHaveTitle.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: PageAssertions.NotToHaveTitle.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: PageAssertions.NotToHaveURL
* since: v1.20
* langs: python
- alias-java: hasURL
The opposite of [`method: PageAssertions.toHaveURL`].
### param: PageAssertions.NotToHaveURL.urlOrRegExp
* since: v1.18
- `urlOrRegExp` <[string]|[RegExp]>
Expected substring or RegExp.
### option: PageAssertions.NotToHaveURL.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: PageAssertions.NotToHaveURL.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: PageAssertions.toHaveScreenshot#1
* since: v1.23
* langs: js
This function will wait until two consecutive page screenshots
@ -125,24 +136,37 @@ await expect(page).toHaveScreenshot('image.png');
```
### param: PageAssertions.toHaveScreenshot#1.name
* since: v1.23
- `name` <[string]|[Array]<[string]>>
Snapshot name.
### option: PageAssertions.toHaveScreenshot#1.timeout = %%-js-assertions-timeout-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.animations = %%-screenshot-option-animations-default-disabled-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.caret = %%-screenshot-option-caret-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.clip = %%-screenshot-option-clip-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.fullPage = %%-screenshot-option-full-page-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.mask = %%-screenshot-option-mask-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.omitBackground = %%-screenshot-option-omit-background-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.scale = %%-screenshot-option-scale-default-css-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#1.threshold = %%-assertions-threshold-%%
* since: v1.23
## async method: PageAssertions.toHaveScreenshot#2
* since: v1.23
* langs: js
This function will wait until two consecutive page screenshots
@ -153,19 +177,31 @@ await expect(page).toHaveScreenshot();
```
### option: PageAssertions.toHaveScreenshot#2.timeout = %%-js-assertions-timeout-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.animations = %%-screenshot-option-animations-default-disabled-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.caret = %%-screenshot-option-caret-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.clip = %%-screenshot-option-clip-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.fullPage = %%-screenshot-option-full-page-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.mask = %%-screenshot-option-mask-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.omitBackground = %%-screenshot-option-omit-background-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.scale = %%-screenshot-option-scale-default-css-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
* since: v1.23
### option: PageAssertions.toHaveScreenshot#2.threshold = %%-assertions-threshold-%%
* since: v1.23
## async method: PageAssertions.toHaveTitle
* since: v1.20
* langs:
- alias-java: hasTitle
@ -200,14 +236,18 @@ await Expect(page).ToHaveTitle("Playwright");
```
### param: PageAssertions.toHaveTitle.titleOrRegExp
* since: v1.18
- `titleOrRegExp` <[string]|[RegExp]>
Expected title or RegExp.
### option: PageAssertions.toHaveTitle.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: PageAssertions.toHaveTitle.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18
## async method: PageAssertions.toHaveURL
* since: v1.20
* langs:
- alias-java: hasURL
@ -242,9 +282,12 @@ await Expect(page).ToHaveURL(new Regex(".*checkout"));
```
### param: PageAssertions.toHaveURL.urlOrRegExp
* since: v1.18
- `urlOrRegExp` <[string]|[RegExp]>
Expected substring or RegExp.
### option: PageAssertions.toHaveURL.timeout = %%-js-assertions-timeout-%%
* since: v1.18
### option: PageAssertions.toHaveURL.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.18

Просмотреть файл

@ -1,4 +1,5 @@
# class: Playwright
* since: v1.8
Playwright module provides a method to launch a browser instance. The following is a typical example of using Playwright
to drive automation:
@ -84,11 +85,13 @@ class PlaywrightExample
```
## property: Playwright.chromium
* since: v1.8
- type: <[BrowserType]>
This object can be used to launch or connect to Chromium, returning instances of [Browser].
## property: Playwright.devices
* since: v1.8
* langs: js, python
- type: <[Object]>
@ -148,6 +151,7 @@ with sync_playwright() as playwright:
```
## property: Playwright.devices
* since: v1.8
* langs: csharp
- type: <[IReadOnlyDictionary<string, BrowserNewContextOptions>]>
@ -173,6 +177,7 @@ class PlaywrightExample
```
## property: Playwright.errors
* since: v1.8
* langs: js
- type: <[Object]>
- `TimeoutError` <[function]> A class of [TimeoutError].
@ -210,11 +215,13 @@ except TimeoutError as e:
```
## property: Playwright.firefox
* since: v1.8
- type: <[BrowserType]>
This object can be used to launch or connect to Firefox, returning instances of [Browser].
## property: Playwright.request
* since: v1.16
* langs:
- alias-csharp: APIRequest
- type: <[APIRequest]>
@ -222,12 +229,14 @@ This object can be used to launch or connect to Firefox, returning instances of
Exposes API that can be used for the Web API testing.
## property: Playwright.selectors
* since: v1.8
- type: <[Selectors]>
Selectors can be used to install custom selector engines. See
[Working with selectors](../selectors.md) for more information.
## property: Playwright.webkit
* since: v1.8
- type: <[BrowserType]>
This object can be used to launch or connect to WebKit, returning instances of [Browser].

Просмотреть файл

@ -1,4 +1,5 @@
# class: PlaywrightAssertions
* since: v1.17
Playwright gives you Web-First Assertions with convenience methods for creating assertions that will wait and retry until the expected condition is met.
@ -71,6 +72,7 @@ reached. You can pass this timeout as an option.
By default, the timeout for assertions is set to 5 seconds.
## method: PlaywrightAssertions.expectAPIResponse
* since: v1.18
* langs: js, java, python
- alias-java: assertThat
- alias-python: expect
@ -85,11 +87,13 @@ PlaywrightAssertions.assertThat(response).isOK();
```
### param: PlaywrightAssertions.expectAPIResponse.response
* since: v1.18
- `response` <[APIResponse]>
[APIResponse] object to use for assertions.
## method: PlaywrightAssertions.expectLocator
* since: v1.18
* langs:
- alias-java: assertThat
- alias-python: expect
@ -108,11 +112,13 @@ await Expect(locator).ToBeVisibleAsync();
```
### param: PlaywrightAssertions.expectLocator.locator
* since: v1.18
- `locator` <[Locator]>
[Locator] object to use for assertions.
## method: PlaywrightAssertions.expectPage
* since: v1.18
* langs:
- alias-java: assertThat
- alias-python: expect
@ -131,6 +137,7 @@ await Expect(page).ToHaveTitleAsync("News");
```
### param: PlaywrightAssertions.expectPage.page
* since: v1.18
- `page` <[Page]>
[Page] object to use for assertions.

Просмотреть файл

@ -1,4 +1,5 @@
# class: PlaywrightException
* since: v1.10
* langs: java
* extends: [RuntimeException]

Просмотреть файл

@ -1,4 +1,5 @@
# class: Request
* since: v1.8
Whenever the page sends a request for a network resource the following sequence of events are emitted by [Page]:
* [`event: Page.request`] emitted when the request is issued by the page.
@ -17,11 +18,13 @@ If request gets a 'redirect' response, the request is successfully finished with
request is issued to a redirected url.
## async method: Request.allHeaders
* since: v1.15
- returns: <[Object]<[string], [string]>>
An object with all the request HTTP headers associated with this request. The header names are lower-cased.
## method: Request.failure
* since: v1.8
- returns: <[null]|[string]>
The method returns `null` unless this request has failed, as reported by `requestfailed` event.
@ -52,11 +55,13 @@ page.RequestFailed += (_, request) =>
```
## method: Request.frame
* since: v1.8
- returns: <[Frame]>
Returns the [Frame] that initiated this request.
## method: Request.headers
* since: v1.8
- returns: <[Object]<[string], [string]>>
An object with the request HTTP headers. The header names are lower-cased.
@ -64,6 +69,7 @@ Note that this method does not return security-related headers, including cookie
You can use [`method: Request.allHeaders`] for complete list of headers that include `cookie` information.
## async method: Request.headersArray
* since: v1.15
- returns: <[Array]<[Object]>>
- `name` <[string]> Name of the header.
- `value` <[string]> Value of the header.
@ -72,37 +78,44 @@ An array with all the request HTTP headers associated with this request. Unlike
Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
## async method: Request.headerValue
* since: v1.15
- returns: <[null]|[string]>
Returns the value of the header matching the name. The name is case insensitive.
### param: Request.headerValue.name
* since: v1.15
- `name` <[string]>
Name of the header.
## method: Request.isNavigationRequest
* since: v1.8
- returns: <[boolean]>
Whether this request is driving frame's navigation.
## method: Request.method
* since: v1.8
- returns: <[string]>
Request's method (GET, POST, etc.)
## method: Request.postData
* since: v1.8
- returns: <[null]|[string]>
Request's post body, if any.
## method: Request.postDataBuffer
* since: v1.8
- returns: <[null]|[Buffer]>
Request's post body in a binary form, if any.
## method: Request.postDataJSON
* since: v1.8
* langs: js, python
- returns: <[null]|[Serializable]>
@ -112,6 +125,7 @@ When the response is `application/x-www-form-urlencoded` then a key/value object
Otherwise it will be parsed as JSON.
## method: Request.redirectedFrom
* since: v1.8
- returns: <[null]|[Request]>
Request that was redirected by the server to this one, if any.
@ -175,6 +189,7 @@ Console.WriteLine(response.Request.RedirectedFrom?.Url); // null
```
## method: Request.redirectedTo
* since: v1.8
- returns: <[null]|[Request]>
New request issued by the browser if the server responded with redirect.
@ -198,6 +213,7 @@ Console.WriteLine(request.RedirectedFrom?.RedirectedTo == request); // True
```
## method: Request.resourceType
* since: v1.8
- returns: <[string]>
Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the
@ -205,11 +221,13 @@ following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttr
`websocket`, `manifest`, `other`.
## async method: Request.response
* since: v1.8
- returns: <[null]|[Response]>
Returns the matching [Response] object, or `null` if the response was not received due to error.
## method: Request.serviceWorker
* since: v1.24
- returns: <[null]|[Worker]>
:::note
@ -219,6 +237,7 @@ This field is Chromium only. It's safe to call when using other browsers, but it
The Service [Worker] that is performing the request.
## async method: Request.sizes
* since: v1.15
- returns: <[Object]>
- `requestBodySize` <[int]> Size of the request body (POST data payload) in bytes. Set to 0 if there was no body.
- `requestHeadersSize` <[int]> Total number of bytes from the start of the HTTP request message until (and including) the double CRLF before the body.
@ -228,6 +247,7 @@ The Service [Worker] that is performing the request.
Returns resource size information for given request.
## method: Request.timing
* since: v1.8
- returns: <[Object]>
- `startTime` <[float]> Request start time in milliseconds elapsed since January 1, 1970 00:00:00 UTC
- `domainLookupStart` <[float]> Time immediately before the browser starts the domain name lookup for the
@ -291,6 +311,7 @@ Console.WriteLine(request.Timing.ResponseEnd);
```
## method: Request.url
* since: v1.8
- returns: <[string]>
URL of the request.

Просмотреть файл

@ -1,4 +1,5 @@
# class: RequestOptions
* since: v1.18
* langs: java
The [RequestOptions] allows to create form data to be sent via [APIRequestContext]. Playwright will automatically
@ -40,16 +41,19 @@ APIResponse response = context.request().post("https://example.com/upload_member
```
## method: RequestOptions.create
* since: v1.18
- returns: <[RequestOptions]>
Creates new instance of [RequestOptions].
## method: RequestOptions.setData
* since: v1.18
- returns: <[RequestOptions]>
Sets the request's post data.
### param: RequestOptions.setData.data
* since: v1.18
- `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
@ -57,15 +61,18 @@ and `content-type` header will be set to `application/json` if not explicitly se
set to `application/octet-stream` if not explicitly set.
## method: RequestOptions.setFailOnStatusCode
* since: v1.18
- returns: <[RequestOptions]>
### param: RequestOptions.setFailOnStatusCode.failOnStatusCode
* since: v1.18
- `failOnStatusCode` <[boolean]>
Whether to throw on response codes other than 2xx and 3xx. By default response object is returned
for all status codes.
## method: RequestOptions.setForm
* since: v1.18
- returns: <[RequestOptions]>
Provides [FormData] object that will be serialized as html form using `application/x-www-form-urlencoded` encoding and sent as
@ -73,46 +80,55 @@ this request body. If this parameter is specified `content-type` header will be
unless explicitly provided.
### param: RequestOptions.setForm.form
* since: v1.18
- `form` <[FormData]>
Form data to be serialized as html form using `application/x-www-form-urlencoded` encoding and sent as
this request body.
## method: RequestOptions.setHeader
* since: v1.18
- returns: <[RequestOptions]>
Sets an HTTP header to the request.
### param: RequestOptions.setHeader.name
* since: v1.18
- `name` <[string]>
Header name.
### param: RequestOptions.setHeader.value
* since: v1.18
- `value` <[string]>
Header value.
## method: RequestOptions.setIgnoreHTTPSErrors
* since: v1.18
- returns: <[RequestOptions]>
### param: RequestOptions.setIgnoreHTTPSErrors.ignoreHTTPSErrors
* since: v1.18
- `ignoreHTTPSErrors` <[boolean]>
Whether to ignore HTTPS errors when sending network requests.
## method: RequestOptions.setMethod
* since: v1.18
- returns: <[RequestOptions]>
Changes the request method (e.g. [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) or
[POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST)).
### param: RequestOptions.setMethod.method
* since: v1.18
- `method` <[string]>
Request method, e.g. [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST).
## method: RequestOptions.setMultipart
* since: v1.18
- returns: <[RequestOptions]>
Provides [FormData] object that will be serialized as html form using `multipart/form-data` encoding and sent as
@ -120,32 +136,38 @@ this request body. If this parameter is specified `content-type` header will be
unless explicitly provided.
### param: RequestOptions.setMultipart.form
* since: v1.18
- `form` <[FormData]>
Form data to be serialized as html form using `multipart/form-data` encoding and sent as
this request body.
## method: RequestOptions.setQueryParam
* since: v1.18
- returns: <[RequestOptions]>
Adds a query parameter to the request URL.
### param: RequestOptions.setQueryParam.name
* since: v1.18
- `name` <[string]>
Parameter name.
### param: RequestOptions.setQueryParam.value
* since: v1.18
- `value` <[string]|[boolean]|[int]>
Parameter value.
## method: RequestOptions.setTimeout
* since: v1.18
- returns: <[RequestOptions]>
Sets request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
### param: RequestOptions.setTimeout.timeout
* since: v1.18
- `timeout` <[float]>
Request timeout in milliseconds.

Просмотреть файл

@ -1,33 +1,40 @@
# class: Response
* since: v1.8
[Response] class represents responses which are received by page.
## async method: Response.allHeaders
* since: v1.15
- returns: <[Object]<[string], [string]>>
An object with all the response HTTP headers associated with this response.
## async method: Response.body
* since: v1.8
- returns: <[Buffer]>
Returns the buffer with response body.
## async method: Response.finished
* since: v1.8
- returns: <[null]|[string]>
Waits for this response to finish, returns always `null`.
## method: Response.frame
* since: v1.8
- returns: <[Frame]>
Returns the [Frame] that initiated this response.
## method: Response.fromServiceWorker
* since: v1.23
- returns: <[boolean]>
Indicates whether this Response was fullfilled by a Service Worker's Fetch Handler (i.e. via [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
## method: Response.headers
* since: v1.8
- returns: <[Object]<[string], [string]>>
An object with the response HTTP headers. The header names are lower-cased.
@ -35,6 +42,7 @@ Note that this method does not return security-related headers, including cookie
You can use [`method: Response.allHeaders`] for complete list of headers that include `cookie` information.
## async method: Response.headersArray
* since: v1.15
- returns: <[Array]<[Object]>>
- `name` <[string]> Name of the header.
- `value` <[string]> Value of the header.
@ -43,27 +51,32 @@ An array with all the request HTTP headers associated with this response. Unlike
Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
## async method: Response.headerValue
* since: v1.15
- returns: <[null]|[string]>
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, `null` is returned.
### param: Response.headerValue.name
* since: v1.15
- `name` <[string]>
Name of the header.
## async method: Response.headerValues
* since: v1.15
- returns: <[Array]<[string]>>
Returns all values of the headers matching the name, for example `set-cookie`. The name is case insensitive.
### param: Response.headerValues.name
* since: v1.15
- `name` <[string]>
Name of the header.
## async method: Response.json
* since: v1.8
* langs: js, python
- returns: <[Serializable]>
@ -72,6 +85,7 @@ Returns the JSON representation of response body.
This method will throw if the response body is not parsable via `JSON.parse`.
## async method: Response.json
* since: v1.8
* langs: csharp
- returns: <[null]|[JsonElement]>
@ -80,16 +94,19 @@ Returns the JSON representation of response body.
This method will throw if the response body is not parsable via `JSON.parse`.
## method: Response.ok
* since: v1.8
- returns: <[boolean]>
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
## method: Response.request
* since: v1.8
- returns: <[Request]>
Returns the matching [Request] object.
## async method: Response.securityDetails
* since: v1.13
- returns: <[null]|[Object]>
- `issuer` ?<[string]> Common Name component of the Issuer field.
from the certificate. This should only be used for informational purposes. Optional.
@ -104,6 +121,7 @@ Returns the matching [Request] object.
Returns SSL and other security information.
## async method: Response.serverAddr
* since: v1.13
- returns: <[null]|[Object]>
- `ipAddress` <[string]> IPv4 or IPV6 address of the server.
- `port` <[int]>
@ -111,21 +129,25 @@ Returns SSL and other security information.
Returns the IP address and port of the server.
## method: Response.status
* since: v1.8
- returns: <[int]>
Contains the status code of the response (e.g., 200 for a success).
## method: Response.statusText
* since: v1.8
- returns: <[string]>
Contains the status text of the response (e.g. usually an "OK" for a success).
## async method: Response.text
* since: v1.8
- returns: <[string]>
Returns the text representation of response body.
## method: Response.url
* since: v1.8
- returns: <[string]>
Contains the URL of the response.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Route
* since: v1.8
Whenever a network route is set up with [`method: Page.route`] or [`method: BrowserContext.route`], the `Route` object
allows to handle the route.
@ -6,10 +7,12 @@ allows to handle the route.
Learn more about [networking](../network.md).
## async method: Route.abort
* since: v1.8
Aborts the route's request.
### param: Route.abort.errorCode
* since: v1.8
- `errorCode` ?<[string]>
Optional error code. Defaults to `failed`, could be one of the following:
@ -31,6 +34,7 @@ Optional error code. Defaults to `failed`, could be one of the following:
* `'failed'` - A generic failure occurred.
## async method: Route.continue
* since: v1.8
* langs:
- alias-java: resume
- alias-python: continue_
@ -95,26 +99,31 @@ await page.RouteAsync("**/*", route =>
```
### option: Route.continue.url
* since: v1.8
- `url` <[string]>
If set changes the request URL. New URL must have same protocol as original one.
### option: Route.continue.method
* since: v1.8
- `method` <[string]>
If set changes the request method (e.g. GET or POST)
### option: Route.continue.postData
* since: v1.8
- `postData` <[string]|[Buffer]>
If set changes the post data of request
### option: Route.continue.headers
* since: v1.8
- `headers` <[Object]<[string], [string]>>
If set changes the request HTTP headers. Header values will be converted to a string.
## async method: Route.fallback
* since: v1.23
When several routes match the given pattern, they run in the order opposite to their registration.
That way the last registered route can always override all the previous ones. In the example below,
@ -355,27 +364,32 @@ await page.RouteAsync("**/*", route =>
```
### option: Route.fallback.url
* since: v1.23
- `url` <[string]>
If set changes the request URL. New URL must have same protocol as original one. Changing the URL won't
affect the route matching, all the routes are matched using the original request URL.
### option: Route.fallback.method
* since: v1.23
- `method` <[string]>
If set changes the request method (e.g. GET or POST)
### option: Route.fallback.postData
* since: v1.23
- `postData` <[string]|[Buffer]>
If set changes the post data of request
### option: Route.fallback.headers
* since: v1.23
- `headers` <[Object]<[string], [string]>>
If set changes the request HTTP headers. Header values will be converted to a string.
## async method: Route.fulfill
* since: v1.8
Fulfills route's request with given response.
@ -445,50 +459,59 @@ await page.RouteAsync("**/xhr_endpoint", route => route.FulfillAsync(new RouteFu
```
### option: Route.fulfill.status
* since: v1.8
- `status` <[int]>
Response status code, defaults to `200`.
### option: Route.fulfill.headers
* since: v1.8
- `headers` <[Object]<[string], [string]>>
Response headers. Header values will be converted to a string.
### option: Route.fulfill.contentType
* since: v1.8
- `contentType` <[string]>
If set, equals to setting `Content-Type` response header.
### option: Route.fulfill.body
* since: v1.8
* langs: js, python
- `body` <[string]|[Buffer]>
Response body.
### option: Route.fulfill.body
* since: v1.8
* langs: csharp, java
- `body` <[string]>
Optional response body as text.
### option: Route.fulfill.bodyBytes
* since: v1.9
* langs: csharp, java
- `bodyBytes` <[Buffer]>
Optional response body as raw bytes.
### option: Route.fulfill.path
* since: v1.8
- `path` <[path]>
File path to respond with. The content type will be inferred from file extension. If `path` is a relative path, then it
is resolved relative to the current working directory.
### option: Route.fulfill.response
* since: v1.15
- `response` <[APIResponse]>
[APIResponse] to fulfill route's request with. Individual fields of the response (such as headers) can be overridden using fulfill options.
## method: Route.request
* since: v1.8
- returns: <[Request]>
A request to be routed.

Просмотреть файл

@ -1,4 +1,5 @@
# class: ScreenshotAssertions
* since: v1.20
* langs: js
Playwright provides methods for comparing page and element screenshots with
@ -9,6 +10,7 @@ expect(screenshot).toMatchSnapshot('landing-page.png');
```
## method: ScreenshotAssertions.toMatchSnapshot#1
* since: v1.22
Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test snapshots directory.
@ -32,19 +34,24 @@ expect(await page.screenshot()).toMatchSnapshot(['landing', 'step3.png']);
Learn more about [visual comparisons](./test-snapshots.md).
### param: ScreenshotAssertions.toMatchSnapshot#1.name
* since: v1.22
- `name` <[string]|[Array]<[string]>>
Snapshot name.
### option: ScreenshotAssertions.toMatchSnapshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.22
### option: ScreenshotAssertions.toMatchSnapshot#1.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
* since: v1.22
### option: ScreenshotAssertions.toMatchSnapshot#1.threshold = %%-assertions-threshold-%%
* since: v1.22
## method: ScreenshotAssertions.toMatchSnapshot#2
* since: v1.22
Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test snapshots directory.
@ -67,13 +74,17 @@ expect(await page.screenshot()).toMatchSnapshot({
Learn more about [visual comparisons](./test-snapshots.md).
### option: ScreenshotAssertions.toMatchSnapshot#2.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.22
### option: ScreenshotAssertions.toMatchSnapshot#2.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
* since: v1.22
### option: ScreenshotAssertions.toMatchSnapshot#2.name
* since: v1.22
- `name` <[string]|[Array]<[string]>>
Snapshot name. If not passed, the test name and ordinals are used when called multiple times.
### option: ScreenshotAssertions.toMatchSnapshot#2.threshold = %%-assertions-threshold-%%
* since: v1.22

Просмотреть файл

@ -1,9 +1,11 @@
# class: Selectors
* since: v1.8
Selectors can be used to install custom selector engines. See [Working with selectors](../selectors.md) for more
information.
## async method: Selectors.register
* since: v1.8
An example of registering selector engine that queries elements based on a tag name:
@ -168,12 +170,14 @@ int buttonCount = await page.Locator("tag=button").CountAsync();
```
### param: Selectors.register.name
* since: v1.8
- `name` <[string]>
Name that is used in selectors as a prefix, e.g. `{name: 'foo'}` enables `foo=myselectorbody` selectors. May only
contain `[a-zA-Z0-9_]` characters.
### param: Selectors.register.script
* since: v1.8
* langs: js
- `script` <[function]|[string]|[Object]>
- `path` ?<[path]> Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the
@ -183,24 +187,28 @@ contain `[a-zA-Z0-9_]` characters.
Script that evaluates to a selector engine instance.
### param: Selectors.register.script
* since: v1.8
* langs: java
- `script` <[string]|[path]>
Script that evaluates to a selector engine instance.
### option: Selectors.register.script
* since: v1.8
* langs: csharp
- `script` <[string]>
Script that evaluates to a selector engine instance.
### option: Selectors.register.path
* since: v1.8
* langs: csharp
- `path` <[path]>
Script that evaluates to a selector engine instance.
### option: Selectors.register.contentScript
* since: v1.8
- `contentScript` <[boolean]>
Whether to run this selector engine in isolated JavaScript environment. This environment has access to the same DOM, but

Просмотреть файл

@ -1,4 +1,5 @@
# class: TimeoutError
* since: v1.8
* extends: [Error]
TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. [`method:

Просмотреть файл

@ -1,14 +1,18 @@
# class: Touchscreen
* since: v1.8
The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the
touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true.
## async method: Touchscreen.tap
* since: v1.8
Dispatches a `touchstart` and `touchend` event with a single touch at the position ([`param: x`],[`param: y`]).
### param: Touchscreen.tap.x
* since: v1.8
- `x` <[float]>
### param: Touchscreen.tap.y
* since: v1.8
- `y` <[float]>

Просмотреть файл

@ -1,4 +1,5 @@
# class: Tracing
* since: v1.12
API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](../trace-viewer.md) after Playwright script runs.
@ -60,6 +61,7 @@ await context.Tracing.StopAsync(new TracingStopOptions
```
## async method: Tracing.start
* since: v1.12
Start tracing.
@ -111,18 +113,21 @@ await context.Tracing.StopAsync(new TracingStopOptions
```
### option: Tracing.start.name
* since: v1.12
- `name` <[string]>
If specified, the trace is going to be saved into the file with the
given name inside the [`option: tracesDir`] folder specified in [`method: BrowserType.launch`].
### option: Tracing.start.screenshots
* since: v1.12
- `screenshots` <[boolean]>
Whether to capture screenshots during tracing. Screenshots are used to build
a timeline preview.
### option: Tracing.start.snapshots
* since: v1.12
- `snapshots` <[boolean]>
If this option is true tracing will
@ -130,12 +135,14 @@ If this option is true tracing will
* record network activity
### option: Tracing.start.sources
* since: v1.17
* langs: js, csharp, python
- `sources` <[boolean]>
Whether to include source files for trace actions.
### option: Tracing.start.sources
* since: v1.17
* langs: java
- `sources` <[boolean]>
@ -144,11 +151,13 @@ must be provided via `PLAYWRIGHT_JAVA_SRC` environment variable (the paths shoul
and by ':' on other platforms).
### option: Tracing.start.title
* since: v1.17
- `title` <[string]>
Trace name to be shown in the Trace Viewer.
## async method: Tracing.startChunk
* since: v1.15
Start a new trace chunk. If you'd like to record multiple traces on the same [BrowserContext], use [`method: Tracing.start`] once, and then create multiple trace chunks with [`method: Tracing.startChunk`] and [`method: Tracing.stopChunk`].
@ -249,16 +258,19 @@ await context.Tracing.StopChunkAsync(new TracingStopChunkOptions
```
### option: Tracing.startChunk.title
* since: v1.17
- `title` <[string]>
Trace name to be shown in the Trace Viewer.
## async method: Tracing.stop
* since: v1.12
Stop tracing.
### option: Tracing.stop.path
* since: v1.12
- `path` <[path]>
Export trace into the file with the given path.
@ -266,10 +278,12 @@ Export trace into the file with the given path.
## async method: Tracing.stopChunk
* since: v1.15
Stop the trace chunk. See [`method: Tracing.startChunk`] for more details about multiple trace chunks.
### option: Tracing.stopChunk.path
* since: v1.15
- `path` <[path]>
Export trace collected since the last [`method: Tracing.startChunk`] call into the file with the given path.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Video
* since: v1.8
When browser context is created with the `recordVideo` option, each page has a video object associated with it.
@ -23,21 +24,25 @@ Console.WriteLine(await page.Video.GetPathAsync());
```
## async method: Video.delete
* since: v1.11
Deletes the video file. Will wait for the video to finish if necessary.
## async method: Video.path
* since: v1.8
- returns: <[path]>
Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem
upon closing the browser context. This method throws when connected remotely.
## async method: Video.saveAs
* since: v1.11
Saves the video to a user-specified path. It is safe to call this method while the video
is still in progress, or after the page has closed. This method waits until the page is closed and the video is fully saved.
### param: Video.saveAs.path
* since: v1.11
- `path` <[path]>
Path where the video should be saved.

Просмотреть файл

@ -1,48 +1,58 @@
# class: WebSocket
* since: v1.8
The [WebSocket] class represents websocket connections in the page.
## event: WebSocket.close
* since: v1.8
- argument: <[WebSocket]>
Fired when the websocket closes.
## event: WebSocket.frameReceived
* since: v1.9
- argument: <[Object]>
- `payload` <[string]|[Buffer]> frame payload
Fired when the websocket receives a frame.
## event: WebSocket.frameReceived
* since: v1.9
* langs: csharp, java
- argument: <[WebSocketFrame]>
## event: WebSocket.frameSent
* since: v1.9
- argument: <[Object]>
- `payload` <[string]|[Buffer]> frame payload
Fired when the websocket sends a frame.
## event: WebSocket.frameSent
* since: v1.9
* langs: csharp, java
- argument: <[WebSocketFrame]>
## event: WebSocket.socketError
* since: v1.9
- argument: <[String]>
Fired when the websocket has an error.
## method: WebSocket.isClosed
* since: v1.8
- returns: <[boolean]>
Indicates that the web socket has been closed.
## method: WebSocket.url
* since: v1.8
- returns: <[string]>
Contains the URL of the WebSocket.
## async method: WebSocket.waitForEvent
* since: v1.8
* langs: js, python
- alias-python: expect_event
- returns: <[any]>
@ -51,11 +61,13 @@ Waits for event to fire and passes its value into the predicate function. Return
value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value.
### param: WebSocket.waitForEvent.event
* since: v1.8
- `event` <[string]>
Event name, same one would pass into `webSocket.on(event)`.
### param: WebSocket.waitForEvent.optionsOrPredicate
* since: v1.8
* langs: js
- `optionsOrPredicate` ?<[function]|[Object]>
- `predicate` <[function]> receives the event data and resolves to truthy value when the waiting should resolve.
@ -64,6 +76,7 @@ Event name, same one would pass into `webSocket.on(event)`.
Either a predicate that receives an event or an options object. Optional.
## async method: WebSocket.waitForFrameReceived
* since: v1.10
* langs: java
- returns: <[WebSocketFrame]>
@ -72,13 +85,16 @@ Performs action and waits for a frame to be sent. If predicate is provided, it p
Will throw an error if the WebSocket or Page is closed before the frame is received.
### option: WebSocket.waitForFrameReceived.predicate
* since: v1.9
- `predicate` <[function]\([WebSocketFrame]\):[boolean]>
Receives the [WebSocketFrame] object and resolves to truthy value when the waiting should resolve.
### option: WebSocket.waitForFrameReceived.timeout = %%-wait-for-event-timeout-%%
* since: v1.9
## async method: WebSocket.waitForFrameSent
* since: v1.10
* langs: java
- returns: <[WebSocketFrame]>
@ -87,13 +103,16 @@ Performs action and waits for a frame to be sent. If predicate is provided, it p
Will throw an error if the WebSocket or Page is closed before the frame is sent.
### option: WebSocket.waitForFrameSent.predicate
* since: v1.9
- `predicate` <[function]\([WebSocketFrame]\):[boolean]>
Receives the [WebSocketFrame] object and resolves to truthy value when the waiting should resolve.
### option: WebSocket.waitForFrameSent.timeout = %%-wait-for-event-timeout-%%
* since: v1.9
## async method: WebSocket.waitForEvent2
* since: v1.8
* langs: python
- alias-python: wait_for_event
- returns: <[any]>
@ -107,5 +126,8 @@ event's value into the `predicate` function and waits for `predicate(event)` to
Will throw an error if the socket is closed before the `event` is fired.
### param: WebSocket.waitForEvent2.event = %%-wait-for-event-event-%%
* since: v1.8
### option: WebSocket.waitForEvent2.predicate = %%-wait-for-event-predicate-%%
* since: v1.8
### option: WebSocket.waitForEvent2.timeout = %%-wait-for-event-timeout-%%
* since: v1.8

Просмотреть файл

@ -1,14 +1,17 @@
# class: WebSocketFrame
* since: v1.9
* langs: csharp, java
The [WebSocketFrame] class represents frames sent over [WebSocket] connections in the page. Frame payload is returned by either [`method: WebSocketFrame.text`] or [`method: WebSocketFrame.binary`] method depending on the its type.
## method: WebSocketFrame.binary
* since: v1.9
- returns: <[null]|[Buffer]>
Returns binary payload.
## method: WebSocketFrame.text
* since: v1.9
- returns: <[null]|[string]>
Returns text payload.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Worker
* since: v1.8
The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker`
event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the
@ -52,11 +53,13 @@ foreach(var pageWorker in page.Workers)
```
## event: Worker.close
* since: v1.8
- argument: <[Worker]>
Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is terminated.
## async method: Worker.evaluate
* since: v1.8
- returns: <[Serializable]>
Returns the return value of [`param: expression`].
@ -68,13 +71,16 @@ If the function passed to the [`method: Worker.evaluate`] returns a non-[Seriali
additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
### param: Worker.evaluate.expression = %%-evaluate-expression-%%
* since: v1.8
### param: Worker.evaluate.arg
* since: v1.8
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## async method: Worker.evaluateHandle
* since: v1.8
- returns: <[JSHandle]>
Returns the return value of [`param: expression`] as a [JSHandle].
@ -87,19 +93,24 @@ If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promi
the promise to resolve and return its value.
### param: Worker.evaluateHandle.expression = %%-evaluate-expression-%%
* since: v1.8
### param: Worker.evaluateHandle.arg
* since: v1.8
- `arg` ?<[EvaluationArgument]>
Optional argument to pass to [`param: expression`].
## method: Worker.url
* since: v1.8
- returns: <[string]>
## async method: Worker.waitForClose
* since: v1.10
* langs: java
- returns: <[Worker]>
Performs action and waits for the Worker to close.
### option: Worker.waitForClose.timeout = %%-wait-for-event-timeout-%%
* since: v1.9

Просмотреть файл

@ -1,4 +1,5 @@
## method: Request.PostDataJSON
* since: v1.12
* langs: csharp
- returns: <[null]|[JsonElement]>
@ -8,12 +9,22 @@ When the response is `application/x-www-form-urlencoded` then a key/value object
Otherwise it will be parsed as JSON.
### param: BrowserContext.waitForPage.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Frame.waitForNavigation.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Page.waitForConsoleMessage.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Page.waitForDownload.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Page.waitForFileChooser.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Page.waitForPopup.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Page.waitForRequestFinished.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Page.waitForNavigation.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Page.waitForWebSocket.action = %%-csharp-wait-for-event-action-%%
* since: v1.12
### param: Page.waitForWorker.action = %%-csharp-wait-for-event-action-%%
* since: v1.12

Просмотреть файл

@ -1,4 +1,5 @@
## method: Page.onceDialog
* since: v1.10
* langs: java
Adds one-off [Dialog] handler. The handler will be removed immediately after next [Dialog] is created.
@ -33,6 +34,7 @@ System.out.println(page.evaluate("prompt('Enter string:')"));
```
### param: Page.onceDialog.handler
* since: v1.10
- `handler` <[function]\([Dialog]\)>
Receives the [Dialog] object, it **must** either [`method: Dialog.accept`] or [`method: Dialog.dismiss`] the dialog - otherwise
@ -40,11 +42,13 @@ the page will [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/E
and actions like click will never finish.
## method: Playwright.close
* since: v1.9
* langs: java
Terminates this instance of Playwright, will also close all created browsers if they are still running.
## method: Playwright.create
* since: v1.10
* langs: java
- returns: <[Playwright]>
@ -59,6 +63,7 @@ playwright.close();
```
### option: Playwright.create.env
* since: v1.13
* langs: java
- `env` <[Object]<[string], [string]>>
@ -66,33 +71,49 @@ Additional environment variables that will be passed to the driver process. By d
process inherits environment variables of the Playwright process.
### param: BrowserContext.waitForPage.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Frame.waitForNavigation.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForClose.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForConsoleMessage.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForDownload.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForFileChooser.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForPopup.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForRequest.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForRequestFinished.callback = %%-java-wait-for-event-callback-%%
* since: v1.12
### param: Page.waitForResponse.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForNavigation.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForWebSocket.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Page.waitForWorker.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: WebSocket.waitForFrameReceived.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: WebSocket.waitForFrameSent.callback = %%-java-wait-for-event-callback-%%
* since: v1.9
### param: Worker.waitForClose.callback = %%-java-wait-for-event-callback-%%
* since: v1.9

Просмотреть файл

@ -1,30 +1,53 @@
## async method: Response.finished
* since: v1.8
* langs: js
- returns: <[null]|[Error]>
## method: Request.failure
* since: v1.8
* langs: js
- returns: <[null]|[Object]>
- `errorText` <[string]> Human-readable error message, e.g. `'net::ERR_FAILED'`.
### param: ElementHandle.evalOnSelector.expression = %%-js-evalonselector-pagefunction-%%
* since: v1.9
### param: ElementHandle.evalOnSelectorAll.expression = %%-js-evalonselectorall-pagefunction-%%
* since: v1.9
### param: Frame.evalOnSelector.expression = %%-js-evalonselector-pagefunction-%%
* since: v1.9
### param: Frame.evalOnSelectorAll.expression = %%-js-evalonselectorall-pagefunction-%%
* since: v1.9
### param: Frame.evaluate.expression = %%-js-evaluate-pagefunction-%%
* since: v1.8
### param: Frame.evaluateHandle.expression = %%-js-evaluate-pagefunction-%%
* since: v1.8
### param: Frame.waitForFunction.expression = %%-js-evaluate-pagefunction-%%
* since: v1.8
### param: JSHandle.evaluate.expression = %%-js-evaluate-pagefunction-%%
* since: v1.8
### param: JSHandle.evaluateHandle.expression = %%-js-evaluate-pagefunction-%%
* since: v1.8
### param: Page.evalOnSelector.expression = %%-js-evalonselector-pagefunction-%%
* since: v1.9
### param: Page.evalOnSelectorAll.expression = %%-js-evalonselectorall-pagefunction-%%
* since: v1.9
### param: Page.evaluate.expression = %%-js-evaluate-pagefunction-%%
* since: v1.8
### param: Page.evaluateHandle.expression = %%-js-evaluate-pagefunction-%%
* since: v1.8
### param: Page.waitForFunction.expression = %%-js-evaluate-pagefunction-%%
* since: v1.8
### param: Worker.evaluate.expression = %%-js-worker-evaluate-workerfunction-%%
* since: v1.8
### param: Worker.evaluateHandle.expression = %%-js-worker-evaluate-workerfunction-%%
* since: v1.8
### param: ElectronApplication.evaluate.expression = %%-js-electron-evaluate-workerfunction-%%
* since: v1.9
### param: ElectronApplication.evaluateHandle.expression = %%-js-electron-evaluate-workerfunction-%%
* since: v1.9
### param: Locator.evaluate.expression = %%-js-evaluate-pagefunction-%%
* since: v1.14
### param: Locator.evaluateAll.expression = %%-js-evaluate-pagefunction-%%
* since: v1.14
### param: Locator.evaluateHandle.expression = %%-js-evaluate-pagefunction-%%
* since: v1.14

Просмотреть файл

@ -790,7 +790,7 @@ An acceptable ratio of pixels that are different to the total amount of pixels,
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 `TestConfig.expect`. Defaults to `0.2`.
## shared-context-params-list
## shared-context-params-list-v1.8
- %%-context-option-acceptdownloads-%%
- %%-context-option-ignorehttpserrors-%%
- %%-context-option-bypasscsp-%%
@ -926,7 +926,7 @@ If specified, traces are saved into this directory.
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
## shared-browser-options-list
## shared-browser-options-list-v1.8
- %%-browser-option-args-%%
- %%-browser-option-channel-%%
- %%-browser-option-chromiumsandbox-%%
@ -958,7 +958,7 @@ For example, `article` that has `text=Playwright` matches `<article><div>Playwri
Note that outer and inner locators must belong to the same frame. Inner locator must not contain [FrameLocator]s.
## locator-options-list
## locator-options-list-v1.14
- %%-locator-option-has-text-%%
- %%-locator-option-has-%%
@ -1043,7 +1043,7 @@ Defaults to `"css"`.
When set to `"hide"`, screenshot will hide text caret. When set to `"initial"`, text caret behavior will not be changed. Defaults to `"hide"`.
## screenshot-options-common-list
## screenshot-options-common-list-v1.8
- %%-screenshot-option-animations-%%
- %%-screenshot-option-omit-background-%%
- %%-screenshot-option-quality-%%

Просмотреть файл

@ -1,4 +1,5 @@
## async method: Playwright.stop
* since: v1.8
* langs: python
Terminates this instance of Playwright in case it was created bypassing the Python context manager. This is useful in REPL applications.
@ -18,6 +19,7 @@ Terminates this instance of Playwright in case it was created bypassing the Pyth
```
### param: BrowserContext.addInitScript.path
* since: v1.8
* langs: python
- `path` ?<[path]>
@ -25,129 +27,173 @@ Path to the JavaScript file. If `path` is a relative path, then it is resolved r
### param: BrowserContext.addInitScript.script
* since: v1.8
* langs: python
- `script` ?<[string]>
Script to be evaluated in all pages in the browser context. Optional.
### param: Page.addInitScript.path
* since: v1.8
* langs: python
- `path` ?<[path]>
Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory. Optional.
### param: Page.addInitScript.script
* since: v1.8
* langs: python
- `script` ?<[string]>
Script to be evaluated in all pages in the browser context. Optional.
### param: ElementHandle.selectOption.element = %%-python-select-options-element-%%
* since: v1.8
### param: ElementHandle.selectOption.index = %%-python-select-options-index-%%
* since: v1.8
### param: ElementHandle.selectOption.value = %%-python-select-options-value-%%
* since: v1.8
### param: ElementHandle.selectOption.label = %%-python-select-options-label-%%
* since: v1.8
### param: Frame.selectOption.element = %%-python-select-options-element-%%
* since: v1.8
### param: Frame.selectOption.index = %%-python-select-options-index-%%
* since: v1.8
### param: Frame.selectOption.value = %%-python-select-options-value-%%
* since: v1.8
### param: Frame.selectOption.label = %%-python-select-options-label-%%
* since: v1.8
### param: Page.selectOption.element = %%-python-select-options-element-%%
* since: v1.8
### param: Page.selectOption.index = %%-python-select-options-index-%%
* since: v1.8
### param: Page.selectOption.value = %%-python-select-options-value-%%
* since: v1.8
### param: Page.selectOption.label = %%-python-select-options-label-%%
* since: v1.8
### param: Locator.selectOption.element = %%-python-select-options-element-%%
* since: v1.14
### param: Locator.selectOption.index = %%-python-select-options-index-%%
* since: v1.14
### param: Locator.selectOption.value = %%-python-select-options-value-%%
* since: v1.14
### param: Locator.selectOption.label = %%-python-select-options-label-%%
* since: v1.14
### option: Page.frame.name
* since: v1.8
* langs: python
- `name` ?<[string]>
Frame name specified in the `iframe`'s `name` attribute. Optional.
### option: Page.frame.url
* since: v1.8
* langs: python
- `url` ?<[string]|[RegExp]|[function]\([URL]\):[boolean]>
A glob pattern, regex pattern or predicate receiving frame's `url` as a [URL] object. Optional.
### option: Selectors.register.script
* since: v1.8
* langs: python
- `path` <[path]>
Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory.
### option: Selectors.register.script
* since: v1.8
* langs: python
- `script` <[string]>
Raw script content.
## async method: Page.waitForEvent
* since: v1.8
* langs: python
- returns: <[EventContextManager]>
### option: Page.waitForEvent.predicate = %%-wait-for-event-predicate-%%
* since: v1.8
### option: Page.waitForEvent.timeout = %%-wait-for-event-timeout-%%
* since: v1.8
## async method: BrowserContext.waitForEvent
* since: v1.8
* langs: python
- returns: <[EventContextManager]>
### option: BrowserContext.waitForEvent.predicate = %%-wait-for-event-predicate-%%
* since: v1.8
### option: BrowserContext.waitForEvent.timeout = %%-wait-for-event-timeout-%%
* since: v1.8
## async method: WebSocket.waitForEvent
* since: v1.8
* langs: python
- returns: <[EventContextManager]>
### option: WebSocket.waitForEvent.predicate = %%-wait-for-event-predicate-%%
* since: v1.8
### option: WebSocket.waitForEvent.timeout = %%-wait-for-event-timeout-%%
* since: v1.8
## async method: Page.waitForDownload
* since: v1.9
* langs: python
- returns: <[EventContextManager]<[Download]>>
## async method: Page.waitForPopup
* since: v1.9
* langs: python
- returns: <[EventContextManager]<[Page]>>
## async method: Page.waitForWebSocket
* since: v1.9
* langs: python
- returns: <[EventContextManager]<[WebSocket]>>
## async method: Page.waitForWorker
* since: v1.9
* langs: python
- returns: <[EventContextManager]<[Worker]>>
## async method: Page.waitForConsoleMessage
* since: v1.9
* langs: python
- returns: <[EventContextManager]<[ConsoleMessage]>>
## async method: Page.waitForFileChooser
* since: v1.9
* langs: python
- returns: <[EventContextManager]<[FileChooser]>>
## async method: BrowserContext.waitForPage
* since: v1.9
* langs: python
- returns: <[EventContextManager]<[Page]>>
## async method: Frame.waitForNavigation
* since: v1.8
* langs: python
- returns: <[EventContextManager]<[Response]>>
## async method: Page.waitForNavigation
* since: v1.8
* langs: python
- returns: <[EventContextManager]<[Response]>>
## async method: Page.waitForRequest
* since: v1.8
* langs: python
- returns: <[EventContextManager]<[Request]>>
## async method: Page.waitForRequestFinished
* since: v1.12
* langs: python
- returns: <[EventContextManager]<[Request]>>
## async method: Page.waitForResponse
* since: v1.8
* langs: python
- returns: <[EventContextManager]<[Response]>>

Просмотреть файл

@ -1,4 +1,5 @@
# class: Fixtures
* since: v1.10
* langs: js
Playwright Test is based on the concept of the [test fixtures](../test-fixtures.md). Test fixtures are used to establish environment for each test, giving the test everything it needs and nothing else.
@ -26,6 +27,7 @@ Given the test above, Playwright Test will set up the `page` fixture before runn
Playwright Test comes with builtin fixtures listed below, and you can add your own fixtures as well. Playwright Test also [provides options][TestOptions] to configure [`property: Fixtures.browser`], [`property: Fixtures.context`] and [`property: Fixtures.page`].
## property: Fixtures.browser
* since: v1.10
- type: <[Browser]>
[Browser] instance is shared between all tests in the [same worker](../test-parallel.md) - this makes testing efficient. However, each test runs in an isolated [BrowserContext] and gets a fresh environment.
@ -33,6 +35,7 @@ Playwright Test comes with builtin fixtures listed below, and you can add your o
Learn how to [configure browser](../test-configuration.md) and see [available options][TestOptions].
## property: Fixtures.browserName
* since: v1.10
- type: <[BrowserName]<"chromium"|"firefox"|"webkit">>
Name of the browser that runs tests. Defaults to `'chromium'`. Useful to [annotate tests](../test-annotations.md) based on the browser.
@ -52,6 +55,7 @@ test('skip this test in Firefox', async ({ page, browserName }) => {
```
## property: Fixtures.context
* since: v1.10
- type: <[BrowserContext]>
Isolated [BrowserContext] instance, created for each test. Since contexts are isolated between each other, every test gets a fresh environment, even when multiple tests run in a single [Browser] for maximum efficiency.
@ -61,6 +65,7 @@ Learn how to [configure context](../test-configuration.md) and see [available op
Default [`property: Fixtures.page`] belongs to this context.
## property: Fixtures.page
* since: v1.10
- type: <[Page]>
Isolated [Page] instance, created for each test. Pages are isolated between tests due to [`property: Fixtures.context`] isolation.
@ -92,6 +97,7 @@ test('basic test', async ({ page }) => {
```
## property: Fixtures.request
* since: v1.10
- type: <[APIRequestContext]>
Isolated [APIRequestContext] instance for each test.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Test
* since: v1.10
* langs: js
Playwright Test provides a `test` function to declare tests and [`expect` function](https://jestjs.io/docs/expect) to write assertions.
@ -24,6 +25,7 @@ test('basic test', async ({ page }) => {
```
## method: Test.(call)
* since: v1.10
Declares a test.
@ -48,11 +50,13 @@ test('basic test', async ({ page }) => {
```
### param: Test.(call).title
* since: v1.10
- `title` <[string]>
Test title.
### param: Test.(call).testFunction
* since: v1.10
- `testFunction` <[function]\([Fixtures], [TestInfo]\)>
Test function that takes one or two arguments: an object with fixtures and optional [TestInfo].
@ -60,12 +64,14 @@ Test function that takes one or two arguments: an object with fixtures and optio
## method: Test.afterAll
* since: v1.10
Declares an `afterAll` hook that is executed once per worker after all tests. When called in the scope of a test file, runs after all tests in the file. When called inside a [`method: Test.describe`] group, runs after all tests in the group. If multiple `afterAll` hooks are added, they will run in the order of their registration.
Note that worker process is restarted on test failures, and `afterAll` hook runs again in the new worker. Learn more about [workers and failures](../test-retries.md).
### param: Test.afterAll.hookFunction
* since: v1.10
- `hookFunction` <[function]\([Fixtures], [TestInfo]\)>
Hook function that takes one or two arguments: an object with worker fixtures and optional [TestInfo].
@ -73,6 +79,7 @@ Hook function that takes one or two arguments: an object with worker fixtures an
## method: Test.afterEach
* since: v1.10
Declares an `afterEach` hook that is executed after each test. When called in the scope of a test file, runs after each test in the file. When called inside a [`method: Test.describe`] group, runs after each test in the group. If multiple `afterEach` hooks are added, they will run in the order of their registration.
@ -111,12 +118,14 @@ test('my test', async ({ page }) => {
```
### param: Test.afterEach.hookFunction
* since: v1.10
- `hookFunction` <[function]\([Fixtures], [TestInfo]\)>
Hook function that takes one or two arguments: an object with fixtures and optional [TestInfo].
## method: Test.beforeAll
* since: v1.10
Declares a `beforeAll` hook that is executed once per worker process before all tests. When called in the scope of a test file, runs before all tests in the file. When called inside a [`method: Test.describe`] group, runs before all tests in the group. If multiple `beforeAll` hooks are added, they will run in the order of their registration.
@ -159,6 +168,7 @@ Note that worker process is restarted on test failures, and `beforeAll` hook run
You can use [`method: Test.afterAll`] to teardown any resources set up in `beforeAll`.
### param: Test.beforeAll.hookFunction
* since: v1.10
- `hookFunction` <[function]\([Fixtures], [TestInfo]\)>
Hook function that takes one or two arguments: an object with worker fixtures and optional [TestInfo].
@ -166,6 +176,7 @@ Hook function that takes one or two arguments: an object with worker fixtures an
## method: Test.beforeEach
* since: v1.10
Declares a `beforeEach` hook that is executed before each test. When called in the scope of a test file, runs before each test in the file. When called inside a [`method: Test.describe`] group, runs before each test in the group. If multiple `beforeEach` hooks are added, they will run in the order of their registration.
@ -202,6 +213,7 @@ test('my test', async ({ page }) => {
You can use [`method: Test.afterEach`] to teardown any resources set up in `beforeEach`.
### param: Test.beforeEach.hookFunction
* since: v1.10
- `hookFunction` <[function]\([Fixtures], [TestInfo]\)>
Hook function that takes one or two arguments: an object with fixtures and optional [TestInfo].
@ -210,6 +222,7 @@ Hook function that takes one or two arguments: an object with fixtures and optio
## method: Test.describe
* since: v1.10
Declares a group of tests.
@ -238,17 +251,20 @@ test.describe('two tests', () => {
```
### param: Test.describe.title
* since: v1.10
- `title` <[string]>
Group title.
### param: Test.describe.callback
* since: v1.10
- `callback` <[function]>
A callback that is run immediately when calling [`method: Test.describe`]. Any tests added in this callback will belong to the group.
## method: Test.describe.configure
* since: v1.10
Set execution mode of execution for the enclosing scope. Can be executed either on the top level or inside a describe. Configuration applies to the entire scope, regardless of whether it run before or after the test
declaration.
@ -288,11 +304,13 @@ test('runs second', async ({ page }) => {});
```
### option: Test.describe.configure.mode
* since: v1.10
- `mode` <[TestMode]<"parallel"|"serial">>
## method: Test.describe.only
* since: v1.10
Declares a focused group of tests. If there are some focused tests or suites, all of them will be run but nothing else.
@ -319,11 +337,13 @@ test('not in the focused group', async ({ page }) => {
```
### param: Test.describe.only.title
* since: v1.10
- `title` <[string]>
Group title.
### param: Test.describe.only.callback
* since: v1.10
- `callback` <[function]>
A callback that is run immediately when calling [`method: Test.describe.only`]. Any tests added in this callback will belong to the group.
@ -331,6 +351,7 @@ A callback that is run immediately when calling [`method: Test.describe.only`].
## method: Test.describe.parallel
* since: v1.10
Declares a group of tests that could be run in parallel. By default, tests in a single test file run one after another, but using [`method: Test.describe.parallel`] allows them to run in parallel.
@ -355,11 +376,13 @@ test.describe.parallel('group', () => {
Note that parallel tests are executed in separate processes and cannot share any state or global variables. Each of the parallel tests executes all relevant hooks.
### param: Test.describe.parallel.title
* since: v1.10
- `title` <[string]>
Group title.
### param: Test.describe.parallel.callback
* since: v1.10
- `callback` <[function]>
A callback that is run immediately when calling [`method: Test.describe.parallel`]. Any tests added in this callback will belong to the group.
@ -367,15 +390,18 @@ A callback that is run immediately when calling [`method: Test.describe.parallel
## method: Test.describe.parallel.only
* since: v1.10
Declares a focused group of tests that could be run in parallel. This is similar to [`method: Test.describe.parallel`], but focuses the group. If there are some focused tests or suites, all of them will be run but nothing else.
### param: Test.describe.parallel.only.title
* since: v1.10
- `title` <[string]>
Group title.
### param: Test.describe.parallel.only.callback
* since: v1.10
- `callback` <[function]>
A callback that is run immediately when calling [`method: Test.describe.parallel.only`]. Any tests added in this callback will belong to the group.
@ -383,6 +409,7 @@ A callback that is run immediately when calling [`method: Test.describe.parallel
## method: Test.describe.serial
* since: v1.10
Declares a group of tests that should always be run serially. If one of the tests fails, all subsequent tests are skipped. All tests in a group are retried together.
@ -409,11 +436,13 @@ test.describe.serial('group', () => {
```
### param: Test.describe.serial.title
* since: v1.10
- `title` <[string]>
Group title.
### param: Test.describe.serial.callback
* since: v1.10
- `callback` <[function]>
A callback that is run immediately when calling [`method: Test.describe.serial`]. Any tests added in this callback will belong to the group.
@ -421,6 +450,7 @@ A callback that is run immediately when calling [`method: Test.describe.serial`]
## method: Test.describe.serial.only
* since: v1.10
Declares a focused group of tests that should always be run serially. If one of the tests fails, all subsequent tests are skipped. All tests in a group are retried together. If there are some focused tests or suites, all of them will be run but nothing else.
@ -447,11 +477,13 @@ test.describe.serial.only('group', () => {
```
### param: Test.describe.serial.only.title
* since: v1.10
- `title` <[string]>
Group title.
### param: Test.describe.serial.only.callback
* since: v1.10
- `callback` <[function]>
A callback that is run immediately when calling [`method: Test.describe.serial.only`]. Any tests added in this callback will belong to the group.
@ -460,6 +492,7 @@ A callback that is run immediately when calling [`method: Test.describe.serial.o
## method: Test.describe.skip
* since: v1.10
Declares a skipped test group, similarly to [`method: Test.describe`]. Tests in the skipped group are never run.
@ -480,11 +513,13 @@ test.describe.skip('skipped group', () => {
```
### param: Test.describe.skip.title
* since: v1.10
- `title` <[string]>
Group title.
### param: Test.describe.skip.callback
* since: v1.10
- `callback` <[function]>
A callback that is run immediately when calling [`method: Test.describe.skip`]. Any tests added in this callback will belong to the group, and will not be run.
@ -492,6 +527,7 @@ A callback that is run immediately when calling [`method: Test.describe.skip`].
## property: Test.expect
* since: v1.10
- type: <[Object]>
`expect` function can be used to create test assertions. Read [expect library documentation](https://jestjs.io/docs/expect) for more details.
@ -501,6 +537,7 @@ A callback that is run immediately when calling [`method: Test.describe.skip`].
## method: Test.extend
* since: v1.10
- returns: <[Test]>
Extends the `test` object by defining fixtures and/or options that can be used in the tests.
@ -622,6 +659,7 @@ export default config;
Learn more about [fixtures](../test-fixtures.md) and [parametrizing tests](../test-parameterize.md).
### param: Test.extend.fixtures
* since: v1.10
- `fixtures` <[Object]>
An object containing fixtures and/or options. Learn more about [fixtures format](../test-fixtures.md).
@ -631,6 +669,7 @@ An object containing fixtures and/or options. Learn more about [fixtures format]
## method: Test.fail#1
* since: v1.10
Unconditonally marks a test as "should fail". Playwright Test runs this test and ensures that it is actually failing. This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed.
@ -653,6 +692,7 @@ test('not yet ready', async ({ page }) => {
```
## method: Test.fail#2
* since: v1.10
Conditionally mark a test as "should fail" with an optional description.
@ -675,17 +715,20 @@ test('fail in WebKit', async ({ page, browserName }) => {
```
### param: Test.fail#2.condition
* since: v1.10
- `condition` <[boolean]>
Test is marked as "should fail" when the condition is `true`.
### param: Test.fail#2.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## method: Test.fail#3
* since: v1.10
Conditionally mark all tests in a file or [`method: Test.describe`] group as "should fail".
@ -716,17 +759,20 @@ test('fail in WebKit 2', async ({ page }) => {
```
### param: Test.fail#3.condition
* since: v1.10
- `callback` <[function]\([Fixtures]\):[boolean]>
A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as "should fail" when the return value is `true`.
### param: Test.fail#3.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## method: Test.fixme#1
* since: v1.10
Declares a test to be fixed, similarly to [`method: Test.(call)`]. This test will not be run.
@ -747,11 +793,13 @@ test.fixme('test to be fixed', async ({ page }) => {
```
### param: Test.fixme#1.title
* since: v1.10
- `title` <[string]>
Test title.
### param: Test.fixme#1.testFunction
* since: v1.10
- `testFunction` <[function]\([Fixtures], [TestInfo]\)>
Test function that takes one or two arguments: an object with fixtures and optional [TestInfo].
@ -759,6 +807,7 @@ Test function that takes one or two arguments: an object with fixtures and optio
## method: Test.fixme#2
* since: v1.10
Mark a test as "fixme", with the intention to fix it. Test is immediately aborted when you call [`method: Test.fixme#2`].
@ -810,6 +859,7 @@ test('test to be fixed 2', async ({ page }) => {
## method: Test.fixme#3
* since: v1.10
Conditionally mark a test as "fixme" with an optional description.
@ -833,11 +883,13 @@ test('broken in WebKit', async ({ page, browserName }) => {
### param: Test.fixme#3.condition
* since: v1.10
- `condition` <[boolean]>
Test is marked as "fixme" when the condition is `true`.
### param: Test.fixme#3.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
@ -846,6 +898,7 @@ Optional description that will be reflected in a test report.
## method: Test.fixme#4
* since: v1.10
Conditionally mark all tests in a file or [`method: Test.describe`] group as "fixme".
@ -877,22 +930,26 @@ test('broken in WebKit 2', async ({ page }) => {
### param: Test.fixme#4.condition
* since: v1.10
- `callback` <[function]\([Fixtures]\):[boolean]>
A function that returns whether to mark as "fixme", based on test fixtures. Test or tests are marked as "fixme" when the return value is `true`.
### param: Test.fixme#4.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## method: Test.info
* since: v1.10
- returns: <[TestInfo]>
Returns information about the currently running test. This method can only be called during the test execution, otherwise it throws.
## method: Test.only
* since: v1.10
Declares a focused test. If there are some focused tests or suites, all of them will be run but nothing else.
@ -909,11 +966,13 @@ test.only('focus this test', async ({ page }) => {
```
### param: Test.only.title
* since: v1.10
- `title` <[string]>
Test title.
### param: Test.only.testFunction
* since: v1.10
- `testFunction` <[function]\([Fixtures], [TestInfo]\)>
Test function that takes one or two arguments: an object with fixtures and optional [TestInfo].
@ -922,6 +981,7 @@ Test function that takes one or two arguments: an object with fixtures and optio
## method: Test.setTimeout
* since: v1.10
Changes the timeout for the test. Zero means no timeout. Learn more about [various timeouts](../test-timeouts.md).
@ -1014,6 +1074,7 @@ test.describe('group', () => {
Timeout for the currently running test is available through [`property: TestInfo.timeout`].
### param: Test.setTimeout.timeout
* since: v1.10
- `timeout` <[int]>
Timeout in milliseconds.
@ -1021,6 +1082,7 @@ Timeout in milliseconds.
## method: Test.skip#1
* since: v1.10
Declares a skipped test, similarly to [`method: Test.(call)`]. Skipped test is never run.
@ -1041,11 +1103,13 @@ test.skip('broken test', async ({ page }) => {
```
### param: Test.skip#1.title
* since: v1.10
- `title` <[string]>
Test title.
### param: Test.skip#1.testFunction
* since: v1.10
- `testFunction` <[function]\([Fixtures], [TestInfo]\)>
Test function that takes one or two arguments: an object with fixtures and optional [TestInfo].
@ -1053,6 +1117,7 @@ Test function that takes one or two arguments: an object with fixtures and optio
## method: Test.skip#2
* since: v1.10
Unconditionally skip a test. Test is immediately aborted when you call [`method: Test.skip#2`].
@ -1104,6 +1169,7 @@ test('skipped test 2', async ({ page }) => {
## method: Test.skip#3
* since: v1.10
Conditionally skip a test with an optional description.
@ -1146,11 +1212,13 @@ test.beforeEach(async ({ page }) => {
```
### param: Test.skip#3.condition
* since: v1.10
- `condition` <[boolean]>
A skip condition. Test is skipped when the condition is `true`.
### param: Test.skip#3.description
* since: v1.10
- `description` ?<[void]|[string]>
Optional description that will be reflected in a test report.
@ -1159,6 +1227,7 @@ Optional description that will be reflected in a test report.
## method: Test.skip#4
* since: v1.10
Conditionally skips all tests in a file or [`method: Test.describe`] group.
@ -1190,11 +1259,13 @@ test('skip in WebKit 2', async ({ page }) => {
### param: Test.skip#4.condition
* since: v1.10
- `callback` <[function]\([Fixtures]\):[boolean]>
A function that returns whether to skip, based on test fixtures. Test or tests are skipped when the return value is `true`.
### param: Test.skip#4.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
@ -1202,6 +1273,7 @@ Optional description that will be reflected in a test report.
## method: Test.slow#1
* since: v1.10
Unconditionally marks a test as "slow". Slow test will be given triple the default timeout.
@ -1228,6 +1300,7 @@ test('slow test', async ({ page }) => {
:::
## method: Test.slow#2
* since: v1.10
Conditionally mark a test as "slow" with an optional description. Slow test will be given triple the default timeout.
@ -1250,17 +1323,20 @@ test('slow in WebKit', async ({ page, browserName }) => {
```
### param: Test.slow#2.condition
* since: v1.10
- `condition` <[boolean]>
Test is marked as "slow" when the condition is `true`.
### param: Test.slow#2.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## method: Test.slow#3
* since: v1.10
Conditionally mark all tests in a file or [`method: Test.describe`] group as "slow". Slow tests will be given triple the default timeout.
@ -1291,17 +1367,20 @@ test('fail in WebKit 2', async ({ page }) => {
```
### param: Test.slow#3.condition
* since: v1.10
- `callback` <[function]\([Fixtures]\):[boolean]>
A function that returns whether to mark as "slow", based on test fixtures. Test or tests are marked as "slow" when the return value is `true`.
### param: Test.slow#3.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## async method: Test.step
* since: v1.10
Declares a test step.
@ -1326,12 +1405,14 @@ test('test', async ({ page }) => {
```
### param: Test.step.title
* since: v1.10
- `title` <[string]>
Step name.
### param: Test.step.body
* since: v1.10
- `body` <[function]\(\):[Promise]<[any]>>
Step body.
@ -1339,6 +1420,7 @@ Step body.
## method: Test.use
* since: v1.10
Specifies options or fixtures to use in a single test file or a [`method: Test.describe`] group. Most useful to set an option, for example set `locale` to configure `context` fixture. `test.use` can be called either in the global scope or inside `test.describe`, it's is an error to call it within `beforeEach` or `beforeAll`.
@ -1397,6 +1479,7 @@ test('test with locale', async ({ page }) => {
```
### param: Test.use.fixtures
* since: v1.10
- `options` <[TestOptions]>
An object with local options.

Просмотреть файл

@ -1,4 +1,5 @@
# class: TestConfig
* since: v1.10
* langs: js
Playwright Test provides many options to configure how your tests are collected and executed, for example `timeout` or `testDir`. These options are described in the [TestConfig] object in the [configuration file](../test-configuration.md).
@ -34,6 +35,7 @@ export default config;
```
## property: TestConfig.expect
* since: v1.10
- type: ?<[Object]>
- `timeout` ?<[int]> Default timeout for async expect matchers in milliseconds, defaults to 5000ms.
- `toHaveScreenshot` ?<[Object]> Configuration for the [`method: PageAssertions.toHaveScreenshot#1`] method.
@ -83,6 +85,7 @@ export default config;
```
## property: TestConfig.forbidOnly
* since: v1.10
- type: ?<[boolean]>
Whether to exit with an error if any tests or groups are marked as [`method: Test.only`] or [`method: Test.describe.only`]. Useful on CI.
@ -110,6 +113,7 @@ export default config;
```
## property: TestConfig.fullyParallel
* since: v1.10
- type: ?<[boolean]>
Playwright Test runs tests in parallel. In order to achieve that, it runs several worker processes that run at the same time.
@ -118,6 +122,7 @@ By default, **test files** are run in parallel. Tests in a single file are run i
You can configure entire test run to concurrently execute all tests in all files using this option.
## property: TestConfig.globalSetup
* since: v1.10
- type: ?<[string]>
Path to the global setup file. This file will be required and run before all the tests. It must export a single function that takes a [`TestConfig`] argument.
@ -147,6 +152,7 @@ export default config;
```
## property: TestConfig.globalTeardown
* since: v1.10
- type: ?<[string]>
Path to the global teardown file. This file will be required and run after all the tests. It must export a single function. See also [`property: TestConfig.globalSetup`].
@ -176,6 +182,7 @@ export default config;
```
## property: TestConfig.globalTimeout
* since: v1.10
- type: ?<[int]>
Maximum time in milliseconds the whole test suite can run. Zero timeout (default) disables this behavior. Useful on CI to prevent broken setup from running too long and wasting resources. Learn more about [various timeouts](../test-timeouts.md).
@ -203,6 +210,7 @@ export default config;
```
## property: TestConfig.grep
* since: v1.10
- type: ?<[RegExp]|[Array]<[RegExp]>>
Filter to only run tests with a title matching one of the patterns. For example, passing `grep: /cart/` should only run tests with "cart" in the title. Also available in the [command line](../test-cli.md) with the `-g` option.
@ -211,6 +219,7 @@ Filter to only run tests with a title matching one of the patterns. For example,
## property: TestConfig.grepInvert
* since: v1.10
- type: ?<[RegExp]|[Array]<[RegExp]>>
Filter to only run tests with a title **not** matching one of the patterns. This is the opposite of [`property: TestConfig.grep`]. Also available in the [command line](../test-cli.md) with the `--grep-invert` option.
@ -219,6 +228,7 @@ Filter to only run tests with a title **not** matching one of the patterns. This
## property: TestConfig.maxFailures
* since: v1.10
- type: ?<[int]>
The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. Setting to zero (default) disables this behavior.
@ -248,16 +258,19 @@ export default config;
```
## property: TestConfig.metadata
* since: v1.10
- type: ?<[Metadata]>
Metadata that will be put directly to the test report serialized as JSON.
## property: TestConfig.name
* since: v1.10
- type: ?<[string]>
Config name is visible in the report and during test execution, unless overridden by [`property: TestProject.name`].
## property: TestConfig.outputDir
* since: v1.10
- type: ?<[string]>
The output directory for files created during test execution. Defaults to `<package.json-directory>/test-results`.
@ -310,6 +323,7 @@ test('example test', async ({}, testInfo) => {
## property: TestConfig.snapshotDir
* since: v1.10
- type: ?<[string]>
The base directory, relative to the config file, for snapshot files created with `toMatchSnapshot`. Defaults to [`property: TestConfig.testDir`].
@ -319,6 +333,7 @@ The directory for each test can be accessed by [`property: TestInfo.snapshotDir`
This path will serve as the base directory for each test file snapshot directory. Setting `snapshotDir` to `'snapshots'`, the [`property: TestInfo.snapshotDir`] would resolve to `snapshots/a.spec.js-snapshots`.
## property: TestConfig.preserveOutput
* since: v1.10
- type: ?<[PreserveOutput]<"always"|"never"|"failures-only">>
Whether to preserve test output in the [`property: TestConfig.outputDir`]. Defaults to `'always'`.
@ -328,22 +343,26 @@ Whether to preserve test output in the [`property: TestConfig.outputDir`]. Defau
## property: TestConfig.projects
* since: v1.10
- type: ?<[Array]<[TestProject]>>
Playwright Test supports running multiple test projects at the same time. See [TestProject] for more information.
## property: TestConfig.quiet
* since: v1.10
- type: ?<[boolean]>
Whether to suppress stdio and stderr output from the tests.
## property: TestConfig.repeatEach
* since: v1.10
- type: ?<[int]>
The number of times to repeat each test, useful for debugging flaky tests.
## property: TestConfig.reporter
* since: v1.10
- type: ?<[string]|[Array]<[Object]>|[BuiltInReporter]<"list"|"dot"|"line"|"github"|"json"|"junit"|"null"|"html">>
- `0` <[string]> Reporter name or module or file path
- `1` <[Object]> An object with reporter options if any
@ -380,6 +399,7 @@ export default config;
```
## property: TestConfig.reportSlowTests
* since: v1.10
- type: ?<[null]|[Object]>
- `max` <[int]> The maximum number of slow test files to report. Defaults to `5`.
- `threshold` <[float]> Test duration in milliseconds that is considered slow. Defaults to 15 seconds.
@ -389,6 +409,7 @@ Whether to report slow test files. Pass `null` to disable this feature.
Test files that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold.
## property: TestConfig.retries
* since: v1.10
- type: ?<[int]>
The maximum number of retry attempts given to failed tests. By default failing tests are not retried. Learn more about [test retries](../test-retries.md#retries).
@ -416,6 +437,7 @@ export default config;
```
## property: TestConfig.screenshotsDir
* since: v1.10
* experimental
- type: ?<[string]>
@ -452,6 +474,7 @@ where:
* `Mobile Safari` and `Desktop Chrome` - project names
## property: TestConfig.shard
* since: v1.10
- type: ?<[null]|[Object]>
- `total` <[int]> The total number of shards.
- `current` <[int]> The index of the shard to execute, one-based.
@ -461,6 +484,7 @@ Shard tests and execute only the selected shard. Specify in the one-based form l
Learn more about [parallelism and sharding](../test-parallel.md) with Playwright Test.
## property: TestConfig.testDir
* since: v1.10
- type: ?<[string]>
Directory that will be recursively scanned for test files. Defaults to the directory of the configuration file.
@ -488,6 +512,7 @@ export default config;
```
## property: TestConfig.testIgnore
* since: v1.10
- type: ?<[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Files matching one of these patterns are not executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.
@ -517,6 +542,7 @@ export default config;
```
## property: TestConfig.testMatch
* since: v1.10
- type: ?<[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.
@ -546,6 +572,7 @@ export default config;
```
## property: TestConfig.timeout
* since: v1.10
- type: ?<[int]>
Timeout for each test in milliseconds. Defaults to 30 seconds.
@ -575,6 +602,7 @@ export default config;
```
## property: TestConfig.updateSnapshots
* since: v1.10
- type: ?<[UpdateSnapshots]<"all"|"none"|"missing">>
Whether to update expected snapshots with the actual results produced by the test run. Defaults to `'missing'`.
@ -585,6 +613,7 @@ Whether to update expected snapshots with the actual results produced by the tes
Learn more about [snapshots](../test-snapshots.md).
## property: TestConfig.use
* since: v1.10
- type: ?<[TestOptions]>
Global options for all tests, for example [`property: TestOptions.browserName`]. Learn more about [configuration](../test-configuration.md) and see [available options][TestOptions].
@ -616,6 +645,7 @@ export default config;
```
## property: TestConfig.webServer
* since: v1.10
- type: ?<[Object]>
- `command` <[string]> Shell command to start. For example `npm run start`..
- `port` ?<[int]> The port that your http server is expected to appear on. It does wait until it accepts connections. Exactly one of `port` or `url` is required.
@ -696,6 +726,7 @@ test('test', async ({ page }) => {
```
## property: TestConfig.workers
* since: v1.10
- type: ?<[int]>
The maximum number of concurrent worker processes to use for parallelizing tests.

Просмотреть файл

@ -1,19 +1,23 @@
# class: TestError
* since: v1.10
* langs: js
Information about an error thrown during test execution.
## property: TestError.message
* since: v1.10
- type: ?<[string]>
Error message. Set when [Error] (or its subclass) has been thrown.
## property: TestError.stack
* since: v1.10
- type: ?<[string]>
Error stack. Set when [Error] (or its subclass) has been thrown.
## property: TestError.value
* since: v1.10
- type: ?<[string]>
The value that was thrown. Set when anything except the [Error] (or its subclass) has been thrown.

Просмотреть файл

@ -1,4 +1,5 @@
# class: TestInfo
* since: v1.10
* langs: js
`TestInfo` contains information about currently running test. It is available to any test function, [`method: Test.beforeEach`] and [`method: Test.afterEach`] hooks and test-scoped fixtures. `TestInfo` provides utilities to control test execution: attach files, update test timeout, determine which test is currently running and whether it was retried, etc.
@ -23,6 +24,7 @@ test('basic test', async ({ page }, testInfo) => {
## property: TestInfo.annotations
* since: v1.10
- type: <[Array]<[Object]>>
- `type` <[string]> Annotation type, for example `'skip'` or `'fail'`.
- `description` ?<[string]> Optional description.
@ -32,6 +34,7 @@ The list of annotations applicable to the current test. Includes annotations fro
Learn more about [test annotations](../test-annotations.md).
## property: TestInfo.attachments
* since: v1.10
- type: <[Array]<[Object]>>
- `name` <[string]> Attachment name.
- `contentType` <[string]> Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`.
@ -43,6 +46,7 @@ The list of files or buffers attached to the current test. Some reporters show t
To add an attachment, use [`method: TestInfo.attach`] instead of directly pushing onto this array.
## async method: TestInfo.attach
* since: v1.10
Attach a value or a file from disk to the current test. Some reporters show test attachments. Either [`option: path`] or [`option: body`] must be specified, but not both.
@ -97,57 +101,67 @@ after awaiting the attach call.
:::
### param: TestInfo.attach.name
* since: v1.10
- `name` <[string]>
Attachment name.
### option: TestInfo.attach.body
* since: v1.10
- `body` <[string]|[Buffer]>
Attachment body. Mutually exclusive with [`option: path`].
### option: TestInfo.attach.contentType
* since: v1.10
- `contentType` <[string]>
Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`. If omitted, content type is inferred based on the [`option: path`], or defaults to `text/plain` for [string] attachments and `application/octet-stream` for [Buffer] attachments.
### option: TestInfo.attach.path
* since: v1.10
- `path` <[string]>
Path on the filesystem to the attached file. Mutually exclusive with [`option: body`].
## property: TestInfo.column
* since: v1.10
- type: <[int]>
Column number where the currently running test is declared.
## property: TestInfo.config
* since: v1.10
- type: <[TestConfig]>
Processed configuration from the [configuration file](../test-configuration.md).
## property: TestInfo.duration
* since: v1.10
- type: <[int]>
The number of milliseconds the test took to finish. Always zero before the test finishes, either successfully or not. Can be used in [`method: Test.afterEach`] hook.
## property: TestInfo.error
* since: v1.10
- type: ?<[TestError]>
First error thrown during test execution, if any. This is equal to the first
element in [`property: TestInfo.errors`].
## property: TestInfo.errors
* since: v1.10
- type: <[Array]<[TestError]>>
Errors thrown during test execution, if any.
## property: TestInfo.expectedStatus
* since: v1.10
- type: <[TestStatus]<"passed"|"failed"|"timedOut"|"skipped">>
Expected status for the currently running test. This is usually `'passed'`, except for a few cases:
@ -175,70 +189,84 @@ test.afterEach(async ({}, testInfo) => {
```
## method: TestInfo.fail#1
* since: v1.10
Marks the currently running test as "should fail". Playwright Test runs this test and ensures that it is actually failing. This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed. This is similar to [`method: Test.fail#1`].
## method: TestInfo.fail#2
* since: v1.10
Conditionally mark the currently running test as "should fail" with an optional description. This is similar to [`method: Test.fail#2`].
### param: TestInfo.fail#2.condition
* since: v1.10
- `condition` <[boolean]>
Test is marked as "should fail" when the condition is `true`.
### param: TestInfo.fail#2.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## property: TestInfo.file
* since: v1.10
- type: <[string]>
Absolute path to a file where the currently running test is declared.
## method: TestInfo.fixme#1
* since: v1.10
Mark a test as "fixme", with the intention to fix it. Test is immediately aborted. This is similar to [`method: Test.fixme#2`].
## method: TestInfo.fixme#2
* since: v1.10
Conditionally mark the currently running test as "fixme" with an optional description. This is similar to [`method: Test.fixme#3`].
### param: TestInfo.fixme#2.condition
* since: v1.10
- `condition` <[boolean]>
Test is marked as "fixme" when the condition is `true`.
### param: TestInfo.fixme#2.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## property: TestInfo.fn
* since: v1.10
- type: <[function]>
Test function as passed to `test(title, testFunction)`.
## property: TestInfo.line
* since: v1.10
- type: <[int]>
Line number where the currently running test is declared.
## property: TestInfo.snapshotDir
* since: v1.10
- type: <[string]>
Absolute path to the snapshot output directory for this specific test. Each test suite gets its own directory so they cannot conflict.
## property: TestInfo.outputDir
* since: v1.10
- type: <[string]>
Absolute path to the output directory for this specific test run. Each test run gets its own directory so they cannot conflict.
## method: TestInfo.outputPath
* since: v1.10
- returns: <[string]>
Returns a path inside the [`property: TestInfo.outputDir`] where the test can safely put a temporary file. Guarantees that tests running in parallel will not interfere with each other.
@ -267,11 +295,13 @@ test('example test', async ({}, testInfo) => {
> However, this path must stay within the [`property: TestInfo.outputDir`] directory for each test (i.e. `test-results/a-test-title`), otherwise it will throw.
### param: TestInfo.outputPath.pathSegments
* since: v1.10
- `...pathSegments` <[Array]<[string]>>
Path segments to append at the end of the resulting path.
## property: TestInfo.parallelIndex
* since: v1.10
- type: <[int]>
The index of the worker between `0` and `workers - 1`. It is guaranteed that workers running at the same time have a different `parallelIndex`. When a worker is restarted, for example after a failure, the new worker process has the same `parallelIndex`.
@ -279,17 +309,20 @@ The index of the worker between `0` and `workers - 1`. It is guaranteed that wor
Also available as `process.env.TEST_PARALLEL_INDEX`. Learn more about [parallelism and sharding](../test-parallel.md) with Playwright Test.
## property: TestInfo.project
* since: v1.10
- type: <[TestProject]>
Processed project configuration from the [configuration file](../test-configuration.md).
## property: TestInfo.repeatEachIndex
* since: v1.10
- type: <[int]>
Specifies a unique repeat index when running in "repeat each" mode. This mode is enabled by passing `--repeat-each` to the [command line](../test-cli.md).
## property: TestInfo.retry
* since: v1.10
- type: <[int]>
Specifies the retry number when the test is retried after a failure. The first test run has [`property: TestInfo.retry`] equal to zero, the first retry has it equal to one, and so on. Learn more about [retries](../test-retries.md#retries).
@ -329,6 +362,7 @@ test('my test', async ({ page }, testInfo) => {
```
## method: TestInfo.setTimeout
* since: v1.10
Changes the timeout for the currently running test. Zero means no timeout. Learn more about [various timeouts](../test-timeouts.md).
@ -353,49 +387,59 @@ test.beforeEach(async ({ page }, testInfo) => {
```
### param: TestInfo.setTimeout.timeout
* since: v1.10
- `timeout` <[int]>
Timeout in milliseconds.
## method: TestInfo.skip#1
* since: v1.10
Unconditionally skip the currently running test. Test is immediately aborted. This is similar to [`method: Test.skip#2`].
## method: TestInfo.skip#2
* since: v1.10
Conditionally skips the currently running test with an optional description. This is similar to [`method: Test.skip#3`].
### param: TestInfo.skip#2.condition
* since: v1.10
- `condition` <[boolean]>
A skip condition. Test is skipped when the condition is `true`.
### param: TestInfo.skip#2.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## method: TestInfo.slow#1
* since: v1.10
Marks the currently running test as "slow", giving it triple the default timeout. This is similar to [`method: Test.slow#1`].
## method: TestInfo.slow#2
* since: v1.10
Conditionally mark the currently running test as "slow" with an optional description, giving it triple the default timeout. This is similar to [`method: Test.slow#2`].
### param: TestInfo.slow#2.condition
* since: v1.10
- `condition` <[boolean]>
Test is marked as "slow" when the condition is `true`.
### param: TestInfo.slow#2.description
* since: v1.10
- `description` ?<[string]>
Optional description that will be reflected in a test report.
## method: TestInfo.snapshotPath
* since: v1.10
- returns: <[string]>
Returns a path to a snapshot file with the given `pathSegments`. Learn more about [snapshots](../test-snapshots.md).
@ -404,16 +448,19 @@ Returns a path to a snapshot file with the given `pathSegments`. Learn more abou
> However, this path must stay within the snapshots directory for each test file (i.e. `a.spec.js-snapshots`), otherwise it will throw.
### param: TestInfo.snapshotPath.pathSegments
* since: v1.10
- `...pathSegments` <[Array]<[string]>>
The name of the snapshot or the path segments to define the snapshot file path. Snapshots with the same name in the same test file are expected to be the same.
## property: TestInfo.snapshotSuffix
* since: v1.10
- type: <[string]>
Suffix used to differentiate snapshots between multiple test configurations. For example, if snapshots depend on the platform, you can set `testInfo.snapshotSuffix` equal to `process.platform`. In this case `expect(value).toMatchSnapshot(snapshotName)` will use different snapshots depending on the platform. Learn more about [snapshots](../test-snapshots.md).
## property: TestInfo.status
* since: v1.10
- type: ?<[TestStatus]<"passed"|"failed"|"timedOut"|"skipped">>
Actual status for the currently running test. Available after the test has finished in [`method: Test.afterEach`] hook and fixtures.
@ -439,16 +486,19 @@ test.afterEach(async ({}, testInfo) => {
```
## property: TestInfo.stderr
* since: v1.10
- type: <[Array]<[string]|[Buffer]>>
Output written to `process.stderr` or `console.error` during the test execution.
## property: TestInfo.stdout
* since: v1.10
- type: <[Array]<[string]|[Buffer]>>
Output written to `process.stdout` or `console.log` during the test execution.
## property: TestInfo.timeout
* since: v1.10
- type: <[int]>
Timeout in milliseconds for the currently running test. Zero means no timeout. Learn more about [various timeouts](../test-timeouts.md).
@ -474,16 +524,19 @@ test.beforeEach(async ({ page }, testInfo) => {
```
## property: TestInfo.title
* since: v1.10
- type: <[string]>
The title of the currently running test as passed to `test(title, testFunction)`.
## property: TestInfo.titlePath
* since: v1.10
- type: <[Array]<[string]>>
The full title path starting with the project.
## property: TestInfo.workerIndex
* since: v1.10
- type: <[int]>
The unique index of the worker process that is running the test. When a worker is restarted, for example after a failure, the new worker process gets a new unique `workerIndex`.

Просмотреть файл

@ -1,4 +1,5 @@
# class: TestOptions
* since: v1.10
* langs: js
Playwright Test provides many options to configure test environment, [Browser], [BrowserContext] and more.
@ -61,10 +62,13 @@ test('my portrait test', async ({ page }) => {
```
## property: TestOptions.acceptDownloads = %%-context-option-acceptdownloads-%%
* since: v1.10
## property: TestOptions.baseURL = %%-context-option-baseURL-%%
* since: v1.10
## property: TestOptions.browserName
* since: v1.10
- type: <[BrowserName]<"chromium"|"firefox"|"webkit">>
Name of the browser that runs tests. Defaults to `'chromium'`. Most of the time you should set `browserName` in your [TestConfig]:
@ -96,6 +100,7 @@ export default config;
```
## property: TestOptions.actionTimeout
* since: v1.10
- type: <[int]>
Default timeout for each Playwright action in milliseconds, defaults to 0 (no timeout).
@ -105,12 +110,16 @@ This is a default timeout for all Playwright actions, same as configured via [`m
Learn more about [various timeouts](../test-timeouts.md).
## property: TestOptions.bypassCSP = %%-context-option-bypasscsp-%%
* since: v1.10
## property: TestOptions.channel = %%-browser-option-channel-%%
* since: v1.10
## property: TestOptions.colorScheme = %%-context-option-colorscheme-%%
* since: v1.10
## property: TestOptions.connectOptions
* since: v1.10
- type: <[void]|[Object]>
- `wsEndpoint` <[string]> A browser websocket endpoint to connect to.
- `headers` ?<[void]|[Object]<[string], [string]>> Additional HTTP headers to be sent with web socket connect request. Optional.
@ -119,36 +128,49 @@ Learn more about [various timeouts](../test-timeouts.md).
When connect options are specified, default [`property: Fixtures.browser`], [`property: Fixtures.context`] and [`property: Fixtures.page`] use the remote browser instead of launching a browser locally, and any launch options like [`property: TestOptions.headless`] or [`property: TestOptions.channel`] are ignored.
## property: TestOptions.contextOptions
* since: v1.10
- type: <[Object]>
Options used to create the context, as passed to [`method: Browser.newContext`]. Specific options like [`property: TestOptions.viewport`] take priority over this.
## property: TestOptions.deviceScaleFactor = %%-context-option-devicescalefactor-%%
* since: v1.10
## property: TestOptions.extraHTTPHeaders = %%-context-option-extrahttpheaders-%%
* since: v1.10
## property: TestOptions.geolocation = %%-context-option-geolocation-%%
* since: v1.10
## property: TestOptions.hasTouch = %%-context-option-hastouch-%%
* since: v1.10
## property: TestOptions.headless = %%-browser-option-headless-%%
* since: v1.10
## property: TestOptions.httpCredentials = %%-context-option-httpcredentials-%%
* since: v1.10
## property: TestOptions.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
* since: v1.10
## property: TestOptions.isMobile = %%-context-option-ismobile-%%
* since: v1.10
## property: TestOptions.javaScriptEnabled = %%-context-option-javascriptenabled-%%
* since: v1.10
## property: TestOptions.launchOptions
* since: v1.10
- type: <[Object]>
Options used to launch the browser, as passed to [`method: BrowserType.launch`]. Specific options [`property: TestOptions.headless`] and [`property: TestOptions.channel`] take priority over this.
## property: TestOptions.locale = %%-context-option-locale-%%
* since: v1.10
## property: TestOptions.navigationTimeout
* since: v1.10
- type: <[int]>
Timeout for each navigation action in milliseconds. Defaults to 0 (no timeout).
@ -158,12 +180,16 @@ This is a default navigation timeout, same as configured via [`method: Page.setD
Learn more about [various timeouts](../test-timeouts.md).
## property: TestOptions.offline = %%-context-option-offline-%%
* since: v1.10
## property: TestOptions.permissions = %%-context-option-permissions-%%
* since: v1.10
## property: TestOptions.proxy = %%-browser-option-proxy-%%
* since: v1.10
## property: TestOptions.screenshot
* since: v1.10
- type: <[Screenshot]<"off"|"on"|"only-on-failure">>
Whether to automatically capture a screenshot after each test. Defaults to `'off'`.
@ -174,10 +200,13 @@ Whether to automatically capture a screenshot after each test. Defaults to `'off
Learn more about [automatic screenshots](../test-configuration.md#automatic-screenshots).
## property: TestOptions.storageState = %%-js-python-context-option-storage-state-%%
* since: v1.10
## property: TestOptions.timezoneId = %%-context-option-timezoneid-%%
* since: v1.10
## property: TestOptions.trace
* since: v1.10
- type: <[Object]|[TraceMode]<"off"|"on"|"retain-on-failure"|"on-first-retry">>
- `mode` <[TraceMode]<"off"|"on"|"retain-on-failure"|"on-first-retry">> Trace recording mode.
- `screenshots` ?<[boolean]> Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview. Defaults to true. Optional.
@ -195,8 +224,10 @@ For more control, pass an object that specifies `mode` and trace features to ena
Learn more about [recording trace](../test-configuration.md#record-test-trace).
## property: TestOptions.userAgent = %%-context-option-useragent-%%
* since: v1.10
## property: TestOptions.video
* since: v1.10
- type: <[Object]|[VideoMode]<"off"|"on"|"retain-on-failure"|"on-first-retry">>
- `mode` <[VideoMode]<"off"|"on"|"retain-on-failure"|"on-first-retry">> Video recording mode.
- `size` ?<[Object]> Size of the recorded video. Optional.
@ -214,5 +245,7 @@ To control video size, pass an object with `mode` and `size` properties. If vide
Learn more about [recording video](../test-configuration.md#record-video).
## property: TestOptions.viewport = %%-context-option-viewport-%%
* since: v1.10
## property: TestOptions.serviceWorkers = %%-context-option-service-worker-policy-%%
* since: v1.10

Просмотреть файл

@ -1,4 +1,5 @@
# class: TestProject
* since: v1.10
* langs: js
Playwright Test supports running multiple test projects at the same time. This is useful for running tests in multiple configurations. For example, consider running tests against multiple browsers.
@ -105,6 +106,7 @@ export default config;
```
## property: TestProject.expect
* since: v1.10
- type: ?<[Object]>
- `timeout` ?<[int]> Default timeout for async expect matchers in milliseconds, defaults to 5000ms.
- `toHaveScreenshot` ?<[Object]> Configuration for the [`method: PageAssertions.toHaveScreenshot#1`] method.
@ -124,6 +126,7 @@ Configuration for the `expect` assertion library.
Use [`property: TestConfig.expect`] to change this option for all projects.
## property: TestProject.fullyParallel
* since: v1.10
- type: ?<[boolean]>
Playwright Test runs tests in parallel. In order to achieve that, it runs several worker processes that run at the same time.
@ -132,6 +135,7 @@ By default, **test files** are run in parallel. Tests in a single file are run i
You can configure entire test project to concurrently run all tests in all files using this option.
## property: TestProject.grep
* since: v1.10
- type: ?<[RegExp]|[Array]<[RegExp]>>
Filter to only run tests with a title matching one of the patterns. For example, passing `grep: /cart/` should only run tests with "cart" in the title. Also available globally and in the [command line](../test-cli.md) with the `-g` option.
@ -139,6 +143,7 @@ Filter to only run tests with a title matching one of the patterns. For example,
`grep` option is also useful for [tagging tests](../test-annotations.md#tag-tests).
## property: TestProject.grepInvert
* since: v1.10
- type: ?<[RegExp]|[Array]<[RegExp]>>
Filter to only run tests with a title **not** matching one of the patterns. This is the opposite of [`property: TestProject.grep`]. Also available globally and in the [command line](../test-cli.md) with the `--grep-invert` option.
@ -146,17 +151,20 @@ Filter to only run tests with a title **not** matching one of the patterns. This
`grepInvert` option is also useful for [tagging tests](../test-annotations.md#tag-tests).
## property: TestProject.metadata
* since: v1.10
- type: ?<[Metadata]>
Metadata that will be put directly to the test report serialized as JSON.
## property: TestProject.name
* since: v1.10
- type: ?<[string]>
Project name is visible in the report and during test execution.
## property: TestProject.screenshotsDir
* since: v1.10
* experimental
- type: ?<[string]>
@ -194,6 +202,7 @@ where:
## property: TestProject.snapshotDir
* since: v1.10
- type: ?<[string]>
The base directory, relative to the config file, for snapshot files created with `toMatchSnapshot`. Defaults to [`property: TestProject.testDir`].
@ -203,6 +212,7 @@ The directory for each test can be accessed by [`property: TestInfo.snapshotDir`
This path will serve as the base directory for each test file snapshot directory. Setting `snapshotDir` to `'snapshots'`, the [`property: TestInfo.snapshotDir`] would resolve to `snapshots/a.spec.js-snapshots`.
## property: TestProject.outputDir
* since: v1.10
- type: ?<[string]>
The output directory for files created during test execution. Defaults to `<package.json-directory>/test-results`.
@ -234,6 +244,7 @@ test('example test', async ({}, testInfo) => {
Use [`property: TestConfig.outputDir`] to change this option for all projects.
## property: TestProject.repeatEach
* since: v1.10
- type: ?<[int]>
The number of times to repeat each test, useful for debugging flaky tests.
@ -241,6 +252,7 @@ The number of times to repeat each test, useful for debugging flaky tests.
Use [`property: TestConfig.repeatEach`] to change this option for all projects.
## property: TestProject.retries
* since: v1.10
- type: ?<[int]>
The maximum number of retry attempts given to failed tests. Learn more about [test retries](../test-retries.md#retries).
@ -248,6 +260,7 @@ The maximum number of retry attempts given to failed tests. Learn more about [te
Use [`property: TestConfig.retries`] to change this option for all projects.
## property: TestProject.testDir
* since: v1.10
- type: ?<[string]>
Directory that will be recursively scanned for test files. Defaults to the directory of the configuration file.
@ -339,6 +352,7 @@ export default config;
Use [`property: TestConfig.testDir`] to change this option for all projects.
## property: TestProject.testIgnore
* since: v1.10
- type: ?<[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Files matching one of these patterns are not executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.
@ -348,6 +362,7 @@ For example, `'**/test-assets/**'` will ignore any files in the `test-assets` di
Use [`property: TestConfig.testIgnore`] to change this option for all projects.
## property: TestProject.testMatch
* since: v1.10
- type: ?<[string]|[RegExp]|[Array]<[string]|[RegExp]>>
Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.
@ -357,6 +372,7 @@ By default, Playwright Test looks for files matching `.*(test|spec)\.(js|ts|mjs)
Use [`property: TestConfig.testMatch`] to change this option for all projects.
## property: TestProject.timeout
* since: v1.10
- type: ?<[int]>
Timeout for each test in milliseconds. Defaults to 30 seconds.
@ -366,6 +382,7 @@ This is a base timeout for all tests. In addition, each test can configure its o
Use [`property: TestConfig.timeout`] to change this option for all projects.
## property: TestProject.use
* since: v1.10
- type: <[Fixtures]>
Options for all tests in this project, for example [`property: TestOptions.browserName`]. Learn more about [configuration](../test-configuration.md) and see [available options][TestOptions].

Просмотреть файл

@ -1,4 +1,5 @@
# class: WorkerInfo
* since: v1.10
* langs: js
`WorkerInfo` contains information about the worker that is running tests. It is available to [`method: Test.beforeAll`] and [`method: Test.afterAll`] hooks and worker-scoped fixtures.
@ -20,12 +21,14 @@ test.beforeAll(async ({ browserName }, workerInfo) => {
```
## property: WorkerInfo.config
* since: v1.10
- type: <[TestConfig]>
Processed configuration from the [configuration file](../test-configuration.md).
## property: WorkerInfo.parallelIndex
* since: v1.10
- type: <[int]>
The index of the worker between `0` and `workers - 1`. It is guaranteed that workers running at the same time have a different `parallelIndex`. When a worker is restarted, for example after a failure, the new worker process has the same `parallelIndex`.
@ -34,12 +37,14 @@ Also available as `process.env.TEST_PARALLEL_INDEX`. Learn more about [paralleli
## property: WorkerInfo.project
* since: v1.10
- type: <[TestProject]>
Processed project configuration from the [configuration file](../test-configuration.md).
## property: WorkerInfo.workerIndex
* since: v1.10
- type: <[int]>
The unique index of the worker process that is running the test. When a worker is restarted, for example after a failure, the new worker process gets a new unique `workerIndex`.

Просмотреть файл

@ -1,19 +1,23 @@
# class: Location
* since: v1.10
* langs: js
Represents a location in the source code where [TestCase] or [Suite] is defined.
## property: Location.file
* since: v1.10
- type: <[string]>
Path to the source file.
## property: Location.line
* since: v1.10
- type: <[int]>
Line number in the source file.
## property: Location.column
* since: v1.10
- type: <[int]>
Column number in the source file.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Reporter
* since: v1.10
* langs: js
Test runner notifies the reporter about various events during test execution. All methods of the reporter are optional.
@ -90,15 +91,18 @@ Additionally, [`method: Reporter.onStdOut`] and [`method: Reporter.onStdErr`] ar
and [`method: Reporter.onError`] is called when something went wrong outside of the test execution.
## optional method: Reporter.onBegin
* since: v1.10
Called once before running tests. All tests have been already discovered and put into a hierarchy of [Suite]s.
### param: Reporter.onBegin.config
* since: v1.10
- `config` <[TestConfig]>
Resolved configuration.
### param: Reporter.onBegin.suite
* since: v1.10
- `suite` <[Suite]>
The root suite that contains all projects, files and test cases.
@ -106,10 +110,12 @@ The root suite that contains all projects, files and test cases.
## optional async method: Reporter.onEnd
* since: v1.10
Called after all tests has been run, or testing has been interrupted. Note that this method may return a [Promise] and Playwright Test will await it.
### param: Reporter.onEnd.result
* since: v1.10
- `result` <[Object]>
- `status` <[FullStatus]<"passed"|"failed"|"timedout"|"interrupted">>
@ -123,123 +129,148 @@ Result of the full test run.
## optional method: Reporter.onError
* since: v1.10
Called on some global error, for example unhandled exception in the worker process.
### param: Reporter.onError.error
* since: v1.10
- `error` <[TestError]>
The error.
## optional method: Reporter.onStdErr
* since: v1.10
Called when something has been written to the standard error in the worker process.
### param: Reporter.onStdErr.chunk
* since: v1.10
- `chunk` <[string]|[Buffer]>
Output chunk.
### param: Reporter.onStdErr.test
* since: v1.10
- `test` <[void]|[TestCase]>
Test that was running. Note that output may happen when no test is running, in which case this will be [void].
### param: Reporter.onStdErr.result
* since: v1.10
- `result` <[void]|[TestResult]>
Result of the test run, this object gets populated while the test runs.
## optional method: Reporter.onStdOut
* since: v1.10
Called when something has been written to the standard output in the worker process.
### param: Reporter.onStdOut.chunk
* since: v1.10
- `chunk` <[string]|[Buffer]>
Output chunk.
### param: Reporter.onStdOut.test
* since: v1.10
- `test` <[void]|[TestCase]>
Test that was running. Note that output may happen when no test is running, in which case this will be [void].
### param: Reporter.onStdOut.result
* since: v1.10
- `result` <[void]|[TestResult]>
Result of the test run, this object gets populated while the test runs.
## optional method: Reporter.onStepBegin
* since: v1.10
Called when a test step started in the worker process.
### param: Reporter.onStepBegin.test
* since: v1.10
- `test` <[TestCase]>
Test that the step belongs to.
### param: Reporter.onStepBegin.result
* since: v1.10
- `result` <[TestResult]>
Result of the test run, this object gets populated while the test runs.
### param: Reporter.onStepBegin.step
* since: v1.10
- `step` <[TestStep]>
Test step instance that has started.
## optional method: Reporter.onStepEnd
* since: v1.10
Called when a test step finished in the worker process.
### param: Reporter.onStepEnd.test
* since: v1.10
- `test` <[TestCase]>
Test that the step belongs to.
### param: Reporter.onStepEnd.result
* since: v1.10
- `result` <[TestResult]>
Result of the test run.
### param: Reporter.onStepEnd.step
* since: v1.10
- `step` <[TestStep]>
Test step instance that has finished.
## optional method: Reporter.onTestBegin
* since: v1.10
Called after a test has been started in the worker process.
### param: Reporter.onTestBegin.test
* since: v1.10
- `test` <[TestCase]>
Test that has been started.
### param: Reporter.onTestBegin.result
* since: v1.10
- `result` <[TestResult]>
Result of the test run, this object gets populated while the test runs.
## optional method: Reporter.onTestEnd
* since: v1.10
Called after a test has been finished in the worker process.
### param: Reporter.onTestEnd.test
* since: v1.10
- `test` <[TestCase]>
Test that has been finished.
### param: Reporter.onTestEnd.result
* since: v1.10
- `result` <[TestResult]>
Result of the test run.
## optional method: Reporter.printsToStdio
* since: v1.10
- returns: <[boolean]>
Whether this reporter uses stdio for reporting. When it does not, Playwright Test could add some output to enhance user experience.

Просмотреть файл

@ -1,4 +1,5 @@
# class: Suite
* since: v1.10
* langs: js
`Suite` is a group of tests. All tests in Playwright Test form the following hierarchy:
@ -20,37 +21,44 @@
Reporter is given a root suite in the [`method: Reporter.onBegin`] method.
## method: Suite.allTests
* since: v1.10
- returns: <[Array]<[TestCase]>>
Returns the list of all test cases in this suite and its descendants, as opposite to [`property: Suite.tests`].
## property: Suite.location
* since: v1.10
- type: ?<[Location]>
Location in the source where the suite is defined. Missing for root and project suites.
## property: Suite.parent
* since: v1.10
- type: ?<[Suite]>
Parent suite, missing for the root suite.
## method: Suite.project
* since: v1.10
- returns: ?<[TestProject]>
Configuration of the project this suite belongs to, or [void] for the root suite.
## property: Suite.suites
* since: v1.10
- type: <[Array]<[Suite]>>
Child suites. See [Suite] for the hierarchy of suites.
## property: Suite.tests
* since: v1.10
- type: <[Array]<[TestCase]>>
Test cases in the suite. Note that only test cases defined directly in this suite are in the list. Any test cases defined in nested [`method: Test.describe`] groups are listed
in the child [`property: Suite.suites`].
## property: Suite.title
* since: v1.10
- type: <[string]>
Suite title.
@ -60,6 +68,7 @@ Suite title.
* Title passed to [`method: Test.describe`] for a group suite.
## method: Suite.titlePath
* since: v1.10
- returns: <[Array]<[string]>>
Returns a list of titles from the root down to this suite.

Просмотреть файл

@ -1,9 +1,11 @@
# class: TestCase
* since: v1.10
* langs: js
`TestCase` corresponds to every [`method: Test.(call)`] call in a test file. When a single [`method: Test.(call)`] is running in multiple projects or repeated multiple times, it will have multiple `TestCase` objects in corresponding projects' suites.
## property: TestCase.annotations
* since: v1.10
- type: <[Array]<[Object]>>
- `type` <[string]> Annotation type, for example `'skip'` or `'fail'`.
- `description` ?<[string]> Optional description.
@ -15,6 +17,7 @@ Annotations are available during test execution through [`property: TestInfo.ann
Learn more about [test annotations](../test-annotations.md).
## property: TestCase.expectedStatus
* since: v1.10
- type: <[TestStatus]<"passed"|"failed"|"timedOut"|"skipped">>
Expected test status.
@ -25,16 +28,19 @@ Expected test status.
See also [`property: TestResult.status`] for the actual status.
## property: TestCase.location
* since: v1.10
- type: <[Location]>
Location in the source where the test is defined.
## method: TestCase.ok
* since: v1.10
- returns: <[boolean]>
Whether the test is considered running fine. Non-ok tests fail the test run with non-zero exit code.
## method: TestCase.outcome
* since: v1.10
- returns: <[TestOutcome]<"skipped"|"expected"|"unexpected"|"flaky">>
Testing outcome for this test. Note that outcome is not the same as [`property: TestResult.status`]:
@ -42,21 +48,25 @@ Testing outcome for this test. Note that outcome is not the same as [`property:
* Test that passes on a second retry is `'flaky'`.
## property: TestCase.parent
* since: v1.10
- type: <[Suite]>
Suite this test case belongs to.
## property: TestCase.repeatEachIndex
* since: v1.10
- type: <[int]>
Contains the repeat index when running in "repeat each" mode. This mode is enabled by passing `--repeat-each` to the [command line](../test-cli.md).
## property: TestCase.results
* since: v1.10
- type: <[Array]<[TestResult]>>
Results for each run of this test.
## property: TestCase.retries
* since: v1.10
- type: <[int]>
The maximum number of retries given to this test in the configuration.
@ -64,16 +74,19 @@ The maximum number of retries given to this test in the configuration.
Learn more about [test retries](../test-retries.md#retries).
## property: TestCase.timeout
* since: v1.10
- type: <[float]>
The timeout given to the test. Affected by [`property: TestConfig.timeout`], [`property: TestProject.timeout`], [`method: Test.setTimeout`], [`method: Test.slow#1`] and [`method: TestInfo.setTimeout`].
## property: TestCase.title
* since: v1.10
- type: <[string]>
Test title as passed to the [`method: Test.(call)`] call.
## method: TestCase.titlePath
* since: v1.10
- returns: <[Array]<[string]>>
Returns a list of titles from the root down to this test.

Просмотреть файл

@ -1,9 +1,11 @@
# class: TestResult
* since: v1.10
* langs: js
A result of a single [TestCase] run.
## property: TestResult.attachments
* since: v1.10
- type: <[Array]<[Object]>>
- `name` <[string]> Attachment name.
- `contentType` <[string]> Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`.
@ -13,22 +15,26 @@ A result of a single [TestCase] run.
The list of files or buffers attached during the test execution through [`property: TestInfo.attachments`].
## property: TestResult.duration
* since: v1.10
- type: <[float]>
Running time in milliseconds.
## property: TestResult.error
* since: v1.10
- type: ?<[TestError]>
First error thrown during test execution, if any. This is equal to the first
element in [`property: TestResult.errors`].
## property: TestResult.errors
* since: v1.10
- type: <[Array]<[TestError]>>
Errors thrown during the test execution.
## property: TestResult.retry
* since: v1.10
- type: <[int]>
When test is retries multiple times, each retry attempt is given a sequential number.
@ -36,31 +42,37 @@ When test is retries multiple times, each retry attempt is given a sequential nu
Learn more about [test retries](../test-retries.md#retries).
## property: TestResult.startTime
* since: v1.10
- type: <[Date]>
Start time of this particular test run.
## property: TestResult.status
* since: v1.10
- type: <[TestStatus]<"passed"|"failed"|"timedOut"|"skipped">>
The status of this test result. See also [`property: TestCase.expectedStatus`].
## property: TestResult.stderr
* since: v1.10
- type: <[Array]<[string]|[Buffer]>>
Anything written to the standard error during the test run.
## property: TestResult.stdout
* since: v1.10
- type: <[Array]<[string]|[Buffer]>>
Anything written to the standard output during the test run.
## property: TestResult.steps
* since: v1.10
- type: <[Array]<[TestStep]>>
List of steps inside this test run.
## property: TestResult.workerIndex
* since: v1.10
- type: <[int]>
Index of the worker where the test was run. If the test was not run a single time, for example when the user interrupted testing, the only result will have a `workerIndex` equal to `-1`.

Просмотреть файл

@ -1,9 +1,11 @@
# class: TestStep
* since: v1.10
* langs: js
Represents a step in the [TestRun].
## property: TestStep.category
* since: v1.10
- type: <[string]>
Step category to differentiate steps with different origin and verbosity. Built-in categories are:
@ -13,41 +15,49 @@ Step category to differentiate steps with different origin and verbosity. Built-
* `test.step` for test.step API calls.
## property: TestStep.duration
* since: v1.10
- type: <[float]>
Running time in milliseconds.
## property: TestStep.location
* since: v1.10
- type: ?<[Location]>
Optional location in the source where the step is defined.
## property: TestStep.error
* since: v1.10
- type: ?<[TestError]>
Error thrown during the step execution, if any.
## property: TestStep.parent
* since: v1.10
- type: ?<[TestStep]>
Parent step, if any.
## property: TestStep.startTime
* since: v1.10
- type: <[Date]>
Start time of this particular test step.
## property: TestStep.steps
* since: v1.10
- type: <[Array]<[TestStep]>>
List of steps inside this step.
## property: TestStep.title
* since: v1.10
- type: <[string]>
User-friendly test step title.
## method: TestStep.titlePath
* since: v1.10
- returns: <[Array]<[string]>>
Returns a list of step titles from the root step down to this step.

Просмотреть файл

@ -74,7 +74,7 @@ class ApiParser {
continue;
}
}
const clazz = new Documentation.Class(extractLangs(node), extractExperimental(node), name, [], extendsName, extractComments(node));
const clazz = new Documentation.Class(extractMetainfo(node), name, [], extendsName, extractComments(node));
this.classes.set(clazz.name, clazz);
}
@ -102,11 +102,11 @@ class ApiParser {
const comments = extractComments(spec);
let member;
if (match[1] === 'event')
member = Documentation.Member.createEvent(extractLangs(spec), extractExperimental(spec), name, returnType, comments);
member = Documentation.Member.createEvent(extractMetainfo(spec), name, returnType, comments);
if (match[1] === 'property')
member = Documentation.Member.createProperty(extractLangs(spec), extractExperimental(spec), name, returnType, comments, !optional);
member = Documentation.Member.createProperty(extractMetainfo(spec), name, returnType, comments, !optional);
if (['method', 'async method', 'optional method', 'optional async method'].includes(match[1])) {
member = Documentation.Member.createMethod(extractLangs(spec), extractExperimental(spec), name, [], returnType, comments);
member = Documentation.Member.createMethod(extractMetainfo(spec), name, [], returnType, comments);
if (match[1].includes('async'))
member.async = true;
if (match[1].includes('optional'))
@ -168,7 +168,7 @@ class ApiParser {
let options = method.argsArray.find(o => o.name === 'options');
if (!options) {
const type = new Documentation.Type('Object', []);
options = Documentation.Member.createProperty({}, false /* experimental */, 'options', type, undefined, false);
options = Documentation.Member.createProperty({ langs: {}, experimental: false, since: 'v1.0' }, 'options', type, undefined, false);
method.argsArray.push(options);
}
const p = this.parseProperty(spec);
@ -189,7 +189,7 @@ class ApiParser {
const name = text.substring(0, typeStart).replace(/\`/g, '').trim();
const comments = extractComments(spec);
const { type, optional } = this.parseType(param);
return Documentation.Member.createProperty(extractLangs(spec), extractExperimental(spec), name, type, comments, !optional);
return Documentation.Member.createProperty(extractMetainfo(spec), name, type, comments, !optional);
}
/**
@ -203,7 +203,7 @@ class ApiParser {
const { name, text } = parseVariable(child.text);
const comments = /** @type {MarkdownNode[]} */ ([{ type: 'text', text }]);
const childType = this.parseType(child);
properties.push(Documentation.Member.createProperty({}, childType.experimental, name, childType.type, comments, !childType.optional));
properties.push(Documentation.Member.createProperty({ langs: {}, experimental: childType.experimental, since: 'v1.0' }, name, childType.type, comments, !childType.optional));
}
const type = Documentation.Type.parse(arg.type, properties);
return { type, optional: arg.optional, experimental: arg.experimental };
@ -275,7 +275,7 @@ function applyTemplates(body, params) {
newChildren.push({
type: node.type,
text: name + argName,
children: template.children.map(c => md.clone(c))
children: [...node.children, ...template.children.map(c => md.clone(c))]
});
}
const nodeIndex = parent.children.indexOf(node);
@ -322,6 +322,18 @@ function parseApi(apiDir, paramsPath) {
return new ApiParser(apiDir, paramsPath).documentation;
}
/**
* @param {MarkdownNode} spec
* @returns {import('./documentation').Metainfo}
*/
function extractMetainfo(spec) {
return {
langs: extractLangs(spec),
since: extractSince(spec),
experimental: extractExperimental(spec)
};
}
/**
* @param {MarkdownNode} spec
* @returns {import('./documentation').Langs}
@ -349,6 +361,21 @@ function extractLangs(spec) {
return {};
}
/**
* @param {MarkdownNode} spec
* @returns {string}
*/
function extractSince(spec) {
for (const child of spec.children) {
if (child.type !== 'li' || child.liType !== 'bullet' || !child.text.startsWith('since:'))
continue;
return child.text.substring(child.text.indexOf(':') + 1).trim();
}
console.error('Missing since: v1.** declaration in node:');
console.error(spec);
process.exit(1);
}
/**
* @param {MarkdownNode} spec
* @returns {boolean}
@ -367,7 +394,7 @@ function extractLangs(spec) {
*/
function childrenWithoutProperties(spec) {
return (spec.children || []).filter(c => {
const isProperty = c.liType === 'bullet' && (c.text.startsWith('langs:') || c.text === 'experimental');
const isProperty = c.liType === 'bullet' && (c.text.startsWith('langs:') || c.text.startsWith('since:') || c.text === 'experimental');
return !isProperty;
});
}

Просмотреть файл

@ -43,12 +43,20 @@ const md = require('../markdown');
/**
* @typedef {function({
* clazz?: Documentation.Class,
* member?: Documentation.Member,
* param?: string,
* option?: string
* }): string} Renderer
*/
* clazz?: Documentation.Class,
* member?: Documentation.Member,
* param?: string,
* option?: string
* }): string} Renderer
*/
/**
* @typedef {{
* langs: Langs,
* since: string,
* experimental: boolean
* }} Metainfo
*/
class Documentation {
/**
@ -168,16 +176,16 @@ class Documentation {
Documentation.Class = class {
/**
* @param {Langs} langs
* @param {boolean} experimental
* @param {Metainfo} metainfo
* @param {string} name
* @param {!Array<!Documentation.Member>} membersArray
* @param {?string=} extendsName
* @param {MarkdownNode[]=} spec
*/
constructor(langs, experimental, name, membersArray, extendsName = null, spec = undefined) {
this.langs = langs;
this.experimental = experimental;
constructor(metainfo, name, membersArray, extendsName = null, spec = undefined) {
this.langs = metainfo.langs;
this.experimental = metainfo.experimental;
this.since = metainfo.since;
this.name = name;
this.membersArray = membersArray;
this.spec = spec;
@ -222,7 +230,7 @@ Documentation.Class = class {
}
clone() {
const cls = new Documentation.Class(this.langs, this.experimental, this.name, this.membersArray.map(m => m.clone()), this.extends, this.spec);
const cls = new Documentation.Class({ langs: this.langs, experimental: this.experimental, since: this.since }, this.name, this.membersArray.map(m => m.clone()), this.extends, this.spec);
cls.comment = this.comment;
return cls;
}
@ -313,18 +321,18 @@ Documentation.Class = class {
Documentation.Member = class {
/**
* @param {string} kind
* @param {Langs} langs
* @param {boolean} experimental
* @param {Metainfo} metainfo
* @param {string} name
* @param {?Documentation.Type} type
* @param {!Array<!Documentation.Member>} argsArray
* @param {MarkdownNode[]=} spec
* @param {boolean=} required
*/
constructor(kind, langs, experimental, name, type, argsArray, spec = undefined, required = true) {
constructor(kind, metainfo, name, type, argsArray, spec = undefined, required = true) {
this.kind = kind;
this.langs = langs;
this.experimental = experimental;
this.langs = metainfo.langs;
this.experimental = metainfo.experimental;
this.since = metainfo.since;
this.name = name;
this.type = type;
this.spec = spec;
@ -410,7 +418,7 @@ Documentation.Member = class {
}
clone() {
const result = new Documentation.Member(this.kind, this.langs, this.experimental, this.name, this.type.clone(), this.argsArray.map(arg => arg.clone()), this.spec, this.required);
const result = new Documentation.Member(this.kind, { langs: this.langs, experimental: this.experimental, since: this.since }, this.name, this.type.clone(), this.argsArray.map(arg => arg.clone()), this.spec, this.required);
result.alias = this.alias;
result.async = this.async;
result.paramOrOption = this.paramOrOption;
@ -418,41 +426,38 @@ Documentation.Member = class {
}
/**
* @param {Langs} langs
* @param {boolean} experimental
* @param {Metainfo} metainfo
* @param {string} name
* @param {!Array<!Documentation.Member>} argsArray
* @param {?Documentation.Type} returnType
* @param {MarkdownNode[]=} spec
* @return {!Documentation.Member}
*/
static createMethod(langs, experimental, name, argsArray, returnType, spec) {
return new Documentation.Member('method', langs, experimental, name, returnType, argsArray, spec);
static createMethod(metainfo, name, argsArray, returnType, spec) {
return new Documentation.Member('method', metainfo, name, returnType, argsArray, spec);
}
/**
* @param {!Langs} langs
* @param {boolean} experimental
* @param {Metainfo} metainfo
* @param {!string} name
* @param {!Documentation.Type} type
* @param {!MarkdownNode[]=} spec
* @param {boolean=} required
* @return {!Documentation.Member}
*/
static createProperty(langs, experimental, name, type, spec, required) {
return new Documentation.Member('property', langs, experimental, name, type, [], spec, required);
static createProperty(metainfo, name, type, spec, required) {
return new Documentation.Member('property', metainfo, name, type, [], spec, required);
}
/**
* @param {Langs} langs
* @param {boolean} experimental
* @param {Metainfo} metainfo
* @param {string} name
* @param {?Documentation.Type=} type
* @param {MarkdownNode[]=} spec
* @return {!Documentation.Member}
*/
static createEvent(langs, experimental, name, type = null, spec) {
return new Documentation.Member('event', langs, experimental, name, type, [], spec);
static createEvent(metainfo, name, type = null, spec) {
return new Documentation.Member('event', metainfo, name, type, [], spec);
}
/**

81
utils/doclint/since.js Normal file
Просмотреть файл

@ -0,0 +1,81 @@
const fs = require('fs');
const path = require('path');
const { ZipFile } = require('../../packages/playwright-core/lib/utils/zipFile');
(async () => {
// Extract API.json
if (!process.env.DRIVERS_DIR) {
console.log('DRIVERS_DIR env should contain downloaded drivers');
process.exit(1);
}
for (const name of fs.readdirSync(process.env.DRIVERS_DIR)) {
const match = name.match(/playwright-(.*).0-linux.zip/);
if (!match)
continue;
const apiName = path.join(process.env.DRIVERS_DIR, `api-${match[1]}.json`);
if (!fs.existsSync(apiName)) {
const zipFile = new ZipFile(path.join(process.env.DRIVERS_DIR, name));
const buffer = await zipFile.read('package/api.json');
fs.writeFileSync(path.join(process.env.DRIVERS_DIR, `api-${match[1]}.json`), buffer);
zipFile.close();
}
}
// Build Since map.
const since = new Map();
for (const name of fs.readdirSync(process.env.DRIVERS_DIR)) {
const match = name.match(/api-(.*).json/);
if (!match)
continue;
const version = match[1];
const json = JSON.parse(fs.readFileSync(path.join(process.env.DRIVERS_DIR, `api-${match[1]}.json`), 'utf-8'));
for (const clazz of json) {
add(since, `# class: ${clazz.name}`, version);
for (const member of clazz.members) {
add(since, `## ${member.async ? 'async ' : ''}${member.kind}: ${clazz.name}.${member.name}`, version);
for (const arg of member.args) {
if (arg.name === 'options') {
for (const option of arg.type.properties)
add(since, `### option: ${clazz.name}.${member.name}.${option.name}`, version);
} else {
add(since, `### param: ${clazz.name}.${member.name}.${arg.name}`, version);
}
}
}
}
}
// Patch docs
for (const name of fs.readdirSync('docs/src/api')) {
const lines = fs.readFileSync(path.join('docs/src/api', name), 'utf-8');
const toPatch = new Map();
for (const line of lines.split('\n')) {
if (!line.startsWith('# class:') && !line.startsWith('## method:') && !line.startsWith('## async method:') && !line.startsWith('## property:') && !line.startsWith('## event:') && !line.startsWith('### param:') && !line.startsWith('### option:'))
continue;
const key = line.includes('=') ? line.substring(0, line.indexOf('=')).trim() : line;
const version = since.get(key);
console.log(key);
if (!version) {
console.log('Not yet released: ' + line);
continue;
}
toPatch.set(line +'\n', line + `\n* since: v${version}\n`);
}
if (toPatch.size) {
let newContent = lines;
for (const [from, to] of toPatch)
newContent = newContent.replace(new RegExp(from, 'g'), to);
fs.writeFileSync(path.join('docs/src/api', name), newContent);
}
}
})();
function add(since, name, version) {
let v = since.get(name);
if (!v || (+v.split('.')[1]) > (+version.split('.')[1]))
since.set(name, version);
}