ConsoleMessage objects are dispatched by page via the
page.on('console') event. For each console
messages logged in the page there will be corresponding event in the Playwright context.
// Listen for all console logs page.on('console', msg=>console.log(msg.text()));
// Listen for all console events and handle errors page.on('console', msg=> { if (msg.type() === 'error') console.log(`Error text: "${msg.text()}"`); });
// Get the next console log constmsgPromise = page.waitForEvent('console'); awaitpage.evaluate(() => { console.log('hello', 42, { foo:'bar' }); // Issue console.log inside the page }); constmsg = awaitmsgPromise;
ConsoleMessage objects are dispatched by page via the page.on('console') event. For each console messages logged in the page there will be corresponding event in the Playwright context.