How-to
Class assert (toHaveClass)
Class assert (toHaveClass)
Expect assertion: the Target has the class from Value.
Step model
action_name | toHaveClass |
| Group | Expect |
| Target | Required |
| Value | Required (class_name) |
| expected_value | Unused |
| TEST_ACCOUNT | Allowed |
| Do not confuse with | toHaveAttribute, toHaveCSS |
Target/Value facts match the source-of-truth catalog and Autotest step.
Prerequisites
- The class name is known and stable.
Steps
- Add a
toHaveClassstep. - Set Target.
- Enter the class name in Value.
- Save.
The step is stored on the autotest. Next - neighbouring steps or autotest run creation.
Examples
Primary button
Fields in the UI:
| Field | Value |
|---|---|
action_name | toHaveClass |
| Target | kind ROLE, value button, name Save |
| Value | is-primary |
| value_source_type | INLINE |
Step JSON fragment (copy-paste):
json
{
"action_name": "toHaveClass",
"target": {
"kind": "ROLE",
"value": "button",
"name": "Save"
},
"value_text": "is-primary",
"value_source_type": "INLINE"
}Common mistakes
- Value is the class name, not the whole class attribute and not a CSS property.
Screenshots
Screenshots of the step form for toHaveClass will be added here in a later pass.
Did this page help?