-
-
Notifications
You must be signed in to change notification settings - Fork 207
BrowserPage.waitForNavigation()
David Ortner edited this page Jan 11, 2024
·
4 revisions
Waits for the page to be navigated. This is resolved when the HTML of the new URL has been loaded into the main frame.
This method is useful when JavaScript triggers a redirect or if you click on a link.
async waitForNavigation(): Promise<void>;
Promise<void>
import { Browser } from "happy-dom";
const browser = new Browser();
const page = browser.newPage();
await page.goto("https://example.com");
// Clicks on a link
page.mainFrame.document.querySelector('a').click();
await page.waitForNavigation();
// Page has been navigated
// Do something with the content here
await browser.close();