Check element count

Check element count

Check element count

Assert how many of an element exist on the page

The Check Element Count step lets your automated test verify how many elements matching a selector are present on the current page. Instead of just checking that something exists, this step gives you precision about how many should be visible at a given point in your flow. This is especially useful for list-based content, repeated UI components, search results, or any scenario where quantity matters.

Why element count validation matters

Many areas of your application depend not just on whether something appears, but on how many of them appear. For example:

  • A product list should show the correct number of results

  • A filter should reduce the count of items

  • A table of records should contain a specific number of rows

  • Pagination may be driven by item count

  • Forms with repeated input groups

  • Search results should return expected volumes

By checking the count of elements, you verify that your UI logic produces the right number of items, not just that a single item exists.

What the step does

When you use Check Element Count, your test:

  1. Targets a selector that matches a group of elements

  2. Counts how many elements are currently in the DOM

  3. Compares that count against your expected number

  4. Fails the test if the number does not match

This gives you precise validation of quantity rather than presence alone.

For example:

  • Expect exactly 10 product cards after filtering

  • Assert that there are 3 error messages displayed

  • Verify that a list view contains 5 results

  • Confirm that no items are present before data loads

This makes your automation clearer, more specific, and closer to real user expectations.

Combine with other validations

Count checks are often part of broader validations. For example:

  • After a search action, confirm the expected number of results

  • After applying a filter, check that the count reduces appropriately

  • After removing items, verify the new count reflects the update

  • After pagination, confirm counts on different pages

You can also combine this with:

  • Check Text to validate content inside each element

  • Check Displayed to confirm visibility

  • Wait for Element to synchronise asynchronous rendering

  • Visual regression to capture layout changes

This gives your tests both depth and confidence.

Reliable UI behaviour tests

Counting elements helps catch regressions that simple presence checks miss. Without a count assertion, a test might pass even if too many or too few items render, masking underlying bugs.

By asserting on element counts, you validate not just existence but correctness in volume. This ensures your automation catches subtle UI regressions, giving you reliable insight into how your application behaves across changes.