Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Listen for the page’s console event, then call text() on the event’s ConsoleMessage argument:

page.on('console', msg => {
  console.log(msg.text());
});

msg is not a string; it is a ConsoleMessage object. Its text() method returns the message text as a string.

Get console text from a Puppeteer page

Attach the listener to the Puppeteer Page you want to monitor. Register it before navigating or triggering the page code whose messages you need to capture:

page.on('console', msg => {
  console.log(msg.text());
});

The event callback receives a ConsoleMessage. Use msg.text() for its text representation; the result is a string. See the Puppeteer ConsoleMessage.text() reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture messages in a runnable script

This CommonJS example starts a browser, subscribes to console messages, visits a page, and closes the browser even if navigation fails:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();

    page.on('console', msg => {
      console.log(msg.text());
    });

    await page.goto('https://example.com');
  } finally {
    await browser.close();
  }
})();

Install Puppeteer in the project before running the script. Replace the example URL with the page you need to inspect. Listening before page.goto() ensures the handler is in place for messages emitted during navigation.

Choose the right ConsoleMessage accessor

Text, original arguments, and metadata are separate pieces of information. Use the accessor that matches what your code needs:

Need Use What it provides
A readable text string msg.text() The console message text.
Individual values logged by the page msg.args() The arguments passed to the console call, useful when the page logs multiple values or objects.
Message category msg.type() The console message type.
Where the message originated msg.location() or msg.stackTrace() Location or stack-trace information.

For example, if page code calls console.log('count', 3), use text() when one text representation is sufficient. Use args() when you need to handle the logged values separately rather than treat the text as a structured array.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle message types and page errors

Puppeteer’s console event covers page JavaScript console API calls and can also represent warnings or page errors. If your handler needs to distinguish categories, inspect msg.type() rather than inferring the type from the text:

page.on('console', msg => {
  console.log(`[${msg.type()}] ${msg.text()}`);
});

The event payload is the message object to consume. Do not construct a ConsoleMessage yourself: Puppeteer documents its constructor as internal and says third-party code should not call it. See the ConsoleMessage class reference and the PageEvent documentation.

Troubleshoot missing or unexpected output

  • No message appears: Confirm the listener is attached to the same Page that runs the code, and register it before navigation or the action that emits the message.
  • Your callback value has no text() method: The event provides a ConsoleMessage, not a string. Call msg.text() inside the callback.
  • You need separate values or an object: Use msg.args(); text() provides text, not a structured argument list.
  • You need to distinguish warnings or errors: Inspect msg.type() and, if needed, use location() or stackTrace() for origin details.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to get a screenshot or PDF rather than inspect Puppeteer’s console events, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request can return a screenshot or PDF; its capture options include viewport and full-page shots, element selection, PDF settings, waits, and custom headers or cookies. For API details and the available parameters, see the ScreenshotNeo documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo accepts cookie banners before capture 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 identify the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Best Value
The SQL Programming Language: .
  • 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.