How-to
Text assert (toHaveText)
Text assert (toHaveText)
Asserts that Target text matches Value.
Step model
action_name | toHaveText |
| Group | Expect |
| Target | Required |
| Value | Required (text) |
| expected_value | Unused |
| TEST_ACCOUNT | Allowed |
| Do not confuse with | toBeVisible, toHaveAttribute |
Target/Value facts match the source-of-truth catalog and Autotest step.
Prerequisites
- The element with text exists.
Steps
- Add a
toHaveTextstep. - Set Target.
- Put the expected text in Value.
- Save.
The step is stored on the autotest. Next - neighbouring steps or autotest run creation.
Examples
Card title
Fields in the UI:
| Field | Value |
|---|---|
action_name | toHaveText |
| Target | kind ROLE, value heading, name Profile |
| Value | Profile |
| value_source_type | INLINE |
Step JSON fragment (copy-paste):
json
{
"action_name": "toHaveText",
"target": {
"kind": "ROLE",
"value": "heading",
"name": "Profile"
},
"value_text": "Profile",
"value_source_type": "INLINE"
}Common mistakes
- Match the exact text including spaces and case as the page renders it.
Screenshots
Screenshots of the step form for toHaveText will be added here in a later pass.
Did this page help?