Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
method Frame.prototype.waitForSelector
import { Frame } from "https://deno.land/x/pptr@1.2.0/src/FrameManager.ts";

Examples

Example 1

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  let currentURL;
  page.mainFrame()
  .waitForSelector('img')
  .then(() => console.log('First URL with image: ' + currentURL));

  for (currentURL of ['https://example.com', 'https://google.com', 'https://bbc.com']) {
    await page.goto(currentURL);
  }
  await browser.close();
})();

Parameters

selector: string
  • the selector to wait for.
optional
options: WaitForSelectorOptions = [UNSUPPORTED]
  • options to define if the element should be visible and how long to wait before timing out.

Returns

Promise<ElementHandle | null>

a promise which resolves when an element matching the selector string is added to the DOM.