Ensuring Puppeteer Waits for Complete Page Load After Form Submission

I am attempting to wait until a new page has fully loaded after a form is submitted using Puppeteer. Instead of using a simple fixed wait delay, I need a more reliable method to detect when the new page’s content is completely rendered. Below is an example of what I currently use:

await browserPage.click('button.my-submit');
// Wait until the navigation completes after form submission
await browserPage.waitForNavigation({ waitUntil: 'load' });
await browserPage.screenshot({ path: 'snapshot.png' });

Any guidance on improving this approach to ensure that the page is fully loaded before proceeding would be appreciated.

hey, try waiting for a unique selctor on the new page. using waitForSelector on an element that only appears after full load works better sometimes than waitForNavigation with load