JSFiddle - React, Tailwind, and code Playground
JavaScript
const autoScroll = async page => {
//Scrolls slowly to the bottom of the page
await page.evaluate(async () => {
await new Promise((resolve, reject) => {
var totalHeight = 0;
var distance = 200;
var timer = setInterval(() => {
var scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;
if(totalHeight >= scrollHeight) {
clearInterval(timer);
resolve();
}
}, 500);
});
});
};
await autoScroll(page);