Selector.exists Property

Determines if at least one matching element exists.

Selector().exists → Promise<boolean>

Selector can return a single matching DOM element on the page, multiple elements, or nothing. Use the exists property to check whether matching elements exist.

import { Selector } from 'testcafe';

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

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

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

To determine the number of matching elements, use the count property.