The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →BrowserContext lets Puppeteer keep browser storage for one automation task separate from storage in other contexts. Create one with browser.createBrowserContext(), open task pages with context.newPage(), then close the context to close its pages and finish that session. This is storage isolation inside a browser instance—not a separate browser process or a complete security boundary.
What a Puppeteer BrowserContext isolates
A BrowserContext represents an individual user context. Puppeteer documents context-level separation for cookies, localStorage, and cache: one context does not share these items with other contexts. That makes contexts useful when separate test cases or automation tasks need separate browser state. See the BrowserContext API reference and createBrowserContext() reference.
“Isolated session” is a practical shorthand for this storage separation. The documentation does not establish that each context runs in a separate operating-system process or provides a complete security boundary. Do not rely on contexts alone to isolate mutually hostile workloads.
Create, use, and close a context
In current Puppeteer, create a context from the browser, create pages from that context, and close the context when the task is done:
#1 Best Overall
const context = await browser.createBrowserContext();
try {
const page = await context.newPage();
await page.goto('https://example.com');
// Run this task's checks or automation here.
} finally {
await context.close();
}
This snippet assumes browser is an already launched Puppeteer browser. The finally block ensures that the context is closed even if navigation or a test fails. Closing a non-default context closes its associated pages too; the browser management guide demonstrates the context lifecycle.
Choose the page-creation method deliberately
browser.newPage()creates a page in the browser’s default context.context.newPage()creates a page in the particular context you selected.
Use the default context when a task does not need storage separation or a group of pages to be closed together. Use an explicit context when you want a task’s storage separated from other contexts and want to dispose of its pages as a unit.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
How pages, popups, and the default context relate
A launched browser has at least one default context. A context can contain multiple pages, and a page opened with window.open belongs to its parent page’s context. A popup therefore does not automatically start a fresh isolated context. The Page.browserContext() API reference describes how to identify the context that owns a page.
The default context cannot be closed. Close contexts your code creates rather than assuming every context returned by browser inspection is disposable. In Chrome, non-default contexts are incognito. The default context may also be incognito if Chrome was launched with --incognito, so “default” does not always mean “non-incognito.” These details are documented in the BrowserContext reference and close() reference.
Rank #3
Inspect open contexts
Use browser.browserContexts() to retrieve the browser’s open contexts. A newly created browser returns a single context from this method; that context is the default one. The method is documented in the browserContexts() API reference.
Work with cookies in the right scope
When a test uses a non-default context, use that context’s cookie methods so the operation applies to the session under test. BrowserContext provides methods such as cookies(), setCookie(), and cookie deletion methods. Puppeteer’s cookies guide explains reading, setting, and deleting browser cookies, including the relationship between browser-level methods and methods for a particular context.
Rank #4
- 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
Page-level cookie methods are deprecated in favor of the Browser or BrowserContext APIs in the current Page API reference. For new code, prefer the context-level methods when managing cookies for an explicitly isolated task.
Choosing between the default context and a new context
| Approach | Storage separation | Cleanup | Typical use |
|---|---|---|---|
browser.newPage() |
Uses the default context; it does not create a separate context for the task. | Close the page individually; the default context itself cannot be closed. | A page that can share the default context’s browser state. |
browser.createBrowserContext() then context.newPage() |
Uses a new context with cookies, localStorage, and cache separated from other contexts. | Close the context to close its associated pages together. | A task or test that needs separate browser storage and grouped cleanup. |
Puppeteer’s documentation does not provide a numeric performance comparison between these approaches. Choose based on storage and lifecycle needs, not an assumed speed advantage.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Best Value
Version note: use the current method name
Older examples may call browser.createIncognitoBrowserContext(). Puppeteer 22.0.0 renamed that method to browser.createBrowserContext() as a breaking change; the changelog dates the release entry to 2024-02-05. Current examples should use createBrowserContext(). See the Puppeteer changelog.
Troubleshooting context behavior
- State appears shared: Check whether both pages were created with
browser.newPage(), which uses the default context, rather than with separate calls tocontext.newPage(). - A popup has the opener’s cookies: That is expected when it was opened with
window.open; it belongs to the parent page’s context. Create a separate context explicitly if the task requires separate storage. - Closing a context closes several pages: This is expected behavior for its associated pages. If the pages need independent lifetimes, organize them into different contexts.
- Closing the default context fails: The default context cannot be closed. Close only the non-default contexts created for individual tasks.
- An example says the method does not exist: If it uses
createIncognitoBrowserContext(), it may target an older Puppeteer API. For current Puppeteer, usecreateBrowserContext(). - Cookie changes affect the wrong session: Use the cookie methods on the
BrowserContextthat owns the page, rather than relying on default-context or deprecated Page-level methods.
Or skip the browser setup
If the task is simply to obtain a website screenshot rather than automate browser behavior, ScreenshotNeo offers a one-request screenshot API and an MCP server for AI agents. For example, this cURL call saves a WebP screenshot; see the ScreenshotNeo documentation for request options:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.
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.




