-
-
Notifications
You must be signed in to change notification settings - Fork 269
BrowserPage
David Ortner edited this page Sep 23, 2025
·
14 revisions
BrowserPage represents a browser page (popup window or a tab).
class BrowserPage implements IBrowserPage| Property | Modifiers | Type | Description |
|---|---|---|---|
| virtualConsolePrinter | readonly | VirtualConsolePrinter | API for reading the output of the virtual console. |
| mainFrame | readonly | BrowserFrame | Main frame. |
| context | readonly | BrowserContext | Owner context. |
| console | readonly | Console | VirtualConsole | Console object sent in to the constructor or a virtual console. |
| viewport | readonly | IBrowserPageViewport | Viewport. |
| frames | readonly | BrowserFrame[] | All frames associated with the page. |
| content | string | Page content HTML. | |
| url | string | Page URL. |
| Method | Return type | Description |
|---|---|---|
| close() | Promise<void> | Closes the page. |
| waitUntilComplete() | Promise<void> | Waits for all ongoing operations to complete. This includes operations such as loading resources and executing scripts. |
| waitForNavigation() | Promise<void> | Waits for the page to be navigated after a link has been clicked or the page is redirected by a script. This is resolved when the HTML of the new URL has been loaded into the main frame. |
| abort() | Promise<void> | Aborts all ongoing operations. |
| evaluate() | any | Evaluates code or a VM Script in the page's context. |
| setViewport() | void | Sets the viewport. |
| goto() | Promise<Response | null> | Navigates the main frame to a URL. The promise is resolved after the content has been loaded into the window. |
| goBack() | Promise<Response | null> | Navigates back in the main frame's history. The promise is resolved after the content has been loaded into the window. |
| goForward() | Promise<Response | null> | Navigates forward in the main frame's history. The promise is resolved after the content has been loaded into the window. |
| goSteps() | Promise<Response | null> | Navigates in the main frame's history by a number of steps. The promise is resolved after the content has been loaded into the window. |
| reload() | Promise<Response | null> | Reloads the page. |
import { Browser } from "happy-dom";
const browser = new Browser();
const page = browser.newPage();
await page.goto("https://example.com");
await browser.close();
Help Packages