Create isolated Puppeteer browser contexts with browser.createBrowserContext() for parallel sessions

domain: pptr.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Launch a single browser with puppeteer.launch() and then call browser.createBrowserContext() for each isolated session rather than launching separate browser processes
  2. Open pages within each context using context.newPage(); pages within a context share cookies and storage with each other but are fully isolated from other contexts
  3. When the session is done, call context.close() to destroy the context and all its pages; this also clears all cookies and storage for that context
  4. The default context (browser.defaultBrowserContext()) cannot be closed; only explicitly created contexts can be disposed
  5. For parallel test execution, create one context per test worker and close it in the test teardown step

Known gotchas

Related routes

throttle cpu and network conditions in puppeteer using a cdpsession for performance testing
pptr.dev · 5 steps · unrated
Create a Browserbase Context and reuse it across sessions to persist cookies and local storage
docs.browserbase.com · 6 steps · unrated
Run concurrent Browserbase sessions for parallel agent workloads
docs.browserbase.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans