Categories
JavaScript Answers

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

Spread the love

To wait until an element is visible with JavaScript Puppeteer, we call waitForSelector.

For instance, we write

const puppeteer = require("puppeteer");

const broswer = await puppeteer.launch();
const page = await browser.newPage();
await page.waitForSelector("#myId");
browser.close();

to call launch to launch the browser.

We call awaitForSelector to wait for the element with ID myId to show.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *