How-to

Class assert (toHaveClass)

Class assert (toHaveClass) ​

Expect assertion: the Target has the class from Value.

Step model ​

action_nametoHaveClass
GroupExpect
TargetRequired
ValueRequired (class_name)
expected_valueUnused
TEST_ACCOUNTAllowed
Do not confuse withtoHaveAttribute, toHaveCSS

Target/Value facts match the source-of-truth catalog and Autotest step.

Prerequisites ​

  1. The class name is known and stable.

Steps ​

  1. Add a toHaveClass step.
  2. Set Target.
  3. Enter the class name in Value.
  4. Save.

The step is stored on the autotest. Next - neighbouring steps or autotest run creation.

Examples ​

Primary button ​

Fields in the UI:

FieldValue
action_nametoHaveClass
Targetkind ROLE, value button, name Save
Valueis-primary
value_source_typeINLINE

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.

Version 1.0.0 · Last updated 2026-10-03

Did this page help?