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

Manage browser automation sessions by treating the browser process, browser context, and page as separate objects. Use a fresh context for each independent task or test, share a context only when a workflow deliberately needs shared state, set bounded timeouts, and close contexts before the browser. In Playwright, a context is the practical session-isolation boundary; Puppeteer also provides browser contexts, but its defaults and behavior are framework-specific.

What counts as a browser automation session?

“Session” can refer to several different things. In Playwright, a BrowserContext is the useful isolation boundary: it can own multiple pages, and separate contexts operate as independent browser sessions. A browser process can host multiple contexts. Non-persistent Playwright contexts do not write browsing data to disk.

A page is a tab-like browsing surface inside a context, not an independent session boundary. A popup opened by a Playwright page remains in that page’s parent context. If two pages need to share cookies and storage as part of one workflow, put them in the same context; if they should behave like separate users, use separate contexts.

Puppeteer also recommends BrowserContexts to isolate automation tasks. Its documentation describes non-default Chrome contexts as incognito, but notes that the default context may also be incognito when Chrome is launched with --incognito. Do not assume Playwright and Puppeteer have identical terminology, defaults, or behavior; check the API for your pinned framework and browser versions: Puppeteer BrowserContext API.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Choose the right isolation boundary

Use a fresh context for independent work

For unrelated tests, jobs, or users, create a new context rather than reusing one and hoping cleanup removes every trace of the previous task. Playwright contexts isolate cookies and storage. Its test runner creates a new context per test by default, a design intended to prevent failures and order-dependent behavior from carrying between tests. See Playwright’s isolation guide.

For example, an administrator workflow and a regular-user workflow should normally use separate contexts. That gives each user independent cookies and storage while allowing both contexts to run within one browser process.

Reuse a context when continuity is intentional

Keep steps in the same context when they represent one continuous user journey—for example, signing in and then navigating through pages that rely on that login. The continuity is the point: pages in the context can share its session state.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Reusing a context across unrelated tasks creates a different trade-off. A task may inherit cookies or storage, and deleting selected cookies is not necessarily equivalent to restoring a completely fresh browser state. Playwright’s guide contrasts starting from scratch with cleanup between tests and notes that some state, such as visited links, can be difficult to reset. Choose cleanup only when the workflow truly requires continuity and you can account for the state it retains.

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

A reliable Playwright lifecycle

  1. Launch a browser. Treat the browser process as the container for your contexts, not as the session boundary for every task.
  2. Create a context for the task. Use a new context for independent work. Create separate contexts for separate simulated users.
  3. Create pages inside that context. A context can own one or more pages; keep pages together only when their shared state is intentional.
  4. Set up only the required state. Playwright exposes context-level cookie and permission APIs, including a way to clear cookies. If you reuse authenticated state, decide explicitly how it is introduced, refreshed, invalidated, and protected. The APIs do not prescribe a universal credential-storage policy.
  5. Bound navigation and other waits. Set context-level default timeouts and navigation timeouts appropriate to the task. Page-level timeout settings take precedence over context defaults, so inspect page-specific overrides when a context setting appears ineffective.
  6. Handle task failures at the orchestration boundary. Account for navigation failures, timeouts, and unexpected context closure. Playwright exposes a context close event; a browser closing or crashing can also cause that event.
  7. Close in order. Close explicitly created contexts when the task is done, then close the browser. Closing a context closes its pages. Playwright recommends this order so contexts can close gracefully and artifacts such as HARs and videos can be flushed and saved. See the Playwright Browser API.

Minimal runnable Node.js example

This example creates one isolated context, opens a page, navigates to a URL, and closes the context before the browser even if navigation throws. Install Playwright and its browser binaries in your project before running it; use the API version pinned by that project.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  let context;

  try {
    context = await browser.newContext();
    const page = await context.newPage();

    // Set bounded defaults for this context.
    context.setDefaultTimeout(10_000);
    context.setDefaultNavigationTimeout(30_000);

    await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
    console.log(await page.title());
  } finally {
    if (context) await context.close();
    await browser.close();
  }
})();

The timeout values above are example choices, not universal recommendations. Set them for the pages and environment you automate. If you add page-level timeout overrides elsewhere, those take precedence over the context defaults.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Fresh contexts versus cleanup between tasks

Approach Useful when Trade-off
Fresh context per independent task Tests or jobs should not inherit another task’s cookies or storage; separate users or parallel work must behave independently. State that should persist must be introduced deliberately for each context.
Cleanup within a reused context Several steps intentionally continue one user journey or session. Cleanup can miss browser state. Clearing cookies alone should not be treated as proof that every kind of state has been reset.

This is an isolation and correctness choice, not a universal speed ranking. The official documentation describes lifecycle and isolation behavior; it does not establish a cross-framework resource or performance comparison.

Timeouts, failures, and recovery

Keep waits bounded

Use context-level default timeouts and navigation timeouts to keep operations from waiting indefinitely. A timeout should reflect the operation and deployment conditions; an overly short limit can fail on legitimate slow navigation, while disabling timeouts broadly can leave a task stuck. When a timeout change does not seem to take effect, check whether that page has its own timeout setting, which takes precedence over the context default.

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

Treat closure as a task boundary

Make cleanup part of the orchestration path, including when navigation or a later operation fails. If a context closes unexpectedly, investigate whether the browser was closed or crashed as well as whether task code closed the context. Retry only when the operation is safe to repeat; for workflows that submit forms or trigger other side effects, determine whether the action completed before replaying it.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Keep artifacts in mind

If your workflow records HARs or videos, close the context before closing the browser so context-level artifacts have the opportunity to flush and save. Closing the context also closes its pages; code should not expect those pages to remain usable afterward.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common session-management mistakes

  • Sharing one context across unrelated tests: a later test can inherit session state and make results order-dependent. Use fresh contexts for independent tests.
  • Assuming selected cleanup resets everything: removing cookies does not establish that all browser state is clean. Prefer a fresh context when a clean boundary matters.
  • Closing the browser first: this can interfere with graceful context shutdown and artifact flushing. Close explicitly created contexts first.
  • Disabling timeouts across the board: long or stuck operations can then hold up automation. Use bounded defaults and handle timeout failures.
  • Changing a context timeout but overlooking a page override: inspect page-level settings when the observed timeout differs from the context default.
  • Assuming framework parity: Playwright and Puppeteer do not necessarily share context defaults or semantics. Verify behavior against the installed versions.

Where ScreenshotNeo fits

ScreenshotNeo is a website screenshot API and MCP server, not a replacement for a Playwright or Puppeteer session when your task requires interacting with a site over multiple steps or maintaining browser state. If the task is simply to capture a URL as an image or PDF, it can avoid setting up a browser automation session. See ScreenshotNeo.

Or skip the browser setup

Send one GET request with the target URL and your API key. This cURL example saves a WebP screenshot; parameter details and other capture options are in the ScreenshotNeo documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Before capture, ScreenshotNeo accepts the cookie or consent banner like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up free for 1,000 screenshots a month with no card.

Frequently Asked Questions

Can one Playwright BrowserContext contain more than one page?

Yes. A context can own multiple pages, including a popup opened by a page in that context.

Does ScreenshotNeo replace a stateful Playwright or Puppeteer workflow?

No. It is suited to capturing a URL as an image or PDF; use browser automation when the workflow requires multi-step interaction or maintained browser state.

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.