-
-
Notifications
You must be signed in to change notification settings - Fork 207
BrowserPage.evaluate()
David Ortner edited this page Jan 11, 2024
·
5 revisions
Evaluates code or a VM Script in the context of the page.
execute(): any;
any
import { Browser } from "happy-dom";
const browser = new Browser();
const page = browser.newPage();
page.execute('document.body.innerHTML = "<span>hello world</span>";');
// Outputs: "hello world"
console.log(page.mainFrame.document.querySelector('span').innerText);
page.execute(new Script('document.body.innerHTML = "<span>Hello world!!!!</span>";'));
// Outputs: "Hello world!!!!"
console.log(page.mainFrame.document.querySelector('span').innerText);
await browser.close();