Selector Options

You can pass the following options to the Selector constructor.

You can also overwrite the options you have specified before.


Type: Object

If you need to call a selector from a Node.js callback, assign the current test controller to the boundTestRun option.

For details, see Calling Selectors from Node.js Callbacks.


Type: Number

The amount of time, in milliseconds, allowed for an element returned by the selector to appear in the DOM before the test fails.

If the visibilityCheck option is enabled, the element then must become visible within the timeout.

Default value: timeout specified by using the API method or the selector-timeout command line option.


Type: Boolean

true to additionally require the returned element to become visible within options.timeout.

Default value: false

Overwriting Options

You can overwrite selector options by using the selector's with function.

selector.with( options ) → Selector

with returns a new selector with a different set of options that includes options from the original selector and new options that overwrite the original ones.

The sample below shows how to overwrite the selector options so that it waits for the selected element to become visible.

import { Selector } from 'testcafe';

const elementWithId = Selector(id => document.getElementById(id));

fixture `My fixture`
    .page ``;

test('My Test', async t => {
    const visibleElementWithId = elementWithId.with({
        visibilityCheck: true

    const visibleButton = await visibleElementWithId('submit-button');