Skip to content

Commit fd9b103

Browse files
authored
docs: add actionability doc (microsoft#2577)
1 parent f2c47b1 commit fd9b103

File tree

5 files changed

+83
-87
lines changed

5 files changed

+83
-87
lines changed

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- [Loading a popup](./loading.md#loading-a-popup)
5555
- [Client-side redirects](./loading.md#unusual-client-side-redirects)
5656
- [Navigation after a timeout](./loading.md#click-triggers-navigation-after-a-timeout)
57+
1. [Actionability](./actionability.md)
5758
1. [Continuous Integration](./ci.md)
5859
- [Docker](./ci.md#docker)
5960
- [GitHub Actions](./ci.md#github-actions)

docs/actionability.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Actionability
2+
3+
Playwright does a range of actionability checks on the elements before performing certain actions. These checks ensure that action behaves as expected, for example Playwright does not click on a disabled button.
4+
5+
Playwright waits until all the relevant actionability checks pass before performing an action. This means that action will fail with `TimeoutError` if checks do not pass within the specified `timeout`.
6+
7+
Some actions like `page.click()` support `{force: true}` option that disable non-essential actionability checks, for example passing `force` to `click()` method will not check that the target element actually receives click events.
8+
9+
| Actions | Performed checks |
10+
| ------ | ------- |
11+
| `check()`<br>`click()`<br>`dblclick()`<br>`hover()`<br>`uncheck()` | [Visible]<br>[Stable]<br>[Enabled]<br>[Receiving Events]<br>[Attached]|
12+
| `fill()` | [Visible]<br>[Enabled]<br>[Editable]<br>[Attached]|
13+
| `focus()`<br>`press()`<br>`setInputFiles()`<br>`selectOption()`<br>`type()` | [Attached]|
14+
| `selectText()` | [Visible] |
15+
| `dispatchEvent()`<br>`scrollIntoViewIfNeeded()` | -- |
16+
| `getAttribute()`<br>`innerText()`<br>`innerHTML()`<br>`textContent()` | [Attached]|
17+
18+
[Attached] check is only performed during selector-based actions.
19+
20+
### Visibile
21+
22+
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.
23+
24+
### Stable
25+
26+
Element is considered stable when it has maintanined the same bounding box for at least two consecutive animation frames.
27+
28+
### Enabled
29+
30+
Element is considered enabled when it is not a `<button>`, `<select>` or `<input>` with a `disabled` property set.
31+
32+
### Editable
33+
34+
Element is considered editable when it does not have `readonly` property set.
35+
36+
### Receiving events
37+
38+
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)`.
39+
40+
### Attached
41+
42+
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.
43+
44+
Attached check is performed during a selector-based action, like `page.click(selector, options)` as opposite to `elementHandle.click(options)`.
45+
46+
For example, consider a scenario where Playwright will click `Sign Up` button regardless of when the `page.click()` call was made:
47+
- page is checking that user name is unique and `Sign Up` button is disabled;
48+
- after checking with the server, the disabled `Sign Up` button is replaced with another one that is now enabled.
49+
50+
[Visible]: #visible "Visible"
51+
[Stable]: #stable "Stable"
52+
[Enabled]: #enabled "Enabled"
53+
[Editable]: #editable "Editable"
54+
[Receiving Events]: #receiving-events "Receiving Events"
55+
[Attached]: #attached "Attached"

0 commit comments

Comments
 (0)