Selector.count Property

Returns the number of elements that match the Selector query.

Selector().count → Promise<number>

Selectors can match any number of DOM elements — from zero to infinity. 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);

Use the exists property to check whether matching elements exist.