Selector.exists Property

Returns true if the Selector query matches at least one element.

Selector().exists → Promise<boolean>

Selectors can match any number of DOM elements — from zero to infinity. Use the exists property to determine if matching elements exist.

import { Selector } from 'testcafe';

fixture`Selector.exists`
    .page`http://devexpress.github.io/testcafe/example/`;

test('Button with id "submit-button" exists', async t => {
    const submitButtonExists = Selector('#submit-button').exists;

    await t.expect(submitButtonExists).ok();
});

Use the count property to determine the number of matches.