import { Browser } from "https://dotland.deno.dev/x/puppeteer@16.2.0/mod.ts";
A Browser is created when Puppeteer connects to a Chromium instance, either through {@link PuppeteerNode.launch} or {@link Puppeteer.connect}.
Examples
An example of using a {@link Browser} to create a {@link Page}:
An example of using a {@link Browser} to create a {@link Page}:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await browser.close();
})();
An example of disconnecting from and reconnecting to a {@link Browser}:
An example of disconnecting from and reconnecting to a {@link 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
Methods
Returns an array of all open browser contexts. In a newly created browser, this will return a single instance of {@link BrowserContext}.
Closes Chromium and all of its pages (if any were opened). The {@link 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 {@link Browser} object is considered disposed and
cannot be used anymore.
Promise which resolves to a new {@link Page} object. The Page is created in a default browser context.
The spawned browser process. Returns null
if the browser instance was created with
{@link 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 {@link Page.setUserAgent}.
Searches for a target in all browser contexts.
The browser websocket endpoint which can be used as an argument to {@link Puppeteer.connect}.
Static Methods
import { Browser } from "https://dotland.deno.dev/x/puppeteer@16.2.0/mod.ts";
Copyright 2017 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.