ClientFunction.with Method

Overwrites client function options.

clientFunction.with(options) → ClientFunction

The with method returns a new client function with a different set of options. You can use the with method to override or append client function options and dependencies.


import { ClientFunction, Selector } from 'testcafe';

const option = Selector('option');

const secondOption = option.nth(1);

const getSecondOptionHTML = ClientFunction(() => option().innerHTML, {
    dependencies: { option: secondOption },

const thirdOption = option.nth(2);

const getThirdOptionHTML = getSecondOptionHTML.with({
    dependencies: { option: thirdOption },