I try to scroll area inside div using Puppeteer.
I tried to follow these answers: https://stackoverflow.com/a/67490337 and https://stackoverflow.com/a/52031392 but it didn't work.
Page I try to scroll - https://yandex.ru/profile/1899402108
My code looks like this:
const scrollable_section = '.business-tab-wrapper__content';
await this.page.waitForSelector('.business-reviews-card-view__review');
await this.page.evaluate(selector => {
const scrollableSection = document.querySelector(selector);
scrollableSection.scrollTop = scrollableSection.offsetHeight;
}, scrollable_section);
Previously tried this code but it didn't work too:
await this.page.evaluate(async () => {
await new Promise(resolve => {
let totalHeight = 0;
const distance = 100;
const timer = setInterval(() => {
const scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;
if (totalHeight >= scrollHeight) {
clearInterval(timer);
resolve();
}
}, 100);
});
});