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