mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: release main (#10907)
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This commit is contained in:
parent
86df093824
commit
04384aeaec
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"packages/puppeteer": "21.2.1",
|
"packages/puppeteer": "21.3.0",
|
||||||
"packages/puppeteer-core": "21.2.1",
|
"packages/puppeteer-core": "21.3.0",
|
||||||
"packages/testserver": "0.6.0",
|
"packages/testserver": "0.6.0",
|
||||||
"packages/ng-schematics": "0.5.0",
|
"packages/ng-schematics": "0.5.0",
|
||||||
"packages/browsers": "1.7.1"
|
"packages/browsers": "1.7.1"
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -11406,20 +11406,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/puppeteer": {
|
"packages/puppeteer": {
|
||||||
"version": "21.2.1",
|
"version": "21.3.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@puppeteer/browsers": "1.7.1",
|
"@puppeteer/browsers": "1.7.1",
|
||||||
"cosmiconfig": "8.3.6",
|
"cosmiconfig": "8.3.6",
|
||||||
"puppeteer-core": "21.2.1"
|
"puppeteer-core": "21.3.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.3.0"
|
"node": ">=16.3.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/puppeteer-core": {
|
"packages/puppeteer-core": {
|
||||||
"version": "21.2.1",
|
"version": "21.3.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@puppeteer/browsers": "1.7.1",
|
"@puppeteer/browsers": "1.7.1",
|
||||||
|
@ -20,6 +20,25 @@ All notable changes to this project will be documented in this file. See [standa
|
|||||||
* dependencies
|
* dependencies
|
||||||
* @puppeteer/browsers bumped from 1.5.1 to 1.6.0
|
* @puppeteer/browsers bumped from 1.5.1 to 1.6.0
|
||||||
|
|
||||||
|
## [21.3.0](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v21.2.1...puppeteer-core-v21.3.0) (2023-09-19)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* implement `Browser.connected` ([#10927](https://github.com/puppeteer/puppeteer/issues/10927)) ([a4345a4](https://github.com/puppeteer/puppeteer/commit/a4345a477f58541f5d95da11ffee74abe24c12bf))
|
||||||
|
* implement `BrowserContext.closed` ([#10928](https://github.com/puppeteer/puppeteer/issues/10928)) ([2292078](https://github.com/puppeteer/puppeteer/commit/2292078969fa46a27d5759989cd44a4d48beb310))
|
||||||
|
* implement improved Drag n' Drop APIs ([#10651](https://github.com/puppeteer/puppeteer/issues/10651)) ([9342bac](https://github.com/puppeteer/puppeteer/commit/9342bac2639702090f39fc1e3a97d43a934f3f0b))
|
||||||
|
* implement typed events ([#10889](https://github.com/puppeteer/puppeteer/issues/10889)) ([9b6f1de](https://github.com/puppeteer/puppeteer/commit/9b6f1de8b99445c661c5aebcf041fe90daf469b9))
|
||||||
|
* roll to Chrome 117.0.5938.62 (r1181205) ([#10893](https://github.com/puppeteer/puppeteer/issues/10893)) ([4b8d20d](https://github.com/puppeteer/puppeteer/commit/4b8d20d0edeccaa3028e0c1c0b63c022cfabcee2))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix line/column number in errors ([#10926](https://github.com/puppeteer/puppeteer/issues/10926)) ([a0e57f7](https://github.com/puppeteer/puppeteer/commit/a0e57f7eb230ba6a659c2d418da8d3f67add2d00))
|
||||||
|
* handle frame manager init without unhandled rejection ([#10902](https://github.com/puppeteer/puppeteer/issues/10902)) ([ea14834](https://github.com/puppeteer/puppeteer/commit/ea14834fdf1c7c1afa45bdd1fb5339380f4631a2))
|
||||||
|
* remove explicit resource management from types ([#10918](https://github.com/puppeteer/puppeteer/issues/10918)) ([a1b1bff](https://github.com/puppeteer/puppeteer/commit/a1b1bffb7258f1dec3b0a2e9ce068baf2cc3db19))
|
||||||
|
* roll to Chrome 117.0.5938.88 (r1181205) ([#10920](https://github.com/puppeteer/puppeteer/issues/10920)) ([b7bcc9a](https://github.com/puppeteer/puppeteer/commit/b7bcc9a733a3ac376397a32c3f62eb68101bedf9))
|
||||||
|
|
||||||
## [21.2.1](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v21.2.0...puppeteer-core-v21.2.1) (2023-09-13)
|
## [21.2.1](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v21.2.0...puppeteer-core-v21.2.1) (2023-09-13)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "puppeteer-core",
|
"name": "puppeteer-core",
|
||||||
"version": "21.2.1",
|
"version": "21.3.0",
|
||||||
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
|
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"puppeteer",
|
"puppeteer",
|
||||||
|
@ -29,6 +29,20 @@ All notable changes to this project will be documented in this file. See [standa
|
|||||||
* puppeteer-core bumped from 21.0.2 to 21.0.3
|
* puppeteer-core bumped from 21.0.2 to 21.0.3
|
||||||
* @puppeteer/browsers bumped from 1.5.1 to 1.6.0
|
* @puppeteer/browsers bumped from 1.5.1 to 1.6.0
|
||||||
|
|
||||||
|
## [21.3.0](https://github.com/puppeteer/puppeteer/compare/puppeteer-v21.2.1...puppeteer-v21.3.0) (2023-09-19)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **puppeteer:** Synchronize puppeteer versions
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* puppeteer-core bumped from 21.2.1 to 21.3.0
|
||||||
|
|
||||||
## [21.2.1](https://github.com/puppeteer/puppeteer/compare/puppeteer-v21.2.0...puppeteer-v21.2.1) (2023-09-13)
|
## [21.2.1](https://github.com/puppeteer/puppeteer/compare/puppeteer-v21.2.0...puppeteer-v21.2.1) (2023-09-13)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "puppeteer",
|
"name": "puppeteer",
|
||||||
"version": "21.2.1",
|
"version": "21.3.0",
|
||||||
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
|
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"puppeteer",
|
"puppeteer",
|
||||||
@ -122,7 +122,7 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cosmiconfig": "8.3.6",
|
"cosmiconfig": "8.3.6",
|
||||||
"puppeteer-core": "21.2.1",
|
"puppeteer-core": "21.3.0",
|
||||||
"@puppeteer/browsers": "1.7.1"
|
"@puppeteer/browsers": "1.7.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.[Symbol.asyncDispose]
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.\[Symbol.asyncDispose\]() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
[Symbol.asyncDispose](): Promise<void>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<void>
|
|
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.[Symbol.dispose]
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.\[Symbol.dispose\]() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
[Symbol.dispose](): void;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
void
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.browserContexts
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.browserContexts() method
|
|
||||||
|
|
||||||
Returns an array of all open browser contexts. In a newly created browser, this will return a single instance of [BrowserContext](./puppeteer.browsercontext.md).
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
browserContexts(): BrowserContext[];
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
[BrowserContext](./puppeteer.browsercontext.md)\[\]
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.close
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.close() method
|
|
||||||
|
|
||||||
Closes the browser and all of its pages (if any were opened). The [Browser](./puppeteer.browser.md) object itself is considered to be disposed and cannot be used anymore.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
close(): Promise<void>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<void>
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.disconnect
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.disconnect() method
|
|
||||||
|
|
||||||
Disconnects Puppeteer from the browser, but leaves the browser process running. After calling `disconnect`, the [Browser](./puppeteer.browser.md) object is considered disposed and cannot be used anymore.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
disconnect(): void;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
void
|
|
@ -1,81 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser class
|
|
||||||
|
|
||||||
A Browser is created when Puppeteer connects to a browser instance, either through [PuppeteerNode.launch()](./puppeteer.puppeteernode.launch.md) or [Puppeteer.connect()](./puppeteer.puppeteer.connect.md).
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export declare class Browser extends EventEmitter implements AsyncDisposable, Disposable
|
|
||||||
```
|
|
||||||
|
|
||||||
**Extends:** [EventEmitter](./puppeteer.eventemitter.md)
|
|
||||||
|
|
||||||
**Implements:** AsyncDisposable, Disposable
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
The Browser class extends from Puppeteer's [EventEmitter](./puppeteer.eventemitter.md) class and will emit various events which are documented in the [BrowserEmittedEvents](./puppeteer.browseremittedevents.md) enum.
|
|
||||||
|
|
||||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `Browser` class.
|
|
||||||
|
|
||||||
## Example 1
|
|
||||||
|
|
||||||
An example of using a [Browser](./puppeteer.browser.md) to create a [Page](./puppeteer.page.md):
|
|
||||||
|
|
||||||
```ts
|
|
||||||
import puppeteer from 'puppeteer';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const browser = await puppeteer.launch();
|
|
||||||
const page = await browser.newPage();
|
|
||||||
await page.goto('https://example.com');
|
|
||||||
await browser.close();
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
|
|
||||||
## Example 2
|
|
||||||
|
|
||||||
An example of disconnecting from and reconnecting to a [Browser](./puppeteer.browser.md):
|
|
||||||
|
|
||||||
```ts
|
|
||||||
import puppeteer from 'puppeteer';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const browser = await puppeteer.launch();
|
|
||||||
// Store the endpoint to be able to reconnect to the browser.
|
|
||||||
const browserWSEndpoint = browser.wsEndpoint();
|
|
||||||
// Disconnect puppeteer from the browser.
|
|
||||||
browser.disconnect();
|
|
||||||
|
|
||||||
// Use the endpoint to reestablish a connection
|
|
||||||
const browser2 = await puppeteer.connect({browserWSEndpoint});
|
|
||||||
// Close the browser.
|
|
||||||
await browser2.close();
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
| Method | Modifiers | Description |
|
|
||||||
| ---------------------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| [\[Symbol.asyncDispose\]()](./puppeteer.browser._symbol.asyncdispose_.md) | | |
|
|
||||||
| [\[Symbol.dispose\]()](./puppeteer.browser._symbol.dispose_.md) | | |
|
|
||||||
| [browserContexts()](./puppeteer.browser.browsercontexts.md) | | Returns an array of all open browser contexts. In a newly created browser, this will return a single instance of [BrowserContext](./puppeteer.browsercontext.md). |
|
|
||||||
| [close()](./puppeteer.browser.close.md) | | Closes the browser and all of its pages (if any were opened). The [Browser](./puppeteer.browser.md) object itself is considered to be disposed and cannot be used anymore. |
|
|
||||||
| [createIncognitoBrowserContext(options)](./puppeteer.browser.createincognitobrowsercontext.md) | | Creates a new incognito browser context. This won't share cookies/cache with other browser contexts. |
|
|
||||||
| [defaultBrowserContext()](./puppeteer.browser.defaultbrowsercontext.md) | | Returns the default browser context. The default browser context cannot be closed. |
|
|
||||||
| [disconnect()](./puppeteer.browser.disconnect.md) | | Disconnects Puppeteer from the browser, but leaves the browser process running. After calling <code>disconnect</code>, the [Browser](./puppeteer.browser.md) object is considered disposed and cannot be used anymore. |
|
|
||||||
| [isConnected()](./puppeteer.browser.isconnected.md) | | Indicates that the browser is connected. |
|
|
||||||
| [newPage()](./puppeteer.browser.newpage.md) | | Promise which resolves to a new [Page](./puppeteer.page.md) object. The Page is created in a default browser context. |
|
|
||||||
| [pages()](./puppeteer.browser.pages.md) | | An array of all open pages inside the Browser. |
|
|
||||||
| [process()](./puppeteer.browser.process.md) | | The spawned browser process. Returns <code>null</code> if the browser instance was created with [Puppeteer.connect()](./puppeteer.puppeteer.connect.md). |
|
|
||||||
| [target()](./puppeteer.browser.target.md) | | The target associated with the browser. |
|
|
||||||
| [targets()](./puppeteer.browser.targets.md) | | All active targets inside the Browser. In case of multiple browser contexts, returns an array with all the targets in all browser contexts. |
|
|
||||||
| [userAgent()](./puppeteer.browser.useragent.md) | | The browser's original user agent. Pages can override the browser user agent with [Page.setUserAgent()](./puppeteer.page.setuseragent.md). |
|
|
||||||
| [version()](./puppeteer.browser.version.md) | | A string representing the browser name and version. |
|
|
||||||
| [waitForTarget(predicate, options)](./puppeteer.browser.waitfortarget.md) | | Searches for a target in all browser contexts. |
|
|
||||||
| [wsEndpoint()](./puppeteer.browser.wsendpoint.md) | | The browser websocket endpoint which can be used as an argument to [Puppeteer.connect()](./puppeteer.puppeteer.connect.md). |
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.pages
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.pages() method
|
|
||||||
|
|
||||||
An array of all open pages inside the Browser.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
pages(): Promise<Page[]>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<[Page](./puppeteer.page.md)\[\]>
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
In case of multiple browser contexts, returns an array with all the pages in all browser contexts. Non-visible pages, such as `"background_page"`, will not be listed here. You can find them using [Target.page()](./puppeteer.target.page.md).
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.process
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.process() method
|
|
||||||
|
|
||||||
The spawned browser process. Returns `null` if the browser instance was created with [Puppeteer.connect()](./puppeteer.puppeteer.connect.md).
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
process(): ChildProcess | null;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
ChildProcess \| null
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.targets
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.targets() method
|
|
||||||
|
|
||||||
All active targets inside the Browser. In case of multiple browser contexts, returns an array with all the targets in all browser contexts.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
targets(): Target[];
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
[Target](./puppeteer.target.md)\[\]
|
|
@ -1,25 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.version
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.version() method
|
|
||||||
|
|
||||||
A string representing the browser name and version.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
version(): Promise<string>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<string>
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
For headless browser, this is similar to `HeadlessChrome/61.0.3153.0`. For non-headless or new-headless, this is similar to `Chrome/61.0.3153.0`. For Firefox, it is similar to `Firefox/116.0a1`.
|
|
||||||
|
|
||||||
The format of browser.version() might change with future releases of browsers.
|
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Browser.wsEndpoint
|
|
||||||
---
|
|
||||||
|
|
||||||
# Browser.wsEndpoint() method
|
|
||||||
|
|
||||||
The browser websocket endpoint which can be used as an argument to [Puppeteer.connect()](./puppeteer.puppeteer.connect.md).
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Browser {
|
|
||||||
wsEndpoint(): string;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
string
|
|
||||||
|
|
||||||
The Browser websocket url.
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
The format is `ws://${host}:${port}/devtools/browser/<id>`.
|
|
||||||
|
|
||||||
You can find the `webSocketDebuggerUrl` from `http://${host}:${port}/json/version`. Learn more about the [devtools protocol](https://chromedevtools.github.io/devtools-protocol) and the [browser endpoint](https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target).
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: BrowserContext.close
|
|
||||||
---
|
|
||||||
|
|
||||||
# BrowserContext.close() method
|
|
||||||
|
|
||||||
Closes the browser context. All the targets that belong to the browser context will be closed.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class BrowserContext {
|
|
||||||
close(): Promise<void>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<void>
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
Only incognito browser contexts can be closed.
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: BrowserContext.isIncognito
|
|
||||||
---
|
|
||||||
|
|
||||||
# BrowserContext.isIncognito() method
|
|
||||||
|
|
||||||
Returns whether BrowserContext is incognito. The default browser context is the only non-incognito browser context.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class BrowserContext {
|
|
||||||
isIncognito(): boolean;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
boolean
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
The default browser context cannot be closed.
|
|
@ -1,58 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: BrowserContext
|
|
||||||
---
|
|
||||||
|
|
||||||
# BrowserContext class
|
|
||||||
|
|
||||||
BrowserContexts provide a way to operate multiple independent browser sessions. When a browser is launched, it has a single BrowserContext used by default. The method [Browser.newPage](./puppeteer.browser.newpage.md) creates a page in the default browser context.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export declare class BrowserContext extends EventEmitter
|
|
||||||
```
|
|
||||||
|
|
||||||
**Extends:** [EventEmitter](./puppeteer.eventemitter.md)
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
The Browser class extends from Puppeteer's [EventEmitter](./puppeteer.eventemitter.md) class and will emit various events which are documented in the [BrowserContextEmittedEvents](./puppeteer.browsercontextemittedevents.md) enum.
|
|
||||||
|
|
||||||
If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser context.
|
|
||||||
|
|
||||||
Puppeteer allows creation of "incognito" browser contexts with [Browser.createIncognitoBrowserContext](./puppeteer.browser.createincognitobrowsercontext.md) method. "Incognito" browser contexts don't write any browsing data to disk.
|
|
||||||
|
|
||||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `BrowserContext` class.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```ts
|
|
||||||
// Create a new incognito browser context
|
|
||||||
const context = await browser.createIncognitoBrowserContext();
|
|
||||||
// Create a new page inside context.
|
|
||||||
const page = await context.newPage();
|
|
||||||
// ... do stuff with page ...
|
|
||||||
await page.goto('https://example.com');
|
|
||||||
// Dispose context once it's no longer needed.
|
|
||||||
await context.close();
|
|
||||||
```
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
| Property | Modifiers | Type | Description |
|
|
||||||
| -------- | --------------------- | ------------------- | ----------- |
|
|
||||||
| id | <code>readonly</code> | string \| undefined | |
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
| Method | Modifiers | Description |
|
|
||||||
| --------------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| [browser()](./puppeteer.browsercontext.browser.md) | | The browser this browser context belongs to. |
|
|
||||||
| [clearPermissionOverrides()](./puppeteer.browsercontext.clearpermissionoverrides.md) | | Clears all permission overrides for the browser context. |
|
|
||||||
| [close()](./puppeteer.browsercontext.close.md) | | Closes the browser context. All the targets that belong to the browser context will be closed. |
|
|
||||||
| [isIncognito()](./puppeteer.browsercontext.isincognito.md) | | Returns whether BrowserContext is incognito. The default browser context is the only non-incognito browser context. |
|
|
||||||
| [newPage()](./puppeteer.browsercontext.newpage.md) | | Creates a new page in the browser context. |
|
|
||||||
| [overridePermissions(origin, permissions)](./puppeteer.browsercontext.overridepermissions.md) | | |
|
|
||||||
| [pages()](./puppeteer.browsercontext.pages.md) | | An array of all pages inside the browser context. |
|
|
||||||
| [targets()](./puppeteer.browsercontext.targets.md) | | An array of all active targets inside the browser context. |
|
|
||||||
| [waitForTarget(predicate, options)](./puppeteer.browsercontext.waitfortarget.md) | | This searches for a target in this specific browser context. |
|
|
@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: BrowserContext.pages
|
|
||||||
---
|
|
||||||
|
|
||||||
# BrowserContext.pages() method
|
|
||||||
|
|
||||||
An array of all pages inside the browser context.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class BrowserContext {
|
|
||||||
pages(): Promise<Page[]>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<[Page](./puppeteer.page.md)\[\]>
|
|
||||||
|
|
||||||
Promise which resolves to an array of all open pages. Non visible pages, such as `"background_page"`, will not be listed here. You can find them using [the target page](./puppeteer.target.page.md).
|
|
@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: BrowserContext.waitForTarget
|
|
||||||
---
|
|
||||||
|
|
||||||
# BrowserContext.waitForTarget() method
|
|
||||||
|
|
||||||
This searches for a target in this specific browser context.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class BrowserContext {
|
|
||||||
waitForTarget(
|
|
||||||
predicate: (x: Target) => boolean | Promise<boolean>,
|
|
||||||
options?: {
|
|
||||||
timeout?: number;
|
|
||||||
}
|
|
||||||
): Promise<Target>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| predicate | (x: [Target](./puppeteer.target.md)) => boolean \| Promise<boolean> | A function to be run for every target |
|
|
||||||
| options | { timeout?: number; } | _(Optional)_ An object of options. Accepts a timeout, which is the maximum wait time in milliseconds. Pass <code>0</code> to disable the timeout. Defaults to 30 seconds. |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<[Target](./puppeteer.target.md)>
|
|
||||||
|
|
||||||
Promise which resolves to the first target found that matches the `predicate` function.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
An example of finding a target for a page opened via `window.open`:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
await page.evaluate(() => window.open('https://www.example.com/'));
|
|
||||||
const newWindowTarget = await browserContext.waitForTarget(
|
|
||||||
target => target.url() === 'https://www.example.com/'
|
|
||||||
);
|
|
||||||
```
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: CommonEventEmitter.addListener
|
|
||||||
---
|
|
||||||
|
|
||||||
# CommonEventEmitter.addListener() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface CommonEventEmitter {
|
|
||||||
addListener(event: EventType, handler: Handler): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ----------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md) | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: CommonEventEmitter.emit
|
|
||||||
---
|
|
||||||
|
|
||||||
# CommonEventEmitter.emit() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface CommonEventEmitter {
|
|
||||||
emit(event: EventType, eventData?: unknown): boolean;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ------------ |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | |
|
|
||||||
| eventData | unknown | _(Optional)_ |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
boolean
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: CommonEventEmitter
|
|
||||||
---
|
|
||||||
|
|
||||||
# CommonEventEmitter interface
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export interface CommonEventEmitter
|
|
||||||
```
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| ---------------------------------------------------------------------------------- | ----------- |
|
|
||||||
| [addListener(event, handler)](./puppeteer.commoneventemitter.addlistener.md) | |
|
|
||||||
| [emit(event, eventData)](./puppeteer.commoneventemitter.emit.md) | |
|
|
||||||
| [listenerCount(event)](./puppeteer.commoneventemitter.listenercount.md) | |
|
|
||||||
| [off(event, handler)](./puppeteer.commoneventemitter.off.md) | |
|
|
||||||
| [on(event, handler)](./puppeteer.commoneventemitter.on.md) | |
|
|
||||||
| [once(event, handler)](./puppeteer.commoneventemitter.once.md) | |
|
|
||||||
| [removeAllListeners(event)](./puppeteer.commoneventemitter.removealllisteners.md) | |
|
|
||||||
| [removeListener(event, handler)](./puppeteer.commoneventemitter.removelistener.md) | |
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: CommonEventEmitter.off
|
|
||||||
---
|
|
||||||
|
|
||||||
# CommonEventEmitter.off() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface CommonEventEmitter {
|
|
||||||
off(event: EventType, handler: Handler): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ----------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md) | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: CommonEventEmitter.on
|
|
||||||
---
|
|
||||||
|
|
||||||
# CommonEventEmitter.on() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface CommonEventEmitter {
|
|
||||||
on(event: EventType, handler: Handler): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ----------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md) | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: CommonEventEmitter.once
|
|
||||||
---
|
|
||||||
|
|
||||||
# CommonEventEmitter.once() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface CommonEventEmitter {
|
|
||||||
once(event: EventType, handler: Handler): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ----------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md) | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: CommonEventEmitter.removeAllListeners
|
|
||||||
---
|
|
||||||
|
|
||||||
# CommonEventEmitter.removeAllListeners() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface CommonEventEmitter {
|
|
||||||
removeAllListeners(event?: EventType): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ------------ |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | _(Optional)_ |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: CommonEventEmitter.removeListener
|
|
||||||
---
|
|
||||||
|
|
||||||
# CommonEventEmitter.removeListener() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface CommonEventEmitter {
|
|
||||||
removeListener(event: EventType, handler: Handler): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ----------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md) | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,30 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter.addListener
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter.addListener() method
|
|
||||||
|
|
||||||
> Warning: This API is now obsolete.
|
|
||||||
>
|
|
||||||
> please use [EventEmitter.on()](./puppeteer.eventemitter.on.md) instead.
|
|
||||||
|
|
||||||
Add an event listener.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class EventEmitter {
|
|
||||||
addListener(event: EventType, handler: Handler<any>): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------- | ----------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md)<any> | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter.emit
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter.emit() method
|
|
||||||
|
|
||||||
Emit an event and call any associated listeners.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class EventEmitter {
|
|
||||||
emit(event: EventType, eventData?: unknown): boolean;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ------------------------------------------------------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | the event you'd like to emit |
|
|
||||||
| eventData | unknown | _(Optional)_ any data you'd like to emit with the event |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
boolean
|
|
||||||
|
|
||||||
`true` if there are any listeners, `false` if there are not.
|
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter.listenerCount
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter.listenerCount() method
|
|
||||||
|
|
||||||
Gets the number of listeners for a given event.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class EventEmitter {
|
|
||||||
listenerCount(event: EventType): number;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | --------------------------------------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | the event to get the listener count for |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
number
|
|
||||||
|
|
||||||
the number of listeners bound to the given event
|
|
@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter class
|
|
||||||
|
|
||||||
The EventEmitter class that many Puppeteer classes extend.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export declare class EventEmitter implements CommonEventEmitter
|
|
||||||
```
|
|
||||||
|
|
||||||
**Implements:** [CommonEventEmitter](./puppeteer.commoneventemitter.md)
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
This allows you to listen to events that Puppeteer classes fire and act accordingly. Therefore you'll mostly use [on](./puppeteer.eventemitter.on.md) and [off](./puppeteer.eventemitter.off.md) to bind and unbind to event listeners.
|
|
||||||
|
|
||||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `EventEmitter` class.
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
| Method | Modifiers | Description |
|
|
||||||
| ---------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------ |
|
|
||||||
| [addListener(event, handler)](./puppeteer.eventemitter.addlistener.md) | | Add an event listener. |
|
|
||||||
| [emit(event, eventData)](./puppeteer.eventemitter.emit.md) | | Emit an event and call any associated listeners. |
|
|
||||||
| [listenerCount(event)](./puppeteer.eventemitter.listenercount.md) | | Gets the number of listeners for a given event. |
|
|
||||||
| [off(event, handler)](./puppeteer.eventemitter.off.md) | | Remove an event listener from firing. |
|
|
||||||
| [on(event, handler)](./puppeteer.eventemitter.on.md) | | Bind an event listener to fire when an event occurs. |
|
|
||||||
| [once(event, handler)](./puppeteer.eventemitter.once.md) | | Like <code>on</code> but the listener will only be fired once and then it will be removed. |
|
|
||||||
| [removeAllListeners(event)](./puppeteer.eventemitter.removealllisteners.md) | | Removes all listeners. If given an event argument, it will remove only listeners for that event. |
|
|
||||||
| [removeListener(event, handler)](./puppeteer.eventemitter.removelistener.md) | | Remove an event listener. |
|
|
@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter.off
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter.off() method
|
|
||||||
|
|
||||||
Remove an event listener from firing.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class EventEmitter {
|
|
||||||
off(event: EventType, handler: Handler<any>): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------- | ----------------------------------------------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | the event type you'd like to stop listening to. |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md)<any> | the function that should be removed. |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
||||||
|
|
||||||
`this` to enable you to chain method calls.
|
|
@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter.on
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter.on() method
|
|
||||||
|
|
||||||
Bind an event listener to fire when an event occurs.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class EventEmitter {
|
|
||||||
on(event: EventType, handler: Handler<any>): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------- | ------------------------------------------------------------------ |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | the event type you'd like to listen to. Can be a string or symbol. |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md)<any> | the function to be called when the event occurs. |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
||||||
|
|
||||||
`this` to enable you to chain method calls.
|
|
@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter.once
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter.once() method
|
|
||||||
|
|
||||||
Like `on` but the listener will only be fired once and then it will be removed.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class EventEmitter {
|
|
||||||
once(event: EventType, handler: Handler<any>): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------- | ------------------------------------------------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | the event you'd like to listen to |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md)<any> | the handler function to run when the event occurs |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
||||||
|
|
||||||
`this` to enable you to chain method calls.
|
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter.removeAllListeners
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter.removeAllListeners() method
|
|
||||||
|
|
||||||
Removes all listeners. If given an event argument, it will remove only listeners for that event.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class EventEmitter {
|
|
||||||
removeAllListeners(event?: EventType): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ------------------------------------- | ----------------------------------------------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | _(Optional)_ the event to remove listeners for. |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
||||||
|
|
||||||
`this` to enable you to chain method calls.
|
|
@ -1,30 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventEmitter.removeListener
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventEmitter.removeListener() method
|
|
||||||
|
|
||||||
> Warning: This API is now obsolete.
|
|
||||||
>
|
|
||||||
> please use [EventEmitter.off()](./puppeteer.eventemitter.off.md) instead.
|
|
||||||
|
|
||||||
Remove an event listener.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class EventEmitter {
|
|
||||||
removeListener(event: EventType, handler: Handler<any>): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------- | ----------- |
|
|
||||||
| event | [EventType](./puppeteer.eventtype.md) | |
|
|
||||||
| handler | [Handler](./puppeteer.handler.md)<any> | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: EventType
|
|
||||||
---
|
|
||||||
|
|
||||||
# EventType type
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export type EventType = string | symbol;
|
|
||||||
```
|
|
@ -1,43 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Frame.waitForNavigation
|
|
||||||
---
|
|
||||||
|
|
||||||
# Frame.waitForNavigation() method
|
|
||||||
|
|
||||||
Waits for the frame to navigate. It is useful for when you run code which will indirectly cause the frame to navigate.
|
|
||||||
|
|
||||||
Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Frame {
|
|
||||||
abstract waitForNavigation(options?: {
|
|
||||||
timeout?: number;
|
|
||||||
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
|
|
||||||
}): Promise<HTTPResponse | null>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
||||||
| options | { timeout?: number; waitUntil?: [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md) \| [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md)\[\]; } | _(Optional)_ options to configure when the navigation is consided finished. |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<[HTTPResponse](./puppeteer.httpresponse.md) \| null>
|
|
||||||
|
|
||||||
a promise that resolves when the frame navigates to a new URL.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const [response] = await Promise.all([
|
|
||||||
// The navigation promise resolves after navigation has finished
|
|
||||||
frame.waitForNavigation(),
|
|
||||||
// Clicking the link will indirectly cause a navigation
|
|
||||||
frame.click('a.my-link'),
|
|
||||||
]);
|
|
||||||
```
|
|
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: JSHandle.[Symbol.asyncDispose]
|
|
||||||
---
|
|
||||||
|
|
||||||
# JSHandle.\[Symbol.asyncDispose\]() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class JSHandle {
|
|
||||||
[Symbol.asyncDispose](): Promise<void>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<void>
|
|
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: JSHandle.[Symbol.dispose]
|
|
||||||
---
|
|
||||||
|
|
||||||
# JSHandle.\[Symbol.dispose\]() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class JSHandle {
|
|
||||||
[Symbol.dispose](): void;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
void
|
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Locator.off
|
|
||||||
---
|
|
||||||
|
|
||||||
# Locator.off() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Locator {
|
|
||||||
off<K extends keyof LocatorEventObject>(
|
|
||||||
eventName: K,
|
|
||||||
handler: (event: LocatorEventObject[K]) => void
|
|
||||||
): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------------------------------------------- | ----------- |
|
|
||||||
| eventName | K | |
|
|
||||||
| handler | (event: [LocatorEventObject](./puppeteer.locatoreventobject.md)\[K\]) => void | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Locator.on
|
|
||||||
---
|
|
||||||
|
|
||||||
# Locator.on() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Locator {
|
|
||||||
on<K extends keyof LocatorEventObject>(
|
|
||||||
eventName: K,
|
|
||||||
handler: (event: LocatorEventObject[K]) => void
|
|
||||||
): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------------------------------------------- | ----------- |
|
|
||||||
| eventName | K | |
|
|
||||||
| handler | (event: [LocatorEventObject](./puppeteer.locatoreventobject.md)\[K\]) => void | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Locator.once
|
|
||||||
---
|
|
||||||
|
|
||||||
# Locator.once() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Locator {
|
|
||||||
once<K extends keyof LocatorEventObject>(
|
|
||||||
eventName: K,
|
|
||||||
handler: (event: LocatorEventObject[K]) => void
|
|
||||||
): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------------------------------------------- | ----------- |
|
|
||||||
| eventName | K | |
|
|
||||||
| handler | (event: [LocatorEventObject](./puppeteer.locatoreventobject.md)\[K\]) => void | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: LocatorEventObject
|
|
||||||
---
|
|
||||||
|
|
||||||
# LocatorEventObject interface
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export interface LocatorEventObject
|
|
||||||
```
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
| Property | Modifiers | Type | Description | Default |
|
|
||||||
| -------- | --------- | ----- | ----------- | ------- |
|
|
||||||
| action | | never | | |
|
|
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Page.[Symbol.asyncDispose]
|
|
||||||
---
|
|
||||||
|
|
||||||
# Page.\[Symbol.asyncDispose\]() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Page {
|
|
||||||
[Symbol.asyncDispose](): Promise<void>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<void>
|
|
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Page.[Symbol.dispose]
|
|
||||||
---
|
|
||||||
|
|
||||||
# Page.\[Symbol.dispose\]() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Page {
|
|
||||||
[Symbol.dispose](): void;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
void
|
|
@ -1,54 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Page.goto
|
|
||||||
---
|
|
||||||
|
|
||||||
# Page.goto() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Page {
|
|
||||||
goto(
|
|
||||||
url: string,
|
|
||||||
options?: WaitForOptions & {
|
|
||||||
referer?: string;
|
|
||||||
referrerPolicy?: string;
|
|
||||||
}
|
|
||||||
): Promise<HTTPResponse | null>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
||||||
| url | string | URL to navigate page to. The URL should include scheme, e.g. <code>https://</code> |
|
|
||||||
| options | [WaitForOptions](./puppeteer.waitforoptions.md) & { referer?: string; referrerPolicy?: string; } | _(Optional)_ Navigation Parameter |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<[HTTPResponse](./puppeteer.httpresponse.md) \| null>
|
|
||||||
|
|
||||||
Promise which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
The argument `options` might have the following properties:
|
|
||||||
|
|
||||||
- `timeout` : Maximum navigation time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the [Page.setDefaultNavigationTimeout()](./puppeteer.page.setdefaultnavigationtimeout.md) or [Page.setDefaultTimeout()](./puppeteer.page.setdefaulttimeout.md) methods.
|
|
||||||
|
|
||||||
- `waitUntil`:When to consider navigation succeeded, defaults to `load`. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:<br/> - `load` : consider navigation to be finished when the load event is fired.<br/> - `domcontentloaded` : consider navigation to be finished when the DOMContentLoaded event is fired.<br/> - `networkidle0` : consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.<br/> - `networkidle2` : consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
|
|
||||||
|
|
||||||
- `referer` : Referer header value. If provided it will take preference over the referer header value set by [page.setExtraHTTPHeaders()](./puppeteer.page.setextrahttpheaders.md).<br/> - `referrerPolicy` : ReferrerPolicy. If provided it will take preference over the referer-policy header value set by [page.setExtraHTTPHeaders()](./puppeteer.page.setextrahttpheaders.md).
|
|
||||||
|
|
||||||
`page.goto` will throw an error if:
|
|
||||||
|
|
||||||
- there's an SSL error (e.g. in case of self-signed certificates). - target URL is invalid. - the timeout is exceeded during navigation. - the remote server does not respond or is unreachable. - the main resource failed to load.
|
|
||||||
|
|
||||||
`page.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling response.status().
|
|
||||||
|
|
||||||
NOTE: `page.goto` either throws an error or returns a main resource response. The only exceptions are navigation to about:blank or navigation to the same URL with a different hash, which would succeed and return null.
|
|
||||||
|
|
||||||
NOTE: Headless mode doesn't support navigation to a PDF document. See the [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
|
|
||||||
|
|
||||||
Shortcut for [page.mainFrame().goto(url, options)](./puppeteer.frame.goto.md).
|
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Page.off
|
|
||||||
---
|
|
||||||
|
|
||||||
# Page.off() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Page {
|
|
||||||
off<K extends keyof PageEventObject>(
|
|
||||||
eventName: K,
|
|
||||||
handler: (event: PageEventObject[K]) => void
|
|
||||||
): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------------------------------------- | ----------- |
|
|
||||||
| eventName | K | |
|
|
||||||
| handler | (event: [PageEventObject](./puppeteer.pageeventobject.md)\[K\]) => void | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,35 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Page.on
|
|
||||||
---
|
|
||||||
|
|
||||||
# Page.on() method
|
|
||||||
|
|
||||||
Listen to page events.
|
|
||||||
|
|
||||||
:::note
|
|
||||||
|
|
||||||
This method exists to define event typings and handle proper wireup of cooperative request interception. Actual event listening and dispatching is delegated to [EventEmitter](./puppeteer.eventemitter.md).
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Page {
|
|
||||||
on<K extends keyof PageEventObject>(
|
|
||||||
eventName: K,
|
|
||||||
handler: (event: PageEventObject[K]) => void
|
|
||||||
): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------------------------------------- | ----------- |
|
|
||||||
| eventName | K | |
|
|
||||||
| handler | (event: [PageEventObject](./puppeteer.pageeventobject.md)\[K\]) => void | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Page.once
|
|
||||||
---
|
|
||||||
|
|
||||||
# Page.once() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Page {
|
|
||||||
once<K extends keyof PageEventObject>(
|
|
||||||
eventName: K,
|
|
||||||
handler: (event: PageEventObject[K]) => void
|
|
||||||
): this;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | -------------------------------------------------------------------------- | ----------- |
|
|
||||||
| eventName | K | |
|
|
||||||
| handler | (event: [PageEventObject](./puppeteer.pageeventobject.md)\[K\]) => void | |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
this
|
|
@ -1,33 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Page.reload
|
|
||||||
---
|
|
||||||
|
|
||||||
# Page.reload() method
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
class Page {
|
|
||||||
reload(options?: WaitForOptions): Promise<HTTPResponse | null>;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| --------- | ----------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
||||||
| options | [WaitForOptions](./puppeteer.waitforoptions.md) | _(Optional)_ Navigation parameters which might have the following properties: |
|
|
||||||
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
Promise<[HTTPResponse](./puppeteer.httpresponse.md) \| null>
|
|
||||||
|
|
||||||
Promise which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
The argument `options` might have the following properties:
|
|
||||||
|
|
||||||
- `timeout` : Maximum navigation time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the [Page.setDefaultNavigationTimeout()](./puppeteer.page.setdefaultnavigationtimeout.md) or [Page.setDefaultTimeout()](./puppeteer.page.setdefaulttimeout.md) methods.
|
|
||||||
|
|
||||||
- `waitUntil`: When to consider navigation succeeded, defaults to `load`. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:<br/> - `load` : consider navigation to be finished when the load event is fired.<br/> - `domcontentloaded` : consider navigation to be finished when the DOMContentLoaded event is fired.<br/> - `networkidle0` : consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.<br/> - `networkidle2` : consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
|
|
@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: PuppeteerLifeCycleEvent
|
|
||||||
---
|
|
||||||
|
|
||||||
# PuppeteerLifeCycleEvent type
|
|
||||||
|
|
||||||
#### Signature:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export type PuppeteerLifeCycleEvent =
|
|
||||||
| 'load'
|
|
||||||
| 'domcontentloaded'
|
|
||||||
| 'networkidle0'
|
|
||||||
| 'networkidle2';
|
|
||||||
```
|
|
@ -7,10 +7,10 @@ sidebar_label: API
|
|||||||
## Classes
|
## Classes
|
||||||
|
|
||||||
| Class | Description |
|
| Class | Description |
|
||||||
| --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [Accessibility](./puppeteer.accessibility.md) | The Accessibility class provides methods for inspecting the browser's accessibility tree. The accessibility tree is used by assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or [switches](https://en.wikipedia.org/wiki/Switch_access). |
|
| [Accessibility](./puppeteer.accessibility.md) | The Accessibility class provides methods for inspecting the browser's accessibility tree. The accessibility tree is used by assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or [switches](https://en.wikipedia.org/wiki/Switch_access). |
|
||||||
| [Browser](./puppeteer.browser.md) | A Browser is created when Puppeteer connects to a browser instance, either through [PuppeteerNode.launch()](./puppeteer.puppeteernode.launch.md) or [Puppeteer.connect()](./puppeteer.puppeteer.connect.md). |
|
| [Browser](./puppeteer.browser.md) | <p>[Browser](./puppeteer.browser.md) represents a browser instance that is either:</p><p>- connected to via [Puppeteer.connect()](./puppeteer.puppeteer.connect.md) or - launched by [PuppeteerNode.launch()](./puppeteer.puppeteernode.launch.md).</p><p>[Browser](./puppeteer.browser.md) [emits](./puppeteer.eventemitter.md) various events which are documented in the [BrowserEvent](./puppeteer.browserevent.md) enum.</p> |
|
||||||
| [BrowserContext](./puppeteer.browsercontext.md) | BrowserContexts provide a way to operate multiple independent browser sessions. When a browser is launched, it has a single BrowserContext used by default. The method [Browser.newPage](./puppeteer.browser.newpage.md) creates a page in the default browser context. |
|
| [BrowserContext](./puppeteer.browsercontext.md) | <p>[BrowserContext](./puppeteer.browsercontext.md) represents individual sessions within a [browser](./puppeteer.browser.md).</p><p>When a [browser](./puppeteer.browser.md) is launched, it has a single [browser context](./puppeteer.browsercontext.md) by default. Others can be created using [Browser.createIncognitoBrowserContext()](./puppeteer.browser.createincognitobrowsercontext.md).</p><p>[BrowserContext](./puppeteer.browsercontext.md) [emits](./puppeteer.eventemitter.md) various events which are documented in the [BrowserContextEvent](./puppeteer.browsercontextevent.md) enum.</p><p>If a [page](./puppeteer.page.md) opens another [page](./puppeteer.page.md), e.g. using <code>window.open</code>, the popup will belong to the parent [page's browser context](./puppeteer.page.browsercontext.md).</p> |
|
||||||
| [CDPSession](./puppeteer.cdpsession.md) | The <code>CDPSession</code> instances are used to talk raw Chrome Devtools Protocol. |
|
| [CDPSession](./puppeteer.cdpsession.md) | The <code>CDPSession</code> instances are used to talk raw Chrome Devtools Protocol. |
|
||||||
| [Connection](./puppeteer.connection.md) | |
|
| [Connection](./puppeteer.connection.md) | |
|
||||||
| [ConsoleMessage](./puppeteer.consolemessage.md) | ConsoleMessage objects are dispatched by page via the 'console' event. |
|
| [ConsoleMessage](./puppeteer.consolemessage.md) | ConsoleMessage objects are dispatched by page via the 'console' event. |
|
||||||
@ -46,12 +46,12 @@ sidebar_label: API
|
|||||||
## Enumerations
|
## Enumerations
|
||||||
|
|
||||||
| Enumeration | Description |
|
| Enumeration | Description |
|
||||||
| ------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
| --------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||||
| [BrowserContextEmittedEvents](./puppeteer.browsercontextemittedevents.md) | |
|
| [BrowserContextEvent](./puppeteer.browsercontextevent.md) | |
|
||||||
| [BrowserEmittedEvents](./puppeteer.browseremittedevents.md) | All the events a [browser instance](./puppeteer.browser.md) may emit. |
|
| [BrowserEvent](./puppeteer.browserevent.md) | All the events a [browser instance](./puppeteer.browser.md) may emit. |
|
||||||
| [InterceptResolutionAction](./puppeteer.interceptresolutionaction.md) | |
|
| [InterceptResolutionAction](./puppeteer.interceptresolutionaction.md) | |
|
||||||
| [LocatorEmittedEvents](./puppeteer.locatoremittedevents.md) | All the events that a locator instance may emit. |
|
| [LocatorEvent](./puppeteer.locatorevent.md) | All the events that a locator instance may emit. |
|
||||||
| [PageEmittedEvents](./puppeteer.pageemittedevents.md) | All the events that a page instance may emit. |
|
| [PageEvent](./puppeteer.pageevent.md) | All the events that a page instance may emit. |
|
||||||
| [TargetType](./puppeteer.targettype.md) | |
|
| [TargetType](./puppeteer.targettype.md) | |
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
@ -66,14 +66,17 @@ sidebar_label: API
|
|||||||
## Interfaces
|
## Interfaces
|
||||||
|
|
||||||
| Interface | Description |
|
| Interface | Description |
|
||||||
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [ActionOptions](./puppeteer.actionoptions.md) | |
|
| [ActionOptions](./puppeteer.actionoptions.md) | |
|
||||||
| [AutofillData](./puppeteer.autofilldata.md) | |
|
| [AutofillData](./puppeteer.autofilldata.md) | |
|
||||||
| [BoundingBox](./puppeteer.boundingbox.md) | |
|
| [BoundingBox](./puppeteer.boundingbox.md) | |
|
||||||
| [BoxModel](./puppeteer.boxmodel.md) | |
|
| [BoxModel](./puppeteer.boxmodel.md) | |
|
||||||
| [BrowserConnectOptions](./puppeteer.browserconnectoptions.md) | Generic browser options that can be passed when launching any browser or when connecting to an existing browser instance. |
|
| [BrowserConnectOptions](./puppeteer.browserconnectoptions.md) | Generic browser options that can be passed when launching any browser or when connecting to an existing browser instance. |
|
||||||
| [BrowserContextOptions](./puppeteer.browsercontextoptions.md) | BrowserContext options. |
|
| [BrowserContextEvents](./puppeteer.browsercontextevents.md) | |
|
||||||
|
| [BrowserContextOptions](./puppeteer.browsercontextoptions.md) | |
|
||||||
|
| [BrowserEvents](./puppeteer.browserevents.md) | |
|
||||||
| [BrowserLaunchArgumentOptions](./puppeteer.browserlaunchargumentoptions.md) | Launcher options that only apply to Chrome. |
|
| [BrowserLaunchArgumentOptions](./puppeteer.browserlaunchargumentoptions.md) | Launcher options that only apply to Chrome. |
|
||||||
|
| [CDPSessionEvents](./puppeteer.cdpsessionevents.md) | |
|
||||||
| [ClickOptions](./puppeteer.clickoptions.md) | |
|
| [ClickOptions](./puppeteer.clickoptions.md) | |
|
||||||
| [CommonEventEmitter](./puppeteer.commoneventemitter.md) | |
|
| [CommonEventEmitter](./puppeteer.commoneventemitter.md) | |
|
||||||
| [Configuration](./puppeteer.configuration.md) | <p>Defines options to configure Puppeteer's behavior during installation and runtime.</p><p>See individual properties for more information.</p> |
|
| [Configuration](./puppeteer.configuration.md) | <p>Defines options to configure Puppeteer's behavior during installation and runtime.</p><p>See individual properties for more information.</p> |
|
||||||
@ -88,8 +91,10 @@ sidebar_label: API
|
|||||||
| [Device](./puppeteer.device.md) | |
|
| [Device](./puppeteer.device.md) | |
|
||||||
| [FrameAddScriptTagOptions](./puppeteer.frameaddscripttagoptions.md) | |
|
| [FrameAddScriptTagOptions](./puppeteer.frameaddscripttagoptions.md) | |
|
||||||
| [FrameAddStyleTagOptions](./puppeteer.frameaddstyletagoptions.md) | |
|
| [FrameAddStyleTagOptions](./puppeteer.frameaddstyletagoptions.md) | |
|
||||||
|
| [FrameEvents](./puppeteer.frameevents.md) | |
|
||||||
| [FrameWaitForFunctionOptions](./puppeteer.framewaitforfunctionoptions.md) | |
|
| [FrameWaitForFunctionOptions](./puppeteer.framewaitforfunctionoptions.md) | |
|
||||||
| [GeolocationOptions](./puppeteer.geolocationoptions.md) | |
|
| [GeolocationOptions](./puppeteer.geolocationoptions.md) | |
|
||||||
|
| [GoToOptions](./puppeteer.gotooptions.md) | |
|
||||||
| [InterceptResolutionState](./puppeteer.interceptresolutionstate.md) | |
|
| [InterceptResolutionState](./puppeteer.interceptresolutionstate.md) | |
|
||||||
| [InternalNetworkConditions](./puppeteer.internalnetworkconditions.md) | |
|
| [InternalNetworkConditions](./puppeteer.internalnetworkconditions.md) | |
|
||||||
| [JSCoverageEntry](./puppeteer.jscoverageentry.md) | The CoverageEntry class for JavaScript |
|
| [JSCoverageEntry](./puppeteer.jscoverageentry.md) | The CoverageEntry class for JavaScript |
|
||||||
@ -97,7 +102,7 @@ sidebar_label: API
|
|||||||
| [KeyboardTypeOptions](./puppeteer.keyboardtypeoptions.md) | |
|
| [KeyboardTypeOptions](./puppeteer.keyboardtypeoptions.md) | |
|
||||||
| [KeyDownOptions](./puppeteer.keydownoptions.md) | |
|
| [KeyDownOptions](./puppeteer.keydownoptions.md) | |
|
||||||
| [LaunchOptions](./puppeteer.launchoptions.md) | Generic launch options that can be passed when launching any browser. |
|
| [LaunchOptions](./puppeteer.launchoptions.md) | Generic launch options that can be passed when launching any browser. |
|
||||||
| [LocatorEventObject](./puppeteer.locatoreventobject.md) | |
|
| [LocatorEvents](./puppeteer.locatorevents.md) | |
|
||||||
| [LocatorOptions](./puppeteer.locatoroptions.md) | |
|
| [LocatorOptions](./puppeteer.locatoroptions.md) | |
|
||||||
| [LocatorScrollOptions](./puppeteer.locatorscrolloptions.md) | |
|
| [LocatorScrollOptions](./puppeteer.locatorscrolloptions.md) | |
|
||||||
| [MediaFeature](./puppeteer.mediafeature.md) | |
|
| [MediaFeature](./puppeteer.mediafeature.md) | |
|
||||||
@ -110,7 +115,7 @@ sidebar_label: API
|
|||||||
| [NetworkConditions](./puppeteer.networkconditions.md) | |
|
| [NetworkConditions](./puppeteer.networkconditions.md) | |
|
||||||
| [NewDocumentScriptEvaluation](./puppeteer.newdocumentscriptevaluation.md) | |
|
| [NewDocumentScriptEvaluation](./puppeteer.newdocumentscriptevaluation.md) | |
|
||||||
| [Offset](./puppeteer.offset.md) | |
|
| [Offset](./puppeteer.offset.md) | |
|
||||||
| [PageEventObject](./puppeteer.pageeventobject.md) | <p>Denotes the objects received by callback functions for page events.</p><p>See [PageEmittedEvents](./puppeteer.pageemittedevents.md) for more detail on the events and when they are emitted.</p> |
|
| [PageEvents](./puppeteer.pageevents.md) | <p>Denotes the objects received by callback functions for page events.</p><p>See [PageEvent](./puppeteer.pageevent.md) for more detail on the events and when they are emitted.</p> |
|
||||||
| [PDFMargin](./puppeteer.pdfmargin.md) | |
|
| [PDFMargin](./puppeteer.pdfmargin.md) | |
|
||||||
| [PDFOptions](./puppeteer.pdfoptions.md) | Valid options to configure PDF generation via [Page.pdf()](./puppeteer.page.pdf.md). |
|
| [PDFOptions](./puppeteer.pdfoptions.md) | Valid options to configure PDF generation via [Page.pdf()](./puppeteer.page.pdf.md). |
|
||||||
| [Point](./puppeteer.point.md) | |
|
| [Point](./puppeteer.point.md) | |
|
||||||
@ -123,7 +128,7 @@ sidebar_label: API
|
|||||||
| [SerializedAXNode](./puppeteer.serializedaxnode.md) | Represents a Node and the properties of it that are relevant to Accessibility. |
|
| [SerializedAXNode](./puppeteer.serializedaxnode.md) | Represents a Node and the properties of it that are relevant to Accessibility. |
|
||||||
| [SnapshotOptions](./puppeteer.snapshotoptions.md) | |
|
| [SnapshotOptions](./puppeteer.snapshotoptions.md) | |
|
||||||
| [TracingOptions](./puppeteer.tracingoptions.md) | |
|
| [TracingOptions](./puppeteer.tracingoptions.md) | |
|
||||||
| [Viewport](./puppeteer.viewport.md) | Sets the viewport of the page. |
|
| [Viewport](./puppeteer.viewport.md) | |
|
||||||
| [WaitForOptions](./puppeteer.waitforoptions.md) | |
|
| [WaitForOptions](./puppeteer.waitforoptions.md) | |
|
||||||
| [WaitForSelectorOptions](./puppeteer.waitforselectoroptions.md) | |
|
| [WaitForSelectorOptions](./puppeteer.waitforselectoroptions.md) | |
|
||||||
| [WaitForTargetOptions](./puppeteer.waitfortargetoptions.md) | |
|
| [WaitForTargetOptions](./puppeteer.waitfortargetoptions.md) | |
|
||||||
@ -155,13 +160,14 @@ sidebar_label: API
|
|||||||
| [Awaitable](./puppeteer.awaitable.md) | |
|
| [Awaitable](./puppeteer.awaitable.md) | |
|
||||||
| [AwaitableIterable](./puppeteer.awaitableiterable.md) | |
|
| [AwaitableIterable](./puppeteer.awaitableiterable.md) | |
|
||||||
| [AwaitedLocator](./puppeteer.awaitedlocator.md) | |
|
| [AwaitedLocator](./puppeteer.awaitedlocator.md) | |
|
||||||
|
| [CDPEvents](./puppeteer.cdpevents.md) | |
|
||||||
| [ChromeReleaseChannel](./puppeteer.chromereleasechannel.md) | |
|
| [ChromeReleaseChannel](./puppeteer.chromereleasechannel.md) | |
|
||||||
| [ConsoleMessageType](./puppeteer.consolemessagetype.md) | The supported types for console messages. |
|
| [ConsoleMessageType](./puppeteer.consolemessagetype.md) | The supported types for console messages. |
|
||||||
| [ElementFor](./puppeteer.elementfor.md) | |
|
| [ElementFor](./puppeteer.elementfor.md) | |
|
||||||
| [ErrorCode](./puppeteer.errorcode.md) | |
|
| [ErrorCode](./puppeteer.errorcode.md) | |
|
||||||
| [EvaluateFunc](./puppeteer.evaluatefunc.md) | |
|
| [EvaluateFunc](./puppeteer.evaluatefunc.md) | |
|
||||||
| [EvaluateFuncWith](./puppeteer.evaluatefuncwith.md) | |
|
| [EvaluateFuncWith](./puppeteer.evaluatefuncwith.md) | |
|
||||||
| [EventType](./puppeteer.eventtype.md) | |
|
| [EventsWithWildcard](./puppeteer.eventswithwildcard.md) | |
|
||||||
| [ExperimentsConfiguration](./puppeteer.experimentsconfiguration.md) | <p>Defines experiment options for Puppeteer.</p><p>See individual properties for more information.</p> |
|
| [ExperimentsConfiguration](./puppeteer.experimentsconfiguration.md) | <p>Defines experiment options for Puppeteer.</p><p>See individual properties for more information.</p> |
|
||||||
| [FlattenHandle](./puppeteer.flattenhandle.md) | |
|
| [FlattenHandle](./puppeteer.flattenhandle.md) | |
|
||||||
| [HandleFor](./puppeteer.handlefor.md) | |
|
| [HandleFor](./puppeteer.handlefor.md) | |
|
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser.browserContexts
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser.browserContexts() method
|
||||||
|
|
||||||
|
Gets a list of open [browser contexts](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
|
In a newly-created [browser](./puppeteer.browser.md), this will return a single instance of [BrowserContext](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Browser {
|
||||||
|
abstract browserContexts(): BrowserContext[];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
[BrowserContext](./puppeteer.browsercontext.md)\[\]
|
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser.close
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser.close() method
|
||||||
|
|
||||||
|
Closes this [browser](./puppeteer.browser.md) and all associated [pages](./puppeteer.page.md).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Browser {
|
||||||
|
abstract close(): Promise<void>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<void>
|
@ -4,13 +4,15 @@ sidebar_label: Browser.createIncognitoBrowserContext
|
|||||||
|
|
||||||
# Browser.createIncognitoBrowserContext() method
|
# Browser.createIncognitoBrowserContext() method
|
||||||
|
|
||||||
Creates a new incognito browser context. This won't share cookies/cache with other browser contexts.
|
Creates a new incognito [browser context](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
|
This won't share cookies/cache with other [browser contexts](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class Browser {
|
class Browser {
|
||||||
createIncognitoBrowserContext(
|
abstract createIncognitoBrowserContext(
|
||||||
options?: BrowserContextOptions
|
options?: BrowserContextOptions
|
||||||
): Promise<BrowserContext>;
|
): Promise<BrowserContext>;
|
||||||
}
|
}
|
||||||
@ -29,13 +31,13 @@ Promise<[BrowserContext](./puppeteer.browsercontext.md)>
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
(async () => {
|
import puppeteer from 'puppeteer';
|
||||||
const browser = await puppeteer.launch();
|
|
||||||
// Create a new incognito browser context.
|
const browser = await puppeteer.launch();
|
||||||
const context = await browser.createIncognitoBrowserContext();
|
// Create a new incognito browser context.
|
||||||
// Create a new page in a pristine context.
|
const context = await browser.createIncognitoBrowserContext();
|
||||||
const page = await context.newPage();
|
// Create a new page in a pristine context.
|
||||||
// Do stuff
|
const page = await context.newPage();
|
||||||
await page.goto('https://example.com');
|
// Do stuff
|
||||||
})();
|
await page.goto('https://example.com');
|
||||||
```
|
```
|
@ -4,16 +4,20 @@ sidebar_label: Browser.defaultBrowserContext
|
|||||||
|
|
||||||
# Browser.defaultBrowserContext() method
|
# Browser.defaultBrowserContext() method
|
||||||
|
|
||||||
Returns the default browser context. The default browser context cannot be closed.
|
Gets the default [browser context](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class Browser {
|
class Browser {
|
||||||
defaultBrowserContext(): BrowserContext;
|
abstract defaultBrowserContext(): BrowserContext;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
[BrowserContext](./puppeteer.browsercontext.md)
|
[BrowserContext](./puppeteer.browsercontext.md)
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
The default [browser context](./puppeteer.browsercontext.md) cannot be closed.
|
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser.disconnect
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser.disconnect() method
|
||||||
|
|
||||||
|
Disconnects Puppeteer from this [browser](./puppeteer.browser.md), but leaves the process running.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Browser {
|
||||||
|
disconnect(): void;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
void
|
@ -4,7 +4,11 @@ sidebar_label: Browser.isConnected
|
|||||||
|
|
||||||
# Browser.isConnected() method
|
# Browser.isConnected() method
|
||||||
|
|
||||||
Indicates that the browser is connected.
|
> Warning: This API is now obsolete.
|
||||||
|
>
|
||||||
|
> Use [Browser.connected](./puppeteer.browser.connected.md).
|
||||||
|
|
||||||
|
Whether Puppeteer is connected to this [browser](./puppeteer.browser.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
@ -0,0 +1,81 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser class
|
||||||
|
|
||||||
|
[Browser](./puppeteer.browser.md) represents a browser instance that is either:
|
||||||
|
|
||||||
|
- connected to via [Puppeteer.connect()](./puppeteer.puppeteer.connect.md) or - launched by [PuppeteerNode.launch()](./puppeteer.puppeteernode.launch.md).
|
||||||
|
|
||||||
|
[Browser](./puppeteer.browser.md) [emits](./puppeteer.eventemitter.md) various events which are documented in the [BrowserEvent](./puppeteer.browserevent.md) enum.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export declare abstract class Browser extends EventEmitter<BrowserEvents>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Extends:** [EventEmitter](./puppeteer.eventemitter.md)<[BrowserEvents](./puppeteer.browserevents.md)>
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `Browser` class.
|
||||||
|
|
||||||
|
## Example 1
|
||||||
|
|
||||||
|
Using a [Browser](./puppeteer.browser.md) to create a [Page](./puppeteer.page.md):
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import puppeteer from 'puppeteer';
|
||||||
|
|
||||||
|
const browser = await puppeteer.launch();
|
||||||
|
const page = await browser.newPage();
|
||||||
|
await page.goto('https://example.com');
|
||||||
|
await browser.close();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example 2
|
||||||
|
|
||||||
|
Disconnecting from and reconnecting to a [Browser](./puppeteer.browser.md):
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import puppeteer from 'puppeteer';
|
||||||
|
|
||||||
|
const browser = await puppeteer.launch();
|
||||||
|
// Store the endpoint to be able to reconnect to the browser.
|
||||||
|
const browserWSEndpoint = browser.wsEndpoint();
|
||||||
|
// Disconnect puppeteer from the browser.
|
||||||
|
browser.disconnect();
|
||||||
|
|
||||||
|
// Use the endpoint to reestablish a connection
|
||||||
|
const browser2 = await puppeteer.connect({browserWSEndpoint});
|
||||||
|
// Close the browser.
|
||||||
|
await browser2.close();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Modifiers | Type | Description |
|
||||||
|
| --------- | --------------------- | ------- | ------------------------------------------------------------------------- |
|
||||||
|
| connected | <code>readonly</code> | boolean | Whether Puppeteer is connected to this [browser](./puppeteer.browser.md). |
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
| Method | Modifiers | Description |
|
||||||
|
| ---------------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| [browserContexts()](./puppeteer.browser.browsercontexts.md) | | <p>Gets a list of open [browser contexts](./puppeteer.browsercontext.md).</p><p>In a newly-created [browser](./puppeteer.browser.md), this will return a single instance of [BrowserContext](./puppeteer.browsercontext.md).</p> |
|
||||||
|
| [close()](./puppeteer.browser.close.md) | | Closes this [browser](./puppeteer.browser.md) and all associated [pages](./puppeteer.page.md). |
|
||||||
|
| [createIncognitoBrowserContext(options)](./puppeteer.browser.createincognitobrowsercontext.md) | | <p>Creates a new incognito [browser context](./puppeteer.browsercontext.md).</p><p>This won't share cookies/cache with other [browser contexts](./puppeteer.browsercontext.md).</p> |
|
||||||
|
| [defaultBrowserContext()](./puppeteer.browser.defaultbrowsercontext.md) | | Gets the default [browser context](./puppeteer.browsercontext.md). |
|
||||||
|
| [disconnect()](./puppeteer.browser.disconnect.md) | | Disconnects Puppeteer from this [browser](./puppeteer.browser.md), but leaves the process running. |
|
||||||
|
| [isConnected()](./puppeteer.browser.isconnected.md) | | Whether Puppeteer is connected to this [browser](./puppeteer.browser.md). |
|
||||||
|
| [newPage()](./puppeteer.browser.newpage.md) | | Creates a new [page](./puppeteer.page.md) in the [default browser context](./puppeteer.browser.defaultbrowsercontext.md). |
|
||||||
|
| [pages()](./puppeteer.browser.pages.md) | | <p>Gets a list of all open [pages](./puppeteer.page.md) inside this .</p><p>If there ar multiple [browser contexts](./puppeteer.browsercontext.md), this returns all [pages](./puppeteer.page.md) in all [browser contexts](./puppeteer.browsercontext.md).</p> |
|
||||||
|
| [process()](./puppeteer.browser.process.md) | | Gets the associated [ChildProcess](https://nodejs.org/api/child_process.html#class-childprocess). |
|
||||||
|
| [target()](./puppeteer.browser.target.md) | | Gets the [target](./puppeteer.target.md) associated with the [default browser context](./puppeteer.browser.defaultbrowsercontext.md)). |
|
||||||
|
| [targets()](./puppeteer.browser.targets.md) | | <p>Gets all active [targets](./puppeteer.target.md).</p><p>In case of multiple [browser contexts](./puppeteer.browsercontext.md), this returns all [targets](./puppeteer.target.md) in all [browser contexts](./puppeteer.browsercontext.md).</p> |
|
||||||
|
| [userAgent()](./puppeteer.browser.useragent.md) | | <p>Gets this [browser's](./puppeteer.browser.md) original user agent.</p><p>[Pages](./puppeteer.page.md) can override the user agent with [Page.setUserAgent()](./puppeteer.page.setuseragent.md).</p> |
|
||||||
|
| [version()](./puppeteer.browser.version.md) | | <p>Gets a string representing this [browser's](./puppeteer.browser.md) name and version.</p><p>For headless browser, this is similar to <code>"HeadlessChrome/61.0.3153.0"</code>. For non-headless or new-headless, this is similar to <code>"Chrome/61.0.3153.0"</code>. For Firefox, it is similar to <code>"Firefox/116.0a1"</code>.</p><p>The format of [Browser.version()](./puppeteer.browser.version.md) might change with future releases of browsers.</p> |
|
||||||
|
| [waitForTarget(predicate, options)](./puppeteer.browser.waitfortarget.md) | | <p>Waits until a [target](./puppeteer.target.md) matching the given <code>predicate</code> appears and returns it.</p><p>This will look all open [browser contexts](./puppeteer.browsercontext.md).</p> |
|
||||||
|
| [wsEndpoint()](./puppeteer.browser.wsendpoint.md) | | <p>Gets the WebSocket URL to connect to this [browser](./puppeteer.browser.md).</p><p>This is usually used with [Puppeteer.connect()](./puppeteer.puppeteer.connect.md).</p><p>You can find the debugger URL (<code>webSocketDebuggerUrl</code>) from <code>http://${host}:${port}/json/version</code>.</p><p>See [browser endpoint](https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target) for more information.</p> |
|
@ -4,13 +4,13 @@ sidebar_label: Browser.newPage
|
|||||||
|
|
||||||
# Browser.newPage() method
|
# Browser.newPage() method
|
||||||
|
|
||||||
Promise which resolves to a new [Page](./puppeteer.page.md) object. The Page is created in a default browser context.
|
Creates a new [page](./puppeteer.page.md) in the [default browser context](./puppeteer.browser.defaultbrowsercontext.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class Browser {
|
class Browser {
|
||||||
newPage(): Promise<Page>;
|
abstract newPage(): Promise<Page>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser.pages
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser.pages() method
|
||||||
|
|
||||||
|
Gets a list of all open [pages](./puppeteer.page.md) inside this .
|
||||||
|
|
||||||
|
If there ar multiple [browser contexts](./puppeteer.browsercontext.md), this returns all [pages](./puppeteer.page.md) in all [browser contexts](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Browser {
|
||||||
|
pages(): Promise<Page[]>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<[Page](./puppeteer.page.md)\[\]>
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
Non-visible [pages](./puppeteer.page.md), such as `"background_page"`, will not be listed here. You can find them using [Target.page()](./puppeteer.target.page.md).
|
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser.process
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser.process() method
|
||||||
|
|
||||||
|
Gets the associated [ChildProcess](https://nodejs.org/api/child_process.html#class-childprocess).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Browser {
|
||||||
|
process(): ChildProcess | null;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
ChildProcess \| null
|
||||||
|
|
||||||
|
`null` if this instance was connected to via [Puppeteer.connect()](./puppeteer.puppeteer.connect.md).
|
@ -4,13 +4,13 @@ sidebar_label: Browser.target
|
|||||||
|
|
||||||
# Browser.target() method
|
# Browser.target() method
|
||||||
|
|
||||||
The target associated with the browser.
|
Gets the [target](./puppeteer.target.md) associated with the [default browser context](./puppeteer.browser.defaultbrowsercontext.md)).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class Browser {
|
class Browser {
|
||||||
target(): Target;
|
abstract target(): Target;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser.targets
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser.targets() method
|
||||||
|
|
||||||
|
Gets all active [targets](./puppeteer.target.md).
|
||||||
|
|
||||||
|
In case of multiple [browser contexts](./puppeteer.browsercontext.md), this returns all [targets](./puppeteer.target.md) in all [browser contexts](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Browser {
|
||||||
|
abstract targets(): Target[];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
[Target](./puppeteer.target.md)\[\]
|
@ -4,7 +4,9 @@ sidebar_label: Browser.userAgent
|
|||||||
|
|
||||||
# Browser.userAgent() method
|
# Browser.userAgent() method
|
||||||
|
|
||||||
The browser's original user agent. Pages can override the browser user agent with [Page.setUserAgent()](./puppeteer.page.setuseragent.md).
|
Gets this [browser's](./puppeteer.browser.md) original user agent.
|
||||||
|
|
||||||
|
[Pages](./puppeteer.page.md) can override the user agent with [Page.setUserAgent()](./puppeteer.page.setuseragent.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser.version
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser.version() method
|
||||||
|
|
||||||
|
Gets a string representing this [browser's](./puppeteer.browser.md) name and version.
|
||||||
|
|
||||||
|
For headless browser, this is similar to `"HeadlessChrome/61.0.3153.0"`. For non-headless or new-headless, this is similar to `"Chrome/61.0.3153.0"`. For Firefox, it is similar to `"Firefox/116.0a1"`.
|
||||||
|
|
||||||
|
The format of [Browser.version()](./puppeteer.browser.version.md) might change with future releases of browsers.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Browser {
|
||||||
|
abstract version(): Promise<string>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<string>
|
@ -4,7 +4,9 @@ sidebar_label: Browser.waitForTarget
|
|||||||
|
|
||||||
# Browser.waitForTarget() method
|
# Browser.waitForTarget() method
|
||||||
|
|
||||||
Searches for a target in all browser contexts.
|
Waits until a [target](./puppeteer.target.md) matching the given `predicate` appears and returns it.
|
||||||
|
|
||||||
|
This will look all open [browser contexts](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
@ -20,19 +22,17 @@ class Browser {
|
|||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
| --------- | ---------------------------------------------------------------------------- | -------------------------------------- |
|
| --------- | ---------------------------------------------------------------------------- | ------------ |
|
||||||
| predicate | (x: [Target](./puppeteer.target.md)) => boolean \| Promise<boolean> | A function to be run for every target. |
|
| predicate | (x: [Target](./puppeteer.target.md)) => boolean \| Promise<boolean> | |
|
||||||
| options | [WaitForTargetOptions](./puppeteer.waitfortargetoptions.md) | _(Optional)_ |
|
| options | [WaitForTargetOptions](./puppeteer.waitfortargetoptions.md) | _(Optional)_ |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
Promise<[Target](./puppeteer.target.md)>
|
Promise<[Target](./puppeteer.target.md)>
|
||||||
|
|
||||||
The first target found that matches the `predicate` function.
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
An example of finding a target for a page opened via `window.open`:
|
Finding a target for a page opened via `window.open`:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
await page.evaluate(() => window.open('https://www.example.com/'));
|
await page.evaluate(() => window.open('https://www.example.com/'));
|
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: Browser.wsEndpoint
|
||||||
|
---
|
||||||
|
|
||||||
|
# Browser.wsEndpoint() method
|
||||||
|
|
||||||
|
Gets the WebSocket URL to connect to this [browser](./puppeteer.browser.md).
|
||||||
|
|
||||||
|
This is usually used with [Puppeteer.connect()](./puppeteer.puppeteer.connect.md).
|
||||||
|
|
||||||
|
You can find the debugger URL (`webSocketDebuggerUrl`) from `http://${host}:${port}/json/version`.
|
||||||
|
|
||||||
|
See [browser endpoint](https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target) for more information.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class Browser {
|
||||||
|
abstract wsEndpoint(): string;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
string
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
The format is always `ws://${host}:${port}/devtools/browser/<id>`.
|
@ -4,13 +4,13 @@ sidebar_label: BrowserContext.browser
|
|||||||
|
|
||||||
# BrowserContext.browser() method
|
# BrowserContext.browser() method
|
||||||
|
|
||||||
The browser this browser context belongs to.
|
Gets the [browser](./puppeteer.browser.md) associated with this [browser context](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class BrowserContext {
|
class BrowserContext {
|
||||||
browser(): Browser;
|
abstract browser(): Browser;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -4,7 +4,7 @@ sidebar_label: BrowserContext.clearPermissionOverrides
|
|||||||
|
|
||||||
# BrowserContext.clearPermissionOverrides() method
|
# BrowserContext.clearPermissionOverrides() method
|
||||||
|
|
||||||
Clears all permission overrides for the browser context.
|
Clears all permission overrides for this [browser context](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
@ -20,6 +20,8 @@ Promise<void>
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
Clearing overridden permissions in the [default browser context](./puppeteer.browser.defaultbrowsercontext.md):
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const context = browser.defaultBrowserContext();
|
const context = browser.defaultBrowserContext();
|
||||||
context.overridePermissions('https://example.com', ['clipboard-read']);
|
context.overridePermissions('https://example.com', ['clipboard-read']);
|
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: BrowserContext.close
|
||||||
|
---
|
||||||
|
|
||||||
|
# BrowserContext.close() method
|
||||||
|
|
||||||
|
Closes this [browser context](./puppeteer.browsercontext.md) and all associated [pages](./puppeteer.page.md).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class BrowserContext {
|
||||||
|
abstract close(): Promise<void>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<void>
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
The [default browser context](./puppeteer.browser.defaultbrowsercontext.md) cannot be closed.
|
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: BrowserContext.isIncognito
|
||||||
|
---
|
||||||
|
|
||||||
|
# BrowserContext.isIncognito() method
|
||||||
|
|
||||||
|
Whether this [browser context](./puppeteer.browsercontext.md) is incognito.
|
||||||
|
|
||||||
|
The [default browser context](./puppeteer.browser.defaultbrowsercontext.md) is the only non-incognito browser context.
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class BrowserContext {
|
||||||
|
abstract isIncognito(): boolean;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
boolean
|
@ -0,0 +1,61 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: BrowserContext
|
||||||
|
---
|
||||||
|
|
||||||
|
# BrowserContext class
|
||||||
|
|
||||||
|
[BrowserContext](./puppeteer.browsercontext.md) represents individual sessions within a [browser](./puppeteer.browser.md).
|
||||||
|
|
||||||
|
When a [browser](./puppeteer.browser.md) is launched, it has a single [browser context](./puppeteer.browsercontext.md) by default. Others can be created using [Browser.createIncognitoBrowserContext()](./puppeteer.browser.createincognitobrowsercontext.md).
|
||||||
|
|
||||||
|
[BrowserContext](./puppeteer.browsercontext.md) [emits](./puppeteer.eventemitter.md) various events which are documented in the [BrowserContextEvent](./puppeteer.browsercontextevent.md) enum.
|
||||||
|
|
||||||
|
If a [page](./puppeteer.page.md) opens another [page](./puppeteer.page.md), e.g. using `window.open`, the popup will belong to the parent [page's browser context](./puppeteer.page.browsercontext.md).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export declare abstract class BrowserContext extends EventEmitter<BrowserContextEvents>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Extends:** [EventEmitter](./puppeteer.eventemitter.md)<[BrowserContextEvents](./puppeteer.browsercontextevents.md)>
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `BrowserContext` class.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Creating an incognito [browser context](./puppeteer.browsercontext.md):
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Create a new incognito browser context
|
||||||
|
const context = await browser.createIncognitoBrowserContext();
|
||||||
|
// Create a new page inside context.
|
||||||
|
const page = await context.newPage();
|
||||||
|
// ... do stuff with page ...
|
||||||
|
await page.goto('https://example.com');
|
||||||
|
// Dispose context once it's no longer needed.
|
||||||
|
await context.close();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Modifiers | Type | Description |
|
||||||
|
| -------- | --------------------- | ------------------- | ------------------------------------------------------------------------ |
|
||||||
|
| closed | <code>readonly</code> | boolean | Whether this [browser context](./puppeteer.browsercontext.md) is closed. |
|
||||||
|
| id | <code>readonly</code> | string \| undefined | Identifier for this [browser context](./puppeteer.browsercontext.md). |
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
| Method | Modifiers | Description |
|
||||||
|
| --------------------------------------------------------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| [browser()](./puppeteer.browsercontext.browser.md) | | Gets the [browser](./puppeteer.browser.md) associated with this [browser context](./puppeteer.browsercontext.md). |
|
||||||
|
| [clearPermissionOverrides()](./puppeteer.browsercontext.clearpermissionoverrides.md) | | Clears all permission overrides for this [browser context](./puppeteer.browsercontext.md). |
|
||||||
|
| [close()](./puppeteer.browsercontext.close.md) | | Closes this [browser context](./puppeteer.browsercontext.md) and all associated [pages](./puppeteer.page.md). |
|
||||||
|
| [isIncognito()](./puppeteer.browsercontext.isincognito.md) | | <p>Whether this [browser context](./puppeteer.browsercontext.md) is incognito.</p><p>The [default browser context](./puppeteer.browser.defaultbrowsercontext.md) is the only non-incognito browser context.</p> |
|
||||||
|
| [newPage()](./puppeteer.browsercontext.newpage.md) | | Creates a new [page](./puppeteer.page.md) in this [browser context](./puppeteer.browsercontext.md). |
|
||||||
|
| [overridePermissions(origin, permissions)](./puppeteer.browsercontext.overridepermissions.md) | | Grants this [browser context](./puppeteer.browsercontext.md) the given <code>permissions</code> within the given <code>origin</code>. |
|
||||||
|
| [pages()](./puppeteer.browsercontext.pages.md) | | Gets a list of all open [pages](./puppeteer.page.md) inside this [browser context](./puppeteer.browsercontext.md). |
|
||||||
|
| [targets()](./puppeteer.browsercontext.targets.md) | | Gets all active [targets](./puppeteer.target.md) inside this [browser context](./puppeteer.browsercontext.md). |
|
||||||
|
| [waitForTarget(predicate, options)](./puppeteer.browsercontext.waitfortarget.md) | | <p>Waits until a [target](./puppeteer.target.md) matching the given <code>predicate</code> appears and returns it.</p><p>This will look all open [browser contexts](./puppeteer.browsercontext.md).</p> |
|
@ -4,13 +4,13 @@ sidebar_label: BrowserContext.newPage
|
|||||||
|
|
||||||
# BrowserContext.newPage() method
|
# BrowserContext.newPage() method
|
||||||
|
|
||||||
Creates a new page in the browser context.
|
Creates a new [page](./puppeteer.page.md) in this [browser context](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class BrowserContext {
|
class BrowserContext {
|
||||||
newPage(): Promise<Page>;
|
abstract newPage(): Promise<Page>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -4,6 +4,8 @@ sidebar_label: BrowserContext.overridePermissions
|
|||||||
|
|
||||||
# BrowserContext.overridePermissions() method
|
# BrowserContext.overridePermissions() method
|
||||||
|
|
||||||
|
Grants this [browser context](./puppeteer.browsercontext.md) the given `permissions` within the given `origin`.
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@ -25,6 +27,8 @@ Promise<void>
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
Overriding permissions in the [default browser context](./puppeteer.browser.defaultbrowsercontext.md):
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const context = browser.defaultBrowserContext();
|
const context = browser.defaultBrowserContext();
|
||||||
await context.overridePermissions('https://html5demos.com', ['geolocation']);
|
await context.overridePermissions('https://html5demos.com', ['geolocation']);
|
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: BrowserContext.pages
|
||||||
|
---
|
||||||
|
|
||||||
|
# BrowserContext.pages() method
|
||||||
|
|
||||||
|
Gets a list of all open [pages](./puppeteer.page.md) inside this [browser context](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class BrowserContext {
|
||||||
|
abstract pages(): Promise<Page[]>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<[Page](./puppeteer.page.md)\[\]>
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
Non-visible [pages](./puppeteer.page.md), such as `"background_page"`, will not be listed here. You can find them using [Target.page()](./puppeteer.target.page.md).
|
@ -4,7 +4,7 @@ sidebar_label: BrowserContext.targets
|
|||||||
|
|
||||||
# BrowserContext.targets() method
|
# BrowserContext.targets() method
|
||||||
|
|
||||||
An array of all active targets inside the browser context.
|
Gets all active [targets](./puppeteer.target.md) inside this [browser context](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: BrowserContext.waitForTarget
|
||||||
|
---
|
||||||
|
|
||||||
|
# BrowserContext.waitForTarget() method
|
||||||
|
|
||||||
|
Waits until a [target](./puppeteer.target.md) matching the given `predicate` appears and returns it.
|
||||||
|
|
||||||
|
This will look all open [browser contexts](./puppeteer.browsercontext.md).
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class BrowserContext {
|
||||||
|
abstract waitForTarget(
|
||||||
|
predicate: (x: Target) => boolean | Promise<boolean>,
|
||||||
|
options?: {
|
||||||
|
timeout?: number;
|
||||||
|
}
|
||||||
|
): Promise<Target>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
| Parameter | Type | Description |
|
||||||
|
| --------- | ---------------------------------------------------------------------------- | ------------ |
|
||||||
|
| predicate | (x: [Target](./puppeteer.target.md)) => boolean \| Promise<boolean> | |
|
||||||
|
| options | { timeout?: number; } | _(Optional)_ |
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
Promise<[Target](./puppeteer.target.md)>
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Finding a target for a page opened via `window.open`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await page.evaluate(() => window.open('https://www.example.com/'));
|
||||||
|
const newWindowTarget = await browserContext.waitForTarget(
|
||||||
|
target => target.url() === 'https://www.example.com/'
|
||||||
|
);
|
||||||
|
```
|
@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
sidebar_label: BrowserContextEmittedEvents
|
sidebar_label: BrowserContextEvent
|
||||||
---
|
---
|
||||||
|
|
||||||
# BrowserContextEmittedEvents enum
|
# BrowserContextEvent enum
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare const enum BrowserContextEmittedEvents
|
export declare const enum BrowserContextEvent
|
||||||
```
|
```
|
||||||
|
|
||||||
## Enumeration Members
|
## Enumeration Members
|
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: BrowserContextEvents
|
||||||
|
---
|
||||||
|
|
||||||
|
# BrowserContextEvents interface
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export interface BrowserContextEvents extends Record<EventType, unknown>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Extends:** Record<EventType, unknown>
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Modifiers | Type | Description | Default |
|
||||||
|
| --------------- | --------- | ------------------------------- | ----------- | ------- |
|
||||||
|
| targetchanged | | [Target](./puppeteer.target.md) | | |
|
||||||
|
| targetcreated | | [Target](./puppeteer.target.md) | | |
|
||||||
|
| targetdestroyed | | [Target](./puppeteer.target.md) | | |
|
@ -4,8 +4,6 @@ sidebar_label: BrowserContextOptions
|
|||||||
|
|
||||||
# BrowserContextOptions interface
|
# BrowserContextOptions interface
|
||||||
|
|
||||||
BrowserContext options.
|
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
@ -1,22 +1,22 @@
|
|||||||
---
|
---
|
||||||
sidebar_label: BrowserEmittedEvents
|
sidebar_label: BrowserEvent
|
||||||
---
|
---
|
||||||
|
|
||||||
# BrowserEmittedEvents enum
|
# BrowserEvent enum
|
||||||
|
|
||||||
All the events a [browser instance](./puppeteer.browser.md) may emit.
|
All the events a [browser instance](./puppeteer.browser.md) may emit.
|
||||||
|
|
||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare const enum BrowserEmittedEvents
|
export declare const enum BrowserEvent
|
||||||
```
|
```
|
||||||
|
|
||||||
## Enumeration Members
|
## Enumeration Members
|
||||||
|
|
||||||
| Member | Value | Description |
|
| Member | Value | Description |
|
||||||
| --------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| --------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Disconnected | <code>"disconnected"</code> | <p>Emitted when Puppeteer gets disconnected from the browser instance. This might happen because of one of the following:</p><p>- browser is closed or crashed</p><p>- The [browser.disconnect](./puppeteer.browser.disconnect.md) method was called.</p> |
|
| Disconnected | <code>"disconnected"</code> | <p>Emitted when Puppeteer gets disconnected from the browser instance. This might happen because either:</p><p>- The browser closes/crashes or - [Browser.disconnect()](./puppeteer.browser.disconnect.md) was called.</p> |
|
||||||
| TargetChanged | <code>"targetchanged"</code> | Emitted when the url of a target changes. Contains a [Target](./puppeteer.target.md) instance. |
|
| TargetChanged | <code>"targetchanged"</code> | Emitted when the URL of a target changes. Contains a [Target](./puppeteer.target.md) instance. |
|
||||||
| TargetCreated | <code>"targetcreated"</code> | <p>Emitted when a target is created, for example when a new page is opened by [window.open](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) or by [browser.newPage](./puppeteer.browser.newpage.md)</p><p>Contains a [Target](./puppeteer.target.md) instance.</p> |
|
| TargetCreated | <code>"targetcreated"</code> | <p>Emitted when a target is created, for example when a new page is opened by [window.open](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) or by [browser.newPage](./puppeteer.browser.newpage.md)</p><p>Contains a [Target](./puppeteer.target.md) instance.</p> |
|
||||||
| TargetDestroyed | <code>"targetdestroyed"</code> | Emitted when a target is destroyed, for example when a page is closed. Contains a [Target](./puppeteer.target.md) instance. |
|
| TargetDestroyed | <code>"targetdestroyed"</code> | Emitted when a target is destroyed, for example when a page is closed. Contains a [Target](./puppeteer.target.md) instance. |
|
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: BrowserEvents
|
||||||
|
---
|
||||||
|
|
||||||
|
# BrowserEvents interface
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export interface BrowserEvents extends Record<EventType, unknown>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Extends:** Record<EventType, unknown>
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Modifiers | Type | Description | Default |
|
||||||
|
| --------------- | --------- | ------------------------------- | ----------- | ------- |
|
||||||
|
| disconnected | | undefined | | |
|
||||||
|
| targetchanged | | [Target](./puppeteer.target.md) | | |
|
||||||
|
| targetcreated | | [Target](./puppeteer.target.md) | | |
|
||||||
|
| targetdestroyed | | [Target](./puppeteer.target.md) | | |
|
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: CDPEvents
|
||||||
|
---
|
||||||
|
|
||||||
|
# CDPEvents type
|
||||||
|
|
||||||
|
#### Signature:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export type CDPEvents = {
|
||||||
|
[Property in keyof ProtocolMapping.Events]: ProtocolMapping.Events[Property][0];
|
||||||
|
};
|
||||||
|
```
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user