I want to use Puppeteer to scroll inside a div that has a scrollbar, but where the overall window doesn't have a scrollbar. Let's take for example, the following URL:
You can see in the left hand side there are reviews, and the whole section has a scrollbar. A quick inspect element shows that the whole thing is surrounded by a div which has the following classes widget-pane-content scrollable-y
. So, I tried to do something like this:
const scrollable_section = 'div.widget-pane-content.scrollable-y';
await page.evaluate((selector) => {
const scrollableSection = document.querySelector(selector);
scrollableSection.scrollTop = scrollableSection.offsetHeight;
}, scrollable_section);
But, this didn't work. I also noticed that one clicks the space button, if it is focused inside the reviews section, it also scrolls down automatically. So, I also tried to do something like this:
await page.focus(scrollable_section);
await page.keyboard.press('Space');
But, this also didn't seem to work. Any ideas how can I scroll inside a div with Puppeteer?