Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Go to Latest
method Frame.prototype.waitForSelector
import { Frame } from "https://deno.land/x/puppeteer@14.1.1/vendor/puppeteer-core/puppeteer/common/FrameManager.d.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
  • 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.