2021-01-01 15:17:27 -08:00
---
id: actionability
title: "Actionability"
---
2020-12-30 18:04:51 -08:00
2021-01-01 15:17:27 -08:00
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.
2020-06-15 13:40:55 -07:00
2021-01-01 15:17:27 -08:00
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` .
2020-06-15 13:40:55 -07:00
2021-01-01 15:17:27 -08:00
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.
2020-06-15 13:40:55 -07:00
| Actions | Performed checks |
| ------ | ------- |
2021-01-03 08:47:29 -08:00
| `check()` < br ></ br > `click()` < br ></ br > `dblclick()` < br ></ br > `tap()` < br ></ br > `uncheck()` | [Visible]< br ></ br > [Stable]< br ></ br > [Enabled]< br ></ br > [Receiving Events]< br ></ br > [Attached] |
| `hover()` | [Visible]< br ></ br > [Stable]< br ></ br > [Receiving Events]< br ></ br > [Attached] |
| `fill()` | [Visible]< br ></ br > [Enabled]< br ></ br > [Editable]< br ></ br > [Attached] |
| `dispatchEvent()` < br ></ br > `focus()` < br ></ br > `press()` < br ></ br > `setInputFiles()` < br ></ br > `selectOption()` < br ></ br > `type()` | [Attached] |
| `scrollIntoViewIfNeeded()` < br ></ br > `screenshot()` | [Visible]< br ></ br > [Stable]< br ></ br > [Attached] |
| `selectText()` | [Visible]< br ></ br > [Attached] |
| `getAttribute()` < br ></ br > `innerText()` < br ></ br > `innerHTML()` < br ></ br > `textContent()` | [Attached] |
2020-06-15 13:40:55 -07:00
2020-06-19 00:04:21 +02:00
### Visible
2020-06-15 13:40:55 -07:00
2021-01-01 15:17:27 -08: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.
2020-06-15 13:40:55 -07:00
### Stable
2021-01-01 15:17:27 -08:00
Element is considered stable when it has maintained the same bounding box for at least two consecutive animation frames.
2020-06-15 13:40:55 -07:00
### Enabled
2021-01-01 15:17:27 -08:00
Element is considered enabled when it is not a `<button>` , `<select>` or `<input>` with a `disabled` property set.
2020-06-15 13:40:55 -07:00
### Editable
Element is considered editable when it does not have `readonly` property set.
### Receiving events
2021-01-01 15:17:27 -08: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)` .
2020-06-15 13:40:55 -07:00
### Attached
2021-01-01 15:17:27 -08:00
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.
2020-06-15 13:40:55 -07:00
2021-01-01 15:17:27 -08:00
Attached check differs between selector-based and handle-based actions, like `page.click(selector, options)` as opposite to `elementHandle.click(options)` :
- For selector-based actions, Playwright first waits for an element matching `selector` to be attached to the DOM, and then checks that element is still attached before performing the action. If element was detached, the action is retried from the start.
2020-06-24 10:16:54 -07:00
- For handle-based actions, Playwright throws if the element is not attached.
2020-06-15 13:40:55 -07:00
2021-01-01 15:17:27 -08:00
For example, consider a scenario where Playwright will click `Sign Up` button regardless of when the `page.click()` call was made:
2020-06-15 13:40:55 -07:00
- page is checking that user name is unique and `Sign Up` button is disabled;
2021-01-01 15:17:27 -08:00
- after checking with the server, the disabled `Sign Up` button is replaced with another one that is now enabled.
2020-06-15 13:40:55 -07:00
[Visible]: #visible "Visible"
[Stable]: #stable "Stable"
[Enabled]: #enabled "Enabled"
[Editable]: #editable "Editable"
[Receiving Events]: #receiving -events "Receiving Events"
[Attached]: #attached "Attached"
2021-01-03 08:47:29 -08:00
2021-01-01 15:17:27 -08:00
[Playwright]: api/class-playwright.md "Playwright"
[Browser]: api/class-browser.md "Browser"
[BrowserContext]: api/class-browsercontext.md "BrowserContext"
[Page]: api/class-page.md "Page"
[Frame]: api/class-frame.md "Frame"
[ElementHandle]: api/class-elementhandle.md "ElementHandle"
[JSHandle]: api/class-jshandle.md "JSHandle"
[ConsoleMessage]: api/class-consolemessage.md "ConsoleMessage"
[Dialog]: api/class-dialog.md "Dialog"
[Download]: api/class-download.md "Download"
[Video]: api/class-video.md "Video"
[FileChooser]: api/class-filechooser.md "FileChooser"
[Keyboard]: api/class-keyboard.md "Keyboard"
[Mouse]: api/class-mouse.md "Mouse"
[Touchscreen]: api/class-touchscreen.md "Touchscreen"
[Request]: api/class-request.md "Request"
[Response]: api/class-response.md "Response"
[Selectors]: api/class-selectors.md "Selectors"
[Route]: api/class-route.md "Route"
[WebSocket]: api/class-websocket.md "WebSocket"
[TimeoutError]: api/class-timeouterror.md "TimeoutError"
[Accessibility]: api/class-accessibility.md "Accessibility"
[Worker]: api/class-worker.md "Worker"
[BrowserServer]: api/class-browserserver.md "BrowserServer"
[BrowserType]: api/class-browsertype.md "BrowserType"
[Logger]: api/class-logger.md "Logger"
[ChromiumBrowser]: api/class-chromiumbrowser.md "ChromiumBrowser"
[ChromiumBrowserContext]: api/class-chromiumbrowsercontext.md "ChromiumBrowserContext"
[ChromiumCoverage]: api/class-chromiumcoverage.md "ChromiumCoverage"
[CDPSession]: api/class-cdpsession.md "CDPSession"
[FirefoxBrowser]: api/class-firefoxbrowser.md "FirefoxBrowser"
[WebKitBrowser]: api/class-webkitbrowser.md "WebKitBrowser"
2020-12-30 18:04:51 -08:00
[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array"
[Buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer "Buffer"
[ChildProcess]: https://nodejs.org/api/child_process.html "ChildProcess"
[Element]: https://developer.mozilla.org/en-US/docs/Web/API/element "Element"
[Error]: https://nodejs.org/api/errors.html#errors_class_error "Error"
2021-01-01 15:17:27 -08:00
[Evaluation Argument]: ./core-concepts.md#evaluationargument "Evaluation Argument"
2020-12-30 18:04:51 -08:00
[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map"
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object"
[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise"
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp "RegExp"
[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"
[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail"
[URL]: https://nodejs.org/api/url.html "URL"
[USKeyboardLayout]: ../src/usKeyboardLayout.ts "USKeyboardLayout"
[UnixTime]: https://en.wikipedia.org/wiki/Unix_time "Unix Time"
[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean"
[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function "Function"
[iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols "Iterator"
[null]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null"
[number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number"
[origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin "Origin"
[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"
[Read able]: https://nodejs.org/api/stream.html#stream_class_stream_readable "Readable"
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string"
[xpath]: https://developer.mozilla.org/en-US/docs/Web/XPath "xpath"