Version: 1.8.0
Assertions
Playwright provides convenience APIs for common tasks, like reading the text content of an element. These APIs can be used in your test assertions.
- Text content
- Inner text
- Attribute value
- Checkbox state
- JS expression
- Inner HTML
- Visibility
- Enabled state
- Custom assertions
#
Text content- Sync
- Async
#
API reference#
Inner text- Sync
- Async
#
API reference#
Attribute value- Sync
- Async
#
Checkbox state- Sync
- Async
#
API reference#
JS expression- Sync
- Async
#
API reference#
Inner HTML- Sync
- Async
#
API reference#
Visibility- Sync
- Async
#
API reference#
Enabled state- Sync
- Async
#
API reference#
Custom assertionsWith Playwright, you can also write custom JavaScript to run in the context of the browser. This is useful in situations where you want to assert for values that are not covered by the convenience APIs above.
- Sync
- Async
#
API reference- page.evaluate(expression, **kwargs)
- page.eval_on_selector(selector, expression, **kwargs)
- page.eval_on_selector_all(selector, expression, **kwargs)
- frame.evaluate(expression, **kwargs)
- frame.eval_on_selector(selector, expression, **kwargs)
- frame.eval_on_selector_all(selector, expression, **kwargs)
- element_handle.eval_on_selector(selector, expression, **kwargs)
- element_handle.eval_on_selector_all(selector, expression, **kwargs)
- [EvaluationArgument]