Skip to content Skip to sidebar Skip to footer

TestCafe ClientFunction TypeError Error As Document Is Undefined

I can successfully execute the following .click: const clickMockContinueButton = ClientFunction(() => document.getElementsByName('paymentGatewayIframeReturnSubmit')[0].click())

Solution 1:

I can't reproduce the "TypeError" issue with your information. My test.js:

import { Selector, ClientFunction } from 'testcafe';

fixture `My fixture`
    .page `https://google.com/`;

const clickInput = ClientFunction(() => document.getElementsByName('q')[0].click())

test('test', async t => {
    await clickInput(); 
});

TestCafe version: 1.3.3

Command: testcafe chrome test.js

Result:

Running tests in:
- Chrome 75.0.3770 / Windows 10.0.0

My fixture
√ test


1 passed (3s)

I suggest you use t.click( selector [, options] ) in your test.


Post a Comment for "TestCafe ClientFunction TypeError Error As Document Is Undefined"