How can I console.log something inside the page.evaluate, passing it to node and using it during the evaluation of the page?
I actually want to log
I am trying to share my workaround if it helps anybody in future.
Print all the console outputs to stdout including warning, error, log:
page = await browser.newPage();
page.on("console", (consoleObj) => console.log(consoleObj.text()));
Print everything except warning:
page.on('console', consoleObj => {
if (consoleObj.type() !== 'warning') {
console.log(consoleObj.text());
}
})
Print only logs (Ex: console.logs
).
page.on('console', consoleObj => {
if (consoleObj.type() === 'log') {
console.log(consoleObj.text());
}
})
The last one helped me more to debug efficiently.