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

Call context.targets() on the Puppeteer BrowserContext you want to inspect. It synchronously returns a Target[] for the active targets in that context.

List targets in one BrowserContext

Keep a reference to the context you want to inspect, then call targets() on it:

const targets = context.targets();
console.log(targets);

The return value is an array of Target objects, and the call is synchronous; do not put await before it.

Runnable example

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const context = await browser.createBrowserContext();

const targets = context.targets();
console.log(`Active targets in this context: ${targets.length}`);

await browser.close();

A browser context isolates its storage from other contexts. A popup opened by a page belongs to the same context as the page that opened it. Close the browser when finished to close its associated pages. See Puppeteer’s BrowserContext API.

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

Choose between targets, pages, and browser-wide targets

Use the API whose scope and return type match the task:

API Scope and result Use it when
context.targets() Active targets in one context; synchronous Target[]. You need all active targets scoped to a particular context. See BrowserContext.targets().
context.pages() Pages in one context; asynchronous Promise<Page[]>. By default, non-visible pages such as background pages are omitted. You need page objects rather than every target. The docs describe an experimental includeAll option. See BrowserContext.pages().
browser.targets() Targets across all browser contexts. You intentionally need browser-wide coverage, not just one context. See Browser.targets().
browser.browserContexts() The open BrowserContext objects. You need to enumerate contexts before inspecting an individual one. A newly launched browser has one context. See Browser.browserContexts().

Common mistakes and fixes

  • Using browser.targets() for a context-only result: it includes targets from all contexts. Call targets() on the specific context instead.
  • Expecting pages() to include every target: it returns pages, not all target types, and omits non-visible pages by default. Use context.targets() when you need active targets, or consult the documented experimental includeAll option if the need is specifically all pages.
  • Awaiting context.targets(): it is synchronous and already returns its array. By contrast, context.pages() returns a promise and should be awaited.
  • Inspecting a context after closing it or its browser: retain and inspect the live context while its browser is open. The example closes the browser only after reading the targets.
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 a website screenshot rather than inspecting Puppeteer targets, ScreenshotNeo provides a screenshot API and MCP server. Its one-call request can return an image or PDF:

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
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
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 documentation for request options. Cookie banners, popups, and chat widgets are removed before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for free.

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.