import { Browser } from "https://deno.land/x/pptr@1.2.0/mod.ts";
A Browser is created when Puppeteer connects to a Chromium instance, either through PuppeteerNode.launch or Puppeteer.connect.
Examples
An example of disconnecting from and reconnecting to a Browser:
An example of disconnecting from and reconnecting to a Browser:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
// Store the endpoint to be able to reconnect to Chromium
const browserWSEndpoint = browser.wsEndpoint();
// Disconnect puppeteer from Chromium
browser.disconnect();
// Use the endpoint to reestablish a connection
const browser2 = await puppeteer.connect({browserWSEndpoint});
// Close Chromium
await browser2.close();
})();
Constructors
Properties
Methods
Returns an array of all open browser contexts. In a newly created browser, this will return a single instance of BrowserContext.
Closes Chromium and all of its pages (if any were opened). The Browser object itself is considered to be disposed and cannot be used anymore.
Creates a new incognito browser context. This won't share cookies/cache with other browser contexts.
Returns the default browser context. The default browser context cannot be closed.
Disconnects Puppeteer from the browser, but leaves the Chromium process running.
After calling disconnect
, the Browser object is considered disposed and
cannot be used anymore.
Indicates that the browser is connected.
The spawned browser process. Returns null
if the browser instance was created with
Puppeteer.connect.
All active targets inside the Browser. In case of multiple browser contexts, returns an array with all the targets in all browser contexts.
The browser's original user agent. Pages can override the browser user agent with Page.setUserAgent.
A string representing the browser name and version.
Searches for a target in all browser contexts.
The browser websocket endpoint which can be used as an argument to Puppeteer.connect.