| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Thank you for your contribution to TestCafe. When a member of the TestCafe team becomes available, they will review this PR. |
Sorry, something went wrong.
Add the ability to open fully isolated browser sessions within a single test. Each session gets its own Chrome browser context (separate cookies, localStorage, sessionStorage, service workers) via CDP's Target.createBrowserContext(). Includes 40 functional tests, selector chaining support, t2.run() for transparent Selector/ClientFunction evaluation, and automatic cleanup. Requires Native Automation mode (Chrome only).
| Back | FazBrowse Home | New Git URL |
Note: This feature was developed with the assistance of Claude Opus 4.6 (Anthropic) and should be considered "vibe coded." We have been running it in production for our multi-user e2e test suite and all 40 functional tests pass, but the codebase has not undergone traditional peer review beyond AI-assisted iteration. We welcome feedback on the implementation approach and are happy to iterate.
Summary
Adds t.openIsolatedSession() — the ability to open fully isolated browser sessions within a single test. Each session gets its own Chrome browser context (separate cookies, localStorage, sessionStorage, service workers) via CDP's Target.createBrowserContext().
This enables multi-user e2e tests: doctor + patient in a video call, two users editing the same document, concurrent booking scenarios — all within a single test.
Motivation
Currently, testing multi-user scenarios requires either:
This PR provides a native solution: t.openIsolatedSession() returns a second test controller (t2) backed by a completely isolated Chrome browser context.
API
Supported commands
Command-based: click, rightClick, doubleClick, hover, drag, dragToElement, typeText, pressKey, selectText, scroll, scrollBy, scrollIntoView, dispatchEvent, navigateTo, wait, eval, expect, useRole, getCookies, setCookies, deleteCookies
Direct session methods: setHttpAuth, setWindowBounds, takeScreenshot, takeElementScreenshot, maximizeWindow, resizeWindow, setFilesToUpload, setPageLoadTimeout, switchToIframe, switchToMainWindow
Selector chaining: withText, withExactText, filterVisible, filterHidden, nth, find, parent, child, sibling, nextSibling, prevSibling, withAttribute
Requirements
Architecture
Three new files, six modified files:
New files:
Modified files:
Key design decisions:
Tests
40 functional tests in test/functional/fixtures/isolated-sessions/:
Run tests:
Documentation
t.openIsolatedSession() → IsolatedTestController
Opens a new browser window in a fully isolated Chrome browser context. Returns an IsolatedTestController (commonly named t2) with a subset of the standard TestCafe API.
Requires: Native Automation mode.
The isolated session has completely separate cookies, localStorage, sessionStorage, and service workers from the main session and from other isolated sessions.
Sessions are automatically cleaned up when the test ends. The CDP WebSocket is closed and Target.disposeBrowserContext() destroys the context.
t2.run(callback)
Executes a callback where Selector queries and ClientFunction evaluations target the isolated session's CDP tab. Inside the callback, Selector.exists, Selector.visible, Selector.innerText, and ClientFunction all evaluate in the isolated tab. Action commands (click, typeText, etc.) still require using t2 directly.