     [Answers](https://scrapfly.io/blog)   /  [headless-browser](https://scrapfly.io/blog/tag/headless-browser)   /  [How to wait for a page to load in Puppeteer?](https://scrapfly.io/blog/answers/how-to-wait-for-page-to-load-in-puppeteer)   # How to wait for a page to load in Puppeteer?

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) Oct 28, 2022 1 min read [\#headless-browser](https://scrapfly.io/blog/tag/headless-browser) [\#puppeteer](https://scrapfly.io/blog/tag/puppeteer) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-wait-for-page-to-load-in-puppeteer "Share on LinkedIn") [  ](https://x.com/intent/tweet?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-wait-for-page-to-load-in-puppeteer&text=How%20to%20wait%20for%20a%20page%20to%20load%20in%20Puppeteer%3F "Share on X") [  ](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-wait-for-page-to-load-in-puppeteer "Share on Facebook")    

 

 

Summarize this article with

 [  ](https://chat.openai.com/?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-wait-for-page-to-load-in-puppeteer) [  ](https://claude.ai/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-wait-for-page-to-load-in-puppeteer) [  ](https://x.com/i/grok?text=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-wait-for-page-to-load-in-puppeteer) [  ](https://www.perplexity.ai/search/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-wait-for-page-to-load-in-puppeteer) [  ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-wait-for-page-to-load-in-puppeteer) 



When scraping dynamic web pages with Puppeteer and NodeJS we need to wait for the page to fully load before we retrieve the page source. Using Puppeteer's `waitForSelector` method we can wait for a specific element to appear on the page which indicates that the web page has fully loaded and then we can grab the page source:

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

async function run() {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto("https://httpbin.dev/");
    // wait for the selector appear on the page in this case we wait for "Auth" drop down to appear:
    await page.waitForSelector('#operations-tag-Auth', {timeout: 5_000});
    console.log(await page.content());
    browser.close();
}

run();
```





 

   [  Add as a preferred source ](https://google.com/preferences/source?q=scrapfly.io)   Join the Newsletter  Get monthly web scraping insights 

 

  



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. 

 

 ## 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) [  

 python headless-browser 

### How To Take Screenshots In Python?

Learn how to take Python screenshots through Selenium and Playwright, including common browser tips and tricks for custo...

 

 ](https://scrapfly.io/blog/posts/how-to-take-screenshots-in-python) [     

 blocking nodejs 

### Puppeteer Stealth: Complete Guide to Avoiding Detection

Complete guide to puppeteer-extra-plugin-stealth for avoiding bot detection. Learn how detection works, configure stealt...

 

 ](https://scrapfly.io/blog/posts/puppeteer-stealth-complete-guide) 

  ## Related Questions

- [ Q How to wait for page to load in Selenium? ](https://scrapfly.io/blog/answers/how-to-wait-for-page-to-load-in-selenium)
- [ Q How to take a screenshot with Selenium? ](https://scrapfly.io/blog/answers/how-to-take-screenshot-with-selenium)
- [ Q How to load local files in Puppeteer? ](https://scrapfly.io/blog/answers/how-to-load-local-files-in-puppeteer)
- [ Q How to save and load cookies in Puppeteer? ](https://scrapfly.io/blog/answers/how-to-save-and-load-cookies-in-puppeteer)
 
  



   



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