Skip to content

BrowserPage

David Ortner edited this page Apr 6, 2024 · 9 revisions

BrowserPage represents a browser page (popup window or a tab).

Signature

class BrowserPage implements IBrowserPage

Example

import { Browser } from "happy-dom";

const browser = new Browser();
const page = browser.newPage();

await page.goto("https://example.com");

await browser.close();

Properties

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.

Methods

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. 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<IResponse | null> Go to a URL.
reload() Promise<IResponse | null> Reloads the page.
Clone this wiki locally