question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Goto url and wait until page fully rendered

See original GitHub issue

Hi, me again 😃

I’m currently trying to visit a webpage and wait for the page being rendered (including javascripts run) to find a specific image. I’ve seen this example in the docs (https://github.com/capricorn86/happy-dom/tree/master/packages/happy-dom), so I tried to go a similar way:

function visitUrl(url: string): Promise<AsyncWindow> {
  // ...
  const window = new AsyncWindow();
  window.location.href = url;
  window.happyDOM.whenAsyncComplete().then(() => {
    console.log('innerHTML', window.document.body.innerHTML);
    resolve(window);
  });
}

// resolves directly with empty innerHTML:
const window = await visitUrl('https://page-to-visit.com');
const img = window.document.querySelector('img');

The console log only shows innerHTML , so I assume there’s either something wrong with my code, or there might be a bug with happy-dom. Do you know what’s the issue here? Is there maybe any “load”-event I can listen to?

  • Maybe it could also be useful to have this use case in the docs 😃

Thanks in advance, keep up the great work!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
capricorn86commented, Feb 15, 2021

Thank you @JulianLang! 🙂

0reactions
JulianLangcommented, Feb 16, 2021

Thanks a lot for helping, will try it the next days 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer wait until page is completely loaded - Stack Overflow
You can use page.waitForNavigation() to wait for the new page to load completely before generating a PDF: await page.goto(fullUrl, ...
Read more >
How to make puppeteer wait for page to load - Urlbox
waitUntil : load. The load option fires when the whole page has loaded, including all dependent resources such as stylesheets, fonts and images....
Read more >
Navigating & waiting - Checkly
You can use Puppeteer's page.waitForNavigation() method here to explicitly wait for this event to happen and then continue your script. The accepted notation...
Read more >
Wait For The Page And Elements To Fully Render Before ...
This video shows how I wait for the page to fully load by observing the new elements that appear during the tests, and...
Read more >
Puppeteer, wait until the page is ready! - ScreenshotOne
In order to take a screenshot when the page is fully loaded and rendered, one of the most working combination is to set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found