mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1647439 - Sync Puppeteer to v5.0.0 r=remote-protocol-reviewers,jgraham
Differential Revision: https://phabricator.services.mozilla.com/D82072
This commit is contained in:
parent
9b12e5b93a
commit
24c63a2d0c
@ -96,6 +96,8 @@ module.exports = {
|
||||
"rules": {
|
||||
"no-unused-vars": 0,
|
||||
"@typescript-eslint/no-unused-vars": 2,
|
||||
"func-call-spacing": 0,
|
||||
"@typescript-eslint/func-call-spacing": 2,
|
||||
"semi": 0,
|
||||
"@typescript-eslint/semi": 2,
|
||||
"@typescript-eslint/no-empty-function": 0,
|
||||
|
@ -64,11 +64,19 @@ jobs:
|
||||
- CHROMIUM=true
|
||||
script:
|
||||
- npm run compare-protocol-d-ts
|
||||
- npm run test-install
|
||||
- npm run lint
|
||||
- npm run test-doclint
|
||||
- npm run ensure-new-docs-up-to-date
|
||||
|
||||
# This bot runs separately as it changes package.json to test puppeteer-core
|
||||
# and we don't want that leaking into other bots and causing issues.
|
||||
- node_js: "10.19.0"
|
||||
name: 'Test bundling and install of packages'
|
||||
env:
|
||||
- CHROMIUM=true
|
||||
script:
|
||||
- npm run test-install
|
||||
|
||||
# Runs unit tests on Linux + Firefox
|
||||
- node_js: "10.19.0"
|
||||
name: 'Unit tests: Linux/Firefox'
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<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/v4.0.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://github.com/puppeteer/puppeteer/blob/v5.0.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)
|
||||
|
||||
> 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.
|
||||
|
||||
@ -37,7 +37,7 @@ 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, or to download a different browser, see [Environment variables](https://github.com/puppeteer/puppeteer/blob/v4.0.0/docs/api.md#environment-variables).
|
||||
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, or to download a different browser, see [Environment variables](https://github.com/puppeteer/puppeteer/blob/v5.0.0/docs/api.md#environment-variables).
|
||||
|
||||
|
||||
### puppeteer-core
|
||||
@ -63,7 +63,7 @@ Note: Prior to v1.18.1, Puppeteer required at least Node v6.4.0. Versions from v
|
||||
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/v4.0.0/docs/api.md#).
|
||||
of `Browser`, open pages, and then manipulate them with [Puppeteer's API](https://github.com/puppeteer/puppeteer/blob/v5.0.0/docs/api.md#).
|
||||
|
||||
**Example** - navigating to https://example.com and saving a screenshot as *example.png*:
|
||||
|
||||
@ -88,7 +88,7 @@ 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/v4.0.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://github.com/puppeteer/puppeteer/blob/v5.0.0/docs/api.md#pagesetviewportviewport).
|
||||
|
||||
**Example** - create a PDF.
|
||||
|
||||
@ -113,7 +113,7 @@ Execute script on the command line
|
||||
node hn.js
|
||||
```
|
||||
|
||||
See [`Page.pdf()`](https://github.com/puppeteer/puppeteer/blob/v4.0.0/docs/api.md#pagepdfoptions) for more information about creating pdfs.
|
||||
See [`Page.pdf()`](https://github.com/puppeteer/puppeteer/blob/v5.0.0/docs/api.md#pagepdfoptions) for more information about creating pdfs.
|
||||
|
||||
**Example** - evaluate script in the context of the page
|
||||
|
||||
@ -148,7 +148,7 @@ Execute script on the command line
|
||||
node get-dimensions.js
|
||||
```
|
||||
|
||||
See [`Page.evaluate()`](https://github.com/puppeteer/puppeteer/blob/v4.0.0/docs/api.md#pageevaluatepagefunction-args) for more information on `evaluate` and related methods like `evaluateOnNewDocument` and `exposeFunction`.
|
||||
See [`Page.evaluate()`](https://github.com/puppeteer/puppeteer/blob/v5.0.0/docs/api.md#pageevaluatepagefunction-args) for more information on `evaluate` and related methods like `evaluateOnNewDocument` and `exposeFunction`.
|
||||
|
||||
<!-- [END getstarted] -->
|
||||
|
||||
@ -157,7 +157,7 @@ See [`Page.evaluate()`](https://github.com/puppeteer/puppeteer/blob/v4.0.0/docs/
|
||||
|
||||
**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/v4.0.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://github.com/puppeteer/puppeteer/blob/v5.0.0/docs/api.md#puppeteerlaunchoptions) when launching a browser:
|
||||
|
||||
```js
|
||||
const browser = await puppeteer.launch({headless: false}); // default is true
|
||||
@ -173,7 +173,7 @@ pass in the executable's path when creating a `Browser` instance:
|
||||
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/v4.0.0/docs/api.md#puppeteerlaunchoptions) for more information.
|
||||
You can also use Puppeteer with Firefox Nightly (experimental support). See [`Puppeteer.launch()`](https://github.com/puppeteer/puppeteer/blob/v5.0.0/docs/api.md#puppeteerlaunchoptions) 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/+/master/docs/chromium_browser_vs_google_chrome.md) describes some differences for Linux users.
|
||||
|
||||
@ -185,7 +185,7 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
|
||||
## Resources
|
||||
|
||||
- [API Documentation](https://github.com/puppeteer/puppeteer/blob/v4.0.0/docs/api.md)
|
||||
- [API Documentation](https://github.com/puppeteer/puppeteer/blob/v5.0.0/docs/api.md)
|
||||
- [Examples](https://github.com/puppeteer/puppeteer/tree/main/examples/)
|
||||
- [Community list of Puppeteer resources](https://github.com/transitive-bullshit/awesome-puppeteer)
|
||||
|
||||
@ -292,9 +292,25 @@ Puppeteer creates its own browser user profile which it **cleans up on every run
|
||||
|
||||
- debug your test inside chromium like a boss!
|
||||
|
||||
|
||||
<!-- [END debugging] -->
|
||||
|
||||
|
||||
<!-- [START typescript] -->
|
||||
## Usage with TypeScript
|
||||
|
||||
We have recently completed a migration to move the Puppeteer source code from JavaScript to TypeScript and we're currently working on shipping type definitions for TypeScript with Puppeteer's npm package.
|
||||
|
||||
Until this work is complete 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.
|
||||
@ -312,7 +328,7 @@ See [Contributing](https://github.com/puppeteer/puppeteer/blob/main/CONTRIBUTING
|
||||
|
||||
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/v4.0.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.
|
||||
From Puppeteer v2.1.0 onwards you can specify [`puppeteer.launch({product: 'firefox'})`](https://github.com/puppeteer/puppeteer/blob/v5.0.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).
|
||||
@ -364,12 +380,12 @@ npm install puppeteer-core@chrome-71
|
||||
|
||||
#### Q: Which Chromium version does Puppeteer use?
|
||||
|
||||
Look for `chromium_revision` in [package.json](https://github.com/puppeteer/puppeteer/blob/main/package.json). 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 `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.
|
||||
|
||||
|
||||
#### 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_revision` in [package.json](https://github.com/puppeteer/puppeteer/blob/main/package.json) is `latest` -- Puppeteer isn't tied to a particular Firefox version.
|
||||
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:
|
||||
|
||||
@ -408,7 +424,7 @@ await page.evaluate(() => {
|
||||
|
||||
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/v4.0.0/docs/api.md#puppeteerlaunchoptions). You should only use this configuration if you need an official release of Chrome that supports these media formats.)
|
||||
* 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/v5.0.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?
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/api-docs-entry.d.ts",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/cjs/api-docs-entry.d.ts",
|
||||
"bundledPackages": [ ],
|
||||
|
||||
"apiReport": {
|
||||
@ -27,6 +27,9 @@
|
||||
},
|
||||
|
||||
"extractorMessageReporting": {
|
||||
"ae-internal-missing-underscore": {
|
||||
"logLevel": "none"
|
||||
},
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
}
|
||||
|
29
remote/test/puppeteer/cjs-entry-core.js
Normal file
29
remote/test/puppeteer/cjs-entry-core.js
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* We use `export default puppeteer` in `src/index.ts` to expose the library But
|
||||
* TypeScript in CJS mode compiles that to `exports.default = `. This means that
|
||||
* our CJS Node users would have to use `require('puppeteer').default` which
|
||||
* isn't very nice.
|
||||
*
|
||||
* So instead we expose this file as our entry point. This requires the compiled
|
||||
* Puppeteer output and re-exports the `default` export via `module.exports.`
|
||||
* This means that we can publish to CJS and ESM whilst maintaining the expected
|
||||
* import behaviour for CJS and ESM users.
|
||||
*/
|
||||
const puppeteerExport = require('./lib/cjs/index-core');
|
||||
module.exports = puppeteerExport.default;
|
29
remote/test/puppeteer/cjs-entry.js
Normal file
29
remote/test/puppeteer/cjs-entry.js
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* We use `export default puppeteer` in `src/index.ts` to expose the library But
|
||||
* TypeScript in CJS mode compiles that to `exports.default = `. This means that
|
||||
* our CJS Node users would have to use `require('puppeteer').default` which
|
||||
* isn't very nice.
|
||||
*
|
||||
* So instead we expose this file as our entry point. This requires the compiled
|
||||
* Puppeteer output and re-exports the `default` export via `module.exports.`
|
||||
* This means that we can publish to CJS and ESM whilst maintaining the expected
|
||||
* import behaviour for CJS and ESM users.
|
||||
*/
|
||||
const puppeteerExport = require('./lib/cjs/index');
|
||||
module.exports = puppeteerExport.default;
|
@ -1,5 +1,5 @@
|
||||
|
||||
# Puppeteer API <!-- GEN:version -->Tip-Of-Tree<!-- GEN:stop-->
|
||||
# Puppeteer API <!-- GEN:version -->v5.0.0<!-- GEN:stop-->
|
||||
<!-- GEN:empty-if-release --><!-- GEN:stop -->
|
||||
|
||||
- Interactive Documentation: https://pptr.dev
|
||||
@ -170,6 +170,8 @@
|
||||
* [page.waitForSelector(selector[, options])](#pagewaitforselectorselector-options)
|
||||
* [page.waitForXPath(xpath[, options])](#pagewaitforxpathxpath-options)
|
||||
* [page.workers()](#pageworkers)
|
||||
* [GeolocationOptions](#geolocationoptions)
|
||||
* [WaitTimeoutOptions](#waittimeoutoptions)
|
||||
- [class: WebWorker](#class-webworker)
|
||||
* [webWorker.evaluate(pageFunction[, ...args])](#webworkerevaluatepagefunction-args)
|
||||
* [webWorker.evaluateHandle(pageFunction[, ...args])](#webworkerevaluatehandlepagefunction-args)
|
||||
@ -354,7 +356,7 @@ The Puppeteer API is hierarchical and mirrors the browser structure.
|
||||
|
||||
> **NOTE** On the following diagram, faded entities are not currently represented in Puppeteer.
|
||||
|
||||
![puppeteer overview](../docs/assets/overview.png)
|
||||
![puppeteer overview](https://user-images.githubusercontent.com/81942/86137523-ab2ba080-baed-11ea-9d4b-30eda784585a.png)
|
||||
|
||||
- [`Puppeteer`](#class-puppeteer) communicates with the browser using [DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/).
|
||||
- [`Browser`](#class-browser) instance can own multiple browser contexts.
|
||||
@ -1454,7 +1456,7 @@ Shortcut for [page.mainFrame().evaluate(pageFunction, ...args)](#frameevaluatepa
|
||||
#### page.evaluateHandle(pageFunction[, ...args])
|
||||
- `pageFunction` <[function]|[string]> Function to be evaluated in the page context
|
||||
- `...args` <...[Serializable]|[JSHandle]> Arguments to pass to `pageFunction`
|
||||
- returns: <[Promise]<[JSHandle]>> Promise which resolves to the return value of `pageFunction` as in-page object (JSHandle)
|
||||
- returns: <[Promise]<[JSHandle]|[ElementHandle]>> Promise which resolves to the return value of `pageFunction` as an in-page object.
|
||||
|
||||
The only difference between `page.evaluate` and `page.evaluateHandle` is that `page.evaluateHandle` returns in-page object (JSHandle).
|
||||
|
||||
@ -1473,6 +1475,14 @@ console.log(await resultHandle.jsonValue());
|
||||
await resultHandle.dispose();
|
||||
```
|
||||
|
||||
This function will return a [JSHandle] by default, however if your `pageFunction` returns an HTML element you will get back an `ElementHandle`:
|
||||
|
||||
```js
|
||||
const button = await page.evaluateHandle(() => document.querySelector('button'))
|
||||
// button is an ElementHandle, so you can call methods such as click:
|
||||
await button.click();
|
||||
```
|
||||
|
||||
Shortcut for [page.mainFrame().executionContext().evaluateHandle(pageFunction, ...args)](#executioncontextevaluatehandlepagefunction-args).
|
||||
|
||||
#### page.evaluateOnNewDocument(pageFunction[, ...args])
|
||||
@ -1900,10 +1910,7 @@ The extra HTTP headers will be sent with every request the page initiates.
|
||||
> **NOTE** page.setExtraHTTPHeaders does not guarantee the order of headers in the outgoing requests.
|
||||
|
||||
#### page.setGeolocation(options)
|
||||
- `options` <[Object]>
|
||||
- `latitude` <[number]> Latitude between -90 and 90.
|
||||
- `longitude` <[number]> Longitude between -180 and 180.
|
||||
- `accuracy` <[number]> Optional non-negative accuracy value.
|
||||
- `options` <[GeolocationOptions](####GeolocationOptions)>
|
||||
- returns: <[Promise]>
|
||||
|
||||
Sets the page's geolocation.
|
||||
@ -2077,8 +2084,7 @@ await page.waitFor(selector => !!document.querySelector(selector), {}, selector)
|
||||
Shortcut for [page.mainFrame().waitFor(selectorOrFunctionOrTimeout[, options[, ...args]])](#framewaitforselectororfunctionortimeout-options-args).
|
||||
|
||||
#### page.waitForFileChooser([options])
|
||||
- `options` <[Object]> Optional waiting parameters
|
||||
- `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
|
||||
- `options` <[WaitTimeoutOptions](####WaitTimeoutOptions)> Optional waiting parameters
|
||||
- returns: <[Promise]<[FileChooser]>> A promise that resolves after a page requests a file picker.
|
||||
|
||||
> **NOTE** In non-headless Chromium, this method results in the native file picker dialog **not showing up** for the user.
|
||||
@ -2263,6 +2269,15 @@ This method returns all of the dedicated [WebWorkers](https://developer.mozilla.
|
||||
|
||||
> **NOTE** This does not contain ServiceWorkers
|
||||
|
||||
#### GeolocationOptions
|
||||
- `latitude` <[number]> Latitude between -90 and 90.
|
||||
- `longitude` <[number]> Longitude between -180 and 180.
|
||||
- `accuracy` <[number]> Optional non-negative accuracy value.
|
||||
|
||||
#### WaitTimeoutOptions
|
||||
- `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
|
||||
|
||||
|
||||
### class: WebWorker
|
||||
|
||||
The WebWorker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
|
||||
@ -2291,12 +2306,14 @@ Shortcut for [(await worker.executionContext()).evaluate(pageFunction, ...args)]
|
||||
#### webWorker.evaluateHandle(pageFunction[, ...args])
|
||||
- `pageFunction` <[function]|[string]> Function to be evaluated in the page context
|
||||
- `...args` <...[Serializable]|[JSHandle]> Arguments to pass to `pageFunction`
|
||||
- returns: <[Promise]<[JSHandle]>> Promise which resolves to the return value of `pageFunction` as in-page object (JSHandle)
|
||||
- returns: <[Promise]<[JSHandle]|[ElementHandle]>> Promise which resolves to the return value of `pageFunction` as an in-page object.
|
||||
|
||||
The only difference between `worker.evaluate` and `worker.evaluateHandle` is that `worker.evaluateHandle` returns in-page object (JSHandle).
|
||||
|
||||
If the function passed to the `worker.evaluateHandle` returns a [Promise], then `worker.evaluateHandle` would wait for the promise to resolve and return its value.
|
||||
|
||||
If the function returns an element, the returned handle is an [ElementHandle].
|
||||
|
||||
Shortcut for [(await worker.executionContext()).evaluateHandle(pageFunction, ...args)](#executioncontextevaluatehandlepagefunction-args).
|
||||
|
||||
#### webWorker.executionContext()
|
||||
@ -2848,12 +2865,14 @@ await bodyHandle.dispose();
|
||||
#### frame.evaluateHandle(pageFunction[, ...args])
|
||||
- `pageFunction` <[function]|[string]> Function to be evaluated in the page context
|
||||
- `...args` <...[Serializable]|[JSHandle]> Arguments to pass to `pageFunction`
|
||||
- returns: <[Promise]<[JSHandle]>> Promise which resolves to the return value of `pageFunction` as in-page object (JSHandle)
|
||||
- returns: <[Promise]<[JSHandle]|[ElementHandle]>> Promise which resolves to the return value of `pageFunction` as an in-page object.
|
||||
|
||||
The only difference between `frame.evaluate` and `frame.evaluateHandle` is that `frame.evaluateHandle` returns in-page object (JSHandle).
|
||||
|
||||
If the function, passed to the `frame.evaluateHandle`, returns a [Promise], then `frame.evaluateHandle` would wait for the promise to resolve and return its value.
|
||||
|
||||
If the function returns an element, the returned handle is an [ElementHandle].
|
||||
|
||||
```js
|
||||
const aWindowHandle = await frame.evaluateHandle(() => Promise.resolve(window));
|
||||
aWindowHandle; // Handle for the window object.
|
||||
@ -3177,10 +3196,12 @@ console.log(result); // prints '3'.
|
||||
#### executionContext.evaluateHandle(pageFunction[, ...args])
|
||||
- `pageFunction` <[function]|[string]> Function to be evaluated in the `executionContext`
|
||||
- `...args` <...[Serializable]|[JSHandle]> Arguments to pass to `pageFunction`
|
||||
- returns: <[Promise]<[JSHandle]>> Promise which resolves to the return value of `pageFunction` as in-page object (JSHandle)
|
||||
- returns: <[Promise]<[JSHandle]|[ElementHandle]>> Promise which resolves to the return value of `pageFunction` as an in-page object.
|
||||
|
||||
The only difference between `executionContext.evaluate` and `executionContext.evaluateHandle` is that `executionContext.evaluateHandle` returns in-page object (JSHandle).
|
||||
|
||||
If the function returns an element, the returned handle is an [ElementHandle].
|
||||
|
||||
If the function passed to the `executionContext.evaluateHandle` returns a [Promise], then `executionContext.evaluateHandle` would wait for the promise to resolve and return its value.
|
||||
|
||||
```js
|
||||
@ -3270,12 +3291,14 @@ expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10');
|
||||
#### jsHandle.evaluateHandle(pageFunction[, ...args])
|
||||
- `pageFunction` <[function]|[string]> Function to be evaluated
|
||||
- `...args` <...[Serializable]|[JSHandle]> Arguments to pass to `pageFunction`
|
||||
- returns: <[Promise]<[JSHandle]>> Promise which resolves to the return value of `pageFunction` as in-page object (JSHandle)
|
||||
- returns: <[Promise]<[JSHandle]|[ElementHandle]>> Promise which resolves to the return value of `pageFunction` as an in-page object.
|
||||
|
||||
This method passes this handle as the first argument to `pageFunction`.
|
||||
|
||||
The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `executionContext.evaluateHandle` returns in-page object (JSHandle).
|
||||
|
||||
If the function returns an element, the returned handle is an [ElementHandle].
|
||||
|
||||
If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait for the promise to resolve and return its value.
|
||||
|
||||
See [Page.evaluateHandle](#pageevaluatehandlepagefunction-args) for more details.
|
||||
@ -3459,12 +3482,14 @@ expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10');
|
||||
#### elementHandle.evaluateHandle(pageFunction[, ...args])
|
||||
- `pageFunction` <[function]|[string]> Function to be evaluated
|
||||
- `...args` <...[Serializable]|[JSHandle]> Arguments to pass to `pageFunction`
|
||||
- returns: <[Promise]<[JSHandle]>> Promise which resolves to the return value of `pageFunction` as in-page object (JSHandle)
|
||||
- returns: <[Promise]<[JSHandle]|[ElementHandle]>> Promise which resolves to the return value of `pageFunction` as an in-page object.
|
||||
|
||||
This method passes this handle as the first argument to `pageFunction`.
|
||||
|
||||
The only difference between `evaluateHandle.evaluate` and `evaluateHandle.evaluateHandle` is that `executionContext.evaluateHandle` returns in-page object (JSHandle).
|
||||
|
||||
If the function returns an element, the returned handle is an [ElementHandle].
|
||||
|
||||
If the function passed to the `evaluateHandle.evaluateHandle` returns a [Promise], then `evaluateHandle.evaluateHandle` would wait for the promise to resolve and return its value.
|
||||
|
||||
See [Page.evaluateHandle](#pageevaluatehandlepagefunction-args) for more details.
|
||||
@ -4050,8 +4075,8 @@ This method is identical to `off` and maintained for compatibility with Node's E
|
||||
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object"
|
||||
[Page]: #class-page "Page"
|
||||
[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise"
|
||||
[HTTPRequest]: #class-request "HTTPRequest"
|
||||
[HTTPResponse]: #class-response "HTTPRHTTPesponse"
|
||||
[HTTPRequest]: #class-httprequest "HTTPRequest"
|
||||
[HTTPResponse]: #class-httpresponse "HTTPResponse"
|
||||
[SecurityDetails]: #class-securitydetails "SecurityDetails"
|
||||
[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"
|
||||
[Target]: #class-target "Target"
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
## Chrome headless doesn't launch on Windows
|
||||
|
||||
Some [chrome policies](https://support.google.com/chrome/a/answer/7532015?hl=en) might enforce running Chrome/Chromium
|
||||
Some [chrome policies](https://support.google.com/chrome/a/answer/7532015) might enforce running Chrome/Chromium
|
||||
with certain extensions.
|
||||
|
||||
Puppeteer passes `--disable-extensions` flag by default and will fail to launch when such policies are active.
|
||||
|
@ -25,221 +25,62 @@
|
||||
*/
|
||||
|
||||
const compileTypeScriptIfRequired = require('./typescript-if-required');
|
||||
const os = require('os');
|
||||
|
||||
const firefoxVersions =
|
||||
'https://product-details.mozilla.org/1.0/firefox_versions.json';
|
||||
const supportedProducts = {
|
||||
chrome: 'Chromium',
|
||||
firefox: 'Firefox Nightly',
|
||||
};
|
||||
|
||||
async function download() {
|
||||
await compileTypeScriptIfRequired();
|
||||
// need to ensure TS is compiled before loading the installer
|
||||
const { downloadBrowser, logPolitely } = require('./lib/cjs/install');
|
||||
|
||||
const downloadHost =
|
||||
process.env.PUPPETEER_DOWNLOAD_HOST ||
|
||||
process.env.npm_config_puppeteer_download_host ||
|
||||
process.env.npm_package_config_puppeteer_download_host;
|
||||
const puppeteer = require('.');
|
||||
const product =
|
||||
process.env.PUPPETEER_PRODUCT ||
|
||||
process.env.npm_config_puppeteer_product ||
|
||||
process.env.npm_package_config_puppeteer_product ||
|
||||
'chrome';
|
||||
const browserFetcher = puppeteer.createBrowserFetcher({
|
||||
product,
|
||||
host: downloadHost,
|
||||
});
|
||||
const revision = await getRevision();
|
||||
await fetchBinary(revision);
|
||||
|
||||
function getRevision() {
|
||||
if (product === 'chrome') {
|
||||
return (
|
||||
process.env.PUPPETEER_CHROMIUM_REVISION ||
|
||||
process.env.npm_config_puppeteer_chromium_revision ||
|
||||
process.env.npm_package_config_puppeteer_chromium_revision ||
|
||||
require('./package.json').puppeteer.chromium_revision
|
||||
);
|
||||
} else if (product === 'firefox') {
|
||||
puppeteer._preferredRevision = require('./package.json').puppeteer.firefox_revision;
|
||||
return getFirefoxNightlyVersion(browserFetcher.host()).catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
} else {
|
||||
throw new Error(`Unsupported product ${product}`);
|
||||
}
|
||||
if (process.env.PUPPETEER_SKIP_DOWNLOAD) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" environment variable was found.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
process.env.NPM_CONFIG_PUPPETEER_SKIP_DOWNLOAD ||
|
||||
process.env.npm_config_puppeteer_skip_download
|
||||
) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" was set in npm config.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
process.env.NPM_PACKAGE_CONFIG_PUPPETEER_SKIP_DOWNLOAD ||
|
||||
process.env.npm_package_config_puppeteer_skip_download
|
||||
) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" was set in project config.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
process.env.NPM_CONFIG_PUPPETEER_SKIP_CHROMIUM_DOWNLOAD ||
|
||||
process.env.npm_config_puppeteer_skip_chromium_download
|
||||
) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" was set in npm config.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
process.env.NPM_PACKAGE_CONFIG_PUPPETEER_SKIP_CHROMIUM_DOWNLOAD ||
|
||||
process.env.npm_package_config_puppeteer_skip_chromium_download
|
||||
) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" was set in project config.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
function fetchBinary(revision) {
|
||||
const revisionInfo = browserFetcher.revisionInfo(revision);
|
||||
|
||||
// Do nothing if the revision is already downloaded.
|
||||
if (revisionInfo.local) {
|
||||
logPolitely(
|
||||
`${supportedProducts[product]} is already in ${revisionInfo.folderPath}; skipping download.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Override current environment proxy settings with npm configuration, if any.
|
||||
const NPM_HTTPS_PROXY =
|
||||
process.env.npm_config_https_proxy || process.env.npm_config_proxy;
|
||||
const NPM_HTTP_PROXY =
|
||||
process.env.npm_config_http_proxy || process.env.npm_config_proxy;
|
||||
const NPM_NO_PROXY = process.env.npm_config_no_proxy;
|
||||
|
||||
if (NPM_HTTPS_PROXY) process.env.HTTPS_PROXY = NPM_HTTPS_PROXY;
|
||||
if (NPM_HTTP_PROXY) process.env.HTTP_PROXY = NPM_HTTP_PROXY;
|
||||
if (NPM_NO_PROXY) process.env.NO_PROXY = NPM_NO_PROXY;
|
||||
|
||||
/**
|
||||
* @param {!Array<string>}
|
||||
* @returns {!Promise}
|
||||
*/
|
||||
function onSuccess(localRevisions) {
|
||||
if (os.arch() !== 'arm64') {
|
||||
logPolitely(
|
||||
`${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}`
|
||||
);
|
||||
}
|
||||
localRevisions = localRevisions.filter(
|
||||
(revision) => revision !== revisionInfo.revision
|
||||
);
|
||||
const cleanupOldVersions = localRevisions.map((revision) =>
|
||||
browserFetcher.remove(revision)
|
||||
);
|
||||
Promise.all([...cleanupOldVersions]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Error} error
|
||||
*/
|
||||
function onError(error) {
|
||||
console.error(
|
||||
`ERROR: Failed to set up ${supportedProducts[product]} r${revision}! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.`
|
||||
);
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let progressBar = null;
|
||||
let lastDownloadedBytes = 0;
|
||||
function onProgress(downloadedBytes, totalBytes) {
|
||||
if (!progressBar) {
|
||||
const ProgressBar = require('progress');
|
||||
progressBar = new ProgressBar(
|
||||
`Downloading ${
|
||||
supportedProducts[product]
|
||||
} r${revision} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `,
|
||||
{
|
||||
complete: '=',
|
||||
incomplete: ' ',
|
||||
width: 20,
|
||||
total: totalBytes,
|
||||
}
|
||||
);
|
||||
}
|
||||
const delta = downloadedBytes - lastDownloadedBytes;
|
||||
lastDownloadedBytes = downloadedBytes;
|
||||
progressBar.tick(delta);
|
||||
}
|
||||
|
||||
return browserFetcher
|
||||
.download(revisionInfo.revision, onProgress)
|
||||
.then(() => browserFetcher.localRevisions())
|
||||
.then(onSuccess)
|
||||
.catch(onError);
|
||||
}
|
||||
|
||||
function toMegabytes(bytes) {
|
||||
const mb = bytes / 1024 / 1024;
|
||||
return `${Math.round(mb * 10) / 10} Mb`;
|
||||
}
|
||||
|
||||
function getFirefoxNightlyVersion(host) {
|
||||
const https = require('https');
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
let data = '';
|
||||
logPolitely(`Requesting latest Firefox Nightly version from ${host}`);
|
||||
https
|
||||
.get(firefoxVersions, (r) => {
|
||||
if (r.statusCode >= 400)
|
||||
return reject(new Error(`Got status code ${r.statusCode}`));
|
||||
r.on('data', (chunk) => {
|
||||
data += chunk;
|
||||
});
|
||||
r.on('end', () => {
|
||||
try {
|
||||
const versions = JSON.parse(data);
|
||||
return resolve(versions.FIREFOX_NIGHTLY);
|
||||
} catch {
|
||||
return reject(new Error('Firefox version not found'));
|
||||
}
|
||||
});
|
||||
})
|
||||
.on('error', reject);
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
||||
function logPolitely(toBeLogged) {
|
||||
const logLevel = process.env.npm_config_loglevel;
|
||||
const logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1;
|
||||
|
||||
if (!logLevelDisplay) console.log(toBeLogged);
|
||||
}
|
||||
|
||||
if (process.env.PUPPETEER_SKIP_DOWNLOAD) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" environment variable was found.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
process.env.NPM_CONFIG_PUPPETEER_SKIP_DOWNLOAD ||
|
||||
process.env.npm_config_puppeteer_skip_download
|
||||
) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" was set in npm config.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
process.env.NPM_PACKAGE_CONFIG_PUPPETEER_SKIP_DOWNLOAD ||
|
||||
process.env.npm_package_config_puppeteer_skip_download
|
||||
) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" was set in project config.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
process.env.NPM_CONFIG_PUPPETEER_SKIP_CHROMIUM_DOWNLOAD ||
|
||||
process.env.npm_config_puppeteer_skip_chromium_download
|
||||
) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" was set in npm config.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
process.env.NPM_PACKAGE_CONFIG_PUPPETEER_SKIP_CHROMIUM_DOWNLOAD ||
|
||||
process.env.npm_package_config_puppeteer_skip_chromium_download
|
||||
) {
|
||||
logPolitely(
|
||||
'**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" was set in project config.'
|
||||
);
|
||||
return;
|
||||
downloadBrowser();
|
||||
}
|
||||
|
||||
download();
|
||||
|
@ -5,6 +5,6 @@ origin:
|
||||
description: Headless Chrome Node API
|
||||
license: Apache-2.0
|
||||
name: puppeteer
|
||||
release: f7f3f2803d628c25c3f8c0a4480d06732335eb79
|
||||
release: 6d06adea10572d2667a9d1c5a48193903860341b
|
||||
url: https://github.com/mjzffr/puppeteer.git
|
||||
schema: 1
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
## BoxModel interface
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
|
@ -21,7 +21,7 @@ download(revision: string, progressCallback?: (x: number, y: number) => void): P
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<BrowserFetcherRevisionInfo>
|
||||
Promise<[BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md)<!-- -->>
|
||||
|
||||
A promise with revision information when the revision is downloaded and extracted.
|
||||
|
||||
|
@ -11,7 +11,7 @@ platform(): Platform;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
Platform
|
||||
[Platform](./puppeteer.platform.md)
|
||||
|
||||
Returns the current `Platform`<!-- -->.
|
||||
|
||||
|
@ -11,7 +11,7 @@ product(): Product;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
Product
|
||||
[Product](./puppeteer.product.md)
|
||||
|
||||
Returns the current `Product`<!-- -->.
|
||||
|
||||
|
@ -18,7 +18,7 @@ revisionInfo(revision: string): BrowserFetcherRevisionInfo;
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
BrowserFetcherRevisionInfo
|
||||
[BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md)
|
||||
|
||||
The revision info for the given revision.
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
## BrowserFetcherOptions interface
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
@ -16,6 +17,6 @@ export interface BrowserFetcherOptions
|
||||
| --- | --- | --- |
|
||||
| [host](./puppeteer.browserfetcheroptions.host.md) | string | |
|
||||
| [path](./puppeteer.browserfetcheroptions.path.md) | string | |
|
||||
| [platform](./puppeteer.browserfetcheroptions.platform.md) | Platform | |
|
||||
| [platform](./puppeteer.browserfetcheroptions.platform.md) | [Platform](./puppeteer.platform.md) | |
|
||||
| [product](./puppeteer.browserfetcheroptions.product.md) | string | |
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [executablePath](./puppeteer.browserfetcherrevisioninfo.executablepath.md)
|
||||
|
||||
## BrowserFetcherRevisionInfo.executablePath property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
executablePath: string;
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [folderPath](./puppeteer.browserfetcherrevisioninfo.folderpath.md)
|
||||
|
||||
## BrowserFetcherRevisionInfo.folderPath property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
folderPath: string;
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [local](./puppeteer.browserfetcherrevisioninfo.local.md)
|
||||
|
||||
## BrowserFetcherRevisionInfo.local property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
local: boolean;
|
||||
```
|
@ -0,0 +1,24 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md)
|
||||
|
||||
## BrowserFetcherRevisionInfo interface
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface BrowserFetcherRevisionInfo
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | 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 | |
|
||||
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [product](./puppeteer.browserfetcherrevisioninfo.product.md)
|
||||
|
||||
## BrowserFetcherRevisionInfo.product property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
product: string;
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [revision](./puppeteer.browserfetcherrevisioninfo.revision.md)
|
||||
|
||||
## BrowserFetcherRevisionInfo.revision property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
revision: string;
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [url](./puppeteer.browserfetcherrevisioninfo.url.md)
|
||||
|
||||
## BrowserFetcherRevisionInfo.url property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
url: string;
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserOptions](./puppeteer.browseroptions.md) > [defaultViewport](./puppeteer.browseroptions.defaultviewport.md)
|
||||
|
||||
## BrowserOptions.defaultViewport property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
defaultViewport?: Viewport;
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserOptions](./puppeteer.browseroptions.md) > [ignoreHTTPSErrors](./puppeteer.browseroptions.ignorehttpserrors.md)
|
||||
|
||||
## BrowserOptions.ignoreHTTPSErrors property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
ignoreHTTPSErrors?: boolean;
|
||||
```
|
22
remote/test/puppeteer/new-docs/puppeteer.browseroptions.md
Normal file
22
remote/test/puppeteer/new-docs/puppeteer.browseroptions.md
Normal file
@ -0,0 +1,22 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserOptions](./puppeteer.browseroptions.md)
|
||||
|
||||
## BrowserOptions interface
|
||||
|
||||
Generic browser options that can be passed when launching any browser.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface BrowserOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [defaultViewport](./puppeteer.browseroptions.defaultviewport.md) | Viewport | |
|
||||
| [ignoreHTTPSErrors](./puppeteer.browseroptions.ignorehttpserrors.md) | boolean | |
|
||||
| [slowMo](./puppeteer.browseroptions.slowmo.md) | number | |
|
||||
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserOptions](./puppeteer.browseroptions.md) > [slowMo](./puppeteer.browseroptions.slowmo.md)
|
||||
|
||||
## BrowserOptions.slowMo property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
slowMo?: number;
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md) > [args](./puppeteer.chromeargoptions.args.md)
|
||||
|
||||
## ChromeArgOptions.args property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
args?: string[];
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md) > [devtools](./puppeteer.chromeargoptions.devtools.md)
|
||||
|
||||
## ChromeArgOptions.devtools property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
devtools?: boolean;
|
||||
```
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md) > [headless](./puppeteer.chromeargoptions.headless.md)
|
||||
|
||||
## ChromeArgOptions.headless property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
headless?: boolean;
|
||||
```
|
23
remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.md
Normal file
23
remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.md
Normal file
@ -0,0 +1,23 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md)
|
||||
|
||||
## ChromeArgOptions interface
|
||||
|
||||
Launcher options that only apply to Chrome.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface ChromeArgOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [args](./puppeteer.chromeargoptions.args.md) | string\[\] | |
|
||||
| [devtools](./puppeteer.chromeargoptions.devtools.md) | boolean | |
|
||||
| [headless](./puppeteer.chromeargoptions.headless.md) | boolean | |
|
||||
| [userDataDir](./puppeteer.chromeargoptions.userdatadir.md) | string | |
|
||||
|
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md) > [userDataDir](./puppeteer.chromeargoptions.userdatadir.md)
|
||||
|
||||
## ChromeArgOptions.userDataDir property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
userDataDir?: string;
|
||||
```
|
@ -1,11 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [Coverage](./puppeteer.coverage.md) > [\_jsCoverage](./puppeteer.coverage._jscoverage.md)
|
||||
|
||||
## Coverage.\_jsCoverage property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_jsCoverage: JSCoverage;
|
||||
```
|
@ -4,25 +4,53 @@
|
||||
|
||||
## Coverage class
|
||||
|
||||
The Coverage class provides methods to gathers information about parts of JavaScript and CSS that were used by the page.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class Coverage
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
To output coverage in a form consumable by [Istanbul](https://github.com/istanbuljs)<!-- -->, see [puppeteer-to-istanbul](https://github.com/istanbuljs/puppeteer-to-istanbul)<!-- -->.
|
||||
|
||||
## Example
|
||||
|
||||
An example of using JavaScript and CSS coverage to get percentage of initially executed code:
|
||||
|
||||
```js
|
||||
// Enable both JavaScript and CSS coverage
|
||||
await Promise.all([
|
||||
page.coverage.startJSCoverage(),
|
||||
page.coverage.startCSSCoverage()
|
||||
]);
|
||||
// Navigate to page
|
||||
await page.goto('https://example.com');
|
||||
// Disable both JavaScript and CSS coverage
|
||||
const [jsCoverage, cssCoverage] = await Promise.all([
|
||||
page.coverage.stopJSCoverage(),
|
||||
page.coverage.stopCSSCoverage(),
|
||||
]);
|
||||
let totalBytes = 0;
|
||||
let usedBytes = 0;
|
||||
const coverage = [...jsCoverage, ...cssCoverage];
|
||||
for (const entry of coverage) {
|
||||
totalBytes += entry.text.length;
|
||||
for (const range of entry.ranges)
|
||||
usedBytes += range.end - range.start - 1;
|
||||
}
|
||||
console.log(`Bytes used: ${usedBytes / totalBytes * 100}%`);
|
||||
|
||||
```
|
||||
|
||||
## Constructors
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(client)](./puppeteer.coverage._constructor_.md) | | Constructs a new instance of the <code>Coverage</code> class |
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [\_cssCoverage](./puppeteer.coverage._csscoverage.md) | | CSSCoverage | |
|
||||
| [\_jsCoverage](./puppeteer.coverage._jscoverage.md) | | JSCoverage | |
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
|
@ -7,18 +7,18 @@
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
startCSSCoverage(options?: {
|
||||
resetOnNavigation?: boolean;
|
||||
}): Promise<void>;
|
||||
startCSSCoverage(options?: CSSCoverageOptions): Promise<void>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| options | { resetOnNavigation?: boolean; } | |
|
||||
| options | [CSSCoverageOptions](./puppeteer.csscoverageoptions.md) | defaults to <code>{ resetOnNavigation : true }</code> |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<void>
|
||||
|
||||
Promise that resolves when coverage is started.
|
||||
|
||||
|
@ -7,19 +7,22 @@
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
startJSCoverage(options?: {
|
||||
resetOnNavigation?: boolean;
|
||||
reportAnonymousScripts?: boolean;
|
||||
}): Promise<void>;
|
||||
startJSCoverage(options?: JSCoverageOptions): Promise<void>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| options | { resetOnNavigation?: boolean; reportAnonymousScripts?: boolean; } | |
|
||||
| options | [JSCoverageOptions](./puppeteer.jscoverageoptions.md) | defaults to <code>{ resetOnNavigation : true, reportAnonymousScripts : false }</code> |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<void>
|
||||
|
||||
Promise that resolves when coverage is started.
|
||||
|
||||
## Remarks
|
||||
|
||||
Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created on the page using `eval` or `new Function`<!-- -->. If `reportAnonymousScripts` is set to `true`<!-- -->, anonymous scripts will have `__puppeteer_evaluation_script__` as their URL.
|
||||
|
||||
|
@ -11,5 +11,11 @@ stopCSSCoverage(): Promise<CoverageEntry[]>;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<CoverageEntry\[\]>
|
||||
Promise<[CoverageEntry](./puppeteer.coverageentry.md)<!-- -->\[\]>
|
||||
|
||||
Promise that resolves to the array of coverage reports for all stylesheets.
|
||||
|
||||
## Remarks
|
||||
|
||||
CSS Coverage doesn't include dynamically injected style tags without sourceURLs.
|
||||
|
||||
|
@ -11,5 +11,11 @@ stopJSCoverage(): Promise<CoverageEntry[]>;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<CoverageEntry\[\]>
|
||||
Promise<[CoverageEntry](./puppeteer.coverageentry.md)<!-- -->\[\]>
|
||||
|
||||
Promise that resolves to the array of coverage reports for all scripts.
|
||||
|
||||
## Remarks
|
||||
|
||||
JavaScript Coverage doesn't include anonymous scripts by default. However, scripts with sourceURLs are reported.
|
||||
|
||||
|
22
remote/test/puppeteer/new-docs/puppeteer.coverageentry.md
Normal file
22
remote/test/puppeteer/new-docs/puppeteer.coverageentry.md
Normal file
@ -0,0 +1,22 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [CoverageEntry](./puppeteer.coverageentry.md)
|
||||
|
||||
## CoverageEntry interface
|
||||
|
||||
The CoverageEntry class represents one entry of the coverage report.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface CoverageEntry
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [ranges](./puppeteer.coverageentry.ranges.md) | Array<{ start: number; end: number; }> | The covered range as start and end positions. |
|
||||
| [text](./puppeteer.coverageentry.text.md) | string | The content of the style sheet or script. |
|
||||
| [url](./puppeteer.coverageentry.url.md) | string | The URL of the style sheet or script. |
|
||||
|
@ -0,0 +1,16 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [CoverageEntry](./puppeteer.coverageentry.md) > [ranges](./puppeteer.coverageentry.ranges.md)
|
||||
|
||||
## CoverageEntry.ranges property
|
||||
|
||||
The covered range as start and end positions.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
ranges: Array<{
|
||||
start: number;
|
||||
end: number;
|
||||
}>;
|
||||
```
|
@ -0,0 +1,13 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [CoverageEntry](./puppeteer.coverageentry.md) > [text](./puppeteer.coverageentry.text.md)
|
||||
|
||||
## CoverageEntry.text property
|
||||
|
||||
The content of the style sheet or script.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
text: string;
|
||||
```
|
@ -1,11 +1,13 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [Coverage](./puppeteer.coverage.md) > [\_cssCoverage](./puppeteer.coverage._csscoverage.md)
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [CoverageEntry](./puppeteer.coverageentry.md) > [url](./puppeteer.coverageentry.url.md)
|
||||
|
||||
## Coverage.\_cssCoverage property
|
||||
## CoverageEntry.url property
|
||||
|
||||
The URL of the style sheet or script.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_cssCoverage: CSSCoverage;
|
||||
url: string;
|
||||
```
|
@ -0,0 +1,20 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [CSSCoverageOptions](./puppeteer.csscoverageoptions.md)
|
||||
|
||||
## CSSCoverageOptions interface
|
||||
|
||||
Set of configurable options for CSS coverage.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface CSSCoverageOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [resetOnNavigation](./puppeteer.csscoverageoptions.resetonnavigation.md) | boolean | Whether to reset coverage on every navigation. |
|
||||
|
@ -0,0 +1,13 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [CSSCoverageOptions](./puppeteer.csscoverageoptions.md) > [resetOnNavigation](./puppeteer.csscoverageoptions.resetonnavigation.md)
|
||||
|
||||
## CSSCoverageOptions.resetOnNavigation property
|
||||
|
||||
Whether to reset coverage on every navigation.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
resetOnNavigation?: boolean;
|
||||
```
|
11
remote/test/puppeteer/new-docs/puppeteer.devicesmap.md
Normal file
11
remote/test/puppeteer/new-docs/puppeteer.devicesmap.md
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [devicesMap](./puppeteer.devicesmap.md)
|
||||
|
||||
## devicesMap variable
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
devicesMap: DevicesMap
|
||||
```
|
@ -4,7 +4,7 @@
|
||||
|
||||
## ElementHandle.$() method
|
||||
|
||||
The method runs `element.querySelector` within the page. If no element matches the selector, the return value resolves to `null`<!-- -->.
|
||||
Runs `element.querySelector` within the page. If no element matches the selector, the return value resolves to `null`<!-- -->.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
## ElementHandle.$$() method
|
||||
|
||||
The method runs `element.querySelectorAll` within the page. If no elements match the selector, the return value resolves to `[]`<!-- -->.
|
||||
Runs `element.querySelectorAll` within the page. If no elements match the selector, the return value resolves to `[]`<!-- -->.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
|
@ -11,7 +11,7 @@ If `pageFunction` returns a Promise, then `frame.$$eval` would wait for the prom
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
$$eval<ReturnType extends any>(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise<ReturnType>;
|
||||
$$eval<ReturnType extends any>(selector: string, pageFunction: EvaluateFn | string, ...args: SerializableOrJSHandle[]): Promise<ReturnType>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
@ -19,8 +19,8 @@ $$eval<ReturnType extends any>(selector: string, pageFunction: Function | string
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| selector | string | |
|
||||
| pageFunction | Function \| string | |
|
||||
| args | unknown\[\] | |
|
||||
| pageFunction | [EvaluateFn](./puppeteer.evaluatefn.md) \| string | |
|
||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
@ -11,7 +11,7 @@ If `pageFunction` returns a Promise, then `frame.$eval` would wait for the promi
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
$eval<ReturnType extends any>(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise<ReturnType>;
|
||||
$eval<ReturnType>(selector: string, pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise<ReturnType>, ...args: SerializableOrJSHandle[]): Promise<WrapElementHandle<ReturnType>>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
@ -19,12 +19,12 @@ $eval<ReturnType extends any>(selector: string, pageFunction: Function | string,
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| selector | string | |
|
||||
| pageFunction | Function \| string | |
|
||||
| args | unknown\[\] | |
|
||||
| pageFunction | (element: Element, ...args: unknown\[\]) => ReturnType \| Promise<ReturnType> | |
|
||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<ReturnType>
|
||||
Promise<[WrapElementHandle](./puppeteer.wrapelementhandle.md)<!-- --><ReturnType>>
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -7,9 +7,9 @@
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
asElement(): ElementHandle | null;
|
||||
asElement(): ElementHandle<ElementType> | null;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
[ElementHandle](./puppeteer.elementhandle.md) \| null
|
||||
[ElementHandle](./puppeteer.elementhandle.md)<!-- --><ElementType> \| null
|
||||
|
||||
|
@ -9,7 +9,7 @@ ElementHandle represents an in-page DOM element.
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class ElementHandle extends JSHandle
|
||||
export declare class ElementHandle<ElementType extends Element = Element> extends JSHandle
|
||||
```
|
||||
<b>Extends:</b> [JSHandle](./puppeteer.jshandle.md)
|
||||
|
||||
@ -30,18 +30,20 @@ const puppeteer = require('puppeteer');
|
||||
})();
|
||||
|
||||
```
|
||||
ElementHandle prevents DOM element from garbage collection unless the handle is [disposed](./puppeteer.jshandle.dispose.md)<!-- -->. ElementHandles are auto-disposed when their origin frame gets navigated.
|
||||
ElementHandle prevents the DOM element from being garbage-collected unless the handle is [disposed](./puppeteer.jshandle.dispose.md)<!-- -->. ElementHandles are auto-disposed when their origin frame gets navigated.
|
||||
|
||||
ElementHandle instances can be used as arguments in [Page.$eval()](./puppeteer.page._eval.md) and [Page.evaluate()](./puppeteer.page.evaluate.md) methods.
|
||||
|
||||
If you're using TypeScript, ElementHandle takes a generic argument that denotes the type of element the handle is holding within. For example, if you have a handle to a `<select>` element, you can type it as `ElementHandle<HTMLSelectElement>` and you get some nicer type checks.
|
||||
|
||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `ElementHandle` class.
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [$(selector)](./puppeteer.elementhandle._.md) | | The method runs <code>element.querySelector</code> within the page. If no element matches the selector, the return value resolves to <code>null</code>. |
|
||||
| [$$(selector)](./puppeteer.elementhandle.__.md) | | The method runs <code>element.querySelectorAll</code> within the page. If no elements match the selector, the return value resolves to <code>[]</code>. |
|
||||
| [$(selector)](./puppeteer.elementhandle._.md) | | Runs <code>element.querySelector</code> within the page. If no element matches the selector, the return value resolves to <code>null</code>. |
|
||||
| [$$(selector)](./puppeteer.elementhandle.__.md) | | Runs <code>element.querySelectorAll</code> within the page. If no elements match the selector, the return value resolves to <code>[]</code>. |
|
||||
| [$$eval(selector, pageFunction, args)](./puppeteer.elementhandle.__eval.md) | | This method runs <code>document.querySelectorAll</code> within the element and passes it as the first argument to <code>pageFunction</code>. If there's no element matching <code>selector</code>, the method throws an error.<!-- -->If <code>pageFunction</code> returns a Promise, then <code>frame.$$eval</code> would wait for the promise to resolve and return its value. |
|
||||
| [$eval(selector, pageFunction, args)](./puppeteer.elementhandle._eval.md) | | This method runs <code>document.querySelector</code> within the element and passes it as the first argument to <code>pageFunction</code>. If there's no element matching <code>selector</code>, the method throws an error.<!-- -->If <code>pageFunction</code> returns a Promise, then <code>frame.$eval</code> would wait for the promise to resolve and return its value. |
|
||||
| [$x(expression)](./puppeteer.elementhandle._x.md) | | The method evaluates the XPath expression relative to the elementHandle. If there are no such elements, the method will resolve to an empty array. |
|
||||
|
12
remote/test/puppeteer/new-docs/puppeteer.evaluatefn.md
Normal file
12
remote/test/puppeteer/new-docs/puppeteer.evaluatefn.md
Normal file
@ -0,0 +1,12 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EvaluateFn](./puppeteer.evaluatefn.md)
|
||||
|
||||
## EvaluateFn type
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type EvaluateFn<T = any> = string | ((arg1: T, ...args: any[]) => any);
|
||||
```
|
@ -0,0 +1,12 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EvaluateFnReturnType](./puppeteer.evaluatefnreturntype.md)
|
||||
|
||||
## EvaluateFnReturnType type
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type EvaluateFnReturnType<T extends EvaluateFn> = T extends (...args: any[]) => infer R ? R : unknown;
|
||||
```
|
12
remote/test/puppeteer/new-docs/puppeteer.evaluatehandlefn.md
Normal file
12
remote/test/puppeteer/new-docs/puppeteer.evaluatehandlefn.md
Normal file
@ -0,0 +1,12 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md)
|
||||
|
||||
## EvaluateHandleFn type
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type EvaluateHandleFn = string | ((...args: unknown[]) => unknown);
|
||||
```
|
@ -1,22 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_adoptBackendNodeId](./puppeteer.executioncontext._adoptbackendnodeid.md)
|
||||
|
||||
## ExecutionContext.\_adoptBackendNodeId() method
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_adoptBackendNodeId(backendNodeId: Protocol.DOM.BackendNodeId): Promise<ElementHandle>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| backendNodeId | Protocol.DOM.BackendNodeId | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<[ElementHandle](./puppeteer.elementhandle.md)<!-- -->>
|
||||
|
@ -1,22 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_adoptElementHandle](./puppeteer.executioncontext._adoptelementhandle.md)
|
||||
|
||||
## ExecutionContext.\_adoptElementHandle() method
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_adoptElementHandle(elementHandle: ElementHandle): Promise<ElementHandle>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| elementHandle | [ElementHandle](./puppeteer.elementhandle.md) | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<[ElementHandle](./puppeteer.elementhandle.md)<!-- -->>
|
||||
|
@ -1,11 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_client](./puppeteer.executioncontext._client.md)
|
||||
|
||||
## ExecutionContext.\_client property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_client: CDPSession;
|
||||
```
|
@ -1,22 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [(constructor)](./puppeteer.executioncontext._constructor_.md)
|
||||
|
||||
## ExecutionContext.(constructor)
|
||||
|
||||
Constructs a new instance of the `ExecutionContext` class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(client: CDPSession, contextPayload: Protocol.Runtime.ExecutionContextDescription, world: DOMWorld);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| client | [CDPSession](./puppeteer.cdpsession.md) | |
|
||||
| contextPayload | Protocol.Runtime.ExecutionContextDescription | |
|
||||
| world | DOMWorld | |
|
||||
|
@ -1,11 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_contextId](./puppeteer.executioncontext._contextid.md)
|
||||
|
||||
## ExecutionContext.\_contextId property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_contextId: number;
|
||||
```
|
@ -1,11 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_world](./puppeteer.executioncontext._world.md)
|
||||
|
||||
## ExecutionContext.\_world property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_world: DOMWorld;
|
||||
```
|
@ -14,10 +14,51 @@ evaluate<ReturnType extends any>(pageFunction: Function | string, ...args: unkno
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| pageFunction | Function \| string | |
|
||||
| args | unknown\[\] | |
|
||||
| pageFunction | Function \| string | a function to be evaluated in the <code>executionContext</code> |
|
||||
| args | unknown\[\] | argument to pass to the page function |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<ReturnType>
|
||||
|
||||
A promise that resolves to the return value of the given function.
|
||||
|
||||
## Remarks
|
||||
|
||||
If the function passed to the `executionContext.evaluate` returns a Promise, then `executionContext.evaluate` would wait for the promise to resolve and return its value. If the function passed to the `executionContext.evaluate` returns a non-serializable value, then `executionContext.evaluate` resolves to `undefined`<!-- -->. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`<!-- -->: `-0`<!-- -->, `NaN`<!-- -->, `Infinity`<!-- -->, `-Infinity`<!-- -->, and bigint literals.
|
||||
|
||||
## Example 1
|
||||
|
||||
|
||||
```js
|
||||
const executionContext = await page.mainFrame().executionContext();
|
||||
const result = await executionContext.evaluate(() => Promise.resolve(8 * 7))* ;
|
||||
console.log(result); // prints "56"
|
||||
|
||||
```
|
||||
|
||||
## Example 2
|
||||
|
||||
A string can also be passed in instead of a function.
|
||||
|
||||
```js
|
||||
console.log(await executionContext.evaluate('1 + 2')); // prints "3"
|
||||
|
||||
```
|
||||
|
||||
## Example 3
|
||||
|
||||
[JSHandle](./puppeteer.jshandle.md) instances can be passed as arguments to the `executionContext.* evaluate`<!-- -->:
|
||||
|
||||
```js
|
||||
const oneHandle = await executionContext.evaluateHandle(() => 1);
|
||||
const twoHandle = await executionContext.evaluateHandle(() => 2);
|
||||
const result = await executionContext.evaluate(
|
||||
(a, b) => a + b, oneHandle, * twoHandle
|
||||
);
|
||||
await oneHandle.dispose();
|
||||
await twoHandle.dispose();
|
||||
console.log(result); // prints '3'.
|
||||
|
||||
```
|
||||
|
||||
|
@ -7,17 +7,56 @@
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
evaluateHandle(pageFunction: Function | string, ...args: unknown[]): Promise<JSHandle>;
|
||||
evaluateHandle<HandleType extends JSHandle | ElementHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandleType>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| pageFunction | Function \| string | |
|
||||
| args | unknown\[\] | |
|
||||
| pageFunction | [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md) | a function to be evaluated in the <code>executionContext</code> |
|
||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | argument to pass to the page function |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<[JSHandle](./puppeteer.jshandle.md)<!-- -->>
|
||||
Promise<HandleType>
|
||||
|
||||
A promise that resolves to the return value of the given function as an in-page object (a [JSHandle](./puppeteer.jshandle.md)<!-- -->).
|
||||
|
||||
## Remarks
|
||||
|
||||
The only difference between `executionContext.evaluate` and `executionContext.evaluateHandle` is that `executionContext.evaluateHandle` returns an in-page object (a [JSHandle](./puppeteer.jshandle.md)<!-- -->). If the function passed to the `executionContext.evaluateHandle` returns a Promise, then `executionContext.evaluateHandle` would wait for the promise to resolve and return its value.
|
||||
|
||||
## Example 1
|
||||
|
||||
|
||||
```js
|
||||
const context = await page.mainFrame().executionContext();
|
||||
const aHandle = await context.evaluateHandle(() => Promise.resolve(self));
|
||||
aHandle; // Handle for the global object.
|
||||
|
||||
```
|
||||
|
||||
## Example 2
|
||||
|
||||
A string can also be passed in instead of a function.
|
||||
|
||||
```js
|
||||
// Handle for the '3' * object.
|
||||
const aHandle = await context.evaluateHandle('1 + 2');
|
||||
|
||||
```
|
||||
|
||||
## Example 3
|
||||
|
||||
JSHandle instances can be passed as arguments to the `executionContext.* evaluateHandle`<!-- -->:
|
||||
|
||||
```js
|
||||
const aHandle = await context.evaluateHandle(() => document.body);
|
||||
const resultHandle = await context.evaluateHandle(body => body.innerHTML, * aHandle);
|
||||
console.log(await resultHandle.jsonValue()); // prints body's innerHTML
|
||||
await aHandle.dispose();
|
||||
await resultHandle.dispose();
|
||||
|
||||
```
|
||||
|
||||
|
@ -13,3 +13,9 @@ frame(): Frame | null;
|
||||
|
||||
[Frame](./puppeteer.frame.md) \| null
|
||||
|
||||
The frame associated with this execution context.
|
||||
|
||||
## Remarks
|
||||
|
||||
Not every execution context is associated with a frame. For example, workers and extensions have execution contexts that are not associated with frames.
|
||||
|
||||
|
@ -4,34 +4,26 @@
|
||||
|
||||
## ExecutionContext class
|
||||
|
||||
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 method. - [Extension](https://developer.chrome.com/extensions)<!-- -->'s content scripts create additional execution contexts.
|
||||
|
||||
Besides pages, execution contexts can be found in [workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)<!-- -->.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class ExecutionContext
|
||||
```
|
||||
|
||||
## Constructors
|
||||
## Remarks
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(client, contextPayload, world)](./puppeteer.executioncontext._constructor_.md) | | Constructs a new instance of the <code>ExecutionContext</code> class |
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [\_client](./puppeteer.executioncontext._client.md) | | [CDPSession](./puppeteer.cdpsession.md) | |
|
||||
| [\_contextId](./puppeteer.executioncontext._contextid.md) | | number | |
|
||||
| [\_world](./puppeteer.executioncontext._world.md) | | DOMWorld | |
|
||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `ExecutionContext` class.
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [\_adoptBackendNodeId(backendNodeId)](./puppeteer.executioncontext._adoptbackendnodeid.md) | | |
|
||||
| [\_adoptElementHandle(elementHandle)](./puppeteer.executioncontext._adoptelementhandle.md) | | |
|
||||
| [evaluate(pageFunction, args)](./puppeteer.executioncontext.evaluate.md) | | |
|
||||
| [evaluateHandle(pageFunction, args)](./puppeteer.executioncontext.evaluatehandle.md) | | |
|
||||
| [frame()](./puppeteer.executioncontext.frame.md) | | |
|
||||
| [queryObjects(prototypeHandle)](./puppeteer.executioncontext.queryobjects.md) | | |
|
||||
| [queryObjects(prototypeHandle)](./puppeteer.executioncontext.queryobjects.md) | | This method iterates the JavaScript heap and finds all the objects with the given prototype. |
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
## ExecutionContext.queryObjects() method
|
||||
|
||||
This method iterates the JavaScript heap and finds all the objects with the given prototype.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
@ -14,9 +16,31 @@ queryObjects(prototypeHandle: JSHandle): Promise<JSHandle>;
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| prototypeHandle | [JSHandle](./puppeteer.jshandle.md) | |
|
||||
| prototypeHandle | [JSHandle](./puppeteer.jshandle.md) | a handle to the object prototype |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<[JSHandle](./puppeteer.jshandle.md)<!-- -->>
|
||||
|
||||
A handle to an array of objects with the given prototype.
|
||||
|
||||
## Remarks
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
```js
|
||||
// Create a Map object
|
||||
await page.evaluate(() => window.map = new Map());
|
||||
// Get a handle to the Map object prototype
|
||||
const mapPrototype = await page.evaluateHandle(() => Map.prototype);
|
||||
// Query all map instances into an array
|
||||
const mapInstances = await page.queryObjects(mapPrototype);
|
||||
// Count amount of map objects in heap
|
||||
const count = await page.evaluate(maps => maps.length, mapInstances);
|
||||
await mapInstances.dispose();
|
||||
await mapPrototype.dispose();
|
||||
|
||||
```
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
$$eval<ReturnType extends any>(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise<ReturnType>;
|
||||
$$eval<ReturnType extends any>(selector: string, pageFunction: EvaluateFn | string, ...args: SerializableOrJSHandle[]): Promise<ReturnType>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
@ -15,8 +15,8 @@ $$eval<ReturnType extends any>(selector: string, pageFunction: Function | string
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| selector | string | |
|
||||
| pageFunction | Function \| string | |
|
||||
| args | unknown\[\] | |
|
||||
| pageFunction | [EvaluateFn](./puppeteer.evaluatefn.md) \| string | |
|
||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
$eval<ReturnType extends any>(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise<ReturnType>;
|
||||
$eval<ReturnType>(selector: string, pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise<ReturnType>, ...args: SerializableOrJSHandle[]): Promise<WrapElementHandle<ReturnType>>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
@ -15,10 +15,10 @@ $eval<ReturnType extends any>(selector: string, pageFunction: Function | string,
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| selector | string | |
|
||||
| pageFunction | Function \| string | |
|
||||
| args | unknown\[\] | |
|
||||
| pageFunction | (element: Element, ...args: unknown\[\]) => ReturnType \| Promise<ReturnType> | |
|
||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<ReturnType>
|
||||
Promise<[WrapElementHandle](./puppeteer.wrapelementhandle.md)<!-- --><ReturnType>>
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
```typescript
|
||||
click(selector: string, options?: {
|
||||
delay?: number;
|
||||
button?: MouseButtonInput;
|
||||
button?: MouseButton;
|
||||
clickCount?: number;
|
||||
}): Promise<void>;
|
||||
```
|
||||
@ -19,7 +19,7 @@ click(selector: string, options?: {
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| selector | string | |
|
||||
| options | { delay?: number; button?: [MouseButtonInput](./puppeteer.mousebuttoninput.md)<!-- -->; clickCount?: number; } | |
|
||||
| options | { delay?: number; button?: [MouseButton](./puppeteer.mousebutton.md)<!-- -->; clickCount?: number; } | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
@ -7,17 +7,17 @@
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
evaluateHandle(pageFunction: Function | string, ...args: unknown[]): Promise<JSHandle>;
|
||||
evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| pageFunction | Function \| string | |
|
||||
| args | unknown\[\] | |
|
||||
| pageFunction | [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md) | |
|
||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<[JSHandle](./puppeteer.jshandle.md)<!-- -->>
|
||||
Promise<HandlerType>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, ...args: unknown[]): Promise<JSHandle | null>;
|
||||
waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, ...args: SerializableOrJSHandle[]): Promise<JSHandle | null>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
@ -16,7 +16,7 @@ waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, .
|
||||
| --- | --- | --- |
|
||||
| selectorOrFunctionOrTimeout | string \| number \| Function | |
|
||||
| options | {} | |
|
||||
| args | unknown\[\] | |
|
||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
waitForFunction(pageFunction: Function | string, options?: {
|
||||
polling?: string | number;
|
||||
timeout?: number;
|
||||
}, ...args: unknown[]): Promise<JSHandle>;
|
||||
}, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
@ -19,7 +19,7 @@ waitForFunction(pageFunction: Function | string, options?: {
|
||||
| --- | --- | --- |
|
||||
| pageFunction | Function \| string | |
|
||||
| options | { polling?: string \| number; timeout?: number; } | |
|
||||
| args | unknown\[\] | |
|
||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [GeolocationOptions](./puppeteer.geolocationoptions.md) > [accuracy](./puppeteer.geolocationoptions.accuracy.md)
|
||||
|
||||
## GeolocationOptions.accuracy property
|
||||
|
||||
Optional non-negative accuracy value.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
accuracy?: number;
|
||||
```
|
@ -0,0 +1,13 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [GeolocationOptions](./puppeteer.geolocationoptions.md) > [latitude](./puppeteer.geolocationoptions.latitude.md)
|
||||
|
||||
## GeolocationOptions.latitude property
|
||||
|
||||
Longitude between -180 and 180.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
latitude: number;
|
||||
```
|
@ -0,0 +1,13 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [GeolocationOptions](./puppeteer.geolocationoptions.md) > [longitude](./puppeteer.geolocationoptions.longitude.md)
|
||||
|
||||
## GeolocationOptions.longitude property
|
||||
|
||||
Latitude between -90 and 90.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
longitude: number;
|
||||
```
|
@ -0,0 +1,21 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [GeolocationOptions](./puppeteer.geolocationoptions.md)
|
||||
|
||||
## GeolocationOptions interface
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface GeolocationOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [accuracy](./puppeteer.geolocationoptions.accuracy.md) | number | Optional non-negative accuracy value. |
|
||||
| [latitude](./puppeteer.geolocationoptions.latitude.md) | number | Longitude between -180 and 180. |
|
||||
| [longitude](./puppeteer.geolocationoptions.longitude.md) | number | Latitude between -90 and 90. |
|
||||
|
@ -1,22 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [HTTPResponse](./puppeteer.httpresponse.md) > [(constructor)](./puppeteer.httpresponse._constructor_.md)
|
||||
|
||||
## HTTPResponse.(constructor)
|
||||
|
||||
Constructs a new instance of the `HTTPResponse` class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(client: CDPSession, request: HTTPRequest, responsePayload: Protocol.Network.Response);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| client | [CDPSession](./puppeteer.cdpsession.md) | |
|
||||
| request | [HTTPRequest](./puppeteer.httprequest.md) | |
|
||||
| responsePayload | Protocol.Network.Response | |
|
||||
|
@ -1,22 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [HTTPResponse](./puppeteer.httpresponse.md) > [\_resolveBody](./puppeteer.httpresponse._resolvebody.md)
|
||||
|
||||
## HTTPResponse.\_resolveBody() method
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_resolveBody(err: Error | null): void;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| err | Error \| null | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
void
|
||||
|
@ -13,3 +13,5 @@ buffer(): Promise<Buffer>;
|
||||
|
||||
Promise<Buffer>
|
||||
|
||||
Promise which resolves to a buffer with response body.
|
||||
|
||||
|
@ -13,3 +13,5 @@ frame(): Frame | null;
|
||||
|
||||
[Frame](./puppeteer.frame.md) \| null
|
||||
|
||||
A [Frame](./puppeteer.frame.md) that initiated this response, or `null` if navigating to error pages.
|
||||
|
||||
|
@ -13,3 +13,5 @@ fromCache(): boolean;
|
||||
|
||||
boolean
|
||||
|
||||
True if the response was served from either the browser's disk cache or memory cache.
|
||||
|
||||
|
@ -13,3 +13,5 @@ fromServiceWorker(): boolean;
|
||||
|
||||
boolean
|
||||
|
||||
True if the response was served by a service worker.
|
||||
|
||||
|
@ -13,3 +13,5 @@ headers(): Record<string, string>;
|
||||
|
||||
Record<string, string>
|
||||
|
||||
An object with HTTP headers associated with the response. All header names are lower-case.
|
||||
|
||||
|
@ -13,3 +13,9 @@ json(): Promise<any>;
|
||||
|
||||
Promise<any>
|
||||
|
||||
Promise which resolves to a JSON representation of response body.
|
||||
|
||||
## Remarks
|
||||
|
||||
This method will throw if the response body is not parsable via `JSON.parse`<!-- -->.
|
||||
|
||||
|
@ -4,23 +4,22 @@
|
||||
|
||||
## HTTPResponse class
|
||||
|
||||
The HTTPResponse class represents responses which are received by the [Page](./puppeteer.page.md) class.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class HTTPResponse
|
||||
```
|
||||
|
||||
## Constructors
|
||||
## Remarks
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(client, request, responsePayload)](./puppeteer.httpresponse._constructor_.md) | | Constructs a new instance of the <code>HTTPResponse</code> class |
|
||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `HTTPResponse` class.
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [\_resolveBody(err)](./puppeteer.httpresponse._resolvebody.md) | | |
|
||||
| [buffer()](./puppeteer.httpresponse.buffer.md) | | |
|
||||
| [frame()](./puppeteer.httpresponse.frame.md) | | |
|
||||
| [fromCache()](./puppeteer.httpresponse.fromcache.md) | | |
|
||||
|
@ -13,3 +13,5 @@ ok(): boolean;
|
||||
|
||||
boolean
|
||||
|
||||
True if the response was successful (status in the range 200-299).
|
||||
|
||||
|
@ -11,5 +11,7 @@ remoteAddress(): RemoteAddress;
|
||||
```
|
||||
<b>Returns:</b>
|
||||
|
||||
RemoteAddress
|
||||
[RemoteAddress](./puppeteer.remoteaddress.md)
|
||||
|
||||
The IP address and port number used to connect to the remote server.
|
||||
|
||||
|
@ -13,3 +13,5 @@ request(): HTTPRequest;
|
||||
|
||||
[HTTPRequest](./puppeteer.httprequest.md)
|
||||
|
||||
A matching [HTTPRequest](./puppeteer.httprequest.md) object.
|
||||
|
||||
|
@ -13,3 +13,5 @@ securityDetails(): SecurityDetails | null;
|
||||
|
||||
[SecurityDetails](./puppeteer.securitydetails.md) \| null
|
||||
|
||||
[SecurityDetails](./puppeteer.securitydetails.md) if the response was received over the secure connection, or `null` otherwise.
|
||||
|
||||
|
@ -13,3 +13,5 @@ status(): number;
|
||||
|
||||
number
|
||||
|
||||
The status code of the response (e.g., 200 for a success).
|
||||
|
||||
|
@ -13,3 +13,5 @@ statusText(): string;
|
||||
|
||||
string
|
||||
|
||||
The status text of the response (e.g. usually an "OK" for a success).
|
||||
|
||||
|
@ -13,3 +13,5 @@ text(): Promise<string>;
|
||||
|
||||
Promise<string>
|
||||
|
||||
Promise which resolves to a text representation of response body.
|
||||
|
||||
|
@ -13,3 +13,5 @@ url(): string;
|
||||
|
||||
string
|
||||
|
||||
The URL of the response.
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSCoverageOptions](./puppeteer.jscoverageoptions.md)
|
||||
|
||||
## JSCoverageOptions interface
|
||||
|
||||
Set of configurable options for JS coverage.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface JSCoverageOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [reportAnonymousScripts](./puppeteer.jscoverageoptions.reportanonymousscripts.md) | boolean | Whether anonymous scripts generated by the page should be reported. |
|
||||
| [resetOnNavigation](./puppeteer.jscoverageoptions.resetonnavigation.md) | boolean | Whether to reset coverage on every navigation. |
|
||||
|
@ -0,0 +1,13 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSCoverageOptions](./puppeteer.jscoverageoptions.md) > [reportAnonymousScripts](./puppeteer.jscoverageoptions.reportanonymousscripts.md)
|
||||
|
||||
## JSCoverageOptions.reportAnonymousScripts property
|
||||
|
||||
Whether anonymous scripts generated by the page should be reported.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
reportAnonymousScripts?: boolean;
|
||||
```
|
@ -0,0 +1,13 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSCoverageOptions](./puppeteer.jscoverageoptions.md) > [resetOnNavigation](./puppeteer.jscoverageoptions.resetonnavigation.md)
|
||||
|
||||
## JSCoverageOptions.resetOnNavigation property
|
||||
|
||||
Whether to reset coverage on every navigation.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
resetOnNavigation?: boolean;
|
||||
```
|
@ -1,11 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [\_client](./puppeteer.jshandle._client.md)
|
||||
|
||||
## JSHandle.\_client property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_client: CDPSession;
|
||||
```
|
@ -1,22 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [(constructor)](./puppeteer.jshandle._constructor_.md)
|
||||
|
||||
## JSHandle.(constructor)
|
||||
|
||||
Constructs a new instance of the `JSHandle` class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(context: ExecutionContext, client: CDPSession, remoteObject: Protocol.Runtime.RemoteObject);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| context | [ExecutionContext](./puppeteer.executioncontext.md) | |
|
||||
| client | [CDPSession](./puppeteer.cdpsession.md) | |
|
||||
| remoteObject | Protocol.Runtime.RemoteObject | |
|
||||
|
@ -1,11 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [\_context](./puppeteer.jshandle._context.md)
|
||||
|
||||
## JSHandle.\_context property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_context: ExecutionContext;
|
||||
```
|
@ -1,11 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [\_disposed](./puppeteer.jshandle._disposed.md)
|
||||
|
||||
## JSHandle.\_disposed property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_disposed: boolean;
|
||||
```
|
@ -1,11 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [\_remoteObject](./puppeteer.jshandle._remoteobject.md)
|
||||
|
||||
## JSHandle.\_remoteObject property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
_remoteObject: Protocol.Runtime.RemoteObject;
|
||||
```
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user