-
-
Notifications
You must be signed in to change notification settings - Fork 216
BrowserContext
David Ortner edited this page Jan 21, 2025
·
13 revisions
BrowserContext represents a context where data such as cache and cookies can be shared between its pages.
class BrowserContext implements IBrowserContext
Property | Modifiers | Type | Description |
---|---|---|---|
pages | readonly | BrowserPage[] | Pages. |
browser | readonly | Browser | Owner Browser. |
cookieContainer | readonly | CookieContainer | Cookie container. |
responseCache | readonly | ResponseCache | Response cache. |
preflightResponseCache | readonly | PreflightResponseCache | Preflight response cache. |
Method | Return type | Description |
---|---|---|
close() | Promise<void> | Closes the context. |
waitUntilComplete() | Promise<void> | Waits for all ongoing operations to complete. This includes operations done inside loaded pages, such as loading resources and executing scripts. |
abort() | Promise<void> | Aborts all ongoing operations. |
newPage() | BrowserPage | Creates a new page. |
import { Browser } from "happy-dom";
const browser = new Browser();
const context = browser.newIncognitoContext();
const page = context.newPage();
await page.goto("https://example.com");
await browser.close();
Help Packages