How-to

Attribute assert (toHaveAttribute)

Attribute assert (toHaveAttribute)

Asserts that Target has the attribute named in Value. The expected attribute value goes in expected_value when you set one.

Step model

action_nametoHaveAttribute
GroupExpect
TargetRequired
ValueRequired (attribute_name)
expected_valueUsed
TEST_ACCOUNTAllowed
Do not confuse withtoHaveText, toBeVisible

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

Prerequisites

  1. The element with the attribute is on the page.

Steps

  1. Add a toHaveAttribute step.
  2. Set Target.
  3. In Value put the attribute name (href, src, aria-label).
  4. Optionally fill Expected value (expected_value).
  5. Save.

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

Examples

Fields in the UI:

FieldValue
action_nametoHaveAttribute
Targetkind ROLE, value link, name Docs
Valuehref
value_source_typeINLINE
expected_value/docs/

Step JSON fragment (copy-paste):

json
{
  "action_name": "toHaveAttribute",
  "target": {
    "kind": "ROLE",
    "value": "link",
    "name": "Docs"
  },
  "value_text": "href",
  "expected_value": "/docs/",
  "value_source_type": "INLINE"
}

Common mistakes

  • Value holds the attribute name, not its contents.
  • Put the contents in expected_value.

Screenshots

Screenshots of the step form for toHaveAttribute will be added here in a later pass.

Version 1.0.0 · Last updated 2026-09-11

Did this page help?