You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following test does not produce the website like in the browser due to no execution of the JavaScript. waitForNavigation() is commented out due to a bug.
Is it even possible to use happy-dom with these websites or do I need to use puppeteer?
I can even reproduce with a much simpler example. JavaScript is not executed automatically.
import{assert}from"assert-ts";import{expect,test}from"bun:test";import{Browser,BrowserErrorCaptureEnum,BrowserPage,Window}from"happy-dom";test("tmp",async(): Promise<undefined>=>{constbrowser: Browser=newBrowser();constpage: BrowserPage=browser.newPage();// Get the Document object from the Window instance.constdocument=page.mainFrame.document;// Define your HTML content, including embedded JavaScript.consthtmlContent=`<!DOCTYPE html><html><head> <title>Happy DOM Example</title> <script id="a"> console.log("hi from page"); const messageElement = document.getElementById('message'); if (messageElement) { messageElement.textContent = 'Hello from Happy DOM!'; } </script></head><body> <div id="message">Original Content</div></body></html>`;// Set the HTML content.document.write(htmlContent);awaitpage.waitUntilComplete();//Uncommented for a workaround.//const script = document.getElementById("a");//assert(script !== null);//console.log(script.textContent);//page.evaluate(script.textContent);// Verify the result.constmessageElement=document.getElementById("message");console.log(messageElement?.textContent);// Outputs: "Hello from Happy DOM!"});
The text was updated successfully, but these errors were encountered:
I'm not exactly sure why it is not loaded at all. I need to investigate further. But at least one of the reasons is because Happy DOM doesn't have support for ESM scripts (import, export etc.) yet.
However, I also need support for ESM for one project and a lot of other people in the community do to, so I will definitely prioritize adding support for it.
v16.6.0 with Bun.
The following test does not produce the website like in the browser due to no execution of the JavaScript.
waitForNavigation()
is commented out due to a bug.Is it even possible to use happy-dom with these websites or do I need to use puppeteer?
I can even reproduce with a much simpler example. JavaScript is not executed automatically.
The text was updated successfully, but these errors were encountered: