The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Listen for the page’s console event and call text() on the ConsoleMessage passed to the callback:
page.on('console', msg => {
console.log(msg.text());
});
msg.text() returns a string. Use msg.args() instead when you need the original console arguments as separate values.
As an Amazon Associate I earn from qualifying purchases.
Read a console message’s text
Attach the listener to the Puppeteer Page instance. The callback receives a ConsoleMessage object, not a string, so call its text() method:
Free tools Windows power users keep installed
One-click scans. No signup required.
page.on('console', msg => {
console.log(msg.text());
});
Puppeteer emits the page’s console event for JavaScript console API calls; the event can also represent page errors or warnings. The official ConsoleMessage.text() reference documents the result as a string.
#1 Best Overall
A complete minimal example, assuming page is already a Puppeteer Page, is:
page.on('console', msg => {
const messageText = msg.text();
console.log(messageText);
});
Choose the right message accessor
Use the accessor that matches what you need from the event. The ConsoleMessage class reference documents these message details:
Rank #2
| Accessor | What it provides | Use it when |
|---|---|---|
text() |
The message text as a string. | You want to print, store, or compare the readable message. |
args() |
The arguments passed to the console call. | You need to inspect original values or objects individually. |
type() |
The console message type. | You need to distinguish message categories. |
location() or stackTrace() |
Location or stack-trace information. | You need context about where the message originated. |
For example, this listener logs the text and type separately:
page.on('console', msg => {
console.log(`[${msg.type()}] ${msg.text()}`);
});
If page code logs several values or objects, use args() rather than expecting text() to return a structured array of those values. The two accessors serve different purposes.
Common mistakes and fixes
- Logging the callback argument directly: the callback receives a
ConsoleMessage, not the message text. Callmsg.text(). - Looking for original objects in
text(): usemsg.args()to access the console call’s arguments individually. - Trying to construct a
ConsoleMessageyourself: its constructor is internal; consume the object Puppeteer sends through the event instead. - Expecting only ordinary log calls: the
consoleevent can also represent page errors or warnings. Checkmsg.type()if the category matters. - Attaching the listener to the wrong object: register it on the Puppeteer
Pagewhose console activity you want to observe.
For current event and class details, see Puppeteer’s PageEvent documentation and ConsoleMessage reference.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup:
If the goal is a clean capture of a page rather than inspection of its console output, ScreenshotNeo takes a screenshot with one GET request. Its API can capture PNG, JPEG, WebP, or PDF; it is not a replacement for reading Puppeteer console messages.
Rank #4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for options. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsSign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Quick Recap
Best Value
- Used Book in Good Condition
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.




