Skip to main content
Module

x/puppeteer/mod.ts>Frame#waitForSelector

A port of puppeteer running on Deno
Latest
method Frame.prototype.waitForSelector
Re-export
import { Frame } from "https://deno.land/x/puppeteer@16.2.0/mod.ts";

Waits for an element matching the given selector to appear in the frame.

This method works across navigations.

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();
})();

Type Parameters

Selector extends string

Parameters

selector: Selector
  • The selector to query and wait for.
optional
options: WaitForSelectorOptions
  • Options for customizing waiting behavior.

Returns

Promise<ElementHandle<NodeFor<Selector>> | null>

An element matching the given selector.