Listen for the page’s console event and call args() on the resulting ConsoleMessage. The method returns an array of Puppeteer handles—not ordinary Node.js values—so use jsonValue() to copy serializable arguments into Node.js.
Read the individual console arguments
Register a listener on the Puppeteer Page. Each event supplies a ConsoleMessage; its args() method returns the arguments as handles to values in the browser page’s JavaScript context.
As an Amazon Associate I earn from qualifying purchases.
page.on('console', msg => {
console.log(msg.args());
});
The event can be emitted for different console methods, including console.log and console.dir, and also for page warnings and errors. Check Puppeteer’s ConsoleMessage API and the PageEvent documentation for the event and its payload.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteConvert serializable arguments to Node.js values
For values that can be serialized, call jsonValue() on each handle. Since it returns a promise, await all the conversions before using the resulting array.
#1 Best Overall
page.on('console', async msg => {
const values = await Promise.all(
msg.args().map(arg => arg.jsonValue())
);
console.log(values);
});
await page.evaluate(() => console.log(5, 'hello', { foo: 'bar' }));
Here the page logs three separate arguments. The listener resolves their handles and logs the resulting values in Node.js. Puppeteer’s API index describes JSHandle as a reference to a JavaScript object in the page context. A handle is not itself a plain Node.js object.
Choose between arguments and formatted text
Use msg.text() when the formatted message is sufficient. Use msg.args() when you need to preserve the arguments as separate values—for example, to distinguish a number from a string or inspect an object rather than only its displayed message.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
page.on('console', async msg => {
const args = await Promise.all(
msg.args().map(arg => arg.jsonValue())
);
console.log({
type: msg.type(),
text: msg.text(),
args,
});
});
For additional diagnostics, ConsoleMessage also exposes type(), location(), and stackTrace(). See the ConsoleMessage API reference for these methods.
Free tools Windows power users keep installed
One-click scans. No signup required.
Handle objects that do not serialize as expected
jsonValue() is suitable for ordinary serializable values, but do not assume every browser-side object can be copied intact into Node.js. If you need selected properties from a complex value, keep its handle and evaluate against it in the page context, or select the needed data in the page before returning it. Puppeteer’s Page documentation covers page evaluation.
Rank #3
For example, when logging a browser object, choose the fields you need instead of expecting the full object—including browser-specific or non-serializable state—to round-trip as a plain Node.js object.
Avoid missing early console messages
Attach the listener before the action that can emit the message. If application code logs during navigation or initialization, registering afterward can miss that event.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
page.on('console', async msg => {
const args = await Promise.all(msg.args().map(arg => arg.jsonValue()));
console.log(msg.type(), args);
});
await page.goto('https://example.com');
The exact timing depends on when the page runs its code; registering first ensures the handler is in place before navigation begins.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Filter by message type when needed
The console event is not limited to calls to console.log. It may also represent warnings and errors. Inspect msg.type() and filter in the handler if you only want a particular category.
Best Value
page.on('console', async msg => {
if (msg.type() !== 'log') return;
const args = await Promise.all(msg.args().map(arg => arg.jsonValue()));
console.log(args);
});
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common problems and fixes
- You see a message string but not separate values:
msg.text()provides the message text. Usemsg.args()to access the individual arguments. - The output contains handles rather than usable values: resolve serializable arguments with
jsonValue(), typically usingPromise.allfor the array. - An argument does not become the expected plain object: it may not be suitable for serialization as-is. Keep the handle and inspect selected fields in the page context.
- Startup messages are missing: install the
consolelistener before navigation or other code that triggers them. - Warnings or errors are reaching a log-only handler: check
msg.type()and filter for the message categories you intend to handle.
Or skip the browser setup
If you need a screenshot rather than console arguments, ScreenshotNeo can return an image or PDF from one request. It does not retrieve Puppeteer console arguments; use the Puppeteer listener above for that. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.
Example request (see the ScreenshotNeo API documentation):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Sign up for the free plan: 1,000 screenshots a month, no card required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




