     [Answers](https://scrapfly.io/blog)   /  [puppeteer](https://scrapfly.io/blog/tag/puppeteer)   /  [How to scroll to the bottom of the page with Puppeteer?](https://scrapfly.io/blog/answers/how-to-scroll-to-the-bottom-with-puppeteer)   # How to scroll to the bottom of the page with Puppeteer?

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) Jun 30, 2023 1 min read [\#puppeteer](https://scrapfly.io/blog/tag/puppeteer) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-scroll-to-the-bottom-with-puppeteer "Share on LinkedIn")    

 

 

When web scraping with Puppeteer we might encounter pages that require scrolling to the bottom to load more content. This is a common pattern for infinite scrolling pages.

To scroll our Puppeteer browser custom javascript function `window.scrollTo(x, y)` can be used. This function scrolls the page to the specified coordinates.

So, if we need to scroll to the very bottom of the page we can use a `while` loop to continuously scroll until the bottom is reached. Let's take a look at an example by scraping [web-scraping.dev/testimonials](https://web-scraping.dev/testimonials):

javascript```javascript
const puppeteer = require('puppeteer');

async function scrapeTestimonials() {
    const browser = await puppeteer.launch({headless: false});
    const page = await browser.newPage();

    await page.goto('https://web-scraping.dev/testimonials/');

    let prevHeight = -1;
    let maxScrolls = 100;
    let scrollCount = 0;

    while (scrollCount < maxScrolls) {
        // Scroll to the bottom of the page
        await page.evaluate('window.scrollTo(0, document.body.scrollHeight)');
        // Wait for page load
        await page.waitForTimeout(1000);
        // Calculate new scroll height and compare
        let newHeight = await page.evaluate('document.body.scrollHeight');
        if (newHeight == prevHeight) {
            break;
        }
        prevHeight = newHeight;
        scrollCount += 1;
    }

    // Collect all loaded data
    let elements = await page.$$('.testimonial');
    let results = [];
    for(let element of elements) {
        let text = await element.$eval('.text', node => node.innerHTML);
        results.push(text);
    }

    console.log(`Scraped: ${results.length} results!`);

    await browser.close();
}

scrapeTestimonials();
```



Above, we're scraping an endless paging example from the `web-scraping.dev` website. We start a `while` loop and keep scrolling to the bottom until the browser's vertical size stops changing. Then, once the bottom is reached we can start parsing the content.



 

    



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? Get our newsletter instead. 

 

## Explore this Article with AI

 [ ChatGPT ](https://chat.openai.com/?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-scroll-to-the-bottom-with-puppeteer) [ Gemini ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-scroll-to-the-bottom-with-puppeteer) [ Grok ](https://x.com/i/grok?text=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-scroll-to-the-bottom-with-puppeteer) [ Perplexity ](https://www.perplexity.ai/search/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-scroll-to-the-bottom-with-puppeteer) [ Claude ](https://claude.ai/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-scroll-to-the-bottom-with-puppeteer) 



 ## Related Articles

 [  

 nodejs headless-browser 

### How to Web Scrape with Puppeteer and NodeJS in 2026

Introduction to using Puppeteer in Nodejs for web scraping dynamic web pages and web apps. Tips and tricks, best practic...

 

 ](https://scrapfly.io/blog/posts/web-scraping-with-puppeteer-and-nodejs) [  

 http nodejs 

### Web Scraping With NodeJS and Javascript

In this article we'll take a look at scraping using Javascript through NodeJS. We'll cover common web scraping libraries...

 

 ](https://scrapfly.io/blog/posts/web-scraping-with-nodejs) [  

 python playwright 

### How to Scrape Google Maps

We'll take a look at to find businesses through Google Maps search system and how to scrape their details using either S...

 

 ](https://scrapfly.io/blog/posts/how-to-scrape-google-maps) 

  ## Related Questions

- [ Q How to scroll to the bottom of the page with Selenium? ](https://scrapfly.io/blog/answers/how-to-scroll-to-the-bottom-with-selenium)
- [ Q How to scroll to the bottom of the page with Playwright? ](https://scrapfly.io/blog/answers/how-to-scroll-to-the-bottom-with-playwright)
- [ Q How to scroll to an element in Selenium? ](https://scrapfly.io/blog/answers/scroll-to-element-selenium)
- [ Q Scrapy vs Beautifulsoup - what's the difference? ](https://scrapfly.io/blog/answers/scrapy-vs-beautifulsoup)
 
  



   



 Run headless browsers at scale, **1,000 free credits** [Start Free](https://scrapfly.io/register)