Selector.count Property

Returns the number of elements that match the selector.

Selector().count → Promise<number>

Selectors can return a single matching DOM element on the page, multiple elements or nothing. Use the count property to determine the number of matching elements.

import { Selector } from 'testcafe';


test('Check count of the columns', async t => {
    const osCount = Selector('.column.col-2 label').count;

    await t.expect(osCount).eql(3);

To check whether matching elements exist, use the exists property.