How do I delay script actions until a JavaScript function has finished executing when using Puppeteer with Node.js?

Trying to scrape a page with Puppeteer in Node.js. Report generation waits for a JS function evaluation. Example:

console.log('Navigating...');
await page.goto('https://example.com', { waitUntil: 'networkidle0' });
await page.waitForFunction(() => document.getElementById('status').textContent.includes('done'));

How can I delay further actions?

hey, try wrapping your actions in an async function and awaiting your waitForFunction. if its still giving issues, consider a slight timout before moving on to let any lingering events finish up.