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#
API reference#
Inner text#
API reference#
Attribute value#
Checkbox state#
API reference#
JS expression#
API reference#
Inner HTML#
API reference#
Visibility#
API reference#
Enabled state#
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.
#
API reference- page.evaluate(pageFunction[, arg])
- page.$eval(selector, pageFunction[, arg])
- page.$$eval(selector, pageFunction[, arg])
- frame.evaluate(pageFunction[, arg])
- frame.$eval(selector, pageFunction[, arg])
- frame.$$eval(selector, pageFunction[, arg])
- elementHandle.$eval(selector, pageFunction[, arg])
- elementHandle.$$eval(selector, pageFunction[, arg])
- [EvaluationArgument]