October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

List Browser Targets with Puppeteer

List active Puppeteer targets across browser contexts with browser.targets(), inspect each target type, and learn when to use context.targets() or pages().
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use await browser.targets() to list every active Puppeteer target across all browser contexts. Each returned item is a Target; call target.type() to identify it and target.url() to inspect its URL. To restrict the list to one context, use context.targets().

List all browser targets

Browser.targets() returns a Target[] containing active targets across browser contexts. This example prints each target’s type and URL:

As an Amazon Associate I earn from qualifying purchases.

const targets = await browser.targets();

for (const target of targets) {
  console.log(target.type(), target.url());
}

Use it with an initialized Puppeteer browser instance. The method lists targets; it does not create pages or change browser state. See the Puppeteer Browser.targets() reference.

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

Choose the right listing method

Method What it returns Scope and coverage
browser.targets() Active Target objects Across all browser contexts
context.targets() Active Target objects Only within that browser context
pages() Page objects A page-oriented view; it omits non-visible pages such as background pages

Use browser.targets() for complete active-target enumeration. Choose context.targets() when your task concerns only one context. If you need visible pages rather than every target, a pages listing may be the more suitable view, but it is not a replacement for target enumeration. The BrowserContext.targets() reference and the BrowserContext.pages() reference document those distinctions.

Identify target types

A target is not necessarily a visible tab. Puppeteer documents these Target.type() values: background_page, browser, other, page, service_worker, shared_worker, and webview. Check the type before assuming a target behaves like a page.

for (const target of await browser.targets()) {
  const type = target.type();
  const url = target.url();

  if (type === 'page') {
    console.log('Page:', url);
  } else {
    console.log('Non-page target:', type, url);
  }
}

For the documented target categories, consult the TargetType reference and Target.type() reference.

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

Limit enumeration to a browser context

Contexts isolate storage. A newly created browser has at least one default context; create a separate context when you need an isolated session, then enumerate its targets with context.targets().

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const context = await browser.createBrowserContext();
const page = await context.newPage();

const targets = await context.targets();
for (const target of targets) {
  console.log(target.type(), target.url());
}

The new page is created in that context, and the context-level method limits the returned list to targets in that context. See the Browser.createBrowserContext() reference and BrowserContext.newPage() reference.

Troubleshoot unexpected results

  • Some tabs or targets are missing: Check that you called browser.targets(), not a context-scoped method. Also remember that pages() omits non-visible pages such as background pages.
  • A result is not a regular page: Inspect target.type(). Workers, browser targets, and other documented target kinds can appear in the results.
  • The target list is narrower than expected: Confirm which BrowserContext you queried. context.targets() is intentionally scoped to that context.
  • Types or method behavior differ from your installed package: Check your installed Puppeteer version and use its matching API reference. The official API pages reviewed for this guide reported versions from 25.9.0 through 25.12.0, so this code is not a promise that every release has identical documentation.
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 a screenshot rather than inspecting Puppeteer targets, ScreenshotNeo can return an image or PDF from one GET request. Cookie banners, newsletter popups, and chat widgets are removed before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status. Its MCP server provides screenshot tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. 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 1,000 free screenshots a month, with no card.

Rank #4
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

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.

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

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
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.