This helper waits for requests initiated by the action to finish. It is similar to waitUntil: 'networkidle'
option, but is designed to work with any action, like click.
Example usage:
const waitForNetworkSettled = require('./networkSettled');
// Wait for network settled after navigation,
// account for two long-polling requests that never finish.
await waitForNetworkSettled(page, async () => {
await page.goto('http://my-site.com', { waituntil: 'domcontentloaded' });
}, 2);
// Wait for images to load after clicking the button
// that loads some more images.
await waitForNetworkSettled(page, async () => {
await page.click('text=Load more images');
});