Store element count

Store element count

Store element count

Store element count

The Store element count step allows you to count how many elements match a specific selector and save that number into the value store for later use in your test.

Instead of simply asserting how many elements exist, this step captures the count as structured data. That means you can reuse it in conditions, comparisons, API calls, or custom logic.

It turns layout information into something you can reason about and act on.

Go beyond simple checks

Counting elements is often the first step in deeper validation.

Common use cases include:

  • Counting products in a category page

  • Measuring how many items are in a basket

  • Capturing the number of search results

  • Verifying pagination behaviour

  • Detecting unexpected duplicates

  • Comparing counts before and after an action

By storing the count rather than just checking it, you unlock more advanced test flows.

For example, you could:

  • Store the number of items in a cart

  • Perform an action such as removing one

  • Store the new count

  • Assert that the value has decreased by one

This creates stronger, more meaningful assertions.

Combine with conditions and branching

Once stored, the element count can be used anywhere in your test:

  • Inside a Condition node

  • In a Stop node

  • Within a custom Run Browser Script

  • As part of a dynamic assertion

  • Passed into API steps

  • Logged with Debug value

This is particularly useful when building adaptive tests that respond to page state rather than assuming fixed conditions.

Improve visibility and maintainability

Storing counts instead of hard-coding expectations helps reduce brittleness.

Instead of writing separate flows for different scenarios, you can:

  • Store a value

  • Compare it dynamically

  • Decide what to do next

This keeps your flows more flexible and reduces duplication, especially when working with branching or complex user journeys.

By converting DOM structure into reusable test data, Store element count helps you build smarter, more scalable automation.