DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

How to Get a Page Title in Puppeteer

Use Puppeteer’s dedicated page.title() method after navigation to retrieve a page title as a string. Compare it with evaluate() and $eval(), and see a runnable example.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After navigating to the page, call and await page.title(). It returns the page title as a string:

const title = await page.title();
console.log(title);

This is Puppeteer’s dedicated method for retrieving a page title. It does not require selecting a <title> element or evaluating JavaScript in the page.

As an Amazon Associate I earn from qualifying purchases.

Get a page title with Puppeteer

Here is a complete JavaScript example using Puppeteer’s standard launch, page creation, and navigation flow:

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.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com');

  const title = await page.title();
  console.log(title);
} finally {
  await browser.close();
}

Run it in a JavaScript environment configured for ES module imports and top-level await. The official getting-started guide also describes importing puppeteer-core in place of puppeteer when that package suits your setup. The title method is documented as title(): Promise<string> and as a shortcut for page.mainFrame().title().

Why the order matters

  1. Open a page with await browser.newPage().
  2. Navigate to the destination with await page.goto(url).
  3. Read the title with await page.title().
  4. Close the browser when the work is done.

Await the title call because it returns a Promise. Await navigation first when you want the destination page’s title, rather than reading before navigation has completed.

When to use the alternatives

page.title() is the clearest option when all you need is the title. The alternatives are useful when title retrieval is part of a different kind of page operation.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
Method Example When it fits Important behavior
Dedicated title method await page.title() You want the page title as a string. Returns a Promise of a string.
Page-context evaluation await page.evaluate(() => document.title) You are already evaluating page-context state or combining the title with other DOM work. page.evaluate() runs the function in the page context and returns its result; it also awaits a Promise returned by that function.
Selector evaluation await page.$eval('title', el => el.textContent) You specifically need to select the matching element and process it. $eval() uses the first matching element and throws if there is no match.

Troubleshoot title retrieval

  • The value is not for the destination page: make sure the script awaits page.goto(url) before calling page.title().
  • The result is not available immediately: await the call: const title = await page.title(). Its documented return type is a Promise.
  • $eval() throws: the selector-based method throws when it finds no matching title element. Use page.title() for straightforward title retrieval, or handle the selector failure if selecting the element is essential.
  • You are using page.evaluate() only to read the title: switch to page.title() for the direct, dedicated API. Keep evaluation when you need a larger page-context computation.

Performance and operational notes

For a title alone, page.title() avoids the extra selector-oriented code of $eval() and the broader page-context machinery of evaluate(). The documented API describes the method and its Promise return type, but does not provide comparative performance measurements; there is no sourced benchmark to claim one approach is faster.

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

The browser lifecycle in the example uses try/finally so the browser-close call runs even if work inside the block fails. This is ordinary JavaScript cleanup structure, not a Puppeteer-specific guarantee about recovery from every possible launch or navigation failure.

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • 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
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 actual goal is to capture a page image or PDF rather than read its title, ScreenshotNeo can return a capture with one GET request. It is not a replacement for page.title(): the endpoint returns a screenshot or PDF, not the title string.

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

See the ScreenshotNeo API documentation for request options. ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps 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 provides screenshot tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.