When you call evaluate in puppeteer, an error occurs as follows. 'Evaluation failed: ReferenceError: cov_mjds8ir32 is not defined'
also 'page.$eval' occurs same error
page = await browser.newPage();
await page.goto("https://myurl.com",{timeout: 5000, waitUntil: "networkidle2"});
await page.evaluate(() => {
console.log("log");
});
const userid = 'myid';
page = await browser.newPage();
await page.goto("https://myurl.com",{timeout: 5000, waitUntil: "networkidle2"});
await page.$eval('#input[name=userid]', el => el.value = userid);
Thanks for the answer Yaroslavm. In my case, I had to do it using a template string.
The code below as an example
await page.evaluate(() => {
console.log("log");
});
After making this change, it ran normally.
await page.evaluate(`(async() => {
console.log('1');
})()`);
The reference link is below: https://github.com/puppeteer/puppeteer/issues/1665#issuecomment-354241717