-
-
Notifications
You must be signed in to change notification settings - Fork 322
Browser
David Ortner edited this page Jan 11, 2024
·
30 revisions
Browser represents an instance of a Happy DOM browser.
Signature:
class Browser implements IBrowserimport { Browser } from "happy-dom";
const browser = new Browser();
const page = browser.newPage();
await page.goto("https://example.com");
await browser.close();| Name | Modifiers | Type | Description |
|---|---|---|---|
| contexts | readonly | BrowserContext[] |
Browser contexts. Defaults to one main context. |
| settings | readonly | IBrowserSettings |
Browser settings. The settings can be modified runtime. |
| console | readonly | Console |
Console object sent in to the constructor. |
| defaultContext | readonly | BrowserContext |
Default context. |
| Name | Return type | Description |
|---|---|---|
| close() | Promise<void> |
Closes the browser. |
| 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. |
| newIncognitoContext() | BrowserContext |
Creates a new incognito context. |
| newPage() | BrowserPage |
Creates a new page. |
| Browser represents an instance of a Happy DOM browser. The API is similar to the API for Puppeteer and Playwright. |
Signature:
class Browser implements IBrowserimport { Browser } from 'happy-dom';
const browser = new Browser();
const page = browser.newPage();
await page.goto('https://example.com');
await browser.close();| Name | Modifiers | Type | Description |
|---|---|---|---|
| contexts | readonly | [BrowserContext](https://github.com/capricorn86/happy-dom/wiki/BrowserContext)[] |
Browser contexts. Defaults to one main context. |
| settings | readonly | [IBrowserSettings](https://github.com/capricorn86/happy-dom/wiki/IBrowserSettings) |
Browser settings. The settings can be modified runtime. |
| console | readonly | Console | Console object sent in to the constructor. |
| defaultContext | readonly | BrowserContext | Default context. |
| Name | Return type | Description |
|---|---|---|
| close() | Promise<void> |
Closes the browser. |
| 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. |
| newIncognitoContext() | BrowserContext |
Creates a new incognito context. |
| newPage() | BrowserPage |
Creates a new page. |
Help Packages