Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
I don't find a way to scrolldown in puppeteer

I want to use puppeteer to scroll down in the sidebar. there is a website called discord and I want puppeteer to scroll down the whole sidebar after the sidebar is loading

so I did

await page.waitForSelector('nav[aria-label="Servers sidebar"]')

and then I tried some function from stackoverflow but I didn't succses :(

Can I get anyhelp from you guys?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After page load execute regular JS to scroll to some element:

https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo or https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy

If you have some specific DOM element you want to scroll to, you will need it's offset from top.

e.g.:

await page.waitForSelector('nav[aria-label="Servers sidebar"]')

await page.evaluate(() => {
  const element = document.querySelectorAll('nav[aria-label="Servers sidebar"]')[0];
  if(element){
    const y = element.getBoundingClientRect().top + window.pageYOffset;
    window.scrollTo({top: y});        
  } else {
    console.error('Element by selector was not found :(');
  }      
});

If your selector will get back multiple elements, pick single. While you need single DOM element not array of those to get the bounding rect. Just like i did in sample code with [0] to pick 1st found

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!