import { Page } from "https://deno.land/x/pptr@1.2.0/src/Page.ts";
Page provides methods to interact with a single tab or extension background page in Chromium.
Examples
This example creates a page, navigates it to a URL, and then * saves a screenshot:
This example creates a page, navigates it to a URL, and then * saves a screenshot:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'screenshot.png'});
await browser.close();
})();
The Page class extends from Puppeteer's EventEmitter class and will emit various events which are documented in the PageEmittedEvents enum.
This example logs a message for a single page load
event:
This example logs a message for a single page load
event:
page.once('load', () => console.log('Page loaded!'));
To unsubscribe from events use the off
method:
function logRequest(interceptedRequest) {
console.log('A request was made:', interceptedRequest.url());
}
page.on('request', logRequest);
// Sometime later...
page.off('request', logRequest);
Constructors
Properties
Methods
Runs document.querySelector
within the page. If no element matches the
selector, the return value resolves to null
.
This method runs Array.from(document.querySelectorAll(selector))
within
the page and passes the result as the first argument to the pageFunction
.
This method runs document.querySelector
within the page and passes the
result as the first argument to the pageFunction
.
If no URLs are specified, this method returns cookies for the current page URL. If URLs are specified, only cookies for those URLs are returned.
Emulates the idle state. If no arguments set, clears idle state emulation.
Simulates the given vision deficiency on the page.
Generatees a PDF of the page with the print
CSS media type.
This method iterates the JavaScript heap and finds all objects with the given prototype.
Sets the page's geolocation.
Causes your script to wait for the given number of milliseconds.