import { Frame } from "https://deno.land/x/pptr@1.2.0/src/FrameManager.ts";
Examples
The waitForFunction
can be used to observe viewport size change:
The waitForFunction
can be used to observe viewport size change:
const puppeteer = require('puppeteer');
(async () => {
. const browser = await puppeteer.launch();
. const page = await browser.newPage();
. const watchDog = page.mainFrame().waitForFunction('window.innerWidth < 100');
. page.setViewport({width: 50, height: 50});
. await watchDog;
. await browser.close();
})();
To pass arguments from Node.ts to the predicate of page.waitForFunction
function:
const selector = '.foo';
await frame.waitForFunction(
selector => !!document.querySelector(selector),
{}, // empty options object
selector
);
Parameters
optional
options: FrameWaitForFunctionOptions = [UNSUPPORTED]- options to configure the polling method and timeout.
...args: SerializableOrJSHandle[]
- arguments to pass to the
pageFunction
.