I've created a custom attribute called data-testId and I am trying to reach to using puppeteer and then do a click action, but for some reason, I'm unable to get this element and facing with errors. I've tried these 2 options:
const element = await page.$('[data-testId="testid-button-refresh"]');
await page.click(element, { clickCount: 1 });
and this:
const refreshButton = await page.evaluateHandle(() => {
return document.querySelector('[data-testId=testid-button-refresh]').value;
});
await page.click(element, { clickCount: 1 });
On them both I am getting this error:
JSHandles can be evaluated only in the context they were created!
What I am doing wrong? and what does it means this error?