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';


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

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

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