How-to

Element count assert (toHaveCount)

Element count assert (toHaveCount) ​

Expect assertion: the Target locator matches the given number of elements. Value is an integer from 0 with no leading zeros and at most 9 digits.

Step model ​

action_nametoHaveCount
GroupExpect
TargetRequired
ValueRequired (count)
expected_valueUnused
TEST_ACCOUNTAllowed
Do not confuse withtoBeVisible

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

Prerequisites ​

  1. The locator is meant to match several elements. For one element, prefer an exact locator and toBeVisible.

Steps ​

  1. Add a toHaveCount step.
  2. Set Target.
  3. Enter the count in Value, for example 3.
  4. Save.

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

Examples ​

Three rows ​

Fields in the UI:

FieldValue
action_nametoHaveCount
Targetkind ROLE, value row
Value3
value_source_typeINLINE

Step JSON fragment (copy-paste):

json
{
  "action_name": "toHaveCount",
  "target": {
    "kind": "ROLE",
    "value": "row"
  },
  "value_text": "3",
  "value_source_type": "INLINE"
}

Common mistakes ​

  • 03 and an empty string are rejected. Zero is written as 0.

Screenshots ​

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

Version 1.0.0 · Last updated 2026-10-03

Did this page help?