Use the Page instance that registered the 'console' listener. Puppeteer passes the callback a ConsoleMessage, but its documented API has no method that returns the originating page.
Use the Page listener’s closure
Register the listener on the page you want to monitor, then refer to that same page variable in the callback:
As an Amazon Associate I earn from qualifying purchases.
page.on('console', msg => {
console.log('From page:', page.url());
console.log('Message:', msg.text());
});
The Puppeteer PageEvent documentation describes the 'console' event as a page console API call and says it supplies a ConsoleMessage. The listener is attached to a particular Page, so the callback’s closure already has the page reference.
Identify messages from several pages or tabs
Attach a listener to each page and use its captured reference to label the output:
#1 Best Overall
for (const page of pages) {
page.on('console', msg => {
console.log(`[${page.url()}] ${msg.type()}: ${msg.text()}`);
});
}
Each const page binding in this loop belongs to its iteration. If your code is structured differently and the association is unclear, use a handler factory that accepts a page and returns its listener:
function logConsoleFor(page) {
return msg => {
console.log(`[${page.url()}] ${msg.type()}: ${msg.text()}`);
};
}
for (const page of pages) {
page.on('console', logConsoleFor(page));
}
What ConsoleMessage can and cannot tell you
The documented ConsoleMessage API lists methods for inspecting the console entry: args(), location(), stackTrace(), text(), and type(). It does not list a page accessor, and its constructor is marked internal.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
msg.text()gives the message text;msg.type()gives its type.msg.args()exposes the arguments passed to the console call.msg.location()andmsg.stackTrace()provide source-location information, not a PuppeteerPage.
For the Page event-listener pattern, see the Puppeteer Page API documentation.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchTroubleshooting
- The message has no
page()method: That method is not part of the documentedConsoleMessageAPI. Capture thePagein the listener’s closure instead. - Several tabs produce indistinguishable logs: Install a separate listener on each page and include the captured page’s URL or another label in each log entry.
- The displayed URL is not the URL you expected:
page.url()reports the page’s URL when the callback runs. If navigation may have occurred, treat it as the page’s current URL, not necessarily the URL at the time the console call was made. - You need message details rather than page identity: Use
msg.text(),msg.type(),msg.args(), ormsg.location()for the console entry’s documented details.
Or skip the browser setup
If your goal is to capture a website rather than inspect Puppeteer console output, ScreenshotNeo offers a one-request screenshot API. For example, with cURL:
Quick Recap
Best Value
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
Rank #3
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 request options. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan.
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.




