2021-01-02 02:17:27 +03:00
---
id: actionability
2021-01-18 08:09:40 +03:00
title: "Auto-waiting"
2021-01-02 02:17:27 +03:00
---
2020-12-31 05:04:51 +03:00
2021-01-18 08:09:40 +03:00
Playwright performs a range of actionability checks on the elements before making actions to ensure these actions
behave as expected. It auto-waits for all the relevant checks to pass and only then performs the requested action. If the required checks do not pass within the given `timeout` , action fails with the `TimeoutError` .
2020-12-31 05:04:51 +03:00
2021-01-18 08:09:40 +03:00
For example, for [`method: Page.click`], Playwright will ensure that:
- element is [Attached] to the DOM
- element is [Visible]
- element is [Stable], as in not animating or completed animation
- element [Receives Events], as in not obscured by other elements
- element is [Enabled]
2021-01-06 22:59:29 +03:00
2021-01-18 08:09:40 +03:00
Here is the complete list of actionability checks performed for each action:
2021-01-06 22:59:29 +03:00
2021-01-18 08:09:40 +03:00
| Action | [Attached] | [Visible] | [Stable] | [Receives Events] | [Enabled] | [Editable] |
2021-01-06 22:59:29 +03:00
| :- | :-: | :-: | :-: | :-: | :-: | :-: |
2021-01-07 07:02:51 +03:00
| check | Yes | Yes | Yes | Yes | Yes | - |
| click | Yes | Yes | Yes | Yes | Yes | - |
| dblclick | Yes | Yes | Yes | Yes | Yes | - |
2021-08-30 06:00:40 +03:00
| setChecked | Yes | Yes | Yes | Yes | Yes | - |
2021-01-07 07:02:51 +03:00
| tap | Yes | Yes | Yes | Yes | Yes | - |
| uncheck | Yes | Yes | Yes | Yes | Yes | - |
| hover | Yes | Yes | Yes | Yes | - | - |
2022-04-23 23:48:36 +03:00
| scrollIntoViewIfNeeded | Yes | - | Yes | - | - | - |
2021-01-07 07:02:51 +03:00
| screenshot | Yes | Yes | Yes | - | - | - |
| fill | Yes | Yes | - | - | Yes | Yes |
| selectText | Yes | Yes | - | - | - | - |
| dispatchEvent | Yes | - | - | - | - | - |
| focus | Yes | - | - | - | - | - |
| getAttribute | Yes | - | - | - | - | - |
| innerText | Yes | - | - | - | - | - |
| innerHTML | Yes | - | - | - | - | - |
| press | Yes | - | - | - | - | - |
| setInputFiles | Yes | - | - | - | - | - |
2022-07-11 21:04:34 +03:00
| selectOption | Yes | Yes | - | - | Yes | - |
2021-01-07 07:02:51 +03:00
| textContent | Yes | - | - | - | - | - |
| type | Yes | - | - | - | - | - |
2021-01-06 22:59:29 +03:00
2021-01-18 08:09:40 +03:00
< br / >
## Forcing actions
Some actions like [`method: Page.click`] support `force` option that disables non-essential actionability checks,
for example passing truthy `force` to [`method: Page.click`] method will not check that the target element actually
receives click events.
## Assertions
You can check the actionability state of the element using one of the following methods as well. This is typically
not necessary, but it helps writing assertive tests that ensure that after certain actions, elements reach
actionable state:
2021-01-17 01:37:13 +03:00
- [`method: ElementHandle.isChecked`]
- [`method: ElementHandle.isDisabled`]
- [`method: ElementHandle.isEditable`]
- [`method: ElementHandle.isEnabled`]
- [`method: ElementHandle.isHidden`]
- [`method: ElementHandle.isVisible`]
- [`method: Page.isChecked`]
- [`method: Page.isDisabled`]
- [`method: Page.isEditable`]
- [`method: Page.isEnabled`]
- [`method: Page.isHidden`]
- [`method: Page.isVisible`]
2022-07-12 23:39:31 +03:00
- [`method: Locator.isChecked`]
- [`method: Locator.isDisabled`]
- [`method: Locator.isEditable`]
- [`method: Locator.isEnabled`]
- [`method: Locator.isHidden`]
- [`method: Locator.isVisible`]
2020-12-31 05:04:51 +03:00
2021-01-18 08:09:40 +03:00
< br / >
## Attached
Element is considered attached when it is [connected ](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected ) to a Document or a ShadowRoot.
## Visible
2020-12-31 05:04:51 +03:00
Element is considered visible when it has non-empty bounding box and does not have `visibility:hidden` computed style. Note that elements of zero size or with `display:none` are not considered visible.
2021-01-18 08:09:40 +03:00
## Stable
2020-12-31 05:04:51 +03:00
Element is considered stable when it has maintained the same bounding box for at least two consecutive animation frames.
2021-01-18 08:09:40 +03:00
## Enabled
2020-12-31 05:04:51 +03:00
2022-05-25 22:05:17 +03:00
Element is considered enabled unless it is a `<button>` , `<select>` , `<input>` or `<textarea>` with a `disabled` property.
2020-12-31 05:04:51 +03:00
2021-01-18 08:09:40 +03:00
## Editable
2020-12-31 05:04:51 +03:00
2021-01-08 23:27:54 +03:00
Element is considered editable when it is [enabled] and does not have `readonly` property set.
2020-12-31 05:04:51 +03:00
2021-01-18 08:09:40 +03:00
## Receives Events
2020-12-31 05:04:51 +03:00
Element is considered receiving pointer events when it is the hit target of the pointer event at the action point. For example, when clicking at the point `(10;10)` , Playwright checks whether some other element (usually an overlay) will instead capture the click at `(10;10)` .
2021-01-06 22:59:29 +03:00
For example, consider a scenario where Playwright will click `Sign Up` button regardless of when the [`method: Page.click`] call was made:
2020-12-31 05:04:51 +03:00
- page is checking that user name is unique and `Sign Up` button is disabled;
- after checking with the server, the disabled `Sign Up` button is replaced with another one that is now enabled.
[Visible]: #visible "Visible"
[Stable]: #stable "Stable"
[Enabled]: #enabled "Enabled"
[Editable]: #editable "Editable"
2021-01-18 08:09:40 +03:00
[Receives Events]: #receives -events "Receives Events"
2020-12-31 05:04:51 +03:00
[Attached]: #attached "Attached"