{
  "id": 22226856,
  "title": "Test browser profile isolation after attaching Playwright over CDP",
  "url": "https://urgent.news/2026/11/27/test-browser-profile-isolation-after-attaching-playwright-over-cdp",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-27T20:17:27.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/cloudbrowser/test-browser-profile-isolation-after-attaching-playwright-over-cdp-3gm6"
  },
  "original_language": "en",
  "account": "The Playwright browser automation tool can inspect existing browser contexts when attaching to Chrome over the Chrome DevTools Protocol (CDP). A script demonstrates how a new tab opened within an existing context inherits that context's first-party storage for the targeted origin. This behavior can aid testing by ensuring the right signed-in tab is utilized, but it can also cause tests intended for signed-out behavior to pass unintended screens.\n\nIn the experiment described, a Cloudbrowser Chrome session was used with two pages on a single origin. By setting specific environment variables and leveraging Playwright's JavaScript API, a script demonstrated how an existing context's context can read and write to localStorage. A unique key was generated for the test, and two new pages were created within the same existing context. The first page set the key to \"present\" in localStorage, while the second page retrieved the key's value, resulting in \"present\" being logged. A third page, created with a fresh context, did not retain the key's value, returning \"null\" when queried.\n\nThis experiment highlights the importance of isolating browser contexts for testing purposes. When continuing an existing flow, it's crucial to locate the expected tab and verify its origin and page-specific landmarks. Relying solely on the first open tab might lead to automation targeting unrelated pages. To simulate a fresh visit, a new context should be explicitly opened before testing begins. After the test is complete, closing the context is recommended. When parallel tests share the same remote account, separate contexts should be utilized to prevent request collisions with the same service.\n\nIn cases where write tests would result in conflicting changes, it's advisable to use separate application records or accounts. Cloudbrowser provides additional details regarding the persistence of browser profiles, including how session state is retained between tasks and scenarios where users may be prompted to sign in again.",
  "summary": "When Playwright attaches to Chrome over CDP, it can see the browser's existing context. A script that opens a new tab there inherits that context's first-party storage for the origin. That can help a task continue in the right signed-in tab. It can also make a test for signed-out behavior pass through screens it should have tested. An AI assistant helped run the experiment and prepare this…",
  "summary_source": "publisher",
  "key_points": [
    "Playwright can inspect browser contexts via CDP",
    "New tab inherits context's first-party storage",
    "Separate contexts prevent request collisions"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}