How to wait until an element is visible with Puppeteer and JavaScript?

Estimated read time 1 min read

In Puppeteer, you can wait for an element to be visible by using the page.waitForSelector() method. Here’s an example:

const selector = '.element-selector';

await page.waitForSelector(selector, {
  visible: true,
});

// Now the element with the selector '.element-selector' is visible on the page

The page.waitForSelector() method takes two arguments:

  1. The selector for the element you want to wait for
  2. An options object with the visible property set to true, which specifies that you want to wait for the element to be visible

The method will wait until the element is visible on the page before moving on to the next line of code.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply