mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat: add documentation (#8593)
This commit is contained in:
parent
51ae338acd
commit
066f440ba7
@ -1,7 +1,6 @@
|
||||
assets/
|
||||
build/
|
||||
coverage/
|
||||
doclint/
|
||||
lib/
|
||||
tsconfig.tsbuildinfo
|
||||
vendor/
|
||||
|
64
.github/workflows/ci.yml
vendored
64
.github/workflows/ci.yml
vendored
@ -16,6 +16,67 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check-docs:
|
||||
name: Check documentation
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
needs_deploying: ${{ steps.needs_deploying.outputs.value }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3.3.0
|
||||
with:
|
||||
cache: npm
|
||||
- name: Cache Chromium binary directory
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .local-chromium
|
||||
key: ${{ runner.os }}-chromium-${{ hashFiles('src/revisions.ts') }}
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build
|
||||
run: npm run docs
|
||||
- name: Check if autogenerated docs differ
|
||||
run: $(git diff) || exit 1
|
||||
- name: Check if docs need to be deployed
|
||||
id: needs_deploying
|
||||
run: |
|
||||
if [[ $(git diff @~ -- ./docs ./website) ]]; then
|
||||
needs_deploying=true
|
||||
else
|
||||
needs_deploying=false
|
||||
fi
|
||||
echo "::set-output name=value::$needs_deploying"
|
||||
|
||||
deploy-docs:
|
||||
needs: check-docs
|
||||
name: Deploy docs (if needed)
|
||||
if: ${{ needs.check-docs.outputs.needs_deploying == 'true' && github.event_name != 'pull_request' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3.3.0
|
||||
with:
|
||||
cache: npm
|
||||
- name: Install dependencies
|
||||
working-directory: ./website
|
||||
run: npm ci
|
||||
- name: Build website
|
||||
working-directory: ./website
|
||||
run: npm run build
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./website/build
|
||||
user_name: release-please[bot]
|
||||
user_email: 55107282+release-please[bot]@users.noreply.github.com
|
||||
|
||||
linux:
|
||||
# https://github.com/actions/virtual-environments#available-environments
|
||||
runs-on: ubuntu-latest
|
||||
@ -51,9 +112,6 @@ jobs:
|
||||
run: |
|
||||
npm run test:pinned-deps
|
||||
npm run lint
|
||||
# Skipping as it's flakey and we are not currently using the new documentation site in the wild yet.
|
||||
# See https://github.com/puppeteer/puppeteer/issues/7710 for more info
|
||||
# npm run generate:docs
|
||||
npm run test:protocol-revision
|
||||
npm run test:types
|
||||
|
||||
|
10
.github/workflows/pre-release.yml
vendored
10
.github/workflows/pre-release.yml
vendored
@ -21,10 +21,16 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
node utils/generate_version_file.js
|
||||
IS_RELEASE=1 npm run doc
|
||||
npm run docs
|
||||
- name: Version docs
|
||||
working-directory: ./website
|
||||
run: |
|
||||
npm install
|
||||
npm run docusaurus docs:version $(jq -r .version ../package.json)
|
||||
- name: Commit
|
||||
run: |
|
||||
git config --global user.name 'release-please[bot]'
|
||||
git config --global user.email '55107282+release-please[bot]@users.noreply.github.com'
|
||||
git commit -am 'chore: freeze version on docs'
|
||||
git add .
|
||||
git commit -m 'chore: generated versioned docs'
|
||||
git push --no-verify
|
||||
|
22
.github/workflows/publish.yml
vendored
22
.github/workflows/publish.yml
vendored
@ -36,25 +36,3 @@ jobs:
|
||||
npm config set registry 'https://wombat-dressing-room.appspot.com/'
|
||||
npm config set '//wombat-dressing-room.appspot.com/:_authToken' '${NPM_TOKEN}'
|
||||
npm publish
|
||||
|
||||
post-publish:
|
||||
needs: publish
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: main
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Build main docs
|
||||
run: npm run doc
|
||||
- name: Commit
|
||||
run: |
|
||||
git config --global user.email "55107282+release-please[bot]@users.noreply.github.com"
|
||||
git config --global user.name "release-please[bot]"
|
||||
git commit -am "chore: unfreeze version on docs"
|
||||
git push
|
||||
|
46
.gitignore
vendored
46
.gitignore
vendored
@ -1,19 +1,33 @@
|
||||
.DS_Store
|
||||
.vscode
|
||||
/.dev_profile*
|
||||
/.local-chromium/
|
||||
/.local-firefox/
|
||||
/test/output-*/
|
||||
build/
|
||||
# Dependencies
|
||||
node_modules
|
||||
|
||||
# Production
|
||||
build
|
||||
lib
|
||||
|
||||
# Generated files
|
||||
coverage
|
||||
coverage/
|
||||
doclint/
|
||||
docs-api-json/
|
||||
docs/api.html
|
||||
lib/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
tsconfig.tsbuildinfo
|
||||
puppeteer.api.json
|
||||
puppeteer*.tgz
|
||||
tsconfig.tsbuildinfo
|
||||
yarn.lock
|
||||
yarn.lock
|
||||
.docusaurus
|
||||
.cache-loader
|
||||
.local-chromium
|
||||
.local-firefox
|
||||
test/output-*/
|
||||
.dev_profile*
|
||||
|
||||
# IDE Artifacts
|
||||
.vscode
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
@ -4,7 +4,6 @@ assets/
|
||||
build/
|
||||
CHANGELOG.md
|
||||
coverage/
|
||||
doclint/
|
||||
lib/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
@ -13,4 +12,6 @@ test/assets/
|
||||
tsconfig.tsbuildinfo
|
||||
vendor/
|
||||
yarn.lock
|
||||
puppeteer.api.json
|
||||
puppeteer.api.json
|
||||
website/
|
||||
docs/
|
338
README.md
338
README.md
@ -1,3 +1,7 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Puppeteer
|
||||
|
||||
<!-- [START badges] -->
|
||||
@ -6,15 +10,15 @@
|
||||
|
||||
<!-- [END badges] -->
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png" height="200" align="right">
|
||||
<img src="https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png" height="200" align="right"/>
|
||||
|
||||
###### [API](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md) | [FAQ](#faq) | [Contributing](https://github.com/puppeteer/puppeteer/blob/main/CONTRIBUTING.md) | [Troubleshooting](https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md)
|
||||
###### [API](https://pptr.dev/api) | [FAQ](https://pptr.dev/faq) | [Contributing](https://pptr.dev/contributing) | [Troubleshooting](https://pptr.dev/troubleshooting)
|
||||
|
||||
> Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the [DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/). Puppeteer runs [headless](https://developers.google.com/web/updates/2017/04/headless-chrome) by default, but can be configured to run full (non-headless) Chrome or Chromium.
|
||||
|
||||
<!-- [START usecases] -->
|
||||
|
||||
###### What can I do?
|
||||
##### What can I do?
|
||||
|
||||
Most things that you can do manually in the browser can be done using Puppeteer! Here are a few examples to get you started:
|
||||
|
||||
@ -39,37 +43,81 @@ npm i puppeteer
|
||||
# or "yarn add puppeteer"
|
||||
```
|
||||
|
||||
Note: When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win) that is guaranteed to work with the API. To skip the download, download into another path, or download a different browser, see [Environment variables](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#environment-variables).
|
||||
When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win) that is guaranteed to work with the API (customizable through [Environment Variables](#environment-variables)). For a version of Puppeteer purely for connection, see [`puppeteer-core`](#puppeteer-core).
|
||||
|
||||
### puppeteer-core
|
||||
#### Environment Variables
|
||||
|
||||
Since version 1.7.0 we publish the [`puppeteer-core`](https://www.npmjs.com/package/puppeteer-core) package,
|
||||
a version of Puppeteer that doesn't download any browser by default.
|
||||
Puppeteer looks for certain [environment variables](https://en.wikipedia.org/wiki/Environment_variable) to aid its operations.
|
||||
If Puppeteer doesn't find them in the environment during the installation step, a lowercased variant of these variables will be used from the [npm config](https://docs.npmjs.com/cli/config).
|
||||
|
||||
```bash
|
||||
npm i puppeteer-core
|
||||
# or "yarn add puppeteer-core"
|
||||
- `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY` - defines HTTP proxy settings that are used to download and run the browser.
|
||||
- `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD` - do not download bundled Chromium during installation step.
|
||||
- `PUPPETEER_TMP_DIR` - defines the directory to be used by Puppeteer for creating temporary files. Defaults to [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir).
|
||||
- `PUPPETEER_DOWNLOAD_HOST` - overwrite URL prefix that is used to download Chromium. Note: this includes protocol and might even include path prefix. Defaults to `https://storage.googleapis.com`.
|
||||
- `PUPPETEER_DOWNLOAD_PATH` - overwrite the path for the downloads folder. Defaults to `<root>/.local-chromium`, where `<root>` is Puppeteer's package root.
|
||||
- `PUPPETEER_CHROMIUM_REVISION` - specify a certain version of Chromium you'd like Puppeteer to use. See [`puppeteer.launch`](https://pptr.dev/api/puppeteer.puppeteernode.launch) on how executable path is inferred.
|
||||
- `PUPPETEER_EXECUTABLE_PATH` - specify an executable path to be used in [`puppeteer.launch`](https://pptr.dev/api/puppeteer.puppeteernode.launch).
|
||||
- `PUPPETEER_PRODUCT` - specify which browser you'd like Puppeteer to use. Must be one of `chrome` or `firefox`. This can also be used during installation to fetch the recommended browser binary. Setting `product` programmatically in [`puppeteer.launch`](https://pptr.dev/api/puppeteer.puppeteernode.launch) supersedes this environment variable. The product is exposed in [`puppeteer.product`](https://pptr.dev/api/puppeteer.product)
|
||||
- `PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM` — specify Puppeteer download Chromium for Apple M1. On Apple M1 devices Puppeteer by default downloads the version for Intel's processor which runs via Rosetta. It works without any problems, however, with this option, you should get more efficient resource usage (CPU and RAM) that could lead to a faster execution time.
|
||||
|
||||
:::danger
|
||||
|
||||
Puppeteer is only [guaranteed to work](https://pptr.dev/faq#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy) with the bundled Chromium, use at your own risk.
|
||||
|
||||
:::
|
||||
|
||||
:::caution
|
||||
|
||||
`PUPPETEER_*` env variables are not accounted for in [`puppeteer-core`](#puppeteer-core).
|
||||
|
||||
:::
|
||||
|
||||
#### puppeteer-core
|
||||
|
||||
Every release since v1.7.0 we publish two packages:
|
||||
|
||||
- [`puppeteer`](https://www.npmjs.com/package/puppeteer)
|
||||
- [`puppeteer-core`](https://www.npmjs.com/package/puppeteer-core)
|
||||
|
||||
`puppeteer` is a _product_ for browser automation. When installed, it downloads a version of
|
||||
Chromium, which it then drives using `puppeteer-core`. Being an end-user product, `puppeteer` supports a bunch of convenient `PUPPETEER_*` env variables to tweak its behavior.
|
||||
|
||||
`puppeteer-core` is a _library_ to help drive anything that supports DevTools protocol. `puppeteer-core` doesn't download Chromium when installed. Being a library, `puppeteer-core` is fully driven
|
||||
through its programmatic interface and disregards all the `PUPPETEER_*` env variables.
|
||||
|
||||
To sum up, the only differences between `puppeteer-core` and `puppeteer` are:
|
||||
|
||||
- `puppeteer-core` doesn't automatically download Chromium when installed.
|
||||
- `puppeteer-core` ignores all `PUPPETEER_*` env variables.
|
||||
|
||||
In most cases, you'll be fine using the `puppeteer` package.
|
||||
|
||||
However, you should use `puppeteer-core` if:
|
||||
|
||||
- you're building another end-user product or library atop of DevTools protocol. For example, one might build a PDF generator using `puppeteer-core` and write a custom `install.js` script that downloads [`headless_shell`](https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md) instead of Chromium to save disk space.
|
||||
- you're bundling Puppeteer to use in Chrome Extension / browser with the DevTools protocol where downloading an additional Chromium binary is unnecessary.
|
||||
- you're building a set of tools where `puppeteer-core` is one of the ingredients and you want to postpone `install.js` script execution until Chromium is about to be used.
|
||||
|
||||
When using `puppeteer-core`, remember to change the _include_ line:
|
||||
|
||||
```ts
|
||||
const puppeteer = require('puppeteer-core');
|
||||
```
|
||||
|
||||
`puppeteer-core` is intended to be a lightweight version of Puppeteer for launching an existing browser installation or for connecting to a remote one. Be sure that the version of puppeteer-core you install is compatible with the browser you intend to connect to.
|
||||
|
||||
See [puppeteer vs puppeteer-core](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#puppeteer-vs-puppeteer-core).
|
||||
You will then need to call [`puppeteer.connect`](https://pptr.dev/api/puppeteer.puppeteer.connect) or [`puppeteer.launch`](https://pptr.dev/api/puppeteer.puppeteernode.launch) with an explicit `executablePath` or `channel` option.
|
||||
|
||||
### Usage
|
||||
|
||||
Puppeteer follows the latest [maintenance LTS](https://github.com/nodejs/Release#release-schedule) version of Node.
|
||||
|
||||
Note: Prior to v1.18.1, Puppeteer required at least Node v6.4.0. Versions from v1.18.1 to v2.1.0 rely on
|
||||
Node 8.9.0+. Starting from v3.0.0 Puppeteer starts to rely on Node 10.18.1+. All examples below use async/await which is only supported in Node v7.6.0 or greater.
|
||||
|
||||
Puppeteer will be familiar to people using other browser testing frameworks. You create an instance
|
||||
of `Browser`, open pages, and then manipulate them with [Puppeteer's API](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#).
|
||||
of `Browser`, open pages, and then manipulate them with [Puppeteer's API](https://pptr.dev/api).
|
||||
|
||||
**Example** - navigating to https://example.com and saving a screenshot as _example.png_:
|
||||
|
||||
Save file as **example.js**
|
||||
|
||||
```js
|
||||
```ts
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
(async () => {
|
||||
@ -88,13 +136,13 @@ Execute script on the command line
|
||||
node example.js
|
||||
```
|
||||
|
||||
Puppeteer sets an initial page size to 800×600px, which defines the screenshot size. The page size can be customized with [`Page.setViewport()`](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#pagesetviewportviewport).
|
||||
Puppeteer sets an initial page size to 800×600px, which defines the screenshot size. The page size can be customized with [`Page.setViewport()`](https://pptr.dev/api/puppeteer.page.setviewport).
|
||||
|
||||
**Example** - create a PDF.
|
||||
|
||||
Save file as **hn.js**
|
||||
|
||||
```js
|
||||
```ts
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
(async () => {
|
||||
@ -115,13 +163,13 @@ Execute script on the command line
|
||||
node hn.js
|
||||
```
|
||||
|
||||
See [`Page.pdf()`](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#pagepdfoptions) for more information about creating pdfs.
|
||||
See [`Page.pdf`](https://pptr.dev/api/puppeteer.page.pdf) for more information about creating pdfs.
|
||||
|
||||
**Example** - evaluate script in the context of the page
|
||||
|
||||
Save file as **get-dimensions.js**
|
||||
|
||||
```js
|
||||
```ts
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
(async () => {
|
||||
@ -150,19 +198,64 @@ Execute script on the command line
|
||||
node get-dimensions.js
|
||||
```
|
||||
|
||||
See [`Page.evaluate()`](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#pageevaluatepagefunction-args) for more information on `evaluate` and related methods like `evaluateOnNewDocument` and `exposeFunction`.
|
||||
See [`Page.evaluate`](https://pptr.dev/api/puppeteer.page.evaluate) and related methods like [`Page.evaluateOnNewDocument`](https://pptr.dev/api/puppeteer.page.evaluateOnNewDocument) and [`Page.exposeFunction`](https://pptr.dev/api/puppeteer.page.exposeFunction).
|
||||
|
||||
<!-- [END getstarted] -->
|
||||
|
||||
### Working with Chrome Extensions
|
||||
|
||||
Puppeteer can be used for testing Chrome Extensions.
|
||||
|
||||
:::caution
|
||||
|
||||
Extensions in Chrome / Chromium currently only work in non-headless mode and experimental Chrome headless mode.
|
||||
|
||||
:::
|
||||
|
||||
The following is code for getting a handle to the [background page](https://developer.chrome.com/extensions/background_pages) of an extension whose source is located in `./my-extension`:
|
||||
|
||||
```ts
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
(async () => {
|
||||
const pathToExtension = require('path').join(__dirname, 'my-extension');
|
||||
const browser = await puppeteer.launch({
|
||||
headless: 'chrome',
|
||||
args: [
|
||||
`--disable-extensions-except=${pathToExtension}`,
|
||||
`--load-extension=${pathToExtension}`,
|
||||
],
|
||||
});
|
||||
const backgroundPageTarget = await browser.waitForTarget(
|
||||
target => target.type() === 'background_page'
|
||||
);
|
||||
const backgroundPage = await backgroundPageTarget.page();
|
||||
// Test the background page as you would any other page.
|
||||
await browser.close();
|
||||
})();
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
Chrome Manifest V3 extensions have a background ServiceWorker of type 'service_worker', instead of a page of type 'background_page'.
|
||||
|
||||
:::
|
||||
|
||||
:::note
|
||||
|
||||
It is not yet possible to test extension popups or content scripts.
|
||||
|
||||
:::
|
||||
|
||||
<!-- [START runtimesettings] -->
|
||||
|
||||
## Default runtime settings
|
||||
|
||||
**1. Uses Headless mode**
|
||||
|
||||
Puppeteer launches Chromium in [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome). To launch a full version of Chromium, set the [`headless` option](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#puppeteerlaunchoptions) when launching a browser:
|
||||
Puppeteer launches Chromium in [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome). To launch a full version of Chromium, set the [`headless` option](https://pptr.dev/api/puppeteer.browserlaunchargumentoptions.headless) when launching a browser:
|
||||
|
||||
```js
|
||||
```ts
|
||||
const browser = await puppeteer.launch({headless: false}); // default is true
|
||||
```
|
||||
|
||||
@ -172,11 +265,11 @@ By default, Puppeteer downloads and uses a specific version of Chromium so its A
|
||||
is guaranteed to work out of the box. To use Puppeteer with a different version of Chrome or Chromium,
|
||||
pass in the executable's path when creating a `Browser` instance:
|
||||
|
||||
```js
|
||||
```ts
|
||||
const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});
|
||||
```
|
||||
|
||||
You can also use Puppeteer with Firefox Nightly (experimental support). See [`Puppeteer.launch()`](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#puppeteerlaunchoptions) for more information.
|
||||
You can also use Puppeteer with Firefox Nightly (experimental support). See [`Puppeteer.launch`](https://pptr.dev/api/puppeteer.puppeteernode.launch) for more information.
|
||||
|
||||
See [`this article`](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for a description of the differences between Chromium and Chrome. [`This article`](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/chromium_browser_vs_google_chrome.md) describes some differences for Linux users.
|
||||
|
||||
@ -188,8 +281,8 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
|
||||
## Resources
|
||||
|
||||
- [API Documentation](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md)
|
||||
- [Examples](https://github.com/puppeteer/puppeteer/tree/main/examples/)
|
||||
- [API Documentation](https://pptr.dev/api)
|
||||
- [Examples](https://github.com/puppeteer/puppeteer/tree/main/examples)
|
||||
- [Community list of Puppeteer resources](https://github.com/transitive-bullshit/awesome-puppeteer)
|
||||
|
||||
<!-- [START debugging] -->
|
||||
@ -200,14 +293,14 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
displaying. Instead of launching in headless mode, launch a full version of
|
||||
the browser using `headless: false`:
|
||||
|
||||
```js
|
||||
```ts
|
||||
const browser = await puppeteer.launch({headless: false});
|
||||
```
|
||||
|
||||
2. Slow it down - the `slowMo` option slows down Puppeteer operations by the
|
||||
specified amount of milliseconds. It's another way to help see what's going on.
|
||||
|
||||
```js
|
||||
```ts
|
||||
const browser = await puppeteer.launch({
|
||||
headless: false,
|
||||
slowMo: 250, // slow down by 250ms
|
||||
@ -217,7 +310,7 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
3. Capture console output - You can listen for the `console` event.
|
||||
This is also handy when debugging code in `page.evaluate()`:
|
||||
|
||||
```js
|
||||
```ts
|
||||
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
|
||||
|
||||
await page.evaluate(() => console.log(`url is ${location.href}`));
|
||||
@ -231,7 +324,7 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
|
||||
- Use `{devtools: true}` when launching Puppeteer:
|
||||
|
||||
```js
|
||||
```ts
|
||||
const browser = await puppeteer.launch({devtools: true});
|
||||
```
|
||||
|
||||
@ -245,7 +338,7 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
|
||||
- Add an evaluate statement with `debugger` inside / add `debugger` to an existing evaluate statement:
|
||||
|
||||
```js
|
||||
```ts
|
||||
await page.evaluate(() => {
|
||||
debugger;
|
||||
});
|
||||
@ -263,7 +356,7 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
|
||||
- Add `debugger;` to your test, eg:
|
||||
|
||||
```js
|
||||
```ts
|
||||
debugger;
|
||||
await page.click('a[target=_blank]');
|
||||
```
|
||||
@ -297,177 +390,10 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
|
||||
<!-- [END debugging] -->
|
||||
|
||||
<!-- [START typescript] -->
|
||||
## Contributing
|
||||
|
||||
## Usage with TypeScript
|
||||
Check out our [contributing guide](https://pptr.dev/contributing) to get an overview of Puppeteer development.
|
||||
|
||||
We have recently completed a migration to move the Puppeteer source code from JavaScript to TypeScript and as of version 7.0.1 we ship our own built-in type definitions.
|
||||
## FAQ
|
||||
|
||||
If you are on a version older than 7, we recommend installing the Puppeteer type definitions from the [DefinitelyTyped](https://definitelytyped.org/) repository:
|
||||
|
||||
```bash
|
||||
npm install --save-dev @types/puppeteer
|
||||
```
|
||||
|
||||
The types that you'll see appearing in the Puppeteer source code are based off the great work of those who have contributed to the `@types/puppeteer` package. We really appreciate the hard work those people put in to providing high quality TypeScript definitions for Puppeteer's users.
|
||||
|
||||
<!-- [END typescript] -->
|
||||
|
||||
## Contributing to Puppeteer
|
||||
|
||||
Check out [contributing guide](https://github.com/puppeteer/puppeteer/blob/main/CONTRIBUTING.md) to get an overview of Puppeteer development.
|
||||
|
||||
<!-- [START faq] -->
|
||||
|
||||
# FAQ
|
||||
|
||||
#### Q: Who maintains Puppeteer?
|
||||
|
||||
The Chrome DevTools team maintains the library, but we'd love your help and expertise on the project!
|
||||
See [Contributing](https://github.com/puppeteer/puppeteer/blob/main/CONTRIBUTING.md).
|
||||
|
||||
#### Q: What is the status of cross-browser support?
|
||||
|
||||
Official Firefox support is currently experimental. The ongoing collaboration with Mozilla aims to support common end-to-end testing use cases, for which developers expect cross-browser coverage. The Puppeteer team needs input from users to stabilize Firefox support and to bring missing APIs to our attention.
|
||||
|
||||
From Puppeteer v2.1.0 onwards you can specify [`puppeteer.launch({product: 'firefox'})`](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#puppeteerlaunchoptions) to run your Puppeteer scripts in Firefox Nightly, without any additional custom patches. While [an older experiment](https://www.npmjs.com/package/puppeteer-firefox) required a patched version of Firefox, [the current approach](https://wiki.mozilla.org/Remote) works with “stock” Firefox.
|
||||
|
||||
We will continue to collaborate with other browser vendors to bring Puppeteer support to browsers such as Safari.
|
||||
This effort includes exploration of a standard for executing cross-browser commands (instead of relying on the non-standard DevTools Protocol used by Chrome).
|
||||
|
||||
#### Q: What are Puppeteer’s goals and principles?
|
||||
|
||||
The goals of the project are:
|
||||
|
||||
- Provide a slim, canonical library that highlights the capabilities of the [DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/).
|
||||
- Provide a reference implementation for similar testing libraries. Eventually, these other frameworks could adopt Puppeteer as their foundational layer.
|
||||
- Grow the adoption of headless/automated browser testing.
|
||||
- Help dogfood new DevTools Protocol features...and catch bugs!
|
||||
- Learn more about the pain points of automated browser testing and help fill those gaps.
|
||||
|
||||
We adapt [Chromium principles](https://www.chromium.org/developers/core-principles) to help us drive product decisions:
|
||||
|
||||
- **Speed**: Puppeteer has almost zero performance overhead over an automated page.
|
||||
- **Security**: Puppeteer operates off-process with respect to Chromium, making it safe to automate potentially malicious pages.
|
||||
- **Stability**: Puppeteer should not be flaky and should not leak memory.
|
||||
- **Simplicity**: Puppeteer provides a high-level API that’s easy to use, understand, and debug.
|
||||
|
||||
#### Q: Is Puppeteer replacing Selenium/WebDriver?
|
||||
|
||||
**No**. Both projects are valuable for very different reasons:
|
||||
|
||||
- Selenium/WebDriver focuses on cross-browser automation; its value proposition is a single standard API that works across all major browsers.
|
||||
- Puppeteer focuses on Chromium; its value proposition is richer functionality and higher reliability.
|
||||
|
||||
That said, you **can** use Puppeteer to run tests against Chromium, e.g. using the community-driven [jest-puppeteer](https://github.com/smooth-code/jest-puppeteer). While this probably shouldn’t be your only testing solution, it does have a few good points compared to WebDriver:
|
||||
|
||||
- Puppeteer requires zero setup and comes bundled with the Chromium version it works best with, making it [very easy to start with](https://github.com/puppeteer/puppeteer/#getting-started). At the end of the day, it’s better to have a few tests running chromium-only, than no tests at all.
|
||||
- Puppeteer has event-driven architecture, which removes a lot of potential flakiness. There’s no need for evil “sleep(1000)” calls in puppeteer scripts.
|
||||
- Puppeteer runs headless by default, which makes it fast to run. Puppeteer v1.5.0 also exposes browser contexts, making it possible to efficiently parallelize test execution.
|
||||
- Puppeteer shines when it comes to debugging: flip the “headless” bit to false, add “slowMo”, and you’ll see what the browser is doing. You can even open Chrome DevTools to inspect the test environment.
|
||||
|
||||
#### Q: Why doesn’t Puppeteer v.XXX work with Chromium v.YYY?
|
||||
|
||||
We see Puppeteer as an **indivisible entity** with Chromium. Each version of Puppeteer bundles a specific version of Chromium – **the only** version it is guaranteed to work with.
|
||||
|
||||
This is not an artificial constraint: A lot of work on Puppeteer is actually taking place in the Chromium repository. Here’s a typical story:
|
||||
|
||||
- A Puppeteer bug is reported: https://github.com/puppeteer/puppeteer/issues/2709
|
||||
- It turned out this is an issue with the DevTools protocol, so we’re fixing it in Chromium: https://chromium-review.googlesource.com/c/chromium/src/+/1102154
|
||||
- Once the upstream fix is landed, we roll updated Chromium into Puppeteer: https://github.com/puppeteer/puppeteer/pull/2769
|
||||
|
||||
However, oftentimes it is desirable to use Puppeteer with the official Google Chrome rather than Chromium. For this to work, you should install a `puppeteer-core` version that corresponds to the Chrome version.
|
||||
|
||||
For example, in order to drive Chrome 71 with puppeteer-core, use `chrome-71` npm tag:
|
||||
|
||||
```bash
|
||||
npm install puppeteer-core@chrome-71
|
||||
```
|
||||
|
||||
#### Q: Which Chromium version does Puppeteer use?
|
||||
|
||||
Find the version using one of the following ways:
|
||||
|
||||
- Look for the `chromium` entry in [revisions.ts](https://github.com/puppeteer/puppeteer/blob/main/src/revisions.ts). To find the corresponding Chromium commit and version number, search for the revision prefixed by an `r` in [OmahaProxy](https://omahaproxy.appspot.com/)'s "Find Releases" section.
|
||||
- Look for the `versionsPerRelease` map in [versions.js](https://github.com/puppeteer/puppeteer/blob/main/versions.js) which contains mapping between Chromium and Puppeteer versions. Note: The file contains only Puppeteer versions where Chromium is updated. Not all Puppeteer versions are listed.
|
||||
|
||||
#### Q: Which Firefox version does Puppeteer use?
|
||||
|
||||
Since Firefox support is experimental, Puppeteer downloads the latest [Firefox Nightly](https://wiki.mozilla.org/Nightly) when the `PUPPETEER_PRODUCT` environment variable is set to `firefox`. That's also why the value of `firefox` in [revisions.ts](https://github.com/puppeteer/puppeteer/blob/main/src/revisions.ts) is `latest` -- Puppeteer isn't tied to a particular Firefox version.
|
||||
|
||||
To fetch Firefox Nightly as part of Puppeteer installation:
|
||||
|
||||
```bash
|
||||
PUPPETEER_PRODUCT=firefox npm i puppeteer
|
||||
# or "yarn add puppeteer"
|
||||
```
|
||||
|
||||
#### Q: What’s considered a “Navigation”?
|
||||
|
||||
From Puppeteer’s standpoint, **“navigation” is anything that changes a page’s URL**.
|
||||
Aside from regular navigation where the browser hits the network to fetch a new document from the web server, this includes [anchor navigations](https://www.w3.org/TR/html5/single-page.html#scroll-to-fragid) and [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) usage.
|
||||
|
||||
With this definition of “navigation,” **Puppeteer works seamlessly with single-page applications.**
|
||||
|
||||
#### Q: What’s the difference between a “trusted" and "untrusted" input event?
|
||||
|
||||
In browsers, input events could be divided into two big groups: trusted vs. untrusted.
|
||||
|
||||
- **Trusted events**: events generated by users interacting with the page, e.g. using a mouse or keyboard.
|
||||
- **Untrusted event**: events generated by Web APIs, e.g. `document.createEvent` or `element.click()` methods.
|
||||
|
||||
Websites can distinguish between these two groups:
|
||||
|
||||
- using an [`Event.isTrusted`](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted) event flag
|
||||
- sniffing for accompanying events. For example, every trusted `'click'` event is preceded by `'mousedown'` and `'mouseup'` events.
|
||||
|
||||
For automation purposes it’s important to generate trusted events. **All input events generated with Puppeteer are trusted and fire proper accompanying events.** If, for some reason, one needs an untrusted event, it’s always possible to hop into a page context with `page.evaluate` and generate a fake event:
|
||||
|
||||
```js
|
||||
await page.evaluate(() => {
|
||||
document.querySelector('button[type=submit]').click();
|
||||
});
|
||||
```
|
||||
|
||||
#### Q: What features does Puppeteer not support?
|
||||
|
||||
You may find that Puppeteer does not behave as expected when controlling pages that incorporate audio and video. (For example, [video playback/screenshots is likely to fail](https://github.com/puppeteer/puppeteer/issues/291).) There are two reasons for this:
|
||||
|
||||
- Puppeteer is bundled with Chromium — not Chrome — and so by default, it inherits all of [Chromium's media-related limitations](https://www.chromium.org/audio-video). This means that Puppeteer does not support licensed formats such as AAC or H.264. (However, it is possible to force Puppeteer to use a separately-installed version Chrome instead of Chromium via the [`executablePath` option to `puppeteer.launch`](https://github.com/puppeteer/puppeteer/blob/v15.2.0/docs/api.md#puppeteerlaunchoptions). You should only use this configuration if you need an official release of Chrome that supports these media formats.)
|
||||
- Since Puppeteer (in all configurations) controls a desktop version of Chromium/Chrome, features that are only supported by the mobile version of Chrome are not supported. This means that Puppeteer [does not support HTTP Live Streaming (HLS)](https://caniuse.com/#feat=http-live-streaming).
|
||||
|
||||
#### Q: I am having trouble installing / running Puppeteer in my test environment. Where should I look for help?
|
||||
|
||||
We have a [troubleshooting](https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md) guide for various operating systems that lists the required dependencies.
|
||||
|
||||
#### Q: Chromium gets downloaded on every `npm ci` run. How can I cache the download?
|
||||
|
||||
The default download path is `node_modules/puppeteer/.local-chromium`. However, you can change that path with the `PUPPETEER_DOWNLOAD_PATH` environment variable.
|
||||
|
||||
Puppeteer uses that variable to resolve the Chromium executable location during launch, so you don’t need to specify `PUPPETEER_EXECUTABLE_PATH` as well.
|
||||
|
||||
For example, if you wish to keep the Chromium download in `~/.npm/chromium`:
|
||||
|
||||
```sh
|
||||
export PUPPETEER_DOWNLOAD_PATH=~/.npm/chromium
|
||||
npm ci
|
||||
|
||||
# by default the Chromium executable path is inferred
|
||||
# from the download path
|
||||
npm test
|
||||
|
||||
# a new run of npm ci will check for the existence of
|
||||
# Chromium in ~/.npm/chromium
|
||||
npm ci
|
||||
```
|
||||
|
||||
#### Q: I have more questions! Where do I ask?
|
||||
|
||||
There are many ways to get help on Puppeteer:
|
||||
|
||||
- [bugtracker](https://github.com/puppeteer/puppeteer/issues)
|
||||
- [Stack Overflow](https://stackoverflow.com/questions/tagged/puppeteer)
|
||||
|
||||
Make sure to search these channels before posting your question.
|
||||
|
||||
<!-- [END faq] -->
|
||||
Our [FAQ](https://pptr.dev/faq) has migrated to [our site](https://pptr.dev/faq).
|
||||
|
5645
docs/api.md
5645
docs/api.md
File diff suppressed because it is too large
Load Diff
166
docs/api/index.md
Normal file
166
docs/api/index.md
Normal file
@ -0,0 +1,166 @@
|
||||
---
|
||||
sidebar_label: API
|
||||
---
|
||||
|
||||
# API Reference
|
||||
|
||||
## Classes
|
||||
|
||||
| Class | Description |
|
||||
| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [Accessibility](./puppeteer.accessibility.md) | The Accessibility class provides methods for inspecting Chromium'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 Chromium instance, either through [PuppeteerNode.launch()](./puppeteer.puppeteernode.launch.md) or [Puppeteer.connect()](./puppeteer.puppeteer.connect.md). |
|
||||
| [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. |
|
||||
| [BrowserFetcher](./puppeteer.browserfetcher.md) | BrowserFetcher can download and manage different versions of Chromium and Firefox. |
|
||||
| [CDPSession](./puppeteer.cdpsession.md) | The <code>CDPSession</code> instances are used to talk raw Chrome Devtools Protocol. |
|
||||
| [Connection](./puppeteer.connection.md) | |
|
||||
| [ConsoleMessage](./puppeteer.consolemessage.md) | ConsoleMessage objects are dispatched by page via the 'console' event. |
|
||||
| [Coverage](./puppeteer.coverage.md) | The Coverage class provides methods to gathers information about parts of JavaScript and CSS that were used by the page. |
|
||||
| [CSSCoverage](./puppeteer.csscoverage.md) | |
|
||||
| [CustomError](./puppeteer.customerror.md) | |
|
||||
| [Dialog](./puppeteer.dialog.md) | Dialog instances are dispatched by the [Page](./puppeteer.page.md) via the <code>dialog</code> event. |
|
||||
| [ElementHandle](./puppeteer.elementhandle.md) | ElementHandle represents an in-page DOM element. |
|
||||
| [EventEmitter](./puppeteer.eventemitter.md) | The EventEmitter class that many Puppeteer classes extend. |
|
||||
| [ExecutionContext](./puppeteer.executioncontext.md) | <p>This class represents a context for JavaScript execution. A \[Page\] might have many execution contexts: - each [frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) has "default" execution context that is always created after frame is attached to DOM. This context is returned by the [Frame.executionContext()](./puppeteer.frame.executioncontext.md) method. - [Extension](https://developer.chrome.com/extensions)'s content scripts create additional execution contexts.</p><p>Besides pages, execution contexts can be found in [workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).</p> |
|
||||
| [FileChooser](./puppeteer.filechooser.md) | File choosers let you react to the page requesting for a file. |
|
||||
| [Frame](./puppeteer.frame.md) | At every point of time, page exposes its current frame tree via the [page.mainFrame](./puppeteer.page.mainframe.md) and [frame.childFrames](./puppeteer.frame.childframes.md) methods. |
|
||||
| [HTTPRequest](./puppeteer.httprequest.md) | Represents an HTTP request sent by a page. |
|
||||
| [HTTPResponse](./puppeteer.httpresponse.md) | The HTTPResponse class represents responses which are received by the [Page](./puppeteer.page.md) class. |
|
||||
| [JSCoverage](./puppeteer.jscoverage.md) | |
|
||||
| [JSHandle](./puppeteer.jshandle.md) | Represents an in-page JavaScript object. JSHandles can be created with the [page.evaluateHandle](./puppeteer.page.evaluatehandle.md) method. |
|
||||
| [Keyboard](./puppeteer.keyboard.md) | Keyboard provides an api for managing a virtual keyboard. The high level api is [Keyboard.type()](./puppeteer.keyboard.type.md), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page. |
|
||||
| [Mouse](./puppeteer.mouse.md) | The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport. |
|
||||
| [Page](./puppeteer.page.md) | <p>Page provides methods to interact with a single tab or [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium.</p><p>:::note</p><p>One Browser instance might have multiple Page instances.</p><p>:::</p> |
|
||||
| [ProtocolError](./puppeteer.protocolerror.md) | ProtocolError is emitted whenever there is an error from the protocol. |
|
||||
| [Puppeteer](./puppeteer.puppeteer.md) | <p>The main Puppeteer class.</p><p>IMPORTANT: if you are using Puppeteer in a Node environment, you will get an instance of [PuppeteerNode](./puppeteer.puppeteernode.md) when you import or require <code>puppeteer</code>. That class extends <code>Puppeteer</code>, so has all the methods documented below as well as all that are defined on [PuppeteerNode](./puppeteer.puppeteernode.md).</p> |
|
||||
| [PuppeteerNode](./puppeteer.puppeteernode.md) | <p>Extends the main [Puppeteer](./puppeteer.puppeteer.md) class with Node specific behaviour for fetching and downloading browsers.</p><p>If you're using Puppeteer in a Node environment, this is the class you'll get when you run <code>require('puppeteer')</code> (or the equivalent ES <code>import</code>).</p> |
|
||||
| [SecurityDetails](./puppeteer.securitydetails.md) | The SecurityDetails class represents the security details of a response that was received over a secure connection. |
|
||||
| [Target](./puppeteer.target.md) | |
|
||||
| [TimeoutError](./puppeteer.timeouterror.md) | TimeoutError is emitted whenever certain operations are terminated due to timeout. |
|
||||
| [Touchscreen](./puppeteer.touchscreen.md) | The Touchscreen class exposes touchscreen events. |
|
||||
| [Tracing](./puppeteer.tracing.md) | The Tracing class exposes the tracing audit interface. |
|
||||
| [WebWorker](./puppeteer.webworker.md) | The WebWorker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). |
|
||||
|
||||
## Enumerations
|
||||
|
||||
| Enumeration | Description |
|
||||
| ------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| [BrowserContextEmittedEvents](./puppeteer.browsercontextemittedevents.md) | |
|
||||
| [BrowserEmittedEvents](./puppeteer.browseremittedevents.md) | All the events a [browser instance](./puppeteer.browser.md) may emit. |
|
||||
| [InterceptResolutionAction](./puppeteer.interceptresolutionaction.md) | |
|
||||
| [PageEmittedEvents](./puppeteer.pageemittedevents.md) | All the events that a page instance may emit. |
|
||||
|
||||
## Functions
|
||||
|
||||
| Function | Description |
|
||||
| -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
||||
| [clearCustomQueryHandlers()](./puppeteer.clearcustomqueryhandlers.md) | Clears all registered handlers. |
|
||||
| [customQueryHandlerNames()](./puppeteer.customqueryhandlernames.md) | |
|
||||
| [registerCustomQueryHandler(name, handler)](./puppeteer.registercustomqueryhandler.md) | Registers a [custom query handler](./puppeteer.customqueryhandler.md). |
|
||||
| [unregisterCustomQueryHandler(name)](./puppeteer.unregistercustomqueryhandler.md) | |
|
||||
|
||||
## Interfaces
|
||||
|
||||
| Interface | Description |
|
||||
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [BoundingBox](./puppeteer.boundingbox.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. |
|
||||
| [BrowserContextOptions](./puppeteer.browsercontextoptions.md) | BrowserContext options. |
|
||||
| [BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md) | |
|
||||
| [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) | |
|
||||
| [BrowserLaunchArgumentOptions](./puppeteer.browserlaunchargumentoptions.md) | Launcher options that only apply to Chrome. |
|
||||
| [CDPSessionOnMessageObject](./puppeteer.cdpsessiononmessageobject.md) | |
|
||||
| [ClickOptions](./puppeteer.clickoptions.md) | |
|
||||
| [CommonEventEmitter](./puppeteer.commoneventemitter.md) | |
|
||||
| [ConnectionCallback](./puppeteer.connectioncallback.md) | |
|
||||
| [ConnectionTransport](./puppeteer.connectiontransport.md) | |
|
||||
| [ConnectOptions](./puppeteer.connectoptions.md) | |
|
||||
| [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md) | |
|
||||
| [ContinueRequestOverrides](./puppeteer.continuerequestoverrides.md) | |
|
||||
| [CoverageEntry](./puppeteer.coverageentry.md) | The CoverageEntry class represents one entry of the coverage report. |
|
||||
| [Credentials](./puppeteer.credentials.md) | |
|
||||
| [CSSCoverageOptions](./puppeteer.csscoverageoptions.md) | Set of configurable options for CSS coverage. |
|
||||
| [CustomQueryHandler](./puppeteer.customqueryhandler.md) | Contains two functions <code>queryOne</code> and <code>queryAll</code> that can be [registered](./puppeteer.registercustomqueryhandler.md) as alternative querying strategies. The functions <code>queryOne</code> and <code>queryAll</code> are executed in the page context. <code>queryOne</code> should take an <code>Element</code> and a selector string as argument and return a single <code>Element</code> or <code>null</code> if no element is found. <code>queryAll</code> takes the same arguments but should instead return a <code>NodeListOf<Element></code> or <code>Array<Element></code> with all the elements that match the given query selector. |
|
||||
| [Device](./puppeteer.device.md) | |
|
||||
| [FrameAddScriptTagOptions](./puppeteer.frameaddscripttagoptions.md) | |
|
||||
| [FrameAddStyleTagOptions](./puppeteer.frameaddstyletagoptions.md) | |
|
||||
| [FrameWaitForFunctionOptions](./puppeteer.framewaitforfunctionoptions.md) | |
|
||||
| [GeolocationOptions](./puppeteer.geolocationoptions.md) | |
|
||||
| [InterceptResolutionState](./puppeteer.interceptresolutionstate.md) | |
|
||||
| [InternalNetworkConditions](./puppeteer.internalnetworkconditions.md) | |
|
||||
| [JSCoverageEntry](./puppeteer.jscoverageentry.md) | The CoverageEntry class for JavaScript |
|
||||
| [JSCoverageOptions](./puppeteer.jscoverageoptions.md) | Set of configurable options for JS coverage. |
|
||||
| [LaunchOptions](./puppeteer.launchoptions.md) | Generic launch options that can be passed when launching any browser. |
|
||||
| [MediaFeature](./puppeteer.mediafeature.md) | |
|
||||
| [Metrics](./puppeteer.metrics.md) | |
|
||||
| [MouseOptions](./puppeteer.mouseoptions.md) | |
|
||||
| [MouseWheelOptions](./puppeteer.mousewheeloptions.md) | |
|
||||
| [NetworkConditions](./puppeteer.networkconditions.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> |
|
||||
| [PDFMargin](./puppeteer.pdfmargin.md) | |
|
||||
| [PDFOptions](./puppeteer.pdfoptions.md) | Valid options to configure PDF generation via [Page.pdf()](./puppeteer.page.pdf.md). |
|
||||
| [Point](./puppeteer.point.md) | |
|
||||
| [PressOptions](./puppeteer.pressoptions.md) | |
|
||||
| [ProductLauncher](./puppeteer.productlauncher.md) | Describes a launcher - a class that is able to create and launch a browser instance. |
|
||||
| [PuppeteerErrors](./puppeteer.puppeteererrors.md) | |
|
||||
| [PuppeteerLaunchOptions](./puppeteer.puppeteerlaunchoptions.md) | |
|
||||
| [RemoteAddress](./puppeteer.remoteaddress.md) | |
|
||||
| [ResponseForRequest](./puppeteer.responseforrequest.md) | Required response data to fulfill a request with. |
|
||||
| [ScreenshotClip](./puppeteer.screenshotclip.md) | |
|
||||
| [ScreenshotOptions](./puppeteer.screenshotoptions.md) | |
|
||||
| [SerializedAXNode](./puppeteer.serializedaxnode.md) | Represents a Node and the properties of it that are relevant to Accessibility. |
|
||||
| [SnapshotOptions](./puppeteer.snapshotoptions.md) | |
|
||||
| [TracingOptions](./puppeteer.tracingoptions.md) | |
|
||||
| [Viewport](./puppeteer.viewport.md) | Sets the viewport of the page. |
|
||||
| [WaitForOptions](./puppeteer.waitforoptions.md) | |
|
||||
| [WaitForSelectorOptions](./puppeteer.waitforselectoroptions.md) | |
|
||||
| [WaitForTargetOptions](./puppeteer.waitfortargetoptions.md) | |
|
||||
| [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) | |
|
||||
|
||||
## Variables
|
||||
|
||||
| Variable | Description |
|
||||
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [connect](./puppeteer.connect.md) | |
|
||||
| [createBrowserFetcher](./puppeteer.createbrowserfetcher.md) | |
|
||||
| [DEFAULT_INTERCEPT_RESOLUTION_PRIORITY](./puppeteer.default_intercept_resolution_priority.md) | The default cooperative request interception resolution priority |
|
||||
| [defaultArgs](./puppeteer.defaultargs.md) | |
|
||||
| [devices](./puppeteer.devices.md) | A list of devices to be used with <code>page.emulate(options)</code>. Actual list of devices can be found in [src/common/DeviceDescriptors.ts](https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts). |
|
||||
| [errors](./puppeteer.errors.md) | <p>Puppeteer methods might throw errors if they are unable to fulfill a request. For example, <code>page.waitForSelector(selector[, options])</code> might fail if the selector doesn't match any nodes during the given timeframe.</p><p>For certain types of errors Puppeteer uses specific error classes. These classes are available via <code>puppeteer.errors</code>.</p> |
|
||||
| [EVALUATION_SCRIPT_URL](./puppeteer.evaluation_script_url.md) | |
|
||||
| [executablePath](./puppeteer.executablepath.md) | |
|
||||
| [launch](./puppeteer.launch.md) | |
|
||||
| [networkConditions](./puppeteer.networkconditions.md) | A list of network conditions to be used with <code>page.emulateNetworkConditions(networkConditions)</code>. Actual list of predefined conditions can be found in [src/common/NetworkConditions.ts](https://github.com/puppeteer/puppeteer/blob/main/src/common/NetworkConditions.ts). |
|
||||
|
||||
## Type Aliases
|
||||
|
||||
| Type Alias | Description |
|
||||
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [ActionResult](./puppeteer.actionresult.md) | |
|
||||
| [Awaitable](./puppeteer.awaitable.md) | |
|
||||
| [ChromeReleaseChannel](./puppeteer.chromereleasechannel.md) | |
|
||||
| [ConsoleMessageType](./puppeteer.consolemessagetype.md) | The supported types for console messages. |
|
||||
| [DevicesMap](./puppeteer.devicesmap.md) | |
|
||||
| [ErrorCode](./puppeteer.errorcode.md) | |
|
||||
| [EvaluateFunc](./puppeteer.evaluatefunc.md) | |
|
||||
| [EventType](./puppeteer.eventtype.md) | |
|
||||
| [FlattenHandle](./puppeteer.flattenhandle.md) | |
|
||||
| [HandleFor](./puppeteer.handlefor.md) | |
|
||||
| [HandleOr](./puppeteer.handleor.md) | |
|
||||
| [Handler](./puppeteer.handler.md) | |
|
||||
| [InnerParams](./puppeteer.innerparams.md) | |
|
||||
| [InterceptResolutionStrategy](./puppeteer.interceptresolutionstrategy.md) | |
|
||||
| [KeyInput](./puppeteer.keyinput.md) | All the valid keys that can be passed to functions that take user input, such as [keyboard.press](./puppeteer.keyboard.press.md) |
|
||||
| [LowerCasePaperFormat](./puppeteer.lowercasepaperformat.md) | |
|
||||
| [MouseButton](./puppeteer.mousebutton.md) | |
|
||||
| [PaperFormat](./puppeteer.paperformat.md) | All the valid paper format types when printing a PDF. |
|
||||
| [Permission](./puppeteer.permission.md) | |
|
||||
| [Platform](./puppeteer.platform.md) | Supported platforms. |
|
||||
| [Product](./puppeteer.product.md) | Supported products. |
|
||||
| [ProtocolLifeCycleEvent](./puppeteer.protocollifecycleevent.md) | |
|
||||
| [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md) | |
|
||||
| [PuppeteerNodeLaunchOptions](./puppeteer.puppeteernodelaunchoptions.md) | Utility type exposed to enable users to define options that can be passed to <code>puppeteer.launch</code> without having to list the set of all types. |
|
||||
| [ResourceType](./puppeteer.resourcetype.md) | Resource types for HTTPRequests as perceived by the rendering engine. |
|
||||
| [TargetFilterCallback](./puppeteer.targetfiltercallback.md) | |
|
29
docs/api/puppeteer.accessibility.md
Normal file
29
docs/api/puppeteer.accessibility.md
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
sidebar_label: Accessibility
|
||||
---
|
||||
|
||||
# Accessibility class
|
||||
|
||||
The Accessibility class provides methods for inspecting Chromium'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).
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare class Accessibility
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might have wildly different output.
|
||||
|
||||
Blink - Chrome's rendering engine - has a concept of "accessibility tree", which is then translated into different platform-specific APIs. Accessibility namespace gives users access to the Blink Accessibility Tree.
|
||||
|
||||
Most of the accessibility tree gets filtered out when converting from Blink AX Tree to Platform-specific AX-Tree or by assistive technologies themselves. By default, Puppeteer tries to approximate this filtering, exposing only the "interesting" nodes of the tree.
|
||||
|
||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `Accessibility` class.
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| ---------------------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [snapshot(options)](./puppeteer.accessibility.snapshot.md) | | Captures the current state of the accessibility tree. The returned object represents the root accessible node of the page. |
|
59
docs/api/puppeteer.accessibility.snapshot.md
Normal file
59
docs/api/puppeteer.accessibility.snapshot.md
Normal file
@ -0,0 +1,59 @@
|
||||
---
|
||||
sidebar_label: Accessibility.snapshot
|
||||
---
|
||||
|
||||
# Accessibility.snapshot() method
|
||||
|
||||
Captures the current state of the accessibility tree. The returned object represents the root accessible node of the page.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Accessibility {
|
||||
snapshot(options?: SnapshotOptions): Promise<SerializedAXNode | null>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ------------------------------------------------- | ----------------- |
|
||||
| options | [SnapshotOptions](./puppeteer.snapshotoptions.md) | <i>(Optional)</i> |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<[SerializedAXNode](./puppeteer.serializedaxnode.md) \| null>
|
||||
|
||||
An AXNode object representing the snapshot.
|
||||
|
||||
## Remarks
|
||||
|
||||
\*\*NOTE\*\* The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers. Puppeteer will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
|
||||
|
||||
## Example 1
|
||||
|
||||
An example of dumping the entire accessibility tree:
|
||||
|
||||
```ts
|
||||
const snapshot = await page.accessibility.snapshot();
|
||||
console.log(snapshot);
|
||||
```
|
||||
|
||||
## Example 2
|
||||
|
||||
An example of logging the focused node's name:
|
||||
|
||||
```ts
|
||||
const snapshot = await page.accessibility.snapshot();
|
||||
const node = findFocusedNode(snapshot);
|
||||
console.log(node && node.name);
|
||||
|
||||
function findFocusedNode(node) {
|
||||
if (node.focused) return node;
|
||||
for (const child of node.children || []) {
|
||||
const foundNode = findFocusedNode(child);
|
||||
return foundNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
```
|
11
docs/api/puppeteer.actionresult.md
Normal file
11
docs/api/puppeteer.actionresult.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
sidebar_label: ActionResult
|
||||
---
|
||||
|
||||
# ActionResult type
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare type ActionResult = 'continue' | 'abort' | 'respond';
|
||||
```
|
11
docs/api/puppeteer.awaitable.md
Normal file
11
docs/api/puppeteer.awaitable.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
sidebar_label: Awaitable
|
||||
---
|
||||
|
||||
# Awaitable type
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare type Awaitable<T> = T | PromiseLike<T>;
|
||||
```
|
15
docs/api/puppeteer.boundingbox.height.md
Normal file
15
docs/api/puppeteer.boundingbox.height.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BoundingBox.height
|
||||
---
|
||||
|
||||
# BoundingBox.height property
|
||||
|
||||
the height of the element in pixels.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BoundingBox {
|
||||
height: number;
|
||||
}
|
||||
```
|
20
docs/api/puppeteer.boundingbox.md
Normal file
20
docs/api/puppeteer.boundingbox.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
sidebar_label: BoundingBox
|
||||
---
|
||||
|
||||
# BoundingBox interface
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export interface BoundingBox extends Point
|
||||
```
|
||||
|
||||
**Extends:** [Point](./puppeteer.point.md)
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| ------------------------------------------- | --------- | ------ | ------------------------------------ |
|
||||
| [height](./puppeteer.boundingbox.height.md) | | number | the height of the element in pixels. |
|
||||
| [width](./puppeteer.boundingbox.width.md) | | number | the width of the element in pixels. |
|
15
docs/api/puppeteer.boundingbox.width.md
Normal file
15
docs/api/puppeteer.boundingbox.width.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BoundingBox.width
|
||||
---
|
||||
|
||||
# BoundingBox.width property
|
||||
|
||||
the width of the element in pixels.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BoundingBox {
|
||||
width: number;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.boxmodel.border.md
Normal file
13
docs/api/puppeteer.boxmodel.border.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BoxModel.border
|
||||
---
|
||||
|
||||
# BoxModel.border property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BoxModel {
|
||||
border: Point[];
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.boxmodel.content.md
Normal file
13
docs/api/puppeteer.boxmodel.content.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BoxModel.content
|
||||
---
|
||||
|
||||
# BoxModel.content property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BoxModel {
|
||||
content: Point[];
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.boxmodel.height.md
Normal file
13
docs/api/puppeteer.boxmodel.height.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BoxModel.height
|
||||
---
|
||||
|
||||
# BoxModel.height property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BoxModel {
|
||||
height: number;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.boxmodel.margin.md
Normal file
13
docs/api/puppeteer.boxmodel.margin.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BoxModel.margin
|
||||
---
|
||||
|
||||
# BoxModel.margin property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BoxModel {
|
||||
margin: Point[];
|
||||
}
|
||||
```
|
22
docs/api/puppeteer.boxmodel.md
Normal file
22
docs/api/puppeteer.boxmodel.md
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
sidebar_label: BoxModel
|
||||
---
|
||||
|
||||
# BoxModel interface
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export interface BoxModel
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| ------------------------------------------ | --------- | --------------------------------- | ----------- |
|
||||
| [border](./puppeteer.boxmodel.border.md) | | [Point](./puppeteer.point.md)\[\] | |
|
||||
| [content](./puppeteer.boxmodel.content.md) | | [Point](./puppeteer.point.md)\[\] | |
|
||||
| [height](./puppeteer.boxmodel.height.md) | | number | |
|
||||
| [margin](./puppeteer.boxmodel.margin.md) | | [Point](./puppeteer.point.md)\[\] | |
|
||||
| [padding](./puppeteer.boxmodel.padding.md) | | [Point](./puppeteer.point.md)\[\] | |
|
||||
| [width](./puppeteer.boxmodel.width.md) | | number | |
|
13
docs/api/puppeteer.boxmodel.padding.md
Normal file
13
docs/api/puppeteer.boxmodel.padding.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BoxModel.padding
|
||||
---
|
||||
|
||||
# BoxModel.padding property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BoxModel {
|
||||
padding: Point[];
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.boxmodel.width.md
Normal file
13
docs/api/puppeteer.boxmodel.width.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BoxModel.width
|
||||
---
|
||||
|
||||
# BoxModel.width property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BoxModel {
|
||||
width: number;
|
||||
}
|
||||
```
|
19
docs/api/puppeteer.browser.browsercontexts.md
Normal file
19
docs/api/puppeteer.browser.browsercontexts.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
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)\[\]
|
19
docs/api/puppeteer.browser.close.md
Normal file
19
docs/api/puppeteer.browser.close.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: Browser.close
|
||||
---
|
||||
|
||||
# Browser.close() method
|
||||
|
||||
Closes Chromium 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>
|
41
docs/api/puppeteer.browser.createincognitobrowsercontext.md
Normal file
41
docs/api/puppeteer.browser.createincognitobrowsercontext.md
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
sidebar_label: Browser.createIncognitoBrowserContext
|
||||
---
|
||||
|
||||
# Browser.createIncognitoBrowserContext() method
|
||||
|
||||
Creates a new incognito browser context. This won't share cookies/cache with other browser contexts.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Browser {
|
||||
createIncognitoBrowserContext(
|
||||
options?: BrowserContextOptions
|
||||
): Promise<BrowserContext>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ------------------------------------------------------------- | ----------------- |
|
||||
| options | [BrowserContextOptions](./puppeteer.browsercontextoptions.md) | <i>(Optional)</i> |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<[BrowserContext](./puppeteer.browsercontext.md)>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
(async () => {
|
||||
const browser = await puppeteer.launch();
|
||||
// Create a new incognito browser context.
|
||||
const context = await browser.createIncognitoBrowserContext();
|
||||
// Create a new page in a pristine context.
|
||||
const page = await context.newPage();
|
||||
// Do stuff
|
||||
await page.goto('https://example.com');
|
||||
})();
|
||||
```
|
19
docs/api/puppeteer.browser.defaultbrowsercontext.md
Normal file
19
docs/api/puppeteer.browser.defaultbrowsercontext.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: Browser.defaultBrowserContext
|
||||
---
|
||||
|
||||
# Browser.defaultBrowserContext() method
|
||||
|
||||
Returns the default browser context. The default browser context cannot be closed.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Browser {
|
||||
defaultBrowserContext(): BrowserContext;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
[BrowserContext](./puppeteer.browsercontext.md)
|
19
docs/api/puppeteer.browser.disconnect.md
Normal file
19
docs/api/puppeteer.browser.disconnect.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: Browser.disconnect
|
||||
---
|
||||
|
||||
# Browser.disconnect() method
|
||||
|
||||
Disconnects Puppeteer from the browser, but leaves the Chromium 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
|
19
docs/api/puppeteer.browser.isconnected.md
Normal file
19
docs/api/puppeteer.browser.isconnected.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: Browser.isConnected
|
||||
---
|
||||
|
||||
# Browser.isConnected() method
|
||||
|
||||
Indicates that the browser is connected.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Browser {
|
||||
isConnected(): boolean;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
boolean
|
77
docs/api/puppeteer.browser.md
Normal file
77
docs/api/puppeteer.browser.md
Normal file
@ -0,0 +1,77 @@
|
||||
---
|
||||
sidebar_label: Browser
|
||||
---
|
||||
|
||||
# Browser class
|
||||
|
||||
A Browser is created when Puppeteer connects to a Chromium instance, either through [PuppeteerNode.launch()](./puppeteer.puppeteernode.launch.md) or [Puppeteer.connect()](./puppeteer.puppeteer.connect.md).
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare class Browser 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 [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
|
||||
const puppeteer = require('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
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
(async () => {
|
||||
const browser = await puppeteer.launch();
|
||||
// Store the endpoint to be able to reconnect to Chromium
|
||||
const browserWSEndpoint = browser.wsEndpoint();
|
||||
// Disconnect puppeteer from Chromium
|
||||
browser.disconnect();
|
||||
|
||||
// Use the endpoint to reestablish a connection
|
||||
const browser2 = await puppeteer.connect({browserWSEndpoint});
|
||||
// Close Chromium
|
||||
await browser2.close();
|
||||
})();
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| ---------------------------------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [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 Chromium 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 Chromium 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). |
|
19
docs/api/puppeteer.browser.newpage.md
Normal file
19
docs/api/puppeteer.browser.newpage.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: Browser.newPage
|
||||
---
|
||||
|
||||
# Browser.newPage() method
|
||||
|
||||
Promise which resolves to a new [Page](./puppeteer.page.md) object. The Page is created in a default browser context.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Browser {
|
||||
newPage(): Promise<Page>;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<[Page](./puppeteer.page.md)>
|
23
docs/api/puppeteer.browser.pages.md
Normal file
23
docs/api/puppeteer.browser.pages.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
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).
|
19
docs/api/puppeteer.browser.process.md
Normal file
19
docs/api/puppeteer.browser.process.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
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
|
19
docs/api/puppeteer.browser.target.md
Normal file
19
docs/api/puppeteer.browser.target.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: Browser.target
|
||||
---
|
||||
|
||||
# Browser.target() method
|
||||
|
||||
The target associated with the browser.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Browser {
|
||||
target(): Target;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
[Target](./puppeteer.target.md)
|
19
docs/api/puppeteer.browser.targets.md
Normal file
19
docs/api/puppeteer.browser.targets.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
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)\[\]
|
19
docs/api/puppeteer.browser.useragent.md
Normal file
19
docs/api/puppeteer.browser.useragent.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: Browser.userAgent
|
||||
---
|
||||
|
||||
# Browser.userAgent() method
|
||||
|
||||
The browser's original user agent. Pages can override the browser user agent with [Page.setUserAgent()](./puppeteer.page.setuseragent.md).
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Browser {
|
||||
userAgent(): Promise<string>;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<string>
|
25
docs/api/puppeteer.browser.version.md
Normal file
25
docs/api/puppeteer.browser.version.md
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
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 Chromium, this is similar to `HeadlessChrome/61.0.3153.0`. For non-headless, this is similar to `Chrome/61.0.3153.0`.
|
||||
|
||||
The format of browser.version() might change with future releases of Chromium.
|
42
docs/api/puppeteer.browser.waitfortarget.md
Normal file
42
docs/api/puppeteer.browser.waitfortarget.md
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
sidebar_label: Browser.waitForTarget
|
||||
---
|
||||
|
||||
# Browser.waitForTarget() method
|
||||
|
||||
Searches for a target in all browser contexts.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class Browser {
|
||||
waitForTarget(
|
||||
predicate: (x: Target) => boolean | Promise<boolean>,
|
||||
options?: WaitForTargetOptions
|
||||
): Promise<Target>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---------------------------------------------------------------------------- | -------------------------------------- |
|
||||
| predicate | (x: [Target](./puppeteer.target.md)) => boolean \| Promise<boolean> | A function to be run for every target. |
|
||||
| options | [WaitForTargetOptions](./puppeteer.waitfortargetoptions.md) | <i>(Optional)</i> |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<[Target](./puppeteer.target.md)>
|
||||
|
||||
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 browser.waitForTarget(
|
||||
target => target.url() === 'https://www.example.com/'
|
||||
);
|
||||
```
|
27
docs/api/puppeteer.browser.wsendpoint.md
Normal file
27
docs/api/puppeteer.browser.wsendpoint.md
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
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).
|
15
docs/api/puppeteer.browserconnectoptions.defaultviewport.md
Normal file
15
docs/api/puppeteer.browserconnectoptions.defaultviewport.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserConnectOptions.defaultViewport
|
||||
---
|
||||
|
||||
# BrowserConnectOptions.defaultViewport property
|
||||
|
||||
Sets the viewport for each page.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserConnectOptions {
|
||||
defaultViewport?: Viewport | null;
|
||||
}
|
||||
```
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserConnectOptions.ignoreHTTPSErrors
|
||||
---
|
||||
|
||||
# BrowserConnectOptions.ignoreHTTPSErrors property
|
||||
|
||||
Whether to ignore HTTPS errors during navigation.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserConnectOptions {
|
||||
ignoreHTTPSErrors?: boolean;
|
||||
}
|
||||
```
|
22
docs/api/puppeteer.browserconnectoptions.md
Normal file
22
docs/api/puppeteer.browserconnectoptions.md
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
sidebar_label: BrowserConnectOptions
|
||||
---
|
||||
|
||||
# BrowserConnectOptions interface
|
||||
|
||||
Generic browser options that can be passed when launching any browser or when connecting to an existing browser instance.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export interface BrowserConnectOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| ---------------------------------------------------------------------------- | --------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
||||
| [defaultViewport?](./puppeteer.browserconnectoptions.defaultviewport.md) | | [Viewport](./puppeteer.viewport.md) \| null | <i>(Optional)</i> Sets the viewport for each page. |
|
||||
| [ignoreHTTPSErrors?](./puppeteer.browserconnectoptions.ignorehttpserrors.md) | | boolean | <i>(Optional)</i> Whether to ignore HTTPS errors during navigation. |
|
||||
| [slowMo?](./puppeteer.browserconnectoptions.slowmo.md) | | number | <i>(Optional)</i> Slows down Puppeteer operations by the specified amount of milliseconds to aid debugging. |
|
||||
| [targetFilter?](./puppeteer.browserconnectoptions.targetfilter.md) | | [TargetFilterCallback](./puppeteer.targetfiltercallback.md) | <i>(Optional)</i> Callback to decide if Puppeteer should connect to a given target or not. |
|
15
docs/api/puppeteer.browserconnectoptions.slowmo.md
Normal file
15
docs/api/puppeteer.browserconnectoptions.slowmo.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserConnectOptions.slowMo
|
||||
---
|
||||
|
||||
# BrowserConnectOptions.slowMo property
|
||||
|
||||
Slows down Puppeteer operations by the specified amount of milliseconds to aid debugging.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserConnectOptions {
|
||||
slowMo?: number;
|
||||
}
|
||||
```
|
15
docs/api/puppeteer.browserconnectoptions.targetfilter.md
Normal file
15
docs/api/puppeteer.browserconnectoptions.targetfilter.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserConnectOptions.targetFilter
|
||||
---
|
||||
|
||||
# BrowserConnectOptions.targetFilter property
|
||||
|
||||
Callback to decide if Puppeteer should connect to a given target or not.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserConnectOptions {
|
||||
targetFilter?: TargetFilterCallback;
|
||||
}
|
||||
```
|
19
docs/api/puppeteer.browsercontext.browser.md
Normal file
19
docs/api/puppeteer.browsercontext.browser.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: BrowserContext.browser
|
||||
---
|
||||
|
||||
# BrowserContext.browser() method
|
||||
|
||||
The browser this browser context belongs to.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserContext {
|
||||
browser(): Browser;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
[Browser](./puppeteer.browser.md)
|
@ -0,0 +1,28 @@
|
||||
---
|
||||
sidebar_label: BrowserContext.clearPermissionOverrides
|
||||
---
|
||||
|
||||
# BrowserContext.clearPermissionOverrides() method
|
||||
|
||||
Clears all permission overrides for the browser context.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserContext {
|
||||
clearPermissionOverrides(): Promise<void>;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<void>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const context = browser.defaultBrowserContext();
|
||||
context.overridePermissions('https://example.com', ['clipboard-read']);
|
||||
// do stuff ..
|
||||
context.clearPermissionOverrides();
|
||||
```
|
23
docs/api/puppeteer.browsercontext.close.md
Normal file
23
docs/api/puppeteer.browsercontext.close.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
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.
|
23
docs/api/puppeteer.browsercontext.isincognito.md
Normal file
23
docs/api/puppeteer.browsercontext.isincognito.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
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.
|
52
docs/api/puppeteer.browsercontext.md
Normal file
52
docs/api/puppeteer.browsercontext.md
Normal file
@ -0,0 +1,52 @@
|
||||
---
|
||||
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();
|
||||
```
|
||||
|
||||
## 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. |
|
19
docs/api/puppeteer.browsercontext.newpage.md
Normal file
19
docs/api/puppeteer.browsercontext.newpage.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: BrowserContext.newPage
|
||||
---
|
||||
|
||||
# BrowserContext.newPage() method
|
||||
|
||||
Creates a new page in the browser context.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserContext {
|
||||
newPage(): Promise<Page>;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<[Page](./puppeteer.page.md)>
|
31
docs/api/puppeteer.browsercontext.overridepermissions.md
Normal file
31
docs/api/puppeteer.browsercontext.overridepermissions.md
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
sidebar_label: BrowserContext.overridePermissions
|
||||
---
|
||||
|
||||
# BrowserContext.overridePermissions() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserContext {
|
||||
overridePermissions(origin: string, permissions: Permission[]): Promise<void>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| ----------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
||||
| origin | string | The origin to grant permissions to, e.g. "https://example.com". |
|
||||
| permissions | [Permission](./puppeteer.permission.md)\[\] | An array of permissions to grant. All permissions that are not listed here will be automatically denied. |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<void>
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const context = browser.defaultBrowserContext();
|
||||
await context.overridePermissions('https://html5demos.com', ['geolocation']);
|
||||
```
|
21
docs/api/puppeteer.browsercontext.pages.md
Normal file
21
docs/api/puppeteer.browsercontext.pages.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
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).
|
19
docs/api/puppeteer.browsercontext.targets.md
Normal file
19
docs/api/puppeteer.browsercontext.targets.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: BrowserContext.targets
|
||||
---
|
||||
|
||||
# BrowserContext.targets() method
|
||||
|
||||
An array of all active targets inside the browser context.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserContext {
|
||||
targets(): Target[];
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
[Target](./puppeteer.target.md)\[\]
|
44
docs/api/puppeteer.browsercontext.waitfortarget.md
Normal file
44
docs/api/puppeteer.browsercontext.waitfortarget.md
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
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; } | <i>(Optional)</i> An object of options. Accepts a timout, 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/'
|
||||
);
|
||||
```
|
19
docs/api/puppeteer.browsercontextemittedevents.md
Normal file
19
docs/api/puppeteer.browsercontextemittedevents.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: BrowserContextEmittedEvents
|
||||
---
|
||||
|
||||
# BrowserContextEmittedEvents enum
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare const enum BrowserContextEmittedEvents
|
||||
```
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
| Member | Value | Description |
|
||||
| --------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| TargetChanged | <code>"targetchanged"</code> | Emitted when the url of a target inside the browser context changes. Contains a [Target](./puppeteer.target.md) instance. |
|
||||
| TargetCreated | <code>"targetcreated"</code> | <p>Emitted when a target is created within the browser context, for example when a new page is opened by [window.open](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) or by [browserContext.newPage](./puppeteer.browsercontext.newpage.md)</p><p>Contains a [Target](./puppeteer.target.md) instance.</p> |
|
||||
| TargetDestroyed | <code>"targetdestroyed"</code> | Emitted when a target is destroyed within the browser context, for example when a page is closed. Contains a [Target](./puppeteer.target.md) instance. |
|
20
docs/api/puppeteer.browsercontextoptions.md
Normal file
20
docs/api/puppeteer.browsercontextoptions.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
sidebar_label: BrowserContextOptions
|
||||
---
|
||||
|
||||
# BrowserContextOptions interface
|
||||
|
||||
BrowserContext options.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export interface BrowserContextOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| ------------------------------------------------------------------------ | --------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [proxyBypassList?](./puppeteer.browsercontextoptions.proxybypasslist.md) | | string\[\] | <i>(Optional)</i> Bypass the proxy for the given semi-colon-separated list of hosts. |
|
||||
| [proxyServer?](./puppeteer.browsercontextoptions.proxyserver.md) | | string | <i>(Optional)</i> Proxy server with optional port to use for all requests. Username and password can be set in <code>Page.authenticate</code>. |
|
15
docs/api/puppeteer.browsercontextoptions.proxybypasslist.md
Normal file
15
docs/api/puppeteer.browsercontextoptions.proxybypasslist.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserContextOptions.proxyBypassList
|
||||
---
|
||||
|
||||
# BrowserContextOptions.proxyBypassList property
|
||||
|
||||
Bypass the proxy for the given semi-colon-separated list of hosts.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserContextOptions {
|
||||
proxyBypassList?: string[];
|
||||
}
|
||||
```
|
15
docs/api/puppeteer.browsercontextoptions.proxyserver.md
Normal file
15
docs/api/puppeteer.browsercontextoptions.proxyserver.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserContextOptions.proxyServer
|
||||
---
|
||||
|
||||
# BrowserContextOptions.proxyServer property
|
||||
|
||||
Proxy server with optional port to use for all requests. Username and password can be set in `Page.authenticate`.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserContextOptions {
|
||||
proxyServer?: string;
|
||||
}
|
||||
```
|
22
docs/api/puppeteer.browseremittedevents.md
Normal file
22
docs/api/puppeteer.browseremittedevents.md
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
sidebar_label: BrowserEmittedEvents
|
||||
---
|
||||
|
||||
# BrowserEmittedEvents enum
|
||||
|
||||
All the events a [browser instance](./puppeteer.browser.md) may emit.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare const enum BrowserEmittedEvents
|
||||
```
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
| Member | Value | Description |
|
||||
| --------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Disconnected | <code>"disconnected"</code> | <p>Emitted when Puppeteer gets disconnected from the Chromium instance. This might happen because of one of the following:</p><p>- Chromium is closed or crashed</p><p>- The [browser.disconnect](./puppeteer.browser.disconnect.md) method was called.</p> |
|
||||
| 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> |
|
||||
| TargetDestroyed | <code>"targetdestroyed"</code> | Emitted when a target is destroyed, for example when a page is closed. Contains a [Target](./puppeteer.target.md) instance. |
|
31
docs/api/puppeteer.browserfetcher.candownload.md
Normal file
31
docs/api/puppeteer.browserfetcher.candownload.md
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher.canDownload
|
||||
---
|
||||
|
||||
# BrowserFetcher.canDownload() method
|
||||
|
||||
Initiates a HEAD request to check if the revision is available.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserFetcher {
|
||||
canDownload(revision: string): Promise<boolean>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ------ | --------------------------------------- |
|
||||
| revision | string | The revision to check availability for. |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<boolean>
|
||||
|
||||
A promise that resolves to `true` if the revision could be downloaded from the host.
|
||||
|
||||
## Remarks
|
||||
|
||||
This method is affected by the current `product`.
|
35
docs/api/puppeteer.browserfetcher.download.md
Normal file
35
docs/api/puppeteer.browserfetcher.download.md
Normal file
@ -0,0 +1,35 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher.download
|
||||
---
|
||||
|
||||
# BrowserFetcher.download() method
|
||||
|
||||
Initiates a GET request to download the revision from the host.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserFetcher {
|
||||
download(
|
||||
revision: string,
|
||||
progressCallback?: (x: number, y: number) => void
|
||||
): Promise<BrowserFetcherRevisionInfo | undefined>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| ---------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| revision | string | The revision to download. |
|
||||
| progressCallback | (x: number, y: number) => void | <i>(Optional)</i> A function that will be called with two arguments: How many bytes have been downloaded and the total number of bytes of the download. |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<[BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) \| undefined>
|
||||
|
||||
A promise with revision information when the revision is downloaded and extracted.
|
||||
|
||||
## Remarks
|
||||
|
||||
This method is affected by the current `product`.
|
19
docs/api/puppeteer.browserfetcher.host.md
Normal file
19
docs/api/puppeteer.browserfetcher.host.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher.host
|
||||
---
|
||||
|
||||
# BrowserFetcher.host() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserFetcher {
|
||||
host(): string;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
string
|
||||
|
||||
The download host being used.
|
23
docs/api/puppeteer.browserfetcher.localrevisions.md
Normal file
23
docs/api/puppeteer.browserfetcher.localrevisions.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher.localRevisions
|
||||
---
|
||||
|
||||
# BrowserFetcher.localRevisions() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserFetcher {
|
||||
localRevisions(): Promise<string[]>;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<string\[\]>
|
||||
|
||||
A promise with a list of all revision strings (for the current `product`) available locally on disk.
|
||||
|
||||
## Remarks
|
||||
|
||||
This method is affected by the current `product`.
|
46
docs/api/puppeteer.browserfetcher.md
Normal file
46
docs/api/puppeteer.browserfetcher.md
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher
|
||||
---
|
||||
|
||||
# BrowserFetcher class
|
||||
|
||||
BrowserFetcher can download and manage different versions of Chromium and Firefox.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare class BrowserFetcher
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
BrowserFetcher operates on revision strings that specify a precise version of Chromium, e.g. `"533271"`. Revision strings can be obtained from [omahaproxy.appspot.com](http://omahaproxy.appspot.com/). In the Firefox case, BrowserFetcher downloads Firefox Nightly and operates on version numbers such as `"75"`.
|
||||
|
||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `BrowserFetcher` class.
|
||||
|
||||
## Example
|
||||
|
||||
An example of using BrowserFetcher to download a specific version of Chromium and running Puppeteer against it:
|
||||
|
||||
```ts
|
||||
const browserFetcher = puppeteer.createBrowserFetcher();
|
||||
const revisionInfo = await browserFetcher.download('533271');
|
||||
const browser = await puppeteer.launch({
|
||||
executablePath: revisionInfo.executablePath,
|
||||
});
|
||||
```
|
||||
|
||||
\*\*NOTE\*\* BrowserFetcher is not designed to work concurrently with other instances of BrowserFetcher that share the same downloads directory.
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| ------------------------------------------------------------------------------ | --------- | --------------------------------------------------------------- |
|
||||
| [canDownload(revision)](./puppeteer.browserfetcher.candownload.md) | | Initiates a HEAD request to check if the revision is available. |
|
||||
| [download(revision, progressCallback)](./puppeteer.browserfetcher.download.md) | | Initiates a GET request to download the revision from the host. |
|
||||
| [host()](./puppeteer.browserfetcher.host.md) | | |
|
||||
| [localRevisions()](./puppeteer.browserfetcher.localrevisions.md) | | |
|
||||
| [platform()](./puppeteer.browserfetcher.platform.md) | | |
|
||||
| [product()](./puppeteer.browserfetcher.product.md) | | |
|
||||
| [remove(revision)](./puppeteer.browserfetcher.remove.md) | | |
|
||||
| [revisionInfo(revision)](./puppeteer.browserfetcher.revisioninfo.md) | | |
|
19
docs/api/puppeteer.browserfetcher.platform.md
Normal file
19
docs/api/puppeteer.browserfetcher.platform.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher.platform
|
||||
---
|
||||
|
||||
# BrowserFetcher.platform() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserFetcher {
|
||||
platform(): Platform;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
[Platform](./puppeteer.platform.md)
|
||||
|
||||
Returns the current `Platform`, which is one of `mac`, `linux`, `win32` or `win64`.
|
19
docs/api/puppeteer.browserfetcher.product.md
Normal file
19
docs/api/puppeteer.browserfetcher.product.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher.product
|
||||
---
|
||||
|
||||
# BrowserFetcher.product() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserFetcher {
|
||||
product(): Product;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
[Product](./puppeteer.product.md)
|
||||
|
||||
Returns the current `Product`, which is one of `chrome` or `firefox`.
|
29
docs/api/puppeteer.browserfetcher.remove.md
Normal file
29
docs/api/puppeteer.browserfetcher.remove.md
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher.remove
|
||||
---
|
||||
|
||||
# BrowserFetcher.remove() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserFetcher {
|
||||
remove(revision: string): Promise<void>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ------ | ---------------------------------------------------------- |
|
||||
| revision | string | A revision to remove for the current <code>product</code>. |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<void>
|
||||
|
||||
A promise that resolves when the revision has been removes or throws if the revision has not been downloaded.
|
||||
|
||||
## Remarks
|
||||
|
||||
This method is affected by the current `product`.
|
25
docs/api/puppeteer.browserfetcher.revisioninfo.md
Normal file
25
docs/api/puppeteer.browserfetcher.revisioninfo.md
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcher.revisionInfo
|
||||
---
|
||||
|
||||
# BrowserFetcher.revisionInfo() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class BrowserFetcher {
|
||||
revisionInfo(revision: string): BrowserFetcherRevisionInfo;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ------ | ----------------------------- |
|
||||
| revision | string | The revision to get info for. |
|
||||
|
||||
**Returns:**
|
||||
|
||||
[BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md)
|
||||
|
||||
The revision info for the given revision.
|
13
docs/api/puppeteer.browserfetcheroptions.host.md
Normal file
13
docs/api/puppeteer.browserfetcheroptions.host.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherOptions.host
|
||||
---
|
||||
|
||||
# BrowserFetcherOptions.host property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherOptions {
|
||||
host?: string;
|
||||
}
|
||||
```
|
20
docs/api/puppeteer.browserfetcheroptions.md
Normal file
20
docs/api/puppeteer.browserfetcheroptions.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherOptions
|
||||
---
|
||||
|
||||
# BrowserFetcherOptions interface
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export interface BrowserFetcherOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| ---------------------------------------------------------- | --------- | ----------------------------------- | ----------------- |
|
||||
| [host?](./puppeteer.browserfetcheroptions.host.md) | | string | <i>(Optional)</i> |
|
||||
| [path?](./puppeteer.browserfetcheroptions.path.md) | | string | <i>(Optional)</i> |
|
||||
| [platform?](./puppeteer.browserfetcheroptions.platform.md) | | [Platform](./puppeteer.platform.md) | <i>(Optional)</i> |
|
||||
| [product?](./puppeteer.browserfetcheroptions.product.md) | | string | <i>(Optional)</i> |
|
13
docs/api/puppeteer.browserfetcheroptions.path.md
Normal file
13
docs/api/puppeteer.browserfetcheroptions.path.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherOptions.path
|
||||
---
|
||||
|
||||
# BrowserFetcherOptions.path property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherOptions {
|
||||
path?: string;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.browserfetcheroptions.platform.md
Normal file
13
docs/api/puppeteer.browserfetcheroptions.platform.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherOptions.platform
|
||||
---
|
||||
|
||||
# BrowserFetcherOptions.platform property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherOptions {
|
||||
platform?: Platform;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.browserfetcheroptions.product.md
Normal file
13
docs/api/puppeteer.browserfetcheroptions.product.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherOptions.product
|
||||
---
|
||||
|
||||
# BrowserFetcherOptions.product property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherOptions {
|
||||
product?: string;
|
||||
}
|
||||
```
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherRevisionInfo.executablePath
|
||||
---
|
||||
|
||||
# BrowserFetcherRevisionInfo.executablePath property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherRevisionInfo {
|
||||
executablePath: string;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.browserfetcherrevisioninfo.folderpath.md
Normal file
13
docs/api/puppeteer.browserfetcherrevisioninfo.folderpath.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherRevisionInfo.folderPath
|
||||
---
|
||||
|
||||
# BrowserFetcherRevisionInfo.folderPath property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherRevisionInfo {
|
||||
folderPath: string;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.browserfetcherrevisioninfo.local.md
Normal file
13
docs/api/puppeteer.browserfetcherrevisioninfo.local.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherRevisionInfo.local
|
||||
---
|
||||
|
||||
# BrowserFetcherRevisionInfo.local property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherRevisionInfo {
|
||||
local: boolean;
|
||||
}
|
||||
```
|
22
docs/api/puppeteer.browserfetcherrevisioninfo.md
Normal file
22
docs/api/puppeteer.browserfetcherrevisioninfo.md
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherRevisionInfo
|
||||
---
|
||||
|
||||
# BrowserFetcherRevisionInfo interface
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export interface BrowserFetcherRevisionInfo
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| -------------------------------------------------------------------------- | --------- | ------- | ----------- |
|
||||
| [executablePath](./puppeteer.browserfetcherrevisioninfo.executablepath.md) | | string | |
|
||||
| [folderPath](./puppeteer.browserfetcherrevisioninfo.folderpath.md) | | string | |
|
||||
| [local](./puppeteer.browserfetcherrevisioninfo.local.md) | | boolean | |
|
||||
| [product](./puppeteer.browserfetcherrevisioninfo.product.md) | | string | |
|
||||
| [revision](./puppeteer.browserfetcherrevisioninfo.revision.md) | | string | |
|
||||
| [url](./puppeteer.browserfetcherrevisioninfo.url.md) | | string | |
|
13
docs/api/puppeteer.browserfetcherrevisioninfo.product.md
Normal file
13
docs/api/puppeteer.browserfetcherrevisioninfo.product.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherRevisionInfo.product
|
||||
---
|
||||
|
||||
# BrowserFetcherRevisionInfo.product property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherRevisionInfo {
|
||||
product: string;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.browserfetcherrevisioninfo.revision.md
Normal file
13
docs/api/puppeteer.browserfetcherrevisioninfo.revision.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherRevisionInfo.revision
|
||||
---
|
||||
|
||||
# BrowserFetcherRevisionInfo.revision property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherRevisionInfo {
|
||||
revision: string;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.browserfetcherrevisioninfo.url.md
Normal file
13
docs/api/puppeteer.browserfetcherrevisioninfo.url.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserFetcherRevisionInfo.url
|
||||
---
|
||||
|
||||
# BrowserFetcherRevisionInfo.url property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserFetcherRevisionInfo {
|
||||
url: string;
|
||||
}
|
||||
```
|
15
docs/api/puppeteer.browserlaunchargumentoptions.args.md
Normal file
15
docs/api/puppeteer.browserlaunchargumentoptions.args.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserLaunchArgumentOptions.args
|
||||
---
|
||||
|
||||
# BrowserLaunchArgumentOptions.args property
|
||||
|
||||
Additional command line arguments to pass to the browser instance.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserLaunchArgumentOptions {
|
||||
args?: string[];
|
||||
}
|
||||
```
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: BrowserLaunchArgumentOptions.debuggingPort
|
||||
---
|
||||
|
||||
# BrowserLaunchArgumentOptions.debuggingPort property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserLaunchArgumentOptions {
|
||||
debuggingPort?: number;
|
||||
}
|
||||
```
|
15
docs/api/puppeteer.browserlaunchargumentoptions.devtools.md
Normal file
15
docs/api/puppeteer.browserlaunchargumentoptions.devtools.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserLaunchArgumentOptions.devtools
|
||||
---
|
||||
|
||||
# BrowserLaunchArgumentOptions.devtools property
|
||||
|
||||
Whether to auto-open a DevTools panel for each tab. If this is set to `true`, then `headless` will be forced to `false`.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserLaunchArgumentOptions {
|
||||
devtools?: boolean;
|
||||
}
|
||||
```
|
15
docs/api/puppeteer.browserlaunchargumentoptions.headless.md
Normal file
15
docs/api/puppeteer.browserlaunchargumentoptions.headless.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserLaunchArgumentOptions.headless
|
||||
---
|
||||
|
||||
# BrowserLaunchArgumentOptions.headless property
|
||||
|
||||
Whether to run the browser in headless mode.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserLaunchArgumentOptions {
|
||||
headless?: boolean | 'chrome';
|
||||
}
|
||||
```
|
23
docs/api/puppeteer.browserlaunchargumentoptions.md
Normal file
23
docs/api/puppeteer.browserlaunchargumentoptions.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
sidebar_label: BrowserLaunchArgumentOptions
|
||||
---
|
||||
|
||||
# BrowserLaunchArgumentOptions interface
|
||||
|
||||
Launcher options that only apply to Chrome.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export interface BrowserLaunchArgumentOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --------------------------------------------------------------------------- | --------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [args?](./puppeteer.browserlaunchargumentoptions.args.md) | | string\[\] | <i>(Optional)</i> Additional command line arguments to pass to the browser instance. |
|
||||
| [debuggingPort?](./puppeteer.browserlaunchargumentoptions.debuggingport.md) | | number | <i>(Optional)</i> |
|
||||
| [devtools?](./puppeteer.browserlaunchargumentoptions.devtools.md) | | boolean | <i>(Optional)</i> Whether to auto-open a DevTools panel for each tab. If this is set to <code>true</code>, then <code>headless</code> will be forced to <code>false</code>. |
|
||||
| [headless?](./puppeteer.browserlaunchargumentoptions.headless.md) | | boolean \| 'chrome' | <i>(Optional)</i> Whether to run the browser in headless mode. |
|
||||
| [userDataDir?](./puppeteer.browserlaunchargumentoptions.userdatadir.md) | | string | <i>(Optional)</i> Path to a user data directory. [see the Chromium docs](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/user_data_dir.md) for more info. |
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: BrowserLaunchArgumentOptions.userDataDir
|
||||
---
|
||||
|
||||
# BrowserLaunchArgumentOptions.userDataDir property
|
||||
|
||||
Path to a user data directory. [see the Chromium docs](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/user_data_dir.md) for more info.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface BrowserLaunchArgumentOptions {
|
||||
userDataDir?: string;
|
||||
}
|
||||
```
|
17
docs/api/puppeteer.cdpsession.connection.md
Normal file
17
docs/api/puppeteer.cdpsession.connection.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
sidebar_label: CDPSession.connection
|
||||
---
|
||||
|
||||
# CDPSession.connection() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class CDPSession {
|
||||
connection(): Connection | undefined;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
[Connection](./puppeteer.connection.md) \| undefined
|
19
docs/api/puppeteer.cdpsession.detach.md
Normal file
19
docs/api/puppeteer.cdpsession.detach.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: CDPSession.detach
|
||||
---
|
||||
|
||||
# CDPSession.detach() method
|
||||
|
||||
Detaches the cdpSession from the target. Once detached, the cdpSession object won't emit any events and can't be used to send messages.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class CDPSession {
|
||||
detach(): Promise<void>;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<void>
|
19
docs/api/puppeteer.cdpsession.id.md
Normal file
19
docs/api/puppeteer.cdpsession.id.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebar_label: CDPSession.id
|
||||
---
|
||||
|
||||
# CDPSession.id() method
|
||||
|
||||
Returns the session's id.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class CDPSession {
|
||||
id(): string;
|
||||
}
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
string
|
47
docs/api/puppeteer.cdpsession.md
Normal file
47
docs/api/puppeteer.cdpsession.md
Normal file
@ -0,0 +1,47 @@
|
||||
---
|
||||
sidebar_label: CDPSession
|
||||
---
|
||||
|
||||
# CDPSession class
|
||||
|
||||
The `CDPSession` instances are used to talk raw Chrome Devtools Protocol.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare class CDPSession extends EventEmitter
|
||||
```
|
||||
|
||||
**Extends:** [EventEmitter](./puppeteer.eventemitter.md)
|
||||
|
||||
## Remarks
|
||||
|
||||
Protocol methods can be called with [CDPSession.send()](./puppeteer.cdpsession.send.md) method and protocol events can be subscribed to with `CDPSession.on` method.
|
||||
|
||||
Useful links: [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/) and [Getting Started with DevTools Protocol](https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md).
|
||||
|
||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `CDPSession` class.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const client = await page.target().createCDPSession();
|
||||
await client.send('Animation.enable');
|
||||
client.on('Animation.animationCreated', () =>
|
||||
console.log('Animation created!')
|
||||
);
|
||||
const response = await client.send('Animation.getPlaybackRate');
|
||||
console.log('playback rate is ' + response.playbackRate);
|
||||
await client.send('Animation.setPlaybackRate', {
|
||||
playbackRate: response.playbackRate / 2,
|
||||
});
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| --------------------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [connection()](./puppeteer.cdpsession.connection.md) | | |
|
||||
| [detach()](./puppeteer.cdpsession.detach.md) | | Detaches the cdpSession from the target. Once detached, the cdpSession object won't emit any events and can't be used to send messages. |
|
||||
| [id()](./puppeteer.cdpsession.id.md) | | Returns the session's id. |
|
||||
| [send(method, paramArgs)](./puppeteer.cdpsession.send.md) | | |
|
27
docs/api/puppeteer.cdpsession.send.md
Normal file
27
docs/api/puppeteer.cdpsession.send.md
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
sidebar_label: CDPSession.send
|
||||
---
|
||||
|
||||
# CDPSession.send() method
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
class CDPSession {
|
||||
send<T extends keyof ProtocolMapping.Commands>(
|
||||
method: T,
|
||||
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
|
||||
): Promise<ProtocolMapping.Commands[T]['returnType']>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | --------------------------------------------- | ----------- |
|
||||
| method | T | |
|
||||
| paramArgs | ProtocolMapping.Commands\[T\]\['paramsType'\] | |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<ProtocolMapping.Commands\[T\]\['returnType'\]>
|
17
docs/api/puppeteer.cdpsessiononmessageobject.error.md
Normal file
17
docs/api/puppeteer.cdpsessiononmessageobject.error.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
sidebar_label: CDPSessionOnMessageObject.error
|
||||
---
|
||||
|
||||
# CDPSessionOnMessageObject.error property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface CDPSessionOnMessageObject {
|
||||
error: {
|
||||
message: string;
|
||||
data: any;
|
||||
code: number;
|
||||
};
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.cdpsessiononmessageobject.id.md
Normal file
13
docs/api/puppeteer.cdpsessiononmessageobject.id.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: CDPSessionOnMessageObject.id
|
||||
---
|
||||
|
||||
# CDPSessionOnMessageObject.id property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface CDPSessionOnMessageObject {
|
||||
id?: number;
|
||||
}
|
||||
```
|
21
docs/api/puppeteer.cdpsessiononmessageobject.md
Normal file
21
docs/api/puppeteer.cdpsessiononmessageobject.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
sidebar_label: CDPSessionOnMessageObject
|
||||
---
|
||||
|
||||
# CDPSessionOnMessageObject interface
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export interface CDPSessionOnMessageObject
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| ---------------------------------------------------------- | --------- | --------------------------------------------- | ----------------- |
|
||||
| [error](./puppeteer.cdpsessiononmessageobject.error.md) | | { message: string; data: any; code: number; } | |
|
||||
| [id?](./puppeteer.cdpsessiononmessageobject.id.md) | | number | <i>(Optional)</i> |
|
||||
| [method](./puppeteer.cdpsessiononmessageobject.method.md) | | string | |
|
||||
| [params](./puppeteer.cdpsessiononmessageobject.params.md) | | Record<string, unknown> | |
|
||||
| [result?](./puppeteer.cdpsessiononmessageobject.result.md) | | any | <i>(Optional)</i> |
|
13
docs/api/puppeteer.cdpsessiononmessageobject.method.md
Normal file
13
docs/api/puppeteer.cdpsessiononmessageobject.method.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: CDPSessionOnMessageObject.method
|
||||
---
|
||||
|
||||
# CDPSessionOnMessageObject.method property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface CDPSessionOnMessageObject {
|
||||
method: string;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.cdpsessiononmessageobject.params.md
Normal file
13
docs/api/puppeteer.cdpsessiononmessageobject.params.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: CDPSessionOnMessageObject.params
|
||||
---
|
||||
|
||||
# CDPSessionOnMessageObject.params property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface CDPSessionOnMessageObject {
|
||||
params: Record<string, unknown>;
|
||||
}
|
||||
```
|
13
docs/api/puppeteer.cdpsessiononmessageobject.result.md
Normal file
13
docs/api/puppeteer.cdpsessiononmessageobject.result.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: CDPSessionOnMessageObject.result
|
||||
---
|
||||
|
||||
# CDPSessionOnMessageObject.result property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface CDPSessionOnMessageObject {
|
||||
result?: any;
|
||||
}
|
||||
```
|
15
docs/api/puppeteer.chromereleasechannel.md
Normal file
15
docs/api/puppeteer.chromereleasechannel.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_label: ChromeReleaseChannel
|
||||
---
|
||||
|
||||
# ChromeReleaseChannel type
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare type ChromeReleaseChannel =
|
||||
| 'chrome'
|
||||
| 'chrome-beta'
|
||||
| 'chrome-canary'
|
||||
| 'chrome-dev';
|
||||
```
|
17
docs/api/puppeteer.clearcustomqueryhandlers.md
Normal file
17
docs/api/puppeteer.clearcustomqueryhandlers.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
sidebar_label: clearCustomQueryHandlers
|
||||
---
|
||||
|
||||
# clearCustomQueryHandlers() function
|
||||
|
||||
Clears all registered handlers.
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare function clearCustomQueryHandlers(): void;
|
||||
```
|
||||
|
||||
**Returns:**
|
||||
|
||||
void
|
13
docs/api/puppeteer.clickoptions.button.md
Normal file
13
docs/api/puppeteer.clickoptions.button.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebar_label: ClickOptions.button
|
||||
---
|
||||
|
||||
# ClickOptions.button property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
interface ClickOptions {
|
||||
button?: MouseButton;
|
||||
}
|
||||
```
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user