I use Node.js and Puppeteer and I need to scroll a list. There is a div
that opens with a popup. This div
is characterized by a class named "istrq"
. I've tried to use some code found here, but I can't get the complete list into the popup. This is the unique piece of code that scroll just a bit:
async function scrollDiv() {
try {
const scrollStep = 250
await page.$eval(`div.istrq`,
e => {
e.scrollTop = e.scrollTop + 200;
return e;
}
)
} catch (error) { console.log(error); }
}
How can I scroll until the end of the popup?
You can use nodeJS native function
scrollIntoView()
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
So if you want to scroll strict to this element (with ex align to top):
function scrollToElement(page, element) { await page.evaluate(elem => { elem.scrollIntoView(true) }, element}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.