I am using this code
await new Promise((resolve, reject) => {
var list = [1, 2, 3, 4];
for (var x = 0, ln = list.length; x < ln; x++) {
setTimeout(async () => {
console.log('scrolling');
await page.evaluate(() => {
window.scrollBy(0, window.innerHeight);
});
}, x * 2000);
}
resolve();
});
how do I resolve when all the setTimeouts are over?
>Solution :
Instead of setTimeout, you can use the built-in function of puppeteer:
await page.waitForTimeout(x * 2000);