It executes concurrently while the page is loading
page.on('response', async response => {});
I use this to scroll the page, but it does it after the page has finished loading
async function autoScroll(page){
await page.evaluate(async () => {
await new Promise((resolve, reject) => {
var totalHeight = 0;
var distance = 500;
var timer = setInterval(() => {
var scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;
if(totalHeight >= scrollHeight){
clearInterval(timer);
resolve();
}
}, 100);
});
});
}
Lazy loading demo: https://davidwalsh.name/demo/lazyload-2.0.php
Does anyone have a way?