I am trying to check if a button is disabled in testcafe. Below is my code:
test('Verify button is inactive after disabling button functionality', async (browser) => {
await browser.wait(5000);
const button = '[data-testid=Button]';
await browser.click(button);
const buttonActive = ClientFunction(() => {
const button = '[data-testid=Button]';
const buttonStatus = button.disabled;
console.log(buttonStatus);
return buttonStatus;
});
await browser.expect(buttonActive()).eql(false);
});
this reports an error – TypeError: Cannot read properties of null (reading ‘disabled’)
I tried querying from browser console and it worked –
document.querySelector('[data-testid=Button]').disabled
false
Any idea why it is not working?