How can I output console logs from page.evaluate to local terminal?
await page.evaluate(() => {
console.log("test"); // <-- I want this message to show in my local terminal
I am running my code locally on a MacOS computer.
The following solutions I have found in github issues have not worked:
solution 1
const browser = await puppeteer.launch({
'args': ['--disable-dev-shm-usage', '--disable-software-rasterizer'],
dumpio: true
});
// output:
// ERROR:gpu_process_transport_factory.cc(967)] Lost UI shared context.
solution 2
const browser = await puppeteer.launch({
'args': ['--disable-dev-shm-usage', '--disable-software-rasterizer']
});
page.on('console', msg => {
for (let i = 0; i < msg.args.length; ++i)
console.log(`${i}: ${msg.args[i]}`);
});
// output:
// nothing