diff --git a/remote/test/puppeteer/.eslintrc.js b/remote/test/puppeteer/.eslintrc.js
index 3e40356283bde..32b5d16114941 100644
--- a/remote/test/puppeteer/.eslintrc.js
+++ b/remote/test/puppeteer/.eslintrc.js
@@ -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,
diff --git a/remote/test/puppeteer/.travis.yml b/remote/test/puppeteer/.travis.yml
index 467f88577b8c1..8da18b9a8579a 100644
--- a/remote/test/puppeteer/.travis.yml
+++ b/remote/test/puppeteer/.travis.yml
@@ -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'
diff --git a/remote/test/puppeteer/README.md b/remote/test/puppeteer/README.md
index afbe88db88270..c76cbbbe24e2a 100644
--- a/remote/test/puppeteer/README.md
+++ b/remote/test/puppeteer/README.md
@@ -6,7 +6,7 @@
-###### [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`.
@@ -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!
-
+
+
+## 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.
+
+
+
+
## 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?
diff --git a/remote/test/puppeteer/api-extractor.json b/remote/test/puppeteer/api-extractor.json
index 76afa3db00369..8cc8240aa41e6 100644
--- a/remote/test/puppeteer/api-extractor.json
+++ b/remote/test/puppeteer/api-extractor.json
@@ -1,6 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
- "mainEntryPointFilePath": "/lib/api-docs-entry.d.ts",
+ "mainEntryPointFilePath": "/lib/cjs/api-docs-entry.d.ts",
"bundledPackages": [ ],
"apiReport": {
@@ -27,6 +27,9 @@
},
"extractorMessageReporting": {
+ "ae-internal-missing-underscore": {
+ "logLevel": "none"
+ },
"default": {
"logLevel": "warning"
}
diff --git a/remote/test/puppeteer/cjs-entry-core.js b/remote/test/puppeteer/cjs-entry-core.js
new file mode 100644
index 0000000000000..efcdb39027f7e
--- /dev/null
+++ b/remote/test/puppeteer/cjs-entry-core.js
@@ -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;
diff --git a/remote/test/puppeteer/cjs-entry.js b/remote/test/puppeteer/cjs-entry.js
new file mode 100644
index 0000000000000..424ffadf1a14e
--- /dev/null
+++ b/remote/test/puppeteer/cjs-entry.js
@@ -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;
diff --git a/remote/test/puppeteer/docs/api.md b/remote/test/puppeteer/docs/api.md
index 954e31550b4d7..e3d2c8c198d20 100644
--- a/remote/test/puppeteer/docs/api.md
+++ b/remote/test/puppeteer/docs/api.md
@@ -1,5 +1,5 @@
-# Puppeteer API Tip-Of-Tree
+# Puppeteer API v5.0.0
- 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"
diff --git a/remote/test/puppeteer/docs/troubleshooting.md b/remote/test/puppeteer/docs/troubleshooting.md
index 6e7adc2e59bf9..3b37540a7c446 100644
--- a/remote/test/puppeteer/docs/troubleshooting.md
+++ b/remote/test/puppeteer/docs/troubleshooting.md
@@ -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.
diff --git a/remote/test/puppeteer/install.js b/remote/test/puppeteer/install.js
index cf56da410ea48..402a72e0d2f60 100644
--- a/remote/test/puppeteer/install.js
+++ b/remote/test/puppeteer/install.js
@@ -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();
-
- 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}`);
- }
+ // need to ensure TS is compiled before loading the installer
+ const { downloadBrowser, logPolitely } = require('./lib/cjs/install');
+
+ if (process.env.PUPPETEER_SKIP_DOWNLOAD) {
+ logPolitely(
+ '**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" environment variable was found.'
+ );
+ 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}
- * @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);
+ 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;
}
-
- function toMegabytes(bytes) {
- const mb = bytes / 1024 / 1024;
- return `${Math.round(mb * 10) / 10} Mb`;
+ 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;
}
-
- 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;
+ 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 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();
diff --git a/remote/test/puppeteer/moz.yaml b/remote/test/puppeteer/moz.yaml
index f84d05fe35d79..4353440366025 100644
--- a/remote/test/puppeteer/moz.yaml
+++ b/remote/test/puppeteer/moz.yaml
@@ -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
diff --git a/remote/test/puppeteer/new-docs/puppeteer.boxmodel.md b/remote/test/puppeteer/new-docs/puppeteer.boxmodel.md
index ffdd69fa81896..04414d0adac55 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.boxmodel.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.boxmodel.md
@@ -4,7 +4,6 @@
## BoxModel interface
-
Signature:
```typescript
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.download.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.download.md
index 15679730e6d64..81725d09ddff9 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.download.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.download.md
@@ -21,7 +21,7 @@ download(revision: string, progressCallback?: (x: number, y: number) => void): P
Returns:
-Promise<BrowserFetcherRevisionInfo>
+Promise<[BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md)>
A promise with revision information when the revision is downloaded and extracted.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.platform.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.platform.md
index 92303f46888af..84e37a79101c2 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.platform.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.platform.md
@@ -11,7 +11,7 @@ platform(): Platform;
```
Returns:
-Platform
+[Platform](./puppeteer.platform.md)
Returns the current `Platform`.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.product.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.product.md
index 861c9b7864dcf..4066dfce915b0 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.product.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.product.md
@@ -11,7 +11,7 @@ product(): Product;
```
Returns:
-Product
+[Product](./puppeteer.product.md)
Returns the current `Product`.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.revisioninfo.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.revisioninfo.md
index c72e30ffa3e49..88d4ecadf18d8 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.revisioninfo.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcher.revisioninfo.md
@@ -18,7 +18,7 @@ revisionInfo(revision: string): BrowserFetcherRevisionInfo;
Returns:
-BrowserFetcherRevisionInfo
+[BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md)
The revision info for the given revision.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcheroptions.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcheroptions.md
index 71205e55d95ef..58d14dd54b39d 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.browserfetcheroptions.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcheroptions.md
@@ -4,6 +4,7 @@
## BrowserFetcherOptions interface
+
Signature:
```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 | |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.executablepath.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.executablepath.md
new file mode 100644
index 0000000000000..ef45fac9adaf0
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.executablepath.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [executablePath](./puppeteer.browserfetcherrevisioninfo.executablepath.md)
+
+## BrowserFetcherRevisionInfo.executablePath property
+
+Signature:
+
+```typescript
+executablePath: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.folderpath.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.folderpath.md
new file mode 100644
index 0000000000000..c4ab7a5174672
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.folderpath.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [folderPath](./puppeteer.browserfetcherrevisioninfo.folderpath.md)
+
+## BrowserFetcherRevisionInfo.folderPath property
+
+Signature:
+
+```typescript
+folderPath: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.local.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.local.md
new file mode 100644
index 0000000000000..eed4b9cb20f54
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.local.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [local](./puppeteer.browserfetcherrevisioninfo.local.md)
+
+## BrowserFetcherRevisionInfo.local property
+
+Signature:
+
+```typescript
+local: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.md
new file mode 100644
index 0000000000000..d17fc3dfecd2f
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md)
+
+## BrowserFetcherRevisionInfo interface
+
+
+Signature:
+
+```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 | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.product.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.product.md
new file mode 100644
index 0000000000000..eb32e35bf97c3
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.product.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [product](./puppeteer.browserfetcherrevisioninfo.product.md)
+
+## BrowserFetcherRevisionInfo.product property
+
+Signature:
+
+```typescript
+product: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.revision.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.revision.md
new file mode 100644
index 0000000000000..9fa0d1d57ccf6
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.revision.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [revision](./puppeteer.browserfetcherrevisioninfo.revision.md)
+
+## BrowserFetcherRevisionInfo.revision property
+
+Signature:
+
+```typescript
+revision: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.url.md b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.url.md
new file mode 100644
index 0000000000000..aced0bfccfbec
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browserfetcherrevisioninfo.url.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) > [url](./puppeteer.browserfetcherrevisioninfo.url.md)
+
+## BrowserFetcherRevisionInfo.url property
+
+Signature:
+
+```typescript
+url: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browseroptions.defaultviewport.md b/remote/test/puppeteer/new-docs/puppeteer.browseroptions.defaultviewport.md
new file mode 100644
index 0000000000000..5cb4035c05ff6
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browseroptions.defaultviewport.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserOptions](./puppeteer.browseroptions.md) > [defaultViewport](./puppeteer.browseroptions.defaultviewport.md)
+
+## BrowserOptions.defaultViewport property
+
+Signature:
+
+```typescript
+defaultViewport?: Viewport;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browseroptions.ignorehttpserrors.md b/remote/test/puppeteer/new-docs/puppeteer.browseroptions.ignorehttpserrors.md
new file mode 100644
index 0000000000000..a1951ddedc9c1
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browseroptions.ignorehttpserrors.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserOptions](./puppeteer.browseroptions.md) > [ignoreHTTPSErrors](./puppeteer.browseroptions.ignorehttpserrors.md)
+
+## BrowserOptions.ignoreHTTPSErrors property
+
+Signature:
+
+```typescript
+ignoreHTTPSErrors?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browseroptions.md b/remote/test/puppeteer/new-docs/puppeteer.browseroptions.md
new file mode 100644
index 0000000000000..3decd6b943566
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browseroptions.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserOptions](./puppeteer.browseroptions.md)
+
+## BrowserOptions interface
+
+Generic browser options that can be passed when launching any browser.
+
+Signature:
+
+```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 | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.browseroptions.slowmo.md b/remote/test/puppeteer/new-docs/puppeteer.browseroptions.slowmo.md
new file mode 100644
index 0000000000000..27a83884afac7
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.browseroptions.slowmo.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [BrowserOptions](./puppeteer.browseroptions.md) > [slowMo](./puppeteer.browseroptions.slowmo.md)
+
+## BrowserOptions.slowMo property
+
+Signature:
+
+```typescript
+slowMo?: number;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.args.md b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.args.md
new file mode 100644
index 0000000000000..5ae5f7706d127
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.args.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md) > [args](./puppeteer.chromeargoptions.args.md)
+
+## ChromeArgOptions.args property
+
+Signature:
+
+```typescript
+args?: string[];
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.devtools.md b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.devtools.md
new file mode 100644
index 0000000000000..b1cc7c89194dd
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.devtools.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md) > [devtools](./puppeteer.chromeargoptions.devtools.md)
+
+## ChromeArgOptions.devtools property
+
+Signature:
+
+```typescript
+devtools?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.headless.md b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.headless.md
new file mode 100644
index 0000000000000..8636f6e67aa07
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.headless.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md) > [headless](./puppeteer.chromeargoptions.headless.md)
+
+## ChromeArgOptions.headless property
+
+Signature:
+
+```typescript
+headless?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.md b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.md
new file mode 100644
index 0000000000000..27e52fd0fa1ad
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md)
+
+## ChromeArgOptions interface
+
+Launcher options that only apply to Chrome.
+
+Signature:
+
+```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 | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.userdatadir.md b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.userdatadir.md
new file mode 100644
index 0000000000000..8d5469e240ee9
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.chromeargoptions.userdatadir.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ChromeArgOptions](./puppeteer.chromeargoptions.md) > [userDataDir](./puppeteer.chromeargoptions.userdatadir.md)
+
+## ChromeArgOptions.userDataDir property
+
+Signature:
+
+```typescript
+userDataDir?: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverage._jscoverage.md b/remote/test/puppeteer/new-docs/puppeteer.coverage._jscoverage.md
deleted file mode 100644
index d3b3dd4095e24..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.coverage._jscoverage.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Coverage](./puppeteer.coverage.md) > [\_jsCoverage](./puppeteer.coverage._jscoverage.md)
-
-## Coverage.\_jsCoverage property
-
-Signature:
-
-```typescript
-_jsCoverage: JSCoverage;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverage.md b/remote/test/puppeteer/new-docs/puppeteer.coverage.md
index 947f94e9ed27d..eb041d32a4cc1 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.coverage.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverage.md
@@ -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.
+
Signature:
```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 Coverage
class |
-## Properties
-
-| Property | Modifiers | Type | Description |
-| --- | --- | --- | --- |
-| [\_cssCoverage](./puppeteer.coverage._csscoverage.md) | | CSSCoverage | |
-| [\_jsCoverage](./puppeteer.coverage._jscoverage.md) | | JSCoverage | |
-
## Methods
| Method | Modifiers | Description |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverage.startcsscoverage.md b/remote/test/puppeteer/new-docs/puppeteer.coverage.startcsscoverage.md
index 5091ba68695b9..673535d72d88c 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.coverage.startcsscoverage.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverage.startcsscoverage.md
@@ -7,18 +7,18 @@
Signature:
```typescript
-startCSSCoverage(options?: {
- resetOnNavigation?: boolean;
- }): Promise;
+startCSSCoverage(options?: CSSCoverageOptions): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| options | { resetOnNavigation?: boolean; } | |
+| options | [CSSCoverageOptions](./puppeteer.csscoverageoptions.md) | defaults to { resetOnNavigation : true }
|
Returns:
Promise<void>
+Promise that resolves when coverage is started.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverage.startjscoverage.md b/remote/test/puppeteer/new-docs/puppeteer.coverage.startjscoverage.md
index c7b878cdf17bb..cc24db4b1de97 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.coverage.startjscoverage.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverage.startjscoverage.md
@@ -7,19 +7,22 @@
Signature:
```typescript
-startJSCoverage(options?: {
- resetOnNavigation?: boolean;
- reportAnonymousScripts?: boolean;
- }): Promise;
+startJSCoverage(options?: JSCoverageOptions): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| options | { resetOnNavigation?: boolean; reportAnonymousScripts?: boolean; } | |
+| options | [JSCoverageOptions](./puppeteer.jscoverageoptions.md) | defaults to { resetOnNavigation : true, reportAnonymousScripts : false }
|
Returns:
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.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverage.stopcsscoverage.md b/remote/test/puppeteer/new-docs/puppeteer.coverage.stopcsscoverage.md
index 1134d25f091f9..9b9537ce4eb15 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.coverage.stopcsscoverage.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverage.stopcsscoverage.md
@@ -11,5 +11,11 @@ stopCSSCoverage(): Promise;
```
Returns:
-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.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverage.stopjscoverage.md b/remote/test/puppeteer/new-docs/puppeteer.coverage.stopjscoverage.md
index aec5c0dd8ae8e..6f126873878ff 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.coverage.stopjscoverage.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverage.stopjscoverage.md
@@ -11,5 +11,11 @@ stopJSCoverage(): Promise;
```
Returns:
-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.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverageentry.md b/remote/test/puppeteer/new-docs/puppeteer.coverageentry.md
new file mode 100644
index 0000000000000..96a6b6742160d
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverageentry.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [CoverageEntry](./puppeteer.coverageentry.md)
+
+## CoverageEntry interface
+
+The CoverageEntry class represents one entry of the coverage report.
+
+Signature:
+
+```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. |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverageentry.ranges.md b/remote/test/puppeteer/new-docs/puppeteer.coverageentry.ranges.md
new file mode 100644
index 0000000000000..2e0cfae91842b
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverageentry.ranges.md
@@ -0,0 +1,16 @@
+
+
+[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.
+
+Signature:
+
+```typescript
+ranges: Array<{
+ start: number;
+ end: number;
+ }>;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverageentry.text.md b/remote/test/puppeteer/new-docs/puppeteer.coverageentry.text.md
new file mode 100644
index 0000000000000..c01b4246d4d43
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverageentry.text.md
@@ -0,0 +1,13 @@
+
+
+[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.
+
+Signature:
+
+```typescript
+text: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.coverage._csscoverage.md b/remote/test/puppeteer/new-docs/puppeteer.coverageentry.url.md
similarity index 50%
rename from remote/test/puppeteer/new-docs/puppeteer.coverage._csscoverage.md
rename to remote/test/puppeteer/new-docs/puppeteer.coverageentry.url.md
index df7c773d61e3e..cfd89f611fdbd 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.coverage._csscoverage.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.coverageentry.url.md
@@ -1,11 +1,13 @@
-[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.
Signature:
```typescript
-_cssCoverage: CSSCoverage;
+url: string;
```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.csscoverageoptions.md b/remote/test/puppeteer/new-docs/puppeteer.csscoverageoptions.md
new file mode 100644
index 0000000000000..875f9f0425850
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.csscoverageoptions.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [CSSCoverageOptions](./puppeteer.csscoverageoptions.md)
+
+## CSSCoverageOptions interface
+
+Set of configurable options for CSS coverage.
+
+Signature:
+
+```typescript
+export interface CSSCoverageOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [resetOnNavigation](./puppeteer.csscoverageoptions.resetonnavigation.md) | boolean | Whether to reset coverage on every navigation. |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.csscoverageoptions.resetonnavigation.md b/remote/test/puppeteer/new-docs/puppeteer.csscoverageoptions.resetonnavigation.md
new file mode 100644
index 0000000000000..7bc036974910c
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.csscoverageoptions.resetonnavigation.md
@@ -0,0 +1,13 @@
+
+
+[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.
+
+Signature:
+
+```typescript
+resetOnNavigation?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.devicesmap.md b/remote/test/puppeteer/new-docs/puppeteer.devicesmap.md
new file mode 100644
index 0000000000000..e0b069cc82c61
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.devicesmap.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [devicesMap](./puppeteer.devicesmap.md)
+
+## devicesMap variable
+
+Signature:
+
+```typescript
+devicesMap: DevicesMap
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.elementhandle._.md b/remote/test/puppeteer/new-docs/puppeteer.elementhandle._.md
index 6be4b5ecd7b3e..a6d0df975825d 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.elementhandle._.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.elementhandle._.md
@@ -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`.
Signature:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.elementhandle.__.md b/remote/test/puppeteer/new-docs/puppeteer.elementhandle.__.md
index 34bfb5096f424..41c9843bd3c41 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.elementhandle.__.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.elementhandle.__.md
@@ -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 `[]`.
Signature:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.elementhandle.__eval.md b/remote/test/puppeteer/new-docs/puppeteer.elementhandle.__eval.md
index 62184b0bf0cd5..f351b5ef70c81 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.elementhandle.__eval.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.elementhandle.__eval.md
@@ -11,7 +11,7 @@ If `pageFunction` returns a Promise, then `frame.$$eval` would wait for the prom
Signature:
```typescript
-$$eval(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise;
+$$eval(selector: string, pageFunction: EvaluateFn | string, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
@@ -19,8 +19,8 @@ $$eval(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)\[\] | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.elementhandle._eval.md b/remote/test/puppeteer/new-docs/puppeteer.elementhandle._eval.md
index 51719ae1bfd56..4de0423e19c74 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.elementhandle._eval.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.elementhandle._eval.md
@@ -11,7 +11,7 @@ If `pageFunction` returns a Promise, then `frame.$eval` would wait for the promi
Signature:
```typescript
-$eval(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise;
+$eval(selector: string, pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise, ...args: SerializableOrJSHandle[]): Promise>;
```
## Parameters
@@ -19,12 +19,12 @@ $eval(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)\[\] | |
Returns:
-Promise<ReturnType>
+Promise<[WrapElementHandle](./puppeteer.wrapelementhandle.md)<ReturnType>>
## Example
diff --git a/remote/test/puppeteer/new-docs/puppeteer.elementhandle.aselement.md b/remote/test/puppeteer/new-docs/puppeteer.elementhandle.aselement.md
index 0abe674ad140e..670b0f824b8ab 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.elementhandle.aselement.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.elementhandle.aselement.md
@@ -7,9 +7,9 @@
Signature:
```typescript
-asElement(): ElementHandle | null;
+asElement(): ElementHandle | null;
```
Returns:
-[ElementHandle](./puppeteer.elementhandle.md) \| null
+[ElementHandle](./puppeteer.elementhandle.md)<ElementType> \| null
diff --git a/remote/test/puppeteer/new-docs/puppeteer.elementhandle.md b/remote/test/puppeteer/new-docs/puppeteer.elementhandle.md
index a28c12deee48c..09e5e97085b5f 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.elementhandle.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.elementhandle.md
@@ -9,7 +9,7 @@ ElementHandle represents an in-page DOM element.
Signature:
```typescript
-export declare class ElementHandle extends JSHandle
+export declare class ElementHandle extends JSHandle
```
Extends: [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 `` element, you can type it as `ElementHandle` 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 element.querySelector
within the page. If no element matches the selector, the return value resolves to null
. |
-| [$$(selector)](./puppeteer.elementhandle.__.md) | | The method runs element.querySelectorAll
within the page. If no elements match the selector, the return value resolves to []
. |
+| [$(selector)](./puppeteer.elementhandle._.md) | | Runs element.querySelector
within the page. If no element matches the selector, the return value resolves to null
. |
+| [$$(selector)](./puppeteer.elementhandle.__.md) | | Runs element.querySelectorAll
within the page. If no elements match the selector, the return value resolves to []
. |
| [$$eval(selector, pageFunction, args)](./puppeteer.elementhandle.__eval.md) | | This method runs document.querySelectorAll
within the element and passes it as the first argument to pageFunction
. If there's no element matching selector
, the method throws an error.If pageFunction
returns a Promise, then frame.$$eval
would wait for the promise to resolve and return its value. |
| [$eval(selector, pageFunction, args)](./puppeteer.elementhandle._eval.md) | | This method runs document.querySelector
within the element and passes it as the first argument to pageFunction
. If there's no element matching selector
, the method throws an error.If pageFunction
returns a Promise, then frame.$eval
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. |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.evaluatefn.md b/remote/test/puppeteer/new-docs/puppeteer.evaluatefn.md
new file mode 100644
index 0000000000000..8647ef2b7d374
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.evaluatefn.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [EvaluateFn](./puppeteer.evaluatefn.md)
+
+## EvaluateFn type
+
+
+Signature:
+
+```typescript
+export declare type EvaluateFn = string | ((arg1: T, ...args: any[]) => any);
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.evaluatefnreturntype.md b/remote/test/puppeteer/new-docs/puppeteer.evaluatefnreturntype.md
new file mode 100644
index 0000000000000..471823e316ee9
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.evaluatefnreturntype.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [EvaluateFnReturnType](./puppeteer.evaluatefnreturntype.md)
+
+## EvaluateFnReturnType type
+
+
+Signature:
+
+```typescript
+export declare type EvaluateFnReturnType = T extends (...args: any[]) => infer R ? R : unknown;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.evaluatehandlefn.md b/remote/test/puppeteer/new-docs/puppeteer.evaluatehandlefn.md
new file mode 100644
index 0000000000000..65596a1f6bcd4
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.evaluatehandlefn.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md)
+
+## EvaluateHandleFn type
+
+
+Signature:
+
+```typescript
+export declare type EvaluateHandleFn = string | ((...args: unknown[]) => unknown);
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._adoptbackendnodeid.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext._adoptbackendnodeid.md
deleted file mode 100644
index 1bdf1e05bf9eb..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._adoptbackendnodeid.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_adoptBackendNodeId](./puppeteer.executioncontext._adoptbackendnodeid.md)
-
-## ExecutionContext.\_adoptBackendNodeId() method
-
-Signature:
-
-```typescript
-_adoptBackendNodeId(backendNodeId: Protocol.DOM.BackendNodeId): Promise;
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| backendNodeId | Protocol.DOM.BackendNodeId | |
-
-Returns:
-
-Promise<[ElementHandle](./puppeteer.elementhandle.md)>
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._adoptelementhandle.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext._adoptelementhandle.md
deleted file mode 100644
index a211a82592e1c..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._adoptelementhandle.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_adoptElementHandle](./puppeteer.executioncontext._adoptelementhandle.md)
-
-## ExecutionContext.\_adoptElementHandle() method
-
-Signature:
-
-```typescript
-_adoptElementHandle(elementHandle: ElementHandle): Promise;
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| elementHandle | [ElementHandle](./puppeteer.elementhandle.md) | |
-
-Returns:
-
-Promise<[ElementHandle](./puppeteer.elementhandle.md)>
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._client.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext._client.md
deleted file mode 100644
index b3ad759f69844..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._client.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_client](./puppeteer.executioncontext._client.md)
-
-## ExecutionContext.\_client property
-
-Signature:
-
-```typescript
-_client: CDPSession;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._constructor_.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext._constructor_.md
deleted file mode 100644
index 8271648e1566e..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._constructor_.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-[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
-
-Signature:
-
-```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 | |
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._contextid.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext._contextid.md
deleted file mode 100644
index 3a8457c534803..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._contextid.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_contextId](./puppeteer.executioncontext._contextid.md)
-
-## ExecutionContext.\_contextId property
-
-Signature:
-
-```typescript
-_contextId: number;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._world.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext._world.md
deleted file mode 100644
index e01b99a26ef63..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext._world.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [ExecutionContext](./puppeteer.executioncontext.md) > [\_world](./puppeteer.executioncontext._world.md)
-
-## ExecutionContext.\_world property
-
-Signature:
-
-```typescript
-_world: DOMWorld;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.evaluate.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.evaluate.md
index c59be4be33342..7c767e125c15c 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.evaluate.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.evaluate.md
@@ -14,10 +14,51 @@ evaluate(pageFunction: Function | string, ...args: unkno
| Parameter | Type | Description |
| --- | --- | --- |
-| pageFunction | Function \| string | |
-| args | unknown\[\] | |
+| pageFunction | Function \| string | a function to be evaluated in the executionContext
|
+| args | unknown\[\] | argument to pass to the page function |
Returns:
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'.
+
+```
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.evaluatehandle.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.evaluatehandle.md
index 4ddf2d737a682..3f89892f0a9fa 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.evaluatehandle.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.evaluatehandle.md
@@ -7,17 +7,56 @@
Signature:
```typescript
-evaluateHandle(pageFunction: Function | string, ...args: unknown[]): Promise;
+evaluateHandle(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| pageFunction | Function \| string | |
-| args | unknown\[\] | |
+| pageFunction | [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md) | a function to be evaluated in the executionContext
|
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | argument to pass to the page function |
Returns:
-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();
+
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.frame.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.frame.md
index 112e4b7f60250..94a9dbab56252 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.frame.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.frame.md
@@ -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.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.md
index c07e290665284..c4902fd6d744c 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.md
@@ -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).
+
Signature:
```typescript
export declare class ExecutionContext
```
-## Constructors
-
-| Constructor | Modifiers | Description |
-| --- | --- | --- |
-| [(constructor)(client, contextPayload, world)](./puppeteer.executioncontext._constructor_.md) | | Constructs a new instance of the ExecutionContext
class |
-
-## Properties
+## Remarks
-| 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. |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.queryobjects.md b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.queryobjects.md
index ae9f7c8e0fa6d..1401d91df4a77 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.executioncontext.queryobjects.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.executioncontext.queryobjects.md
@@ -4,6 +4,8 @@
## ExecutionContext.queryObjects() method
+This method iterates the JavaScript heap and finds all the objects with the given prototype.
+
Signature:
```typescript
@@ -14,9 +16,31 @@ queryObjects(prototypeHandle: JSHandle): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| prototypeHandle | [JSHandle](./puppeteer.jshandle.md) | |
+| prototypeHandle | [JSHandle](./puppeteer.jshandle.md) | a handle to the object prototype |
Returns:
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();
+
+```
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.frame.__eval.md b/remote/test/puppeteer/new-docs/puppeteer.frame.__eval.md
index 0a7d7a9e18d95..889af679f5cb0 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.frame.__eval.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.frame.__eval.md
@@ -7,7 +7,7 @@
Signature:
```typescript
-$$eval(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise;
+$$eval(selector: string, pageFunction: EvaluateFn | string, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
@@ -15,8 +15,8 @@ $$eval(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)\[\] | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.frame._eval.md b/remote/test/puppeteer/new-docs/puppeteer.frame._eval.md
index 0d5d3066c14d0..ee1654dd79335 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.frame._eval.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.frame._eval.md
@@ -7,7 +7,7 @@
Signature:
```typescript
-$eval(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise;
+$eval(selector: string, pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise, ...args: SerializableOrJSHandle[]): Promise>;
```
## Parameters
@@ -15,10 +15,10 @@ $eval(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)\[\] | |
Returns:
-Promise<ReturnType>
+Promise<[WrapElementHandle](./puppeteer.wrapelementhandle.md)<ReturnType>>
diff --git a/remote/test/puppeteer/new-docs/puppeteer.frame.click.md b/remote/test/puppeteer/new-docs/puppeteer.frame.click.md
index 10632d573b61f..a6a205e5b266a 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.frame.click.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.frame.click.md
@@ -9,7 +9,7 @@
```typescript
click(selector: string, options?: {
delay?: number;
- button?: MouseButtonInput;
+ button?: MouseButton;
clickCount?: number;
}): Promise;
```
@@ -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; } | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.frame.evaluatehandle.md b/remote/test/puppeteer/new-docs/puppeteer.frame.evaluatehandle.md
index 57b20326df5ff..83e1ee4510842 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.frame.evaluatehandle.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.frame.evaluatehandle.md
@@ -7,17 +7,17 @@
Signature:
```typescript
-evaluateHandle(pageFunction: Function | string, ...args: unknown[]): Promise;
+evaluateHandle(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| pageFunction | Function \| string | |
-| args | unknown\[\] | |
+| pageFunction | [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md) | |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | |
Returns:
-Promise<[JSHandle](./puppeteer.jshandle.md)>
+Promise<HandlerType>
diff --git a/remote/test/puppeteer/new-docs/puppeteer.frame.waitfor.md b/remote/test/puppeteer/new-docs/puppeteer.frame.waitfor.md
index 52a4dc4710a76..9f540b13b12b4 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.frame.waitfor.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.frame.waitfor.md
@@ -7,7 +7,7 @@
Signature:
```typescript
-waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, ...args: unknown[]): Promise;
+waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
@@ -16,7 +16,7 @@ waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, .
| --- | --- | --- |
| selectorOrFunctionOrTimeout | string \| number \| Function | |
| options | {} | |
-| args | unknown\[\] | |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.frame.waitforfunction.md b/remote/test/puppeteer/new-docs/puppeteer.frame.waitforfunction.md
index 93692db5809f0..5c98f20ce8091 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.frame.waitforfunction.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.frame.waitforfunction.md
@@ -10,7 +10,7 @@
waitForFunction(pageFunction: Function | string, options?: {
polling?: string | number;
timeout?: number;
- }, ...args: unknown[]): Promise;
+ }, ...args: SerializableOrJSHandle[]): Promise;
```
## 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)\[\] | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.accuracy.md b/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.accuracy.md
new file mode 100644
index 0000000000000..ca443298b2160
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.accuracy.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [GeolocationOptions](./puppeteer.geolocationoptions.md) > [accuracy](./puppeteer.geolocationoptions.accuracy.md)
+
+## GeolocationOptions.accuracy property
+
+Optional non-negative accuracy value.
+
+Signature:
+
+```typescript
+accuracy?: number;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.latitude.md b/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.latitude.md
new file mode 100644
index 0000000000000..46332f808bd6e
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.latitude.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [GeolocationOptions](./puppeteer.geolocationoptions.md) > [latitude](./puppeteer.geolocationoptions.latitude.md)
+
+## GeolocationOptions.latitude property
+
+Longitude between -180 and 180.
+
+Signature:
+
+```typescript
+latitude: number;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.longitude.md b/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.longitude.md
new file mode 100644
index 0000000000000..b64133dfbe3cd
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.longitude.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [GeolocationOptions](./puppeteer.geolocationoptions.md) > [longitude](./puppeteer.geolocationoptions.longitude.md)
+
+## GeolocationOptions.longitude property
+
+Latitude between -90 and 90.
+
+Signature:
+
+```typescript
+longitude: number;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.md b/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.md
new file mode 100644
index 0000000000000..36664f783dfc2
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.geolocationoptions.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [GeolocationOptions](./puppeteer.geolocationoptions.md)
+
+## GeolocationOptions interface
+
+
+Signature:
+
+```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. |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse._constructor_.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse._constructor_.md
deleted file mode 100644
index c8ab1043d6faa..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse._constructor_.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-[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
-
-Signature:
-
-```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 | |
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse._resolvebody.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse._resolvebody.md
deleted file mode 100644
index aa1294ac795dd..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse._resolvebody.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [HTTPResponse](./puppeteer.httpresponse.md) > [\_resolveBody](./puppeteer.httpresponse._resolvebody.md)
-
-## HTTPResponse.\_resolveBody() method
-
-Signature:
-
-```typescript
-_resolveBody(err: Error | null): void;
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| err | Error \| null | |
-
-Returns:
-
-void
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.buffer.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.buffer.md
index d31a1b1c56daa..1abcd0c0b8c5a 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.buffer.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.buffer.md
@@ -13,3 +13,5 @@ buffer(): Promise;
Promise<Buffer>
+Promise which resolves to a buffer with response body.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.frame.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.frame.md
index dd1847a420266..acdba9205143b 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.frame.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.frame.md
@@ -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.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.fromcache.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.fromcache.md
index a89f753d7d8ac..b764328f49193 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.fromcache.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.fromcache.md
@@ -13,3 +13,5 @@ fromCache(): boolean;
boolean
+True if the response was served from either the browser's disk cache or memory cache.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.fromserviceworker.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.fromserviceworker.md
index 8df040653467a..ad4c5a2e86ad4 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.fromserviceworker.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.fromserviceworker.md
@@ -13,3 +13,5 @@ fromServiceWorker(): boolean;
boolean
+True if the response was served by a service worker.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.headers.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.headers.md
index e9193258ba817..9b53b75bdbe53 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.headers.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.headers.md
@@ -13,3 +13,5 @@ headers(): Record;
Record<string, string>
+An object with HTTP headers associated with the response. All header names are lower-case.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.json.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.json.md
index 141aaa462e328..c53a61b7f13af 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.json.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.json.md
@@ -13,3 +13,9 @@ json(): Promise;
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`.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.md
index 3cf9e6d43699e..80e747c090b6d 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.md
@@ -4,23 +4,22 @@
## HTTPResponse class
+The HTTPResponse class represents responses which are received by the [Page](./puppeteer.page.md) class.
+
Signature:
```typescript
export declare class HTTPResponse
```
-## Constructors
+## Remarks
-| Constructor | Modifiers | Description |
-| --- | --- | --- |
-| [(constructor)(client, request, responsePayload)](./puppeteer.httpresponse._constructor_.md) | | Constructs a new instance of the HTTPResponse
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) | | |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.ok.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.ok.md
index b432851bcd6c0..2e696f870c06e 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.ok.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.ok.md
@@ -13,3 +13,5 @@ ok(): boolean;
boolean
+True if the response was successful (status in the range 200-299).
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.remoteaddress.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.remoteaddress.md
index a447a82c9c832..6785c9d9ccea7 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.remoteaddress.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.remoteaddress.md
@@ -11,5 +11,7 @@ remoteAddress(): RemoteAddress;
```
Returns:
-RemoteAddress
+[RemoteAddress](./puppeteer.remoteaddress.md)
+
+The IP address and port number used to connect to the remote server.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.request.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.request.md
index dff022e4dab9f..948be3053c545 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.request.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.request.md
@@ -13,3 +13,5 @@ request(): HTTPRequest;
[HTTPRequest](./puppeteer.httprequest.md)
+A matching [HTTPRequest](./puppeteer.httprequest.md) object.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.securitydetails.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.securitydetails.md
index 2d7f743262fad..5ffee8df2f726 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.securitydetails.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.securitydetails.md
@@ -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.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.status.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.status.md
index 5d922cae123f3..6f1b928321cbc 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.status.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.status.md
@@ -13,3 +13,5 @@ status(): number;
number
+The status code of the response (e.g., 200 for a success).
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.statustext.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.statustext.md
index 9b3840ca8e64f..fd8376dccced5 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.statustext.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.statustext.md
@@ -13,3 +13,5 @@ statusText(): string;
string
+The status text of the response (e.g. usually an "OK" for a success).
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.text.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.text.md
index d1d21ef32e8a4..3837c5b77921c 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.text.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.text.md
@@ -13,3 +13,5 @@ text(): Promise;
Promise<string>
+Promise which resolves to a text representation of response body.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.url.md b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.url.md
index 9101f549ff1bd..b81b8b4628bc1 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.httpresponse.url.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.httpresponse.url.md
@@ -13,3 +13,5 @@ url(): string;
string
+The URL of the response.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.md b/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.md
new file mode 100644
index 0000000000000..300d4648633c0
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSCoverageOptions](./puppeteer.jscoverageoptions.md)
+
+## JSCoverageOptions interface
+
+Set of configurable options for JS coverage.
+
+Signature:
+
+```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. |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.reportanonymousscripts.md b/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.reportanonymousscripts.md
new file mode 100644
index 0000000000000..ce2cac9cddb81
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.reportanonymousscripts.md
@@ -0,0 +1,13 @@
+
+
+[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.
+
+Signature:
+
+```typescript
+reportAnonymousScripts?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.resetonnavigation.md b/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.resetonnavigation.md
new file mode 100644
index 0000000000000..e6599c38c9d3d
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.jscoverageoptions.resetonnavigation.md
@@ -0,0 +1,13 @@
+
+
+[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.
+
+Signature:
+
+```typescript
+resetOnNavigation?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle._client.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle._client.md
deleted file mode 100644
index c3f8e5e99cd2c..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle._client.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [\_client](./puppeteer.jshandle._client.md)
-
-## JSHandle.\_client property
-
-Signature:
-
-```typescript
-_client: CDPSession;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle._constructor_.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle._constructor_.md
deleted file mode 100644
index 5d8e00d0f1694..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle._constructor_.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-[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
-
-Signature:
-
-```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 | |
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle._context.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle._context.md
deleted file mode 100644
index 1fa562f89dc60..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle._context.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [\_context](./puppeteer.jshandle._context.md)
-
-## JSHandle.\_context property
-
-Signature:
-
-```typescript
-_context: ExecutionContext;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle._disposed.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle._disposed.md
deleted file mode 100644
index 45c1a5d1c9f18..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle._disposed.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [\_disposed](./puppeteer.jshandle._disposed.md)
-
-## JSHandle.\_disposed property
-
-Signature:
-
-```typescript
-_disposed: boolean;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle._remoteobject.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle._remoteobject.md
deleted file mode 100644
index 1c8613531ab90..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle._remoteobject.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSHandle](./puppeteer.jshandle.md) > [\_remoteObject](./puppeteer.jshandle._remoteobject.md)
-
-## JSHandle.\_remoteObject property
-
-Signature:
-
-```typescript
-_remoteObject: Protocol.Runtime.RemoteObject;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.aselement.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.aselement.md
index 87cc90cab8595..1f2b351774bf8 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.aselement.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.aselement.md
@@ -4,6 +4,8 @@
## JSHandle.asElement() method
+Returns either `null` or the object handle itself, if the object handle is an instance of [ElementHandle](./puppeteer.elementhandle.md).
+
Signature:
```typescript
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.dispose.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.dispose.md
index e2db369018232..869eb0e7f9956 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.dispose.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.dispose.md
@@ -4,7 +4,7 @@
## JSHandle.dispose() method
-The method stops referencing the element handle.
+Stops referencing the element handle, and resolves when the object handle is successfully disposed of.
Signature:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.evaluate.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.evaluate.md
index fef1efe89fbd4..c8cd3227e228c 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.evaluate.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.evaluate.md
@@ -9,19 +9,19 @@ This method passes this handle as the first argument to `pageFunction`.
Signature:
```typescript
-evaluate(pageFunction: Function | string, ...args: unknown[]): Promise;
+evaluate(pageFunction: T | string, ...args: SerializableOrJSHandle[]): Promise>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| pageFunction | Function \| string | |
-| args | unknown\[\] | |
+| pageFunction | T \| string | |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | |
Returns:
-Promise<ReturnType>
+Promise<[EvaluateFnReturnType](./puppeteer.evaluatefnreturntype.md)<T>>
## Example
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.evaluatehandle.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.evaluatehandle.md
index d30cffddb0961..3186b25cfa2bb 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.evaluatehandle.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.evaluatehandle.md
@@ -9,25 +9,25 @@ This method passes this handle as the first argument to `pageFunction`.
Signature:
```typescript
-evaluateHandle(pageFunction: Function | string, ...args: unknown[]): Promise;
+evaluateHandle(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| pageFunction | Function \| string | |
-| args | unknown\[\] | |
+| pageFunction | [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md) | |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | |
Returns:
-Promise<[JSHandle](./puppeteer.jshandle.md)>
+Promise<HandleType>
## Remarks
-The only difference between `evaluateHandle.evaluate` and `evaluateHandle.evaluateHandle` is that `executionContext.evaluateHandle` returns in-page object (JSHandle).
+The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns an in-page object (JSHandle).
-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.
+If the function passed to `jsHandle.evaluateHandle` returns a Promise, then `evaluateHandle.evaluateHandle` waits for the promise to resolve and returns its value.
See [Page.evaluateHandle()](./puppeteer.page.evaluatehandle.md) for more details.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.executioncontext.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.executioncontext.md
index ed5afb148a2ba..462cccf787998 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.executioncontext.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.executioncontext.md
@@ -4,6 +4,8 @@
## JSHandle.executionContext() method
+Returns the execution context the handle belongs to.
+
Signature:
```typescript
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.getproperty.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.getproperty.md
index 589f4fef70617..5cea22060750a 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.getproperty.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.getproperty.md
@@ -4,6 +4,8 @@
## JSHandle.getProperty() method
+Fetches a single property from the referenced object.
+
Signature:
```typescript
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.jsonvalue.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.jsonvalue.md
index aeef8ef1f4e12..2cdac0b4110d4 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.jsonvalue.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.jsonvalue.md
@@ -17,5 +17,5 @@ Promise<{}>
## Remarks
-The JSON is generated by running [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) on the object in page and consequent [JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) in puppeteer. \*\*NOTE\*\* The method will throw if the referenced object is not stringifiable.
+The JSON is generated by running [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) on the object in page and consequent [JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) in puppeteer. \*\*NOTE\*\* The method throws if the referenced object is not stringifiable.
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.md
index afe76f97687e9..e1e2b7906f3a1 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.md
@@ -4,6 +4,7 @@
## JSHandle class
+Represents an in-page JavaScript object. JSHandles can be created with the [page.evaluateHandle](./puppeteer.page.evaluatehandle.md) method.
Signature:
@@ -11,32 +12,32 @@
export declare class JSHandle
```
-## Constructors
+## Remarks
+
+The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `JSHandle` class.
+
+## Example
-| Constructor | Modifiers | Description |
-| --- | --- | --- |
-| [(constructor)(context, client, remoteObject)](./puppeteer.jshandle._constructor_.md) | | Constructs a new instance of the JSHandle
class |
-## Properties
+```js
+const windowHandle = await page.evaluateHandle(() => window);
+
+```
+JSHandle prevents the referenced JavaScript object from being garbage-collected unless the handle is [disposed](./puppeteer.jshandle.dispose.md). JSHandles are auto- disposed when their origin frame gets navigated or the parent context gets destroyed.
-| Property | Modifiers | Type | Description |
-| --- | --- | --- | --- |
-| [\_client](./puppeteer.jshandle._client.md) | | [CDPSession](./puppeteer.cdpsession.md) | |
-| [\_context](./puppeteer.jshandle._context.md) | | [ExecutionContext](./puppeteer.executioncontext.md) | |
-| [\_disposed](./puppeteer.jshandle._disposed.md) | | boolean | |
-| [\_remoteObject](./puppeteer.jshandle._remoteobject.md) | | Protocol.Runtime.RemoteObject | |
+JSHandle instances can be used as arguments for [Page.$eval()](./puppeteer.page._eval.md), [Page.evaluate()](./puppeteer.page.evaluate.md), and [Page.evaluateHandle()](./puppeteer.page.evaluatehandle.md).
## Methods
| Method | Modifiers | Description |
| --- | --- | --- |
-| [asElement()](./puppeteer.jshandle.aselement.md) | | |
-| [dispose()](./puppeteer.jshandle.dispose.md) | | The method stops referencing the element handle. |
+| [asElement()](./puppeteer.jshandle.aselement.md) | | Returns either null
or the object handle itself, if the object handle is an instance of [ElementHandle](./puppeteer.elementhandle.md). |
+| [dispose()](./puppeteer.jshandle.dispose.md) | | Stops referencing the element handle, and resolves when the object handle is successfully disposed of. |
| [evaluate(pageFunction, args)](./puppeteer.jshandle.evaluate.md) | | This method passes this handle as the first argument to pageFunction
. If pageFunction
returns a Promise, then handle.evaluate
would wait for the promise to resolve and return its value. |
| [evaluateHandle(pageFunction, args)](./puppeteer.jshandle.evaluatehandle.md) | | This method passes this handle as the first argument to pageFunction
. |
-| [executionContext()](./puppeteer.jshandle.executioncontext.md) | | |
+| [executionContext()](./puppeteer.jshandle.executioncontext.md) | | Returns the execution context the handle belongs to. |
| [getProperties()](./puppeteer.jshandle.getproperties.md) | | The method returns a map with property names as keys and JSHandle instances for the property values. |
-| [getProperty(propertyName)](./puppeteer.jshandle.getproperty.md) | | |
+| [getProperty(propertyName)](./puppeteer.jshandle.getproperty.md) | | Fetches a single property from the referenced object. |
| [jsonValue()](./puppeteer.jshandle.jsonvalue.md) | | Returns a JSON representation of the object. |
-| [toString()](./puppeteer.jshandle.tostring.md) | | |
+| [toString()](./puppeteer.jshandle.tostring.md) | | Returns a string representation of the JSHandle. |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jshandle.tostring.md b/remote/test/puppeteer/new-docs/puppeteer.jshandle.tostring.md
index e81349cd0b721..2062ae6bbda51 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.jshandle.tostring.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.jshandle.tostring.md
@@ -4,6 +4,8 @@
## JSHandle.toString() method
+Returns a string representation of the JSHandle.
+
Signature:
```typescript
@@ -13,3 +15,7 @@ toString(): string;
string
+## Remarks
+
+Useful during debugging.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jsonarray.md b/remote/test/puppeteer/new-docs/puppeteer.jsonarray.md
new file mode 100644
index 0000000000000..fea5db9a72110
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.jsonarray.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSONArray](./puppeteer.jsonarray.md)
+
+## JSONArray type
+
+
+Signature:
+
+```typescript
+export declare type JSONArray = Serializable[];
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.jsonobject.md b/remote/test/puppeteer/new-docs/puppeteer.jsonobject.md
new file mode 100644
index 0000000000000..609425b7804ef
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.jsonobject.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [JSONObject](./puppeteer.jsonobject.md)
+
+## JSONObject interface
+
+
+Signature:
+
+```typescript
+export interface JSONObject
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard._client.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard._client.md
deleted file mode 100644
index d45c2b918d719..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard._client.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Keyboard](./puppeteer.keyboard.md) > [\_client](./puppeteer.keyboard._client.md)
-
-## Keyboard.\_client property
-
-Signature:
-
-```typescript
-_client: CDPSession;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard._constructor_.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard._constructor_.md
deleted file mode 100644
index e8c4f668b84a7..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard._constructor_.md
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Keyboard](./puppeteer.keyboard.md) > [(constructor)](./puppeteer.keyboard._constructor_.md)
-
-## Keyboard.(constructor)
-
-Constructs a new instance of the `Keyboard` class
-
-Signature:
-
-```typescript
-constructor(client: CDPSession);
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| client | [CDPSession](./puppeteer.cdpsession.md) | |
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard._modifiers.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard._modifiers.md
deleted file mode 100644
index c65e5a09a63e1..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard._modifiers.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Keyboard](./puppeteer.keyboard.md) > [\_modifiers](./puppeteer.keyboard._modifiers.md)
-
-## Keyboard.\_modifiers property
-
-Signature:
-
-```typescript
-_modifiers: number;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard._pressedkeys.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard._pressedkeys.md
deleted file mode 100644
index 81f67a3ecb21b..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard._pressedkeys.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Keyboard](./puppeteer.keyboard.md) > [\_pressedKeys](./puppeteer.keyboard._pressedkeys.md)
-
-## Keyboard.\_pressedKeys property
-
-Signature:
-
-```typescript
-_pressedKeys: Set;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard.down.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard.down.md
index 340caccc3c66c..5135cc6f1561c 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard.down.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.keyboard.down.md
@@ -4,6 +4,8 @@
## Keyboard.down() method
+Dispatches a `keydown` event.
+
Signature:
```typescript
@@ -16,10 +18,18 @@ down(key: KeyInput, options?: {
| Parameter | Type | Description |
| --- | --- | --- |
-| key | [KeyInput](./puppeteer.keyinput.md) | |
-| options | { text?: string; } | |
+| key | [KeyInput](./puppeteer.keyinput.md) | Name of key to press, such as ArrowLeft
. See [KeyInput](./puppeteer.keyinput.md) for a list of all key names. |
+| options | { text?: string; } | An object of options. Accepts text which, if specified, generates an input event with this text. |
Returns:
Promise<void>
+## Remarks
+
+If `key` is a single character and no modifier keys besides `Shift` are being held down, a `keypress`/`input` event will also generated. The `text` option can be specified to force an input event to be generated. If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier active. To release the modifier key, use [Keyboard.up()](./puppeteer.keyboard.up.md).
+
+After the key is pressed once, subsequent calls to [Keyboard.down()](./puppeteer.keyboard.down.md) will have [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use [Keyboard.up()](./puppeteer.keyboard.up.md).
+
+Modifier keys DO influence [Keyboard.down()](./puppeteer.keyboard.down.md). Holding down `Shift` will type the text in upper case.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard.md
index 56bda00fc7a5f..ede7de729a121 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.keyboard.md
@@ -4,33 +4,58 @@
## Keyboard class
+Keyboard provides an api for managing a virtual keyboard. The high level api is [Keyboard.type()](./puppeteer.keyboard.type.md), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.
+
Signature:
```typescript
export declare class Keyboard
```
-## Constructors
+## Remarks
-| Constructor | Modifiers | Description |
-| --- | --- | --- |
-| [(constructor)(client)](./puppeteer.keyboard._constructor_.md) | | Constructs a new instance of the Keyboard
class |
+For finer control, you can use [Keyboard.down()](./puppeteer.keyboard.down.md), [Keyboard.up()](./puppeteer.keyboard.up.md), and [Keyboard.sendCharacter()](./puppeteer.keyboard.sendcharacter.md) to manually fire events as if they were generated from a real keyboard.
+
+On MacOS, keyboard shortcuts like `⌘ A` -> Select All do not work. See [\#1313](https://github.com/puppeteer/puppeteer/issues/1313).
+
+The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `Keyboard` class.
+
+## Example 1
+
+An example of holding down `Shift` in order to select and delete some text:
+
+```js
+await page.keyboard.type('Hello World!');
+await page.keyboard.press('ArrowLeft');
-## Properties
+await page.keyboard.down('Shift');
+for (let i = 0; i < ' World'.length; i++)
+ await page.keyboard.press('ArrowLeft');
+await page.keyboard.up('Shift');
-| Property | Modifiers | Type | Description |
-| --- | --- | --- | --- |
-| [\_client](./puppeteer.keyboard._client.md) | | [CDPSession](./puppeteer.cdpsession.md) | |
-| [\_modifiers](./puppeteer.keyboard._modifiers.md) | | number | |
-| [\_pressedKeys](./puppeteer.keyboard._pressedkeys.md) | | Set<string> | |
+await page.keyboard.press('Backspace');
+// Result text will end up saying 'Hello!'
+
+```
+
+## Example 2
+
+An example of pressing `A`
+
+```js
+await page.keyboard.down('Shift');
+await page.keyboard.press('KeyA');
+await page.keyboard.up('Shift');
+
+```
## Methods
| Method | Modifiers | Description |
| --- | --- | --- |
-| [down(key, options)](./puppeteer.keyboard.down.md) | | |
-| [press(key, options)](./puppeteer.keyboard.press.md) | | |
-| [sendCharacter(char)](./puppeteer.keyboard.sendcharacter.md) | | |
-| [type(text, options)](./puppeteer.keyboard.type.md) | | |
-| [up(key)](./puppeteer.keyboard.up.md) | | |
+| [down(key, options)](./puppeteer.keyboard.down.md) | | Dispatches a keydown
event. |
+| [press(key, options)](./puppeteer.keyboard.press.md) | | Shortcut for [Keyboard.down()](./puppeteer.keyboard.down.md) and [Keyboard.up()](./puppeteer.keyboard.up.md). |
+| [sendCharacter(char)](./puppeteer.keyboard.sendcharacter.md) | | Dispatches a keypress
and input
event. This does not send a keydown
or keyup
event. |
+| [type(text, options)](./puppeteer.keyboard.type.md) | | Sends a keydown
, keypress
/input
, and keyup
event for each character in the text. |
+| [up(key)](./puppeteer.keyboard.up.md) | | Dispatches a keyup
event. |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard.press.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard.press.md
index e460e158d8d75..3f82fdea1e333 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard.press.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.keyboard.press.md
@@ -4,6 +4,8 @@
## Keyboard.press() method
+Shortcut for [Keyboard.down()](./puppeteer.keyboard.down.md) and [Keyboard.up()](./puppeteer.keyboard.up.md).
+
Signature:
```typescript
@@ -17,10 +19,16 @@ press(key: KeyInput, options?: {
| Parameter | Type | Description |
| --- | --- | --- |
-| key | [KeyInput](./puppeteer.keyinput.md) | |
-| options | { delay?: number; text?: string; } | |
+| key | [KeyInput](./puppeteer.keyinput.md) | Name of key to press, such as ArrowLeft
. See [KeyInput](./puppeteer.keyinput.md) for a list of all key names. |
+| options | { delay?: number; text?: string; } | An object of options. Accepts text which, if specified, generates an input event with this text. Accepts delay which, if specified, is the time to wait between keydown
and keyup
in milliseconds. Defaults to 0. |
Returns:
Promise<void>
+## Remarks
+
+If `key` is a single character and no modifier keys besides `Shift` are being held down, a `keypress`/`input` event will also generated. The `text` option can be specified to force an input event to be generated.
+
+Modifier keys DO effect [Keyboard.press()](./puppeteer.keyboard.press.md). Holding down `Shift` will type the text in upper case.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard.sendcharacter.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard.sendcharacter.md
index bf3aa5e5ce216..9f5bdf1b44459 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard.sendcharacter.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.keyboard.sendcharacter.md
@@ -4,6 +4,8 @@
## Keyboard.sendCharacter() method
+Dispatches a `keypress` and `input` event. This does not send a `keydown` or `keyup` event.
+
Signature:
```typescript
@@ -14,9 +16,21 @@ sendCharacter(char: string): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| char | string | |
+| char | string | Character to send into the page. |
Returns:
Promise<void>
+## Remarks
+
+Modifier keys DO NOT effect [Keyboard.sendCharacter](./puppeteer.keyboard.sendcharacter.md). Holding down `Shift` will not type the text in upper case.
+
+## Example
+
+
+```js
+page.keyboard.sendCharacter('嗨');
+
+```
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard.type.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard.type.md
index b1d5d78a9ac32..442d7e5fb71de 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard.type.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.keyboard.type.md
@@ -4,6 +4,8 @@
## Keyboard.type() method
+Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
+
Signature:
```typescript
@@ -16,10 +18,25 @@ type(text: string, options?: {
| Parameter | Type | Description |
| --- | --- | --- |
-| text | string | |
-| options | { delay?: number; } | |
+| text | string | A text to type into a focused element. |
+| options | { delay?: number; } | An object of options. Accepts delay which, if specified, is the time to wait between keydown
and keyup
in milliseconds. Defaults to 0. |
Returns:
Promise<void>
+## Remarks
+
+To press a special key, like `Control` or `ArrowDown`, use [Keyboard.press()](./puppeteer.keyboard.press.md).
+
+Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
+
+## Example
+
+
+```js
+await page.keyboard.type('Hello'); // Types instantly
+await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
+
+```
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyboard.up.md b/remote/test/puppeteer/new-docs/puppeteer.keyboard.up.md
index 5740664f9e2f3..412cd2dc18258 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.keyboard.up.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.keyboard.up.md
@@ -4,6 +4,8 @@
## Keyboard.up() method
+Dispatches a `keyup` event.
+
Signature:
```typescript
@@ -14,7 +16,7 @@ up(key: KeyInput): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| key | [KeyInput](./puppeteer.keyinput.md) | |
+| key | [KeyInput](./puppeteer.keyinput.md) | Name of key to release, such as ArrowLeft
. See [KeyInput](./puppeteer.keyinput.md) for a list of all key names. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.code.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.code.md
deleted file mode 100644
index 3f5ee83f3f63f..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.code.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md) > [code](./puppeteer.keydefinition.code.md)
-
-## KeyDefinition.code property
-
-Signature:
-
-```typescript
-code?: string;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.key.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.key.md
deleted file mode 100644
index f83d30beee22d..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.key.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md) > [key](./puppeteer.keydefinition.key.md)
-
-## KeyDefinition.key property
-
-Signature:
-
-```typescript
-key?: string;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.keycode.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.keycode.md
deleted file mode 100644
index ce43b45192f03..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.keycode.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md) > [keyCode](./puppeteer.keydefinition.keycode.md)
-
-## KeyDefinition.keyCode property
-
-Signature:
-
-```typescript
-keyCode?: number;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.location.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.location.md
deleted file mode 100644
index 0f0936265bf3b..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.location.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md) > [location](./puppeteer.keydefinition.location.md)
-
-## KeyDefinition.location property
-
-Signature:
-
-```typescript
-location?: number;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.md
deleted file mode 100644
index 2219ec3b0af1f..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.md
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md)
-
-## KeyDefinition interface
-
-Copyright 2017 Google Inc. All rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
-Signature:
-
-```typescript
-export interface KeyDefinition
-```
-
-## Properties
-
-| Property | Type | Description |
-| --- | --- | --- |
-| [code](./puppeteer.keydefinition.code.md) | string | |
-| [key](./puppeteer.keydefinition.key.md) | string | |
-| [keyCode](./puppeteer.keydefinition.keycode.md) | number | |
-| [location](./puppeteer.keydefinition.location.md) | number | |
-| [shiftKey](./puppeteer.keydefinition.shiftkey.md) | string | |
-| [shiftKeyCode](./puppeteer.keydefinition.shiftkeycode.md) | number | |
-| [shiftText](./puppeteer.keydefinition.shifttext.md) | string | |
-| [text](./puppeteer.keydefinition.text.md) | string | |
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shiftkey.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shiftkey.md
deleted file mode 100644
index 5fb41b7e96efc..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shiftkey.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md) > [shiftKey](./puppeteer.keydefinition.shiftkey.md)
-
-## KeyDefinition.shiftKey property
-
-Signature:
-
-```typescript
-shiftKey?: string;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shiftkeycode.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shiftkeycode.md
deleted file mode 100644
index fedf0de3bbae8..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shiftkeycode.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md) > [shiftKeyCode](./puppeteer.keydefinition.shiftkeycode.md)
-
-## KeyDefinition.shiftKeyCode property
-
-Signature:
-
-```typescript
-shiftKeyCode?: number;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shifttext.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shifttext.md
deleted file mode 100644
index 1a3d6c30676c6..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.shifttext.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md) > [shiftText](./puppeteer.keydefinition.shifttext.md)
-
-## KeyDefinition.shiftText property
-
-Signature:
-
-```typescript
-shiftText?: string;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.text.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinition.text.md
deleted file mode 100644
index b98af18f456fb..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinition.text.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [KeyDefinition](./puppeteer.keydefinition.md) > [text](./puppeteer.keydefinition.text.md)
-
-## KeyDefinition.text property
-
-Signature:
-
-```typescript
-text?: string;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keydefinitions.md b/remote/test/puppeteer/new-docs/puppeteer.keydefinitions.md
deleted file mode 100644
index 601076fbe815b..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.keydefinitions.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [keyDefinitions](./puppeteer.keydefinitions.md)
-
-## keyDefinitions variable
-
-Signature:
-
-```typescript
-keyDefinitions: Readonly>
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.keyinput.md b/remote/test/puppeteer/new-docs/puppeteer.keyinput.md
index 0ff88697c55c8..428dfc5865db4 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.keyinput.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.keyinput.md
@@ -4,6 +4,8 @@
## KeyInput type
+All the valid keys that can be passed to functions that take user input, such as [keyboard.press](./puppeteer.keyboard.press.md)
+
Signature:
```typescript
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.dumpio.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.dumpio.md
new file mode 100644
index 0000000000000..5440814228748
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.dumpio.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [dumpio](./puppeteer.launchoptions.dumpio.md)
+
+## LaunchOptions.dumpio property
+
+Signature:
+
+```typescript
+dumpio?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.env.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.env.md
new file mode 100644
index 0000000000000..ae14781a3fe89
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.env.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [env](./puppeteer.launchoptions.env.md)
+
+## LaunchOptions.env property
+
+Signature:
+
+```typescript
+env?: Record;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.executablepath.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.executablepath.md
new file mode 100644
index 0000000000000..62c61a57a9a34
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.executablepath.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [executablePath](./puppeteer.launchoptions.executablepath.md)
+
+## LaunchOptions.executablePath property
+
+Signature:
+
+```typescript
+executablePath?: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesighup.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesighup.md
new file mode 100644
index 0000000000000..92c0427cc1aa0
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesighup.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [handleSIGHUP](./puppeteer.launchoptions.handlesighup.md)
+
+## LaunchOptions.handleSIGHUP property
+
+Signature:
+
+```typescript
+handleSIGHUP?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesigint.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesigint.md
new file mode 100644
index 0000000000000..d6521475bccbd
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesigint.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [handleSIGINT](./puppeteer.launchoptions.handlesigint.md)
+
+## LaunchOptions.handleSIGINT property
+
+Signature:
+
+```typescript
+handleSIGINT?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesigterm.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesigterm.md
new file mode 100644
index 0000000000000..a8c7083e5fb5f
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.handlesigterm.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [handleSIGTERM](./puppeteer.launchoptions.handlesigterm.md)
+
+## LaunchOptions.handleSIGTERM property
+
+Signature:
+
+```typescript
+handleSIGTERM?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.ignoredefaultargs.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.ignoredefaultargs.md
new file mode 100644
index 0000000000000..4ebdfed2104ab
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.ignoredefaultargs.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [ignoreDefaultArgs](./puppeteer.launchoptions.ignoredefaultargs.md)
+
+## LaunchOptions.ignoreDefaultArgs property
+
+Signature:
+
+```typescript
+ignoreDefaultArgs?: boolean | string[];
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.md
new file mode 100644
index 0000000000000..3cef90e7227c3
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.md
@@ -0,0 +1,28 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md)
+
+## LaunchOptions interface
+
+Generic launch options that can be passed when launching any browser.
+
+Signature:
+
+```typescript
+export interface LaunchOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [dumpio](./puppeteer.launchoptions.dumpio.md) | boolean | |
+| [env](./puppeteer.launchoptions.env.md) | Record<string, string \| undefined> | |
+| [executablePath](./puppeteer.launchoptions.executablepath.md) | string | |
+| [handleSIGHUP](./puppeteer.launchoptions.handlesighup.md) | boolean | |
+| [handleSIGINT](./puppeteer.launchoptions.handlesigint.md) | boolean | |
+| [handleSIGTERM](./puppeteer.launchoptions.handlesigterm.md) | boolean | |
+| [ignoreDefaultArgs](./puppeteer.launchoptions.ignoredefaultargs.md) | boolean \| string\[\] | |
+| [pipe](./puppeteer.launchoptions.pipe.md) | boolean | |
+| [timeout](./puppeteer.launchoptions.timeout.md) | number | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.pipe.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.pipe.md
new file mode 100644
index 0000000000000..36167d158bb75
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.pipe.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [pipe](./puppeteer.launchoptions.pipe.md)
+
+## LaunchOptions.pipe property
+
+Signature:
+
+```typescript
+pipe?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.launchoptions.timeout.md b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.timeout.md
new file mode 100644
index 0000000000000..bbba4d7a277dc
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.launchoptions.timeout.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [LaunchOptions](./puppeteer.launchoptions.md) > [timeout](./puppeteer.launchoptions.timeout.md)
+
+## LaunchOptions.timeout property
+
+Signature:
+
+```typescript
+timeout?: number;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.md b/remote/test/puppeteer/new-docs/puppeteer.md
index e201778516537..c5648645aef22 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.md
@@ -15,21 +15,21 @@
| [CDPSession](./puppeteer.cdpsession.md) | The CDPSession
instances are used to talk raw Chrome Devtools Protocol. |
| [Connection](./puppeteer.connection.md) | |
| [ConsoleMessage](./puppeteer.consolemessage.md) | ConsoleMessage objects are dispatched by page via the 'console' event. |
-| [Coverage](./puppeteer.coverage.md) | |
+| [Coverage](./puppeteer.coverage.md) | The Coverage class provides methods to gathers information about parts of JavaScript and CSS that were used by the page. |
| [Dialog](./puppeteer.dialog.md) | Dialog instances are dispatched by the [Page](./puppeteer.page.md) via the dialog
event. |
| [ElementHandle](./puppeteer.elementhandle.md) | ElementHandle represents an in-page DOM element. |
| [EventEmitter](./puppeteer.eventemitter.md) | The EventEmitter class that many Puppeteer classes extend. |
-| [ExecutionContext](./puppeteer.executioncontext.md) | |
+| [ExecutionContext](./puppeteer.executioncontext.md) | 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). |
| [FileChooser](./puppeteer.filechooser.md) | File choosers let you react to the page requesting for a file. |
| [Frame](./puppeteer.frame.md) | |
| [FrameManager](./puppeteer.framemanager.md) | |
| [HTTPRequest](./puppeteer.httprequest.md) | |
-| [HTTPResponse](./puppeteer.httpresponse.md) | |
-| [JSHandle](./puppeteer.jshandle.md) | |
-| [Keyboard](./puppeteer.keyboard.md) | |
+| [HTTPResponse](./puppeteer.httpresponse.md) | The HTTPResponse class represents responses which are received by the [Page](./puppeteer.page.md) class. |
+| [JSHandle](./puppeteer.jshandle.md) | Represents an in-page JavaScript object. JSHandles can be created with the [page.evaluateHandle](./puppeteer.page.evaluatehandle.md) method. |
+| [Keyboard](./puppeteer.keyboard.md) | Keyboard provides an api for managing a virtual keyboard. The high level api is [Keyboard.type()](./puppeteer.keyboard.type.md), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page. |
| [Mouse](./puppeteer.mouse.md) | The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport. |
| [Page](./puppeteer.page.md) | Page provides methods to interact with a single tab or \[extension background page\](https://developer.chrome.com/extensions/background\_pages) in Chromium. One \[Browser\] instance might have multiple \[Page\] instances. |
-| [Puppeteer](./puppeteer.puppeteer.md) | The main Puppeteer class |
+| [Puppeteer](./puppeteer.puppeteer.md) | The main Puppeteer class Puppeteer module provides a method to launch a browser instance. |
| [SecurityDetails](./puppeteer.securitydetails.md) | The SecurityDetails class represents the security details of a response that was received over a secure connection. |
| [Target](./puppeteer.target.md) | |
| [TimeoutError](./puppeteer.timeouterror.md) | TimeoutError is emitted whenever certain operations are terminated due to timeout. |
@@ -50,21 +50,35 @@
| [BoundingBox](./puppeteer.boundingbox.md) | |
| [BoxModel](./puppeteer.boxmodel.md) | |
| [BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md) | |
+| [BrowserFetcherRevisionInfo](./puppeteer.browserfetcherrevisioninfo.md) | |
+| [BrowserOptions](./puppeteer.browseroptions.md) | Generic browser options that can be passed when launching any browser. |
+| [ChromeArgOptions](./puppeteer.chromeargoptions.md) | Launcher options that only apply to Chrome. |
| [ClickOptions](./puppeteer.clickoptions.md) | |
| [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md) | |
-| [KeyDefinition](./puppeteer.keydefinition.md) | Copyright 2017 Google Inc. All rights reserved.Licensed under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless 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. |
+| [CoverageEntry](./puppeteer.coverageentry.md) | The CoverageEntry class represents one entry of the coverage report. |
+| [CSSCoverageOptions](./puppeteer.csscoverageoptions.md) | Set of configurable options for CSS coverage. |
+| [GeolocationOptions](./puppeteer.geolocationoptions.md) | |
+| [JSCoverageOptions](./puppeteer.jscoverageoptions.md) | Set of configurable options for JS coverage. |
+| [JSONObject](./puppeteer.jsonobject.md) | |
+| [LaunchOptions](./puppeteer.launchoptions.md) | Generic launch options that can be passed when launching any browser. |
| [Metrics](./puppeteer.metrics.md) | |
+| [MouseOptions](./puppeteer.mouseoptions.md) | |
| [PressOptions](./puppeteer.pressoptions.md) | |
+| [ProductLauncher](./puppeteer.productlauncher.md) | Describes a launcher - a class that is able to create and launch a browser instance. |
+| [RemoteAddress](./puppeteer.remoteaddress.md) | |
| [SerializedAXNode](./puppeteer.serializedaxnode.md) | Represents a Node and the properties of it that are relevant to Accessibility. |
| [SnapshotOptions](./puppeteer.snapshotoptions.md) | |
+| [TracingOptions](./puppeteer.tracingoptions.md) | |
+| [WaitForOptions](./puppeteer.waitforoptions.md) | |
| [WaitForTargetOptions](./puppeteer.waitfortargetoptions.md) | |
+| [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) | |
## Variables
| Variable | Description |
| --- | --- |
+| [devicesMap](./puppeteer.devicesmap.md) | |
| [EVALUATION\_SCRIPT\_URL](./puppeteer.evaluation_script_url.md) | |
-| [keyDefinitions](./puppeteer.keydefinitions.md) | |
| [puppeteerErrors](./puppeteer.puppeteererrors.md) | |
## Type Aliases
@@ -72,7 +86,18 @@
| Type Alias | Description |
| --- | --- |
| [ConsoleMessageType](./puppeteer.consolemessagetype.md) | The supported types for console messages. |
-| [KeyInput](./puppeteer.keyinput.md) | |
-| [MouseButtonInput](./puppeteer.mousebuttoninput.md) | |
+| [DevicesMap](./puppeteer.devicesmap.md) | |
+| [EvaluateFn](./puppeteer.evaluatefn.md) | |
+| [EvaluateFnReturnType](./puppeteer.evaluatefnreturntype.md) | |
+| [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md) | |
+| [JSONArray](./puppeteer.jsonarray.md) | |
+| [KeyInput](./puppeteer.keyinput.md) | All the valid keys that can be passed to functions that take user input, such as [keyboard.press](./puppeteer.keyboard.press.md) |
+| [MouseButton](./puppeteer.mousebutton.md) | |
+| [Platform](./puppeteer.platform.md) | Supported platforms. |
+| [Product](./puppeteer.product.md) | Supported products. |
| [PuppeteerErrors](./puppeteer.puppeteererrors.md) | |
+| [Serializable](./puppeteer.serializable.md) | |
+| [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md) | |
+| [UnwrapElementHandle](./puppeteer.unwrapelementhandle.md) | Unwraps a DOM element out of an ElementHandle instance |
+| [WrapElementHandle](./puppeteer.wrapelementhandle.md) | Wraps a DOM element into an ElementHandle instance |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.metrics.md b/remote/test/puppeteer/new-docs/puppeteer.metrics.md
index ae8a3970e1a28..740f32d4ee91c 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.metrics.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.metrics.md
@@ -4,6 +4,7 @@
## Metrics interface
+
Signature:
```typescript
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse._button.md b/remote/test/puppeteer/new-docs/puppeteer.mouse._button.md
deleted file mode 100644
index eec43f862cc31..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse._button.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Mouse](./puppeteer.mouse.md) > [\_button](./puppeteer.mouse._button.md)
-
-## Mouse.\_button property
-
-Signature:
-
-```typescript
-_button: MouseButton;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse._client.md b/remote/test/puppeteer/new-docs/puppeteer.mouse._client.md
deleted file mode 100644
index 7c4de7315fe6a..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse._client.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Mouse](./puppeteer.mouse.md) > [\_client](./puppeteer.mouse._client.md)
-
-## Mouse.\_client property
-
-Signature:
-
-```typescript
-_client: CDPSession;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse._keyboard.md b/remote/test/puppeteer/new-docs/puppeteer.mouse._keyboard.md
deleted file mode 100644
index db7b2e2b5e7e2..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse._keyboard.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Mouse](./puppeteer.mouse.md) > [\_keyboard](./puppeteer.mouse._keyboard.md)
-
-## Mouse.\_keyboard property
-
-Signature:
-
-```typescript
-_keyboard: Keyboard;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse._x.md b/remote/test/puppeteer/new-docs/puppeteer.mouse._x.md
deleted file mode 100644
index cfedc193f9991..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse._x.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Mouse](./puppeteer.mouse.md) > [\_x](./puppeteer.mouse._x.md)
-
-## Mouse.\_x property
-
-Signature:
-
-```typescript
-_x: number;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse._y.md b/remote/test/puppeteer/new-docs/puppeteer.mouse._y.md
deleted file mode 100644
index a6200285366b1..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse._y.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Mouse](./puppeteer.mouse.md) > [\_y](./puppeteer.mouse._y.md)
-
-## Mouse.\_y property
-
-Signature:
-
-```typescript
-_y: number;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse.click.md b/remote/test/puppeteer/new-docs/puppeteer.mouse.click.md
index 4fa9645f800a6..adc356baf500f 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse.click.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.mouse.click.md
@@ -20,7 +20,7 @@ click(x: number, y: number, options?: MouseOptions & {
| --- | --- | --- |
| x | number | Horizontal position of the mouse. |
| y | number | Vertical position of the mouse. |
-| options | MouseOptions & { delay?: number; } | Optional MouseOptions
. |
+| options | [MouseOptions](./puppeteer.mouseoptions.md) & { delay?: number; } | Optional MouseOptions
. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse.down.md b/remote/test/puppeteer/new-docs/puppeteer.mouse.down.md
index b4c0f4641eb1f..ac3b6a6317bbe 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse.down.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.mouse.down.md
@@ -16,7 +16,7 @@ down(options?: MouseOptions): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| options | MouseOptions | Optional MouseOptions
. |
+| options | [MouseOptions](./puppeteer.mouseoptions.md) | Optional MouseOptions
. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse.md b/remote/test/puppeteer/new-docs/puppeteer.mouse.md
index a3ecd2b305138..8a5044cab0017 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.mouse.md
@@ -73,16 +73,6 @@ await browser.defaultBrowserContext().overridePermissions(
```
-## Properties
-
-| Property | Modifiers | Type | Description |
-| --- | --- | --- | --- |
-| [\_button](./puppeteer.mouse._button.md) | | MouseButton | |
-| [\_client](./puppeteer.mouse._client.md) | | [CDPSession](./puppeteer.cdpsession.md) | |
-| [\_keyboard](./puppeteer.mouse._keyboard.md) | | [Keyboard](./puppeteer.keyboard.md) | |
-| [\_x](./puppeteer.mouse._x.md) | | number | |
-| [\_y](./puppeteer.mouse._y.md) | | number | |
-
## Methods
| Method | Modifiers | Description |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouse.up.md b/remote/test/puppeteer/new-docs/puppeteer.mouse.up.md
index d8a4071fdf90f..b85abd625192a 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.mouse.up.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.mouse.up.md
@@ -16,7 +16,7 @@ up(options?: MouseOptions): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| options | MouseOptions | Optional MouseOptions
. |
+| options | [MouseOptions](./puppeteer.mouseoptions.md) | Optional MouseOptions
. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mousebuttoninput.md b/remote/test/puppeteer/new-docs/puppeteer.mousebutton.md
similarity index 55%
rename from remote/test/puppeteer/new-docs/puppeteer.mousebuttoninput.md
rename to remote/test/puppeteer/new-docs/puppeteer.mousebutton.md
index af8eb1803e646..e9f29aca333d8 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.mousebuttoninput.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.mousebutton.md
@@ -1,11 +1,12 @@
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [MouseButtonInput](./puppeteer.mousebuttoninput.md)
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [MouseButton](./puppeteer.mousebutton.md)
+
+## MouseButton type
-## MouseButtonInput type
Signature:
```typescript
-export declare type MouseButtonInput = Exclude;
+export declare type MouseButton = 'left' | 'right' | 'middle';
```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.button.md b/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.button.md
new file mode 100644
index 0000000000000..ba9dfec83498f
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.button.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [MouseOptions](./puppeteer.mouseoptions.md) > [button](./puppeteer.mouseoptions.button.md)
+
+## MouseOptions.button property
+
+Signature:
+
+```typescript
+button?: MouseButton;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.clickcount.md b/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.clickcount.md
new file mode 100644
index 0000000000000..799e1b299a00e
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.clickcount.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [MouseOptions](./puppeteer.mouseoptions.md) > [clickCount](./puppeteer.mouseoptions.clickcount.md)
+
+## MouseOptions.clickCount property
+
+Signature:
+
+```typescript
+clickCount?: number;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.md b/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.md
new file mode 100644
index 0000000000000..897c185af1a66
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.mouseoptions.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [MouseOptions](./puppeteer.mouseoptions.md)
+
+## MouseOptions interface
+
+
+Signature:
+
+```typescript
+export interface MouseOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [button](./puppeteer.mouseoptions.button.md) | [MouseButton](./puppeteer.mousebutton.md) | |
+| [clickCount](./puppeteer.mouseoptions.clickcount.md) | number | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page._.md b/remote/test/puppeteer/new-docs/puppeteer.page._.md
index 1f444aa3d4cbe..ce3fea2d45003 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page._.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page._.md
@@ -4,6 +4,8 @@
## Page.$() method
+Runs `document.querySelector` within the page. If no element matches the selector, the return value resolves to `null`.
+
Signature:
```typescript
@@ -14,9 +16,13 @@ $(selector: string): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| selector | string | |
+| selector | string | A [selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) to query page for. |
Returns:
Promise<[ElementHandle](./puppeteer.elementhandle.md) \| null>
+## Remarks
+
+Shortcut for [Page.mainFrame().$(selector)](./puppeteer.frame._.md).
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.__eval.md b/remote/test/puppeteer/new-docs/puppeteer.page.__eval.md
index 4c7800a501902..3bcb6aea42873 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.__eval.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.__eval.md
@@ -7,7 +7,7 @@
Signature:
```typescript
-$$eval(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise;
+$$eval(selector: string, pageFunction: EvaluateFn | string, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
@@ -15,8 +15,8 @@ $$eval(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)\[\] | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page._eval.md b/remote/test/puppeteer/new-docs/puppeteer.page._eval.md
index d5b18ad8e7794..903b654f16e23 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page._eval.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page._eval.md
@@ -4,21 +4,65 @@
## Page.$eval() method
+This method runs `document.querySelector` within the page and passes the result as the first argument to the `pageFunction`.
+
Signature:
```typescript
-$eval(selector: string, pageFunction: Function | string, ...args: unknown[]): Promise;
+$eval(selector: string, pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise, ...args: SerializableOrJSHandle[]): Promise>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| selector | string | |
-| pageFunction | Function \| string | |
-| args | unknown\[\] | |
+| selector | string | the [selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) to query for |
+| pageFunction | (element: Element, ...args: unknown\[\]) => ReturnType \| Promise<ReturnType> | the function to be evaluated in the page context. Will be passed the result of document.querySelector(selector)
as its first argument. |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | any additional arguments to pass through to pageFunction
. |
Returns:
-Promise<ReturnType>
+Promise<[WrapElementHandle](./puppeteer.wrapelementhandle.md)<ReturnType>>
+
+The result of calling `pageFunction`. If it returns an element it is wrapped in an [ElementHandle](./puppeteer.elementhandle.md), else the raw value itself is returned.
+
+## Remarks
+
+If no element is found matching `selector`, the method will throw an error.
+
+If `pageFunction` returns a promise `$eval` will wait for the promise to resolve and then return its value.
+
+## Example 1
+
+
+```
+const searchValue = await page.$eval('#search', el => el.value);
+const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
+const html = await page.$eval('.main-container', el => el.outerHTML);
+
+```
+If you are using TypeScript, you may have to provide an explicit type to the first argument of the `pageFunction`. By default it is typed as `Element`, but you may need to provide a more specific sub-type:
+
+## Example 2
+
+
+```
+// if you don't provide HTMLInputElement here, TS will error
+// as `value` is not on `Element`
+const searchValue = await page.$eval('#search', (el: HTMLInputElement) => el.value);
+
+```
+The compiler should be able to infer the return type from the `pageFunction` you provide. If it is unable to, you can use the generic type to tell the compiler what return type you expect from `$eval`:
+
+## Example 3
+
+
+```
+// The compiler can infer the return type in this case, but if it can't
+// or if you want to be more explicit, provide it as the generic type.
+const searchValue = await page.$eval(
+ '#search', (el: HTMLInputElement) => el.value
+);
+
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.browser.md b/remote/test/puppeteer/new-docs/puppeteer.page.browser.md
index 9d6ba8690e023..400cdfee654bc 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.browser.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.browser.md
@@ -13,3 +13,5 @@ browser(): Browser;
[Browser](./puppeteer.browser.md)
+The browser this page belongs to.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.browsercontext.md b/remote/test/puppeteer/new-docs/puppeteer.page.browsercontext.md
index 5988e324b039a..d4c0f09824487 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.browsercontext.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.browsercontext.md
@@ -13,3 +13,5 @@ browserContext(): BrowserContext;
[BrowserContext](./puppeteer.browsercontext.md)
+The browser context that the page belongs to
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.click.md b/remote/test/puppeteer/new-docs/puppeteer.page.click.md
index 62317e8f84204..3366641dd27ed 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.click.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.click.md
@@ -9,7 +9,7 @@
```typescript
click(selector: string, options?: {
delay?: number;
- button?: MouseButtonInput;
+ button?: MouseButton;
clickCount?: number;
}): Promise;
```
@@ -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; } | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.evaluatehandle.md b/remote/test/puppeteer/new-docs/puppeteer.page.evaluatehandle.md
index 6d1142de3366d..5c56ce2453573 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.evaluatehandle.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.evaluatehandle.md
@@ -7,17 +7,62 @@
Signature:
```typescript
-evaluateHandle(pageFunction: Function | string, ...args: unknown[]): Promise;
+evaluateHandle(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| pageFunction | Function \| string | |
-| args | unknown\[\] | |
+| pageFunction | [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md) | a function that is run within the page |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | arguments to be passed to the pageFunction |
Returns:
-Promise<[JSHandle](./puppeteer.jshandle.md)>
+Promise<HandlerType>
+
+## Remarks
+
+The only difference between [page.evaluate](./puppeteer.page.evaluate.md) and `page.evaluateHandle` is that `evaluateHandle` will return the value wrapped in an in-page object.
+
+If the function passed to `page.evaluteHandle` returns a Promise, the function will wait for the promise to resolve and return its value.
+
+You can pass a string instead of a function (although functions are recommended as they are easier to debug and use with TypeScript):
+
+## Example 1
+
+
+```
+const aHandle = await page.evaluateHandle('document')
+
+```
+
+## Example 2
+
+[JSHandle](./puppeteer.jshandle.md) instances can be passed as arguments to the `pageFunction`:
+
+```
+const aHandle = await page.evaluateHandle(() => document.body);
+const resultHandle = await page.evaluateHandle(body => body.innerHTML, aHandle);
+console.log(await resultHandle.jsonValue());
+await resultHandle.dispose();
+
+```
+Most of the time this function returns a [JSHandle](./puppeteer.jshandle.md), but if `pageFunction` returns a reference to an element, you instead get an [ElementHandle](./puppeteer.elementhandle.md) back:
+
+## Example 3
+
+
+```
+const button = await page.evaluateHandle(() => document.querySelector('button'));
+// can call `click` because `button` is an `ElementHandle`
+await button.click();
+
+```
+The TypeScript definitions assume that `evaluateHandle` returns a `JSHandle`, but if you know it's going to return an `ElementHandle`, pass it as the generic argument:
+
+```
+const button = await page.evaluateHandle(...);
+
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.frames.md b/remote/test/puppeteer/new-docs/puppeteer.page.frames.md
index e1841d642d92a..1a44ccc11788e 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.frames.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.frames.md
@@ -13,3 +13,5 @@ frames(): Frame[];
[Frame](./puppeteer.frame.md)\[\]
+An array of all frames attached to the page.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.goback.md b/remote/test/puppeteer/new-docs/puppeteer.page.goback.md
index 50dd929482006..169fb6a8a2039 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.goback.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.goback.md
@@ -14,7 +14,7 @@ goBack(options?: WaitForOptions): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| options | WaitForOptions | |
+| options | [WaitForOptions](./puppeteer.waitforoptions.md) | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.goforward.md b/remote/test/puppeteer/new-docs/puppeteer.page.goforward.md
index aea9d75c868bf..a6def6b09d274 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.goforward.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.goforward.md
@@ -14,7 +14,7 @@ goForward(options?: WaitForOptions): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| options | WaitForOptions | |
+| options | [WaitForOptions](./puppeteer.waitforoptions.md) | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.goto.md b/remote/test/puppeteer/new-docs/puppeteer.page.goto.md
index f43ef671511ab..1bdb92f3d25cc 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.goto.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.goto.md
@@ -17,7 +17,7 @@ goto(url: string, options?: WaitForOptions & {
| Parameter | Type | Description |
| --- | --- | --- |
| url | string | |
-| options | WaitForOptions & { referer?: string; } | |
+| options | [WaitForOptions](./puppeteer.waitforoptions.md) & { referer?: string; } | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.isjavascriptenabled.md b/remote/test/puppeteer/new-docs/puppeteer.page.isjavascriptenabled.md
index 8cc5a92c7b9e9..f5ca9fb58cfd0 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.isjavascriptenabled.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.isjavascriptenabled.md
@@ -13,3 +13,5 @@ isJavaScriptEnabled(): boolean;
boolean
+`true` if the page has JavaScript enabled, `false` otherwise.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.mainframe.md b/remote/test/puppeteer/new-docs/puppeteer.page.mainframe.md
index e452cf7299962..19a6c8610e73a 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.mainframe.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.mainframe.md
@@ -13,3 +13,5 @@ mainFrame(): Frame;
[Frame](./puppeteer.frame.md)
+The page's main frame.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.md b/remote/test/puppeteer/new-docs/puppeteer.page.md
index fc1c7965b277c..9b205b6db3412 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.md
@@ -70,10 +70,10 @@ page.off('request', logRequest);
| Method | Modifiers | Description |
| --- | --- | --- |
-| [$(selector)](./puppeteer.page._.md) | | |
+| [$(selector)](./puppeteer.page._.md) | | Runs document.querySelector
within the page. If no element matches the selector, the return value resolves to null
. |
| [$$(selector)](./puppeteer.page.__.md) | | |
| [$$eval(selector, pageFunction, args)](./puppeteer.page.__eval.md) | | |
-| [$eval(selector, pageFunction, args)](./puppeteer.page._eval.md) | | |
+| [$eval(selector, pageFunction, args)](./puppeteer.page._eval.md) | | This method runs document.querySelector
within the page and passes the result as the first argument to the pageFunction
. |
| [$x(expression)](./puppeteer.page._x.md) | | |
| [addScriptTag(options)](./puppeteer.page.addscripttag.md) | | |
| [addStyleTag(options)](./puppeteer.page.addstyletag.md) | | |
@@ -117,7 +117,7 @@ page.off('request', logRequest);
| [setDefaultNavigationTimeout(timeout)](./puppeteer.page.setdefaultnavigationtimeout.md) | | |
| [setDefaultTimeout(timeout)](./puppeteer.page.setdefaulttimeout.md) | | |
| [setExtraHTTPHeaders(headers)](./puppeteer.page.setextrahttpheaders.md) | | |
-| [setGeolocation(options)](./puppeteer.page.setgeolocation.md) | | |
+| [setGeolocation(options)](./puppeteer.page.setgeolocation.md) | | Sets the page's geolocation. |
| [setJavaScriptEnabled(enabled)](./puppeteer.page.setjavascriptenabled.md) | | |
| [setOfflineMode(enabled)](./puppeteer.page.setofflinemode.md) | | |
| [setRequestInterception(value)](./puppeteer.page.setrequestinterception.md) | | |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.reload.md b/remote/test/puppeteer/new-docs/puppeteer.page.reload.md
index fb6a75c53927f..f4f2c681d038b 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.reload.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.reload.md
@@ -14,7 +14,7 @@ reload(options?: WaitForOptions): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| options | WaitForOptions | |
+| options | [WaitForOptions](./puppeteer.waitforoptions.md) | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.setcontent.md b/remote/test/puppeteer/new-docs/puppeteer.page.setcontent.md
index af10901020530..e8732650e04e9 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.setcontent.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.setcontent.md
@@ -15,7 +15,7 @@ setContent(html: string, options?: WaitForOptions): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
| html | string | |
-| options | WaitForOptions | |
+| options | [WaitForOptions](./puppeteer.waitforoptions.md) | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.setdefaultnavigationtimeout.md b/remote/test/puppeteer/new-docs/puppeteer.page.setdefaultnavigationtimeout.md
index 22c4cc052d80f..2085c0363a8a9 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.setdefaultnavigationtimeout.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.setdefaultnavigationtimeout.md
@@ -14,7 +14,7 @@ setDefaultNavigationTimeout(timeout: number): void;
| Parameter | Type | Description |
| --- | --- | --- |
-| timeout | number | |
+| timeout | number | Maximum navigation time in milliseconds. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.setdefaulttimeout.md b/remote/test/puppeteer/new-docs/puppeteer.page.setdefaulttimeout.md
index b3f097584f2a2..1382d0264c800 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.setdefaulttimeout.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.setdefaulttimeout.md
@@ -14,7 +14,7 @@ setDefaultTimeout(timeout: number): void;
| Parameter | Type | Description |
| --- | --- | --- |
-| timeout | number | |
+| timeout | number | Maximum time in milliseconds. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.setgeolocation.md b/remote/test/puppeteer/new-docs/puppeteer.page.setgeolocation.md
index add5c80a86065..65ae8f2941b0e 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.setgeolocation.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.setgeolocation.md
@@ -4,23 +4,33 @@
## Page.setGeolocation() method
+Sets the page's geolocation.
+
Signature:
```typescript
-setGeolocation(options: {
- longitude: number;
- latitude: number;
- accuracy?: number;
- }): Promise;
+setGeolocation(options: GeolocationOptions): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| options | { longitude: number; latitude: number; accuracy?: number; } | |
+| options | [GeolocationOptions](./puppeteer.geolocationoptions.md) | |
Returns:
Promise<void>
+## Remarks
+
+Consider using [BrowserContext.overridePermissions()](./puppeteer.browsercontext.overridepermissions.md) to grant permissions for the page to read its geolocation.
+
+## Example
+
+
+```js
+await page.setGeolocation({latitude: 59.95, longitude: 30.31667});
+
+```
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.setofflinemode.md b/remote/test/puppeteer/new-docs/puppeteer.page.setofflinemode.md
index 979b0b6aa0ac5..a43465a56268b 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.setofflinemode.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.setofflinemode.md
@@ -14,7 +14,7 @@ setOfflineMode(enabled: boolean): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| enabled | boolean | |
+| enabled | boolean | When true
, enables offline mode for the page. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.setrequestinterception.md b/remote/test/puppeteer/new-docs/puppeteer.page.setrequestinterception.md
index bec372b30f2f1..8de3329f1b06d 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.setrequestinterception.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.setrequestinterception.md
@@ -14,9 +14,40 @@ setRequestInterception(value: boolean): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| value | boolean | |
+| value | boolean | Whether to enable request interception. |
Returns:
Promise<void>
+## Remarks
+
+Activating request interception enables [HTTPRequest.abort()](./puppeteer.httprequest.abort.md), [HTTPRequest.continue()](./puppeteer.httprequest.continue.md) and [HTTPRequest.respond()](./puppeteer.httprequest.respond.md) methods. This provides the capability to modify network requests that are made by a page.
+
+Once request interception is enabled, every request will stall unless it's continued, responded or aborted.
+
+\*\*NOTE\*\* Enabling request interception disables page caching.
+
+## Example
+
+An example of a naïve request interceptor that aborts all image requests:
+
+```js
+const puppeteer = require('puppeteer');
+(async () => {
+ const browser = await puppeteer.launch();
+ const page = await browser.newPage();
+ await page.setRequestInterception(true);
+ page.on('request', interceptedRequest => {
+ if (interceptedRequest.url().endsWith('.png') ||
+ interceptedRequest.url().endsWith('.jpg'))
+ interceptedRequest.abort();
+ else
+ interceptedRequest.continue();
+ });
+ await page.goto('https://example.com');
+ await browser.close();
+})();
+
+```
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.target.md b/remote/test/puppeteer/new-docs/puppeteer.page.target.md
index 5525649d13acc..be1079abcfc51 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.target.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.target.md
@@ -13,3 +13,5 @@ target(): Target;
[Target](./puppeteer.target.md)
+A target this page was created from.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.waitfor.md b/remote/test/puppeteer/new-docs/puppeteer.page.waitfor.md
index 8a2eb518ab408..e808df9af69a8 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.waitfor.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.waitfor.md
@@ -12,7 +12,7 @@ waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {
hidden?: boolean;
timeout?: number;
polling?: string | number;
- }, ...args: unknown[]): Promise;
+ }, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
@@ -21,7 +21,7 @@ waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {
| --- | --- | --- |
| selectorOrFunctionOrTimeout | string \| number \| Function | |
| options | { visible?: boolean; hidden?: boolean; timeout?: number; polling?: string \| number; } | |
-| args | unknown\[\] | |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.waitforfilechooser.md b/remote/test/puppeteer/new-docs/puppeteer.page.waitforfilechooser.md
index 7dbf5dcb5908d..4a486d9983aa6 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.waitforfilechooser.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.waitforfilechooser.md
@@ -7,18 +7,18 @@
Signature:
```typescript
-waitForFileChooser(options?: {
- timeout?: number;
- }): Promise;
+waitForFileChooser(options?: WaitTimeoutOptions): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| options | { timeout?: number; } | |
+| options | [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) | Optional waiting parameters |
Returns:
Promise<[FileChooser](./puppeteer.filechooser.md)>
+Resolves after a page requests a file picker.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.waitforfunction.md b/remote/test/puppeteer/new-docs/puppeteer.page.waitforfunction.md
index 697ff57dfc71b..e18be0769aeaa 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.waitforfunction.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.waitforfunction.md
@@ -10,7 +10,7 @@
waitForFunction(pageFunction: Function | string, options?: {
timeout?: number;
polling?: string | number;
- }, ...args: unknown[]): Promise;
+ }, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
@@ -19,7 +19,7 @@ waitForFunction(pageFunction: Function | string, options?: {
| --- | --- | --- |
| pageFunction | Function \| string | |
| options | { timeout?: number; polling?: string \| number; } | |
-| args | unknown\[\] | |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.waitfornavigation.md b/remote/test/puppeteer/new-docs/puppeteer.page.waitfornavigation.md
index d1d7ca2474c4d..109f10e48b46b 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.waitfornavigation.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.waitfornavigation.md
@@ -14,7 +14,7 @@ waitForNavigation(options?: WaitForOptions): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| options | WaitForOptions | |
+| options | [WaitForOptions](./puppeteer.waitforoptions.md) | |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.page.workers.md b/remote/test/puppeteer/new-docs/puppeteer.page.workers.md
index 6202c7303d43d..818d9ed7c8108 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.page.workers.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.page.workers.md
@@ -13,3 +13,5 @@ workers(): WebWorker[];
[WebWorker](./puppeteer.webworker.md)\[\]
+all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) associated with the page.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.platform.md b/remote/test/puppeteer/new-docs/puppeteer.platform.md
new file mode 100644
index 0000000000000..03e8b72dbd427
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.platform.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [Platform](./puppeteer.platform.md)
+
+## Platform type
+
+Supported platforms.
+
+Signature:
+
+```typescript
+export declare type Platform = 'linux' | 'mac' | 'win32' | 'win64';
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.product.md b/remote/test/puppeteer/new-docs/puppeteer.product.md
new file mode 100644
index 0000000000000..1d7e0c025b71d
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.product.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [Product](./puppeteer.product.md)
+
+## Product type
+
+Supported products.
+
+Signature:
+
+```typescript
+export declare type Product = 'chrome' | 'firefox';
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.productlauncher.connect.md b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.connect.md
new file mode 100644
index 0000000000000..6837409efe93a
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.connect.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ProductLauncher](./puppeteer.productlauncher.md) > [connect](./puppeteer.productlauncher.connect.md)
+
+## ProductLauncher.connect() method
+
+Signature:
+
+```typescript
+connect(object: any): any;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| object | any | |
+
+Returns:
+
+any
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.productlauncher.defaultargs.md b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.defaultargs.md
new file mode 100644
index 0000000000000..be1009e3b63ac
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.defaultargs.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ProductLauncher](./puppeteer.productlauncher.md) > [defaultArgs](./puppeteer.productlauncher.defaultargs.md)
+
+## ProductLauncher.defaultArgs() method
+
+Signature:
+
+```typescript
+defaultArgs(object: any): any;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| object | any | |
+
+Returns:
+
+any
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.productlauncher.executablepath.md b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.executablepath.md
new file mode 100644
index 0000000000000..ac30111cc356e
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.executablepath.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ProductLauncher](./puppeteer.productlauncher.md) > [executablePath](./puppeteer.productlauncher.executablepath.md)
+
+## ProductLauncher.executablePath property
+
+Signature:
+
+```typescript
+executablePath: () => string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.productlauncher.launch.md b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.launch.md
new file mode 100644
index 0000000000000..cfe35879a0ea7
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.launch.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ProductLauncher](./puppeteer.productlauncher.md) > [launch](./puppeteer.productlauncher.launch.md)
+
+## ProductLauncher.launch() method
+
+Signature:
+
+```typescript
+launch(object: any): any;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| object | any | |
+
+Returns:
+
+any
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.productlauncher.md b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.md
new file mode 100644
index 0000000000000..4f3dc6fa3c3b8
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.md
@@ -0,0 +1,29 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ProductLauncher](./puppeteer.productlauncher.md)
+
+## ProductLauncher interface
+
+Describes a launcher - a class that is able to create and launch a browser instance.
+
+Signature:
+
+```typescript
+export interface ProductLauncher
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [executablePath](./puppeteer.productlauncher.executablepath.md) | () => string | |
+| [product](./puppeteer.productlauncher.product.md) | string | |
+
+## Methods
+
+| Method | Description |
+| --- | --- |
+| [connect(object)](./puppeteer.productlauncher.connect.md) | |
+| [defaultArgs(object)](./puppeteer.productlauncher.defaultargs.md) | |
+| [launch(object)](./puppeteer.productlauncher.launch.md) | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.productlauncher.product.md b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.product.md
new file mode 100644
index 0000000000000..6d906bad253c4
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.productlauncher.product.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [ProductLauncher](./puppeteer.productlauncher.md) > [product](./puppeteer.productlauncher.product.md)
+
+## ProductLauncher.product property
+
+Signature:
+
+```typescript
+product: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_clearqueryhandlers.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_clearqueryhandlers.md
deleted file mode 100644
index 472cda91f80d8..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_clearqueryhandlers.md
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_\_experimental\_clearQueryHandlers](./puppeteer.puppeteer.__experimental_clearqueryhandlers.md)
-
-## Puppeteer.\_\_experimental\_clearQueryHandlers() method
-
-Signature:
-
-```typescript
-__experimental_clearQueryHandlers(): void;
-```
-Returns:
-
-void
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_customqueryhandlers.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_customqueryhandlers.md
deleted file mode 100644
index a0a3a011db2bd..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_customqueryhandlers.md
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_\_experimental\_customQueryHandlers](./puppeteer.puppeteer.__experimental_customqueryhandlers.md)
-
-## Puppeteer.\_\_experimental\_customQueryHandlers() method
-
-Signature:
-
-```typescript
-__experimental_customQueryHandlers(): Map;
-```
-Returns:
-
-Map<string, QueryHandler>
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_registercustomqueryhandler.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_registercustomqueryhandler.md
deleted file mode 100644
index a82909a005054..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_registercustomqueryhandler.md
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_\_experimental\_registerCustomQueryHandler](./puppeteer.puppeteer.__experimental_registercustomqueryhandler.md)
-
-## Puppeteer.\_\_experimental\_registerCustomQueryHandler() method
-
-Signature:
-
-```typescript
-__experimental_registerCustomQueryHandler(name: string, queryHandler: QueryHandler): void;
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| name | string | |
-| queryHandler | QueryHandler | |
-
-Returns:
-
-void
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_unregistercustomqueryhandler.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_unregistercustomqueryhandler.md
deleted file mode 100644
index 849952443275a..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.__experimental_unregistercustomqueryhandler.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_\_experimental\_unregisterCustomQueryHandler](./puppeteer.puppeteer.__experimental_unregistercustomqueryhandler.md)
-
-## Puppeteer.\_\_experimental\_unregisterCustomQueryHandler() method
-
-Signature:
-
-```typescript
-__experimental_unregisterCustomQueryHandler(name: string): void;
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| name | string | |
-
-Returns:
-
-void
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer._constructor_.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer._constructor_.md
deleted file mode 100644
index 1c81db8fe1cf0..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer._constructor_.md
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [(constructor)](./puppeteer.puppeteer._constructor_.md)
-
-## Puppeteer.(constructor)
-
-Constructs a new instance of the `Puppeteer` class
-
-Signature:
-
-```typescript
-constructor(projectRoot: string, preferredRevision: string, isPuppeteerCore: boolean, productName: string);
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| projectRoot | string | |
-| preferredRevision | string | |
-| isPuppeteerCore | boolean | |
-| productName | string | |
-
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer._launcher.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer._launcher.md
deleted file mode 100644
index df1596e2e3211..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer._launcher.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_launcher](./puppeteer.puppeteer._launcher.md)
-
-## Puppeteer.\_launcher property
-
-Signature:
-
-```typescript
-get _launcher(): ProductLauncher;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer._productname.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer._productname.md
deleted file mode 100644
index 9c00de81a9d5e..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer._productname.md
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_productName](./puppeteer.puppeteer._productname.md)
-
-## Puppeteer.\_productName property
-
-Signature:
-
-```typescript
-get _productName(): string;
-
-set _productName(name: string);
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer._projectroot.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer._projectroot.md
deleted file mode 100644
index 215226cc8552f..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer._projectroot.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_projectRoot](./puppeteer.puppeteer._projectroot.md)
-
-## Puppeteer.\_projectRoot property
-
-Signature:
-
-```typescript
-_projectRoot: string;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.connect.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.connect.md
index 36baa350a0ac4..7e99b6081c049 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.connect.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.connect.md
@@ -4,6 +4,8 @@
## Puppeteer.connect() method
+This method attaches Puppeteer to an existing browser instance.
+
Signature:
```typescript
@@ -19,9 +21,14 @@ connect(options: BrowserOptions & {
| Parameter | Type | Description |
| --- | --- | --- |
-| options | BrowserOptions & { browserWSEndpoint?: string; browserURL?: string; transport?: ConnectionTransport; product?: string; } | |
+| options | [BrowserOptions](./puppeteer.browseroptions.md) & { browserWSEndpoint?: string; browserURL?: string; transport?: ConnectionTransport; product?: string; } | Set of configurable options to set on the browser. |
Returns:
Promise<[Browser](./puppeteer.browser.md)>
+Promise which resolves to browser instance.
+
+## Remarks
+
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.createbrowserfetcher.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.createbrowserfetcher.md
index dffbddfa87dfd..0aecc97bec783 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.createbrowserfetcher.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.createbrowserfetcher.md
@@ -14,9 +14,11 @@ createBrowserFetcher(options: BrowserFetcherOptions): BrowserFetcher;
| Parameter | Type | Description |
| --- | --- | --- |
-| options | [BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md) | |
+| options | [BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md) | Set of configurable options to specify the settings of the BrowserFetcher. |
Returns:
[BrowserFetcher](./puppeteer.browserfetcher.md)
+A new BrowserFetcher instance.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.defaultargs.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.defaultargs.md
index ff0d72ee55c62..007d602a25c5a 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.defaultargs.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.defaultargs.md
@@ -14,9 +14,11 @@ defaultArgs(options?: ChromeArgOptions): string[];
| Parameter | Type | Description |
| --- | --- | --- |
-| options | ChromeArgOptions | |
+| options | [ChromeArgOptions](./puppeteer.chromeargoptions.md) | Set of configurable options to set on the browser. |
Returns:
string\[\]
+The default flags that Chromium will be launched with.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.devices.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.devices.md
index 82469af5b85c4..9a5379dc44363 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.devices.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.devices.md
@@ -9,3 +9,25 @@
```typescript
get devices(): DevicesMap;
```
+
+## Remarks
+
+
+## Example
+
+
+```js
+const puppeteer = require('puppeteer');
+const iPhone = puppeteer.devices['iPhone 6'];
+
+(async () => {
+ const browser = await puppeteer.launch();
+ const page = await browser.newPage();
+ await page.emulate(iPhone);
+ await page.goto('https://www.google.com');
+ // other actions...
+ await browser.close();
+})();
+
+```
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.errors.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.errors.md
index a614dbd5b59cb..f81b4cb41899b 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.errors.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.errors.md
@@ -9,3 +9,25 @@
```typescript
get errors(): PuppeteerErrors;
```
+
+## Remarks
+
+Puppeteer methods might throw errors if they are unable to fulfill a request. For example, `page.waitForSelector(selector[, options])` might fail if the selector doesn't match any nodes during the given timeframe.
+
+For certain types of errors Puppeteer uses specific error classes. These classes are available via `puppeteer.errors`
+
+## Example
+
+An example of handling a timeout error:
+
+```js
+try {
+ await page.waitForSelector('.foo');
+} catch (e) {
+ if (e instanceof puppeteer.errors.TimeoutError) {
+ // Do something if this is a timeout.
+ }
+}
+
+```
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.executablepath.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.executablepath.md
index 7e05dc3a81ba0..970f70a81d071 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.executablepath.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.executablepath.md
@@ -13,3 +13,9 @@ executablePath(): string;
string
+A path where Puppeteer expects to find the bundled browser. The browser binary might not be there if the download was skipped with the `PUPPETEER_SKIP_DOWNLOAD` environment variable.
+
+## Remarks
+
+\*\*NOTE\*\* `puppeteer.executablePath()` is affected by the `PUPPETEER_EXECUTABLE_PATH` and `PUPPETEER_CHROMIUM_REVISION` environment variables.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.launch.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.launch.md
index 6b458e5c9c105..e68a4004afa10 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.launch.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.launch.md
@@ -4,6 +4,8 @@
## Puppeteer.launch() method
+Launches puppeteer and launches a browser instance with given arguments and options when specified.
+
Signature:
```typescript
@@ -17,9 +19,26 @@ launch(options?: LaunchOptions & ChromeArgOptions & BrowserOptions & {
| Parameter | Type | Description |
| --- | --- | --- |
-| options | LaunchOptions & ChromeArgOptions & BrowserOptions & { product?: string; extraPrefsFirefox?: {}; } | |
+| options | [LaunchOptions](./puppeteer.launchoptions.md) & [ChromeArgOptions](./puppeteer.chromeargoptions.md) & [BrowserOptions](./puppeteer.browseroptions.md) & { product?: string; extraPrefsFirefox?: {}; } | Set of configurable options to set on the browser. |
Returns:
Promise<[Browser](./puppeteer.browser.md)>
+Promise which resolves to browser instance.
+
+## Remarks
+
+
+## Example
+
+You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
+
+```js
+const browser = await puppeteer.launch({
+ ignoreDefaultArgs: ['--mute-audio']
+});
+
+```
+\*\*NOTE\*\* Puppeteer can also be used to control the Chrome browser, but it works best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use `executablePath` option with extreme caution. If Google Chrome (rather than Chromium) is preferred, a [Chrome Canary](https://www.google.com/chrome/browser/canary.html) or [Dev Channel](https://www.chromium.org/getting-involved/dev-channel) build is suggested. In `puppeteer.launch([options])`, any mention of Chromium also applies to Chrome. 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/+/lkgr/docs/chromium_browser_vs_google_chrome.md) describes some differences for Linux users.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.md
index bfbf737dc2e11..eb0adb5cc61a2 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.md
@@ -4,7 +4,7 @@
## Puppeteer class
-The main Puppeteer class
+The main Puppeteer class Puppeteer module provides a method to launch a browser instance.
Signature:
@@ -12,11 +12,26 @@ The main Puppeteer class
export declare class Puppeteer
```
-## Constructors
+## Remarks
-| Constructor | Modifiers | Description |
-| --- | --- | --- |
-| [(constructor)(projectRoot, preferredRevision, isPuppeteerCore, productName)](./puppeteer.puppeteer._constructor_.md) | | Constructs a new instance of the Puppeteer
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 `Puppeteer` class.
+
+## Example
+
+The following is a typical example of using Puppeteer to drive automation:
+
+```js
+const puppeteer = require('puppeteer');
+
+(async () => {
+ const browser = await puppeteer.launch();
+ const page = await browser.newPage();
+ await page.goto('https://www.google.com');
+ // other actions...
+ await browser.close();
+})();
+
+```
## Properties
@@ -25,12 +40,9 @@ export declare class Puppeteer
| [\_\_productName](./puppeteer.puppeteer.__productname.md) | | string | |
| [\_changedProduct](./puppeteer.puppeteer._changedproduct.md) | | boolean | |
| [\_isPuppeteerCore](./puppeteer.puppeteer._ispuppeteercore.md) | | boolean | |
-| [\_launcher](./puppeteer.puppeteer._launcher.md) | | ProductLauncher | |
-| [\_lazyLauncher](./puppeteer.puppeteer._lazylauncher.md) | | ProductLauncher | |
+| [\_lazyLauncher](./puppeteer.puppeteer._lazylauncher.md) | | [ProductLauncher](./puppeteer.productlauncher.md) | |
| [\_preferredRevision](./puppeteer.puppeteer._preferredrevision.md) | | string | |
-| [\_productName](./puppeteer.puppeteer._productname.md) | | string | |
-| [\_projectRoot](./puppeteer.puppeteer._projectroot.md) | | string | |
-| [devices](./puppeteer.puppeteer.devices.md) | | DevicesMap | |
+| [devices](./puppeteer.puppeteer.devices.md) | | [DevicesMap](./puppeteer.devicesmap.md) | |
| [errors](./puppeteer.puppeteer.errors.md) | | [PuppeteerErrors](./puppeteer.puppeteererrors.md) | |
| [product](./puppeteer.puppeteer.product.md) | | string | |
@@ -38,13 +50,9 @@ export declare class Puppeteer
| Method | Modifiers | Description |
| --- | --- | --- |
-| [\_\_experimental\_clearQueryHandlers()](./puppeteer.puppeteer.__experimental_clearqueryhandlers.md) | | |
-| [\_\_experimental\_customQueryHandlers()](./puppeteer.puppeteer.__experimental_customqueryhandlers.md) | | |
-| [\_\_experimental\_registerCustomQueryHandler(name, queryHandler)](./puppeteer.puppeteer.__experimental_registercustomqueryhandler.md) | | |
-| [\_\_experimental\_unregisterCustomQueryHandler(name)](./puppeteer.puppeteer.__experimental_unregistercustomqueryhandler.md) | | |
-| [connect(options)](./puppeteer.puppeteer.connect.md) | | |
+| [connect(options)](./puppeteer.puppeteer.connect.md) | | This method attaches Puppeteer to an existing browser instance. |
| [createBrowserFetcher(options)](./puppeteer.puppeteer.createbrowserfetcher.md) | | |
| [defaultArgs(options)](./puppeteer.puppeteer.defaultargs.md) | | |
| [executablePath()](./puppeteer.puppeteer.executablepath.md) | | |
-| [launch(options)](./puppeteer.puppeteer.launch.md) | | |
+| [launch(options)](./puppeteer.puppeteer.launch.md) | | Launches puppeteer and launches a browser instance with given arguments and options when specified. |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.product.md b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.product.md
index 93ef07315b4c6..465211c69b426 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.puppeteer.product.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.puppeteer.product.md
@@ -9,3 +9,8 @@
```typescript
get product(): string;
```
+
+## Remarks
+
+The product is set by the `PUPPETEER_PRODUCT` environment variable or the `product` option in `puppeteer.launch([options])` and defaults to `chrome`. Firefox support is experimental.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.ip.md b/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.ip.md
new file mode 100644
index 0000000000000..2dba06574f24d
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.ip.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [RemoteAddress](./puppeteer.remoteaddress.md) > [ip](./puppeteer.remoteaddress.ip.md)
+
+## RemoteAddress.ip property
+
+Signature:
+
+```typescript
+ip: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.md b/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.md
new file mode 100644
index 0000000000000..a9b5568c0f803
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [RemoteAddress](./puppeteer.remoteaddress.md)
+
+## RemoteAddress interface
+
+
+Signature:
+
+```typescript
+export interface RemoteAddress
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [ip](./puppeteer.remoteaddress.ip.md) | string | |
+| [port](./puppeteer.remoteaddress.port.md) | number | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.port.md b/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.port.md
new file mode 100644
index 0000000000000..631f54697c228
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.remoteaddress.port.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [RemoteAddress](./puppeteer.remoteaddress.md) > [port](./puppeteer.remoteaddress.port.md)
+
+## RemoteAddress.port property
+
+Signature:
+
+```typescript
+port: number;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.serializable.md b/remote/test/puppeteer/new-docs/puppeteer.serializable.md
new file mode 100644
index 0000000000000..8b7a7df8bf15b
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.serializable.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [Serializable](./puppeteer.serializable.md)
+
+## Serializable type
+
+
+Signature:
+
+```typescript
+export declare type Serializable = number | string | boolean | null | JSONArray | JSONObject;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.serializableorjshandle.md b/remote/test/puppeteer/new-docs/puppeteer.serializableorjshandle.md
new file mode 100644
index 0000000000000..84ca6eed8e584
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.serializableorjshandle.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)
+
+## SerializableOrJSHandle type
+
+
+Signature:
+
+```typescript
+export declare type SerializableOrJSHandle = Serializable | JSHandle;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.touchscreen._client.md b/remote/test/puppeteer/new-docs/puppeteer.touchscreen._client.md
deleted file mode 100644
index c0e1f1ca845e2..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.touchscreen._client.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Touchscreen](./puppeteer.touchscreen.md) > [\_client](./puppeteer.touchscreen._client.md)
-
-## Touchscreen.\_client property
-
-Signature:
-
-```typescript
-_client: CDPSession;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.touchscreen._keyboard.md b/remote/test/puppeteer/new-docs/puppeteer.touchscreen._keyboard.md
deleted file mode 100644
index b40e94d320df6..0000000000000
--- a/remote/test/puppeteer/new-docs/puppeteer.touchscreen._keyboard.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [puppeteer](./puppeteer.md) > [Touchscreen](./puppeteer.touchscreen.md) > [\_keyboard](./puppeteer.touchscreen._keyboard.md)
-
-## Touchscreen.\_keyboard property
-
-Signature:
-
-```typescript
-_keyboard: Keyboard;
-```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.touchscreen.md b/remote/test/puppeteer/new-docs/puppeteer.touchscreen.md
index e1f7d85208304..5a079e2b7930b 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.touchscreen.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.touchscreen.md
@@ -16,13 +16,6 @@ export declare class Touchscreen
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `Touchscreen` class.
-## Properties
-
-| Property | Modifiers | Type | Description |
-| --- | --- | --- | --- |
-| [\_client](./puppeteer.touchscreen._client.md) | | [CDPSession](./puppeteer.cdpsession.md) | |
-| [\_keyboard](./puppeteer.touchscreen._keyboard.md) | | [Keyboard](./puppeteer.keyboard.md) | |
-
## Methods
| Method | Modifiers | Description |
diff --git a/remote/test/puppeteer/new-docs/puppeteer.tracing.start.md b/remote/test/puppeteer/new-docs/puppeteer.tracing.start.md
index 5765163397440..bc8a0b7e00fe9 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.tracing.start.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.tracing.start.md
@@ -16,7 +16,7 @@ start(options?: TracingOptions): Promise;
| Parameter | Type | Description |
| --- | --- | --- |
-| options | TracingOptions | Optional TracingOptions
. |
+| options | [TracingOptions](./puppeteer.tracingoptions.md) | Optional TracingOptions
. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.categories.md b/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.categories.md
new file mode 100644
index 0000000000000..1e86ea4729c59
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.categories.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [TracingOptions](./puppeteer.tracingoptions.md) > [categories](./puppeteer.tracingoptions.categories.md)
+
+## TracingOptions.categories property
+
+Signature:
+
+```typescript
+categories?: string[];
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.md b/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.md
new file mode 100644
index 0000000000000..07bd1e046076f
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [TracingOptions](./puppeteer.tracingoptions.md)
+
+## TracingOptions interface
+
+
+Signature:
+
+```typescript
+export interface TracingOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [categories](./puppeteer.tracingoptions.categories.md) | string\[\] | |
+| [path](./puppeteer.tracingoptions.path.md) | string | |
+| [screenshots](./puppeteer.tracingoptions.screenshots.md) | boolean | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.path.md b/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.path.md
new file mode 100644
index 0000000000000..be6b909018252
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.path.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [TracingOptions](./puppeteer.tracingoptions.md) > [path](./puppeteer.tracingoptions.path.md)
+
+## TracingOptions.path property
+
+Signature:
+
+```typescript
+path?: string;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.screenshots.md b/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.screenshots.md
new file mode 100644
index 0000000000000..39a0f913f62d3
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.tracingoptions.screenshots.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [TracingOptions](./puppeteer.tracingoptions.md) > [screenshots](./puppeteer.tracingoptions.screenshots.md)
+
+## TracingOptions.screenshots property
+
+Signature:
+
+```typescript
+screenshots?: boolean;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.unwrapelementhandle.md b/remote/test/puppeteer/new-docs/puppeteer.unwrapelementhandle.md
new file mode 100644
index 0000000000000..44e619ff99961
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.unwrapelementhandle.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [UnwrapElementHandle](./puppeteer.unwrapelementhandle.md)
+
+## UnwrapElementHandle type
+
+Unwraps a DOM element out of an ElementHandle instance
+
+Signature:
+
+```typescript
+export declare type UnwrapElementHandle = X extends ElementHandle ? E : X;
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.md b/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.md
new file mode 100644
index 0000000000000..75c6b9da6d5a9
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [WaitForOptions](./puppeteer.waitforoptions.md)
+
+## WaitForOptions interface
+
+
+Signature:
+
+```typescript
+export interface WaitForOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [timeout](./puppeteer.waitforoptions.timeout.md) | number | Maximum wait time in milliseconds, defaults to 30 seconds, pass 0
to disable the timeout. |
+| [waitUntil](./puppeteer.waitforoptions.waituntil.md) | PuppeteerLifeCycleEvent \| PuppeteerLifeCycleEvent\[\] | |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.timeout.md b/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.timeout.md
new file mode 100644
index 0000000000000..b5aecfc040935
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.timeout.md
@@ -0,0 +1,18 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [WaitForOptions](./puppeteer.waitforoptions.md) > [timeout](./puppeteer.waitforoptions.timeout.md)
+
+## WaitForOptions.timeout property
+
+Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout.
+
+Signature:
+
+```typescript
+timeout?: number;
+```
+
+## Remarks
+
+The default value can be changed by using the [Page.setDefaultTimeout()](./puppeteer.page.setdefaulttimeout.md) or [Page.setDefaultNavigationTimeout()](./puppeteer.page.setdefaultnavigationtimeout.md) methods.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.waituntil.md b/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.waituntil.md
new file mode 100644
index 0000000000000..f6f304b57682e
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.waitforoptions.waituntil.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [WaitForOptions](./puppeteer.waitforoptions.md) > [waitUntil](./puppeteer.waitforoptions.waituntil.md)
+
+## WaitForOptions.waitUntil property
+
+Signature:
+
+```typescript
+waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
+```
diff --git a/remote/test/puppeteer/new-docs/puppeteer.waittimeoutoptions.md b/remote/test/puppeteer/new-docs/puppeteer.waittimeoutoptions.md
new file mode 100644
index 0000000000000..2781ca9ac61c8
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.waittimeoutoptions.md
@@ -0,0 +1,19 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md)
+
+## WaitTimeoutOptions interface
+
+
+Signature:
+
+```typescript
+export interface WaitTimeoutOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [timeout](./puppeteer.waittimeoutoptions.timeout.md) | number | Maximum wait time in milliseconds, defaults to 30 seconds, pass 0
to disable the timeout. |
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.waittimeoutoptions.timeout.md b/remote/test/puppeteer/new-docs/puppeteer.waittimeoutoptions.timeout.md
new file mode 100644
index 0000000000000..91968a12afb20
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.waittimeoutoptions.timeout.md
@@ -0,0 +1,18 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) > [timeout](./puppeteer.waittimeoutoptions.timeout.md)
+
+## WaitTimeoutOptions.timeout property
+
+Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout.
+
+Signature:
+
+```typescript
+timeout?: number;
+```
+
+## Remarks
+
+The default value can be changed by using the [Page.setDefaultTimeout()](./puppeteer.page.setdefaulttimeout.md) method.
+
diff --git a/remote/test/puppeteer/new-docs/puppeteer.webworker.evaluatehandle.md b/remote/test/puppeteer/new-docs/puppeteer.webworker.evaluatehandle.md
index f187a930aa831..aeb5f78519232 100644
--- a/remote/test/puppeteer/new-docs/puppeteer.webworker.evaluatehandle.md
+++ b/remote/test/puppeteer/new-docs/puppeteer.webworker.evaluatehandle.md
@@ -9,15 +9,15 @@ The only difference between `worker.evaluate` and `worker.evaluateHandle` is tha
Signature:
```typescript
-evaluateHandle(pageFunction: Function | string, ...args: any[]): Promise;
+evaluateHandle(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| pageFunction | Function \| string | Function to be evaluated in the page context. |
-| args | any\[\] | Arguments to pass to pageFunction
. |
+| pageFunction | [EvaluateHandleFn](./puppeteer.evaluatehandlefn.md) | Function to be evaluated in the page context. |
+| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | Arguments to pass to pageFunction
. |
Returns:
diff --git a/remote/test/puppeteer/new-docs/puppeteer.wrapelementhandle.md b/remote/test/puppeteer/new-docs/puppeteer.wrapelementhandle.md
new file mode 100644
index 0000000000000..9fe1971c12993
--- /dev/null
+++ b/remote/test/puppeteer/new-docs/puppeteer.wrapelementhandle.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [puppeteer](./puppeteer.md) > [WrapElementHandle](./puppeteer.wrapelementhandle.md)
+
+## WrapElementHandle type
+
+Wraps a DOM element into an ElementHandle instance
+
+Signature:
+
+```typescript
+export declare type WrapElementHandle = X extends Element ? ElementHandle : X;
+```
diff --git a/remote/test/puppeteer/package.json b/remote/test/puppeteer/package.json
index 7164a480ee17f..4f21d88e893ca 100644
--- a/remote/test/puppeteer/package.json
+++ b/remote/test/puppeteer/package.json
@@ -1,16 +1,12 @@
{
"name": "puppeteer",
- "version": "4.0.0-post",
+ "version": "5.0.0",
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
- "main": "lib/index.js",
+ "main": "./cjs-entry.js",
"repository": "github:puppeteer/puppeteer",
"engines": {
"node": ">=10.18.1"
},
- "puppeteer": {
- "chromium_revision": "756035",
- "firefox_revision": "latest"
- },
"scripts": {
"unit": "tsc --version && mocha --config mocha-config/puppeteer-unit-tests.js",
"unit-with-coverage": "cross-env COVERAGE=1 npm run unit",
@@ -28,7 +24,10 @@
"lint": "npm run eslint && npm run tsc && npm run doc",
"doc": "node utils/doclint/cli.js",
"clean-lib": "rm -rf lib",
- "tsc": "npm run clean-lib && tsc --version && tsc -p . && cp src/protocol.d.ts lib/",
+ "tsc": "npm run clean-lib && tsc --version && npm run tsc-cjs && npm run tsc-esm",
+ "tsc-cjs": "tsc -p . && cp src/protocol.d.ts lib/cjs",
+ "tsc-esm": "tsc --build tsconfig-esm.json && cp src/protocol.d.ts lib/esm",
+ "typecheck": "tsc -p . --noEmit",
"apply-next-version": "node utils/apply_next_version.js",
"update-protocol-d-ts": "node utils/protocol-types-generator update",
"compare-protocol-d-ts": "node utils/protocol-types-generator compare",
@@ -39,9 +38,10 @@
},
"files": [
"lib/",
- "index.js",
"install.js",
- "typescript-if-required.js"
+ "typescript-if-required.js",
+ "cjs-entry.js",
+ "cjs-entry-core.js"
],
"author": "The Chromium Authors",
"license": "Apache-2.0",
@@ -51,6 +51,7 @@
"https-proxy-agent": "^4.0.0",
"mime": "^2.0.3",
"mitt": "^2.0.1",
+ "pkg-dir": "^4.2.0",
"progress": "^2.0.1",
"proxy-from-env": "^1.0.0",
"rimraf": "^3.0.2",
diff --git a/remote/test/puppeteer/scripts/test-install.sh b/remote/test/puppeteer/scripts/test-install.sh
index 1fdeeeb7369ee..c9262104e70b6 100755
--- a/remote/test/puppeteer/scripts/test-install.sh
+++ b/remote/test/puppeteer/scripts/test-install.sh
@@ -1,10 +1,12 @@
#!/usr/bin/env sh
set -e
+ROOTDIR="$(pwd)"
# Pack the module into a tarball
npm pack
tarball="$(realpath puppeteer-*.tgz)"
-cd "$(mktemp -d)"
+TMPDIR="$(mktemp -d)"
+cd $TMPDIR
# Check we can install from the tarball.
# This emulates installing from npm and ensures that:
# 1. we publish the right files in the `files` list from package.json
@@ -12,6 +14,7 @@ cd "$(mktemp -d)"
# 3. Requiring Puppeteer from Node works.
npm install --loglevel silent "${tarball}"
node --eval="require('puppeteer')"
+ls $TMPDIR/node_modules/puppeteer/.local-chromium/
# Again for Firefox
TMPDIR="$(mktemp -d)"
@@ -19,4 +22,20 @@ cd $TMPDIR
PUPPETEER_PRODUCT=firefox npm install --loglevel silent "${tarball}"
node --eval="require('puppeteer')"
rm "${tarball}"
-ls $TMPDIR/node_modules/puppeteer/.local-firefox/linux-79.0a1/firefox/firefox
+ls $TMPDIR/node_modules/puppeteer/.local-firefox/
+
+# Again for puppeteer-core
+cd $ROOTDIR
+node ./utils/prepare_puppeteer_core.js
+npm pack
+tarball="$(realpath puppeteer-core-*.tgz)"
+TMPDIR="$(mktemp -d)"
+cd $TMPDIR
+# Check we can install from the tarball.
+# This emulates installing from npm and ensures that:
+# 1. we publish the right files in the `files` list from package.json
+# 2. The install script works and correctly exits without errors
+# 3. Requiring Puppeteer Core from Node works.
+npm install --loglevel silent "${tarball}"
+node --eval="require('puppeteer-core')"
+
diff --git a/remote/test/puppeteer/src/api-docs-entry.ts b/remote/test/puppeteer/src/api-docs-entry.ts
index 8e8ac591378e1..f49087640e501 100644
--- a/remote/test/puppeteer/src/api-docs-entry.ts
+++ b/remote/test/puppeteer/src/api-docs-entry.ts
@@ -31,6 +31,7 @@ export * from './node/BrowserFetcher';
export * from './common/Connection';
export * from './common/ConsoleMessage';
export * from './common/Coverage';
+export * from './common/DeviceDescriptors';
export * from './common/Dialog';
export * from './common/JSHandle';
export * from './common/ExecutionContext';
@@ -40,6 +41,8 @@ export * from './common/FrameManager';
export * from './common/Input';
export * from './common/Page';
export * from './common/Puppeteer';
+export * from './node/LaunchOptions';
+export * from './node/Launcher';
export * from './common/HTTPRequest';
export * from './common/HTTPResponse';
export * from './common/SecurityDetails';
@@ -48,3 +51,4 @@ export * from './common/Errors';
export * from './common/Tracing';
export * from './common/WebWorker';
export * from './common/USKeyboardLayout';
+export * from './common/EvalTypes';
diff --git a/remote/test/puppeteer/src/common/Coverage.ts b/remote/test/puppeteer/src/common/Coverage.ts
index d9537dd0ddbff..5b590a0a2be8d 100644
--- a/remote/test/puppeteer/src/common/Coverage.ts
+++ b/remote/test/puppeteer/src/common/Coverage.ts
@@ -21,14 +21,95 @@ import { CDPSession } from './Connection';
import { EVALUATION_SCRIPT_URL } from './ExecutionContext';
-interface CoverageEntry {
+/**
+ * The CoverageEntry class represents one entry of the coverage report.
+ * @public
+ */
+export interface CoverageEntry {
+ /**
+ * The URL of the style sheet or script.
+ */
url: string;
+ /**
+ * The content of the style sheet or script.
+ */
text: string;
+ /**
+ * The covered range as start and end positions.
+ */
ranges: Array<{ start: number; end: number }>;
}
+/**
+ * Set of configurable options for JS coverage.
+ * @public
+ */
+export interface JSCoverageOptions {
+ /**
+ * Whether to reset coverage on every navigation.
+ */
+ resetOnNavigation?: boolean;
+ /**
+ * Whether anonymous scripts generated by the page should be reported.
+ */
+ reportAnonymousScripts?: boolean;
+}
+
+/**
+ * Set of configurable options for CSS coverage.
+ * @public
+ */
+export interface CSSCoverageOptions {
+ /**
+ * Whether to reset coverage on every navigation.
+ */
+ resetOnNavigation?: boolean;
+}
+
+/**
+ * The Coverage class provides methods to gathers information about parts of
+ * JavaScript and CSS that were used by the page.
+ *
+ * @remarks
+ * To output coverage in a form consumable by {@link https://github.com/istanbuljs | Istanbul},
+ * see {@link https://github.com/istanbuljs/puppeteer-to-istanbul | 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}%`);
+ * ```
+ * @public
+ */
export class Coverage {
+ /**
+ * @internal
+ */
_jsCoverage: JSCoverage;
+ /**
+ * @internal
+ */
_cssCoverage: CSSCoverage;
constructor(client: CDPSession) {
@@ -36,27 +117,48 @@ export class Coverage {
this._cssCoverage = new CSSCoverage(client);
}
- async startJSCoverage(
- options: {
- resetOnNavigation?: boolean;
- reportAnonymousScripts?: boolean;
- } = {}
- ): Promise {
+ /**
+ * @param options - defaults to
+ * `{ resetOnNavigation : true, reportAnonymousScripts : false }`
+ * @returns 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.
+ */
+ async startJSCoverage(options: JSCoverageOptions = {}): Promise {
return await this._jsCoverage.start(options);
}
+ /**
+ * @returns 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.
+ */
async stopJSCoverage(): Promise {
return await this._jsCoverage.stop();
}
- async startCSSCoverage(
- options: {
- resetOnNavigation?: boolean;
- } = {}
- ): Promise {
+ /**
+ * @param options - defaults to `{ resetOnNavigation : true }`
+ * @returns Promise that resolves when coverage is started.
+ */
+ async startCSSCoverage(options: CSSCoverageOptions = {}): Promise {
return await this._cssCoverage.start(options);
}
+ /**
+ * @returns Promise that resolves to the array of coverage reports
+ * for all stylesheets.
+ * @remarks
+ * CSS Coverage doesn't include dynamically injected style tags
+ * without sourceURLs.
+ */
async stopCSSCoverage(): Promise {
return await this._cssCoverage.stop();
}
diff --git a/remote/test/puppeteer/src/common/DOMWorld.ts b/remote/test/puppeteer/src/common/DOMWorld.ts
index 678ddc4300dd1..326cdf0b858f4 100644
--- a/remote/test/puppeteer/src/common/DOMWorld.ts
+++ b/remote/test/puppeteer/src/common/DOMWorld.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import * as fs from 'fs';
import { assert } from './assert';
import { helper } from './helper';
import { LifecycleWatcher, PuppeteerLifeCycleEvent } from './LifecycleWatcher';
@@ -22,16 +21,21 @@ import { TimeoutError } from './Errors';
import { JSHandle, ElementHandle } from './JSHandle';
import { ExecutionContext } from './ExecutionContext';
import { TimeoutSettings } from './TimeoutSettings';
-import { MouseButtonInput } from './Input';
+import { MouseButton } from './Input';
import { FrameManager, Frame } from './FrameManager';
import { getQueryHandlerAndSelector, QueryHandler } from './QueryHandler';
+import {
+ EvaluateFn,
+ SerializableOrJSHandle,
+ EvaluateHandleFn,
+ WrapElementHandle,
+} from './EvalTypes';
+import { isNode } from '../environment';
// This predicateQueryHandler is declared here so that TypeScript knows about it
// when it is used in the predicate function below.
declare const predicateQueryHandler: QueryHandler;
-const readFileAsync = helper.promisify(fs.readFile);
-
export interface WaitForSelectorOptions {
visible?: boolean;
hidden?: boolean;
@@ -104,15 +108,10 @@ export class DOMWorld {
return this._contextPromise;
}
- /**
- * @param {Function|string} pageFunction
- * @param {!Array<*>} args
- * @returns {!Promise}
- */
- async evaluateHandle(
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
+ async evaluateHandle(
+ pageFunction: EvaluateHandleFn,
+ ...args: SerializableOrJSHandle[]
+ ): Promise {
const context = await this.executionContext();
return context.evaluateHandle(pageFunction, ...args);
}
@@ -155,19 +154,22 @@ export class DOMWorld {
return value;
}
- async $eval(
+ async $eval(
selector: string,
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
+ pageFunction: (
+ element: Element,
+ ...args: unknown[]
+ ) => ReturnType | Promise,
+ ...args: SerializableOrJSHandle[]
+ ): Promise> {
const document = await this._document();
return document.$eval(selector, pageFunction, ...args);
}
async $$eval(
selector: string,
- pageFunction: Function | string,
- ...args: unknown[]
+ pageFunction: EvaluateFn | string,
+ ...args: SerializableOrJSHandle[]
): Promise {
const document = await this._document();
const value = await document.$$eval(
@@ -232,8 +234,15 @@ export class DOMWorld {
}
/**
- * @param {!{url?: string, path?: string, content?: string, type?: string}} options
- * @returns {!Promise}
+ * Adds a script tag into the current context.
+ *
+ * @remarks
+ *
+ * You can pass a URL, filepath or string of contents. Note that when running Puppeteer
+ * in a browser environment you cannot pass a filepath and should use either
+ * `url` or `content`.
+ *
+ * @param options
*/
async addScriptTag(options: {
url?: string;
@@ -254,6 +263,16 @@ export class DOMWorld {
}
if (path !== null) {
+ if (!isNode) {
+ throw new Error(
+ 'Cannot pass a filepath to addScriptTag in the browser environment.'
+ );
+ }
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ const fs = require('fs');
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ const { promisify } = require('util');
+ const readFileAsync = promisify(fs.readFile);
let contents = await readFileAsync(path, 'utf8');
contents += '//# sourceURL=' + path.replace(/\n/g, '');
const context = await this.executionContext();
@@ -304,6 +323,17 @@ export class DOMWorld {
}
}
+ /**
+ * Adds a style tag into the current context.
+ *
+ * @remarks
+ *
+ * You can pass a URL, filepath or string of contents. Note that when running Puppeteer
+ * in a browser environment you cannot pass a filepath and should use either
+ * `url` or `content`.
+ *
+ * @param options
+ */
async addStyleTag(options: {
url?: string;
path?: string;
@@ -320,6 +350,16 @@ export class DOMWorld {
}
if (path !== null) {
+ if (!isNode) {
+ throw new Error(
+ 'Cannot pass a filepath to addStyleTag in the browser environment.'
+ );
+ }
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ const fs = require('fs');
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ const { promisify } = require('util');
+ const readFileAsync = promisify(fs.readFile);
let contents = await readFileAsync(path, 'utf8');
contents += '/*# sourceURL=' + path.replace(/\n/g, '') + '*/';
const context = await this.executionContext();
@@ -368,7 +408,7 @@ export class DOMWorld {
async click(
selector: string,
- options: { delay?: number; button?: MouseButtonInput; clickCount?: number }
+ options: { delay?: number; button?: MouseButton; clickCount?: number }
): Promise {
const handle = await this.$(selector);
assert(handle, 'No node found for selector: ' + selector);
@@ -433,7 +473,7 @@ export class DOMWorld {
waitForFunction(
pageFunction: Function | string,
options: { polling?: string | number; timeout?: number } = {},
- ...args: unknown[]
+ ...args: SerializableOrJSHandle[]
): Promise {
const {
polling = 'raf',
@@ -544,7 +584,7 @@ class WaitTask {
_polling: string | number;
_timeout: number;
_predicateBody: string;
- _args: unknown[];
+ _args: SerializableOrJSHandle[];
_runCount = 0;
promise: Promise;
_resolve: (x: JSHandle) => void;
@@ -559,7 +599,7 @@ class WaitTask {
title: string,
polling: string | number,
timeout: number,
- ...args: unknown[]
+ ...args: SerializableOrJSHandle[]
) {
if (helper.isString(polling))
assert(
diff --git a/remote/test/puppeteer/src/common/Debug.ts b/remote/test/puppeteer/src/common/Debug.ts
index 24f0434bf868f..236be96d5b458 100644
--- a/remote/test/puppeteer/src/common/Debug.ts
+++ b/remote/test/puppeteer/src/common/Debug.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-const isNodeEnv = typeof document === 'undefined';
+import { isNode } from '../environment';
/**
* A debug function that can be used in any environment.
@@ -35,7 +35,7 @@ const isNodeEnv = typeof document === 'undefined';
* ```
*/
export const debug = (prefix: string): ((...args: unknown[]) => void) => {
- if (isNodeEnv) {
+ if (isNode) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return require('debug')(prefix);
}
diff --git a/remote/test/puppeteer/src/common/EvalTypes.ts b/remote/test/puppeteer/src/common/EvalTypes.ts
new file mode 100644
index 0000000000000..11f7d35ece82a
--- /dev/null
+++ b/remote/test/puppeteer/src/common/EvalTypes.ts
@@ -0,0 +1,75 @@
+/**
+ * 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.
+ */
+
+import { JSHandle, ElementHandle } from './JSHandle';
+
+/**
+ * @public
+ */
+export type EvaluateFn = string | ((arg1: T, ...args: any[]) => any);
+/**
+ * @public
+ */
+export type EvaluateFnReturnType = T extends (
+ ...args: any[]
+) => infer R
+ ? R
+ : unknown;
+
+/**
+ * @public
+ */
+export type EvaluateHandleFn = string | ((...args: unknown[]) => unknown);
+
+/**
+ * @public
+ */
+export type Serializable =
+ | number
+ | string
+ | boolean
+ | null
+ | JSONArray
+ | JSONObject;
+
+/**
+ * @public
+ */
+export type JSONArray = Serializable[];
+
+/**
+ * @public
+ */
+export interface JSONObject {
+ [key: string]: Serializable;
+}
+
+/**
+ * @public
+ */
+export type SerializableOrJSHandle = Serializable | JSHandle;
+
+/**
+ * Wraps a DOM element into an ElementHandle instance
+ * @public
+ **/
+export type WrapElementHandle = X extends Element ? ElementHandle : X;
+
+/**
+ * Unwraps a DOM element out of an ElementHandle instance
+ * @public
+ **/
+export type UnwrapElementHandle = X extends ElementHandle ? E : X;
diff --git a/remote/test/puppeteer/src/common/ExecutionContext.ts b/remote/test/puppeteer/src/common/ExecutionContext.ts
index b653895e4e796..df7d40246807d 100644
--- a/remote/test/puppeteer/src/common/ExecutionContext.ts
+++ b/remote/test/puppeteer/src/common/ExecutionContext.ts
@@ -21,15 +21,42 @@ import { CDPSession } from './Connection';
import { DOMWorld } from './DOMWorld';
import { Frame } from './FrameManager';
import Protocol from '../protocol';
+import { EvaluateHandleFn, SerializableOrJSHandle } from './EvalTypes';
export const EVALUATION_SCRIPT_URL = '__puppeteer_evaluation_script__';
const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
+/**
+ * This class represents a context for JavaScript execution. A [Page] might have
+ * many execution contexts:
+ * - each
+ * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe |
+ * frame } has "default" execution context that is always created after frame is
+ * attached to DOM. This context is returned by the
+ * {@link frame.executionContext()} method.
+ * - {@link https://developer.chrome.com/extensions | Extension}'s content scripts
+ * create additional execution contexts.
+ *
+ * Besides pages, execution contexts can be found in
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API |
+ * workers }.
+ *
+ * @public
+ */
export class ExecutionContext {
+ /**
+ * @internal
+ */
_client: CDPSession;
+ /**
+ * @internal
+ */
_world: DOMWorld;
- _contextId: number;
+ private _contextId: number;
+ /**
+ * @internal
+ */
constructor(
client: CDPSession,
contextPayload: Protocol.Runtime.ExecutionContextDescription,
@@ -40,10 +67,62 @@ export class ExecutionContext {
this._contextId = contextPayload.id;
}
+ /**
+ * @remarks
+ *
+ * Not every execution context is associated with a frame. For
+ * example, workers and extensions have execution contexts that are not
+ * associated with frames.
+ *
+ * @returns The frame associated with this execution context.
+ */
frame(): Frame | null {
return this._world ? this._world.frame() : null;
}
+ /**
+ * @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
+ * ```js
+ * const executionContext = await page.mainFrame().executionContext();
+ * const result = await executionContext.evaluate(() => Promise.resolve(8 * 7))* ;
+ * console.log(result); // prints "56"
+ * ```
+ *
+ * @example
+ * A string can also be passed in instead of a function.
+ *
+ * ```js
+ * console.log(await executionContext.evaluate('1 + 2')); // prints "3"
+ * ```
+ *
+ * @example
+ * {@link JSHandle} 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'.
+ * ```
+ * @param pageFunction a function to be evaluated in the `executionContext`
+ * @param args argument to pass to the page function
+ *
+ * @returns A promise that resolves to the return value of the given function.
+ */
async evaluate(
pageFunction: Function | string,
...args: unknown[]
@@ -55,15 +134,57 @@ export class ExecutionContext {
);
}
- async evaluateHandle(
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
- return this._evaluateInternal(false, pageFunction, ...args);
+ /**
+ * @remarks
+ * The only difference between `executionContext.evaluate` and
+ * `executionContext.evaluateHandle` is that `executionContext.evaluateHandle`
+ * returns an in-page object (a {@link JSHandle}).
+ * 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
+ * ```js
+ * const context = await page.mainFrame().executionContext();
+ * const aHandle = await context.evaluateHandle(() => Promise.resolve(self));
+ * aHandle; // Handle for the global object.
+ * ```
+ *
+ * @example
+ * 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
+ * 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();
+ * ```
+ *
+ * @param pageFunction a function to be evaluated in the `executionContext`
+ * @param args argument to pass to the page function
+ *
+ * @returns A promise that resolves to the return value of the given function
+ * as an in-page object (a {@link JSHandle}).
+ */
+ async evaluateHandle(
+ pageFunction: EvaluateHandleFn,
+ ...args: SerializableOrJSHandle[]
+ ): Promise {
+ return this._evaluateInternal(false, pageFunction, ...args);
}
private async _evaluateInternal(
- returnByValue,
+ returnByValue: boolean,
pageFunction: Function | string,
...args: unknown[]
): Promise {
@@ -197,6 +318,28 @@ export class ExecutionContext {
}
}
+ /**
+ * This method iterates the JavaScript heap and finds all the 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();
+ * ```
+ *
+ * @param prototypeHandle a handle to the object prototype
+ *
+ * @returns A handle to an array of objects with the given prototype.
+ */
async queryObjects(prototypeHandle: JSHandle): Promise {
assert(!prototypeHandle._disposed, 'Prototype JSHandle is disposed!');
assert(
@@ -209,6 +352,9 @@ export class ExecutionContext {
return createJSHandle(this, response.objects);
}
+ /**
+ * @internal
+ */
async _adoptBackendNodeId(
backendNodeId: Protocol.DOM.BackendNodeId
): Promise {
@@ -219,6 +365,9 @@ export class ExecutionContext {
return createJSHandle(this, object) as ElementHandle;
}
+ /**
+ * @internal
+ */
async _adoptElementHandle(
elementHandle: ElementHandle
): Promise {
diff --git a/remote/test/puppeteer/src/common/FrameManager.ts b/remote/test/puppeteer/src/common/FrameManager.ts
index 6e56c75332952..61bbe8be4dde6 100644
--- a/remote/test/puppeteer/src/common/FrameManager.ts
+++ b/remote/test/puppeteer/src/common/FrameManager.ts
@@ -25,10 +25,16 @@ import { NetworkManager } from './NetworkManager';
import { TimeoutSettings } from './TimeoutSettings';
import { CDPSession } from './Connection';
import { JSHandle, ElementHandle } from './JSHandle';
-import { MouseButtonInput } from './Input';
+import { MouseButton } from './Input';
import { Page } from './Page';
import { HTTPResponse } from './HTTPResponse';
import Protocol from '../protocol';
+import {
+ EvaluateFn,
+ SerializableOrJSHandle,
+ EvaluateHandleFn,
+ WrapElementHandle,
+} from './EvalTypes';
const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';
@@ -430,11 +436,11 @@ export class Frame {
return this._mainWorld.executionContext();
}
- async evaluateHandle(
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
- return this._mainWorld.evaluateHandle(pageFunction, ...args);
+ async evaluateHandle(
+ pageFunction: EvaluateHandleFn,
+ ...args: SerializableOrJSHandle[]
+ ): Promise {
+ return this._mainWorld.evaluateHandle(pageFunction, ...args);
}
async evaluate(
@@ -452,18 +458,21 @@ export class Frame {
return this._mainWorld.$x(expression);
}
- async $eval(
+ async $eval(
selector: string,
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
+ pageFunction: (
+ element: Element,
+ ...args: unknown[]
+ ) => ReturnType | Promise,
+ ...args: SerializableOrJSHandle[]
+ ): Promise> {
return this._mainWorld.$eval(selector, pageFunction, ...args);
}
async $$eval(
selector: string,
- pageFunction: Function | string,
- ...args: unknown[]
+ pageFunction: EvaluateFn | string,
+ ...args: SerializableOrJSHandle[]
): Promise {
return this._mainWorld.$$eval(selector, pageFunction, ...args);
}
@@ -527,7 +536,7 @@ export class Frame {
selector: string,
options: {
delay?: number;
- button?: MouseButtonInput;
+ button?: MouseButton;
clickCount?: number;
} = {}
): Promise {
@@ -561,7 +570,7 @@ export class Frame {
waitFor(
selectorOrFunctionOrTimeout: string | number | Function,
options: {} = {},
- ...args: unknown[]
+ ...args: SerializableOrJSHandle[]
): Promise {
const xPathPattern = '//';
@@ -618,7 +627,7 @@ export class Frame {
waitForFunction(
pageFunction: Function | string,
options: { polling?: string | number; timeout?: number } = {},
- ...args: unknown[]
+ ...args: SerializableOrJSHandle[]
): Promise {
return this._mainWorld.waitForFunction(pageFunction, options, ...args);
}
diff --git a/remote/test/puppeteer/src/common/HTTPResponse.ts b/remote/test/puppeteer/src/common/HTTPResponse.ts
index a8f1ad249a512..c40ecb88feaac 100644
--- a/remote/test/puppeteer/src/common/HTTPResponse.ts
+++ b/remote/test/puppeteer/src/common/HTTPResponse.ts
@@ -19,11 +19,20 @@ import { HTTPRequest } from './HTTPRequest';
import { SecurityDetails } from './SecurityDetails';
import Protocol from '../protocol';
-interface RemoteAddress {
+/**
+ * @public
+ */
+export interface RemoteAddress {
ip: string;
port: number;
}
+/**
+ * The HTTPResponse class represents responses which are received by the
+ * {@link Page} class.
+ *
+ * @public
+ */
export class HTTPResponse {
private _client: CDPSession;
private _request: HTTPRequest;
@@ -39,6 +48,9 @@ export class HTTPResponse {
private _headers: Record = {};
private _securityDetails: SecurityDetails | null;
+ /**
+ * @internal
+ */
constructor(
client: CDPSession,
request: HTTPRequest,
@@ -67,38 +79,70 @@ export class HTTPResponse {
: null;
}
+ /**
+ * @internal
+ */
_resolveBody(err: Error | null): void {
return this._bodyLoadedPromiseFulfill(err);
}
+ /**
+ * @returns The IP address and port number used to connect to the remote
+ * server.
+ */
remoteAddress(): RemoteAddress {
return this._remoteAddress;
}
+ /**
+ * @returns The URL of the response.
+ */
url(): string {
return this._url;
}
+ /**
+ * @returns True if the response was successful (status in the range 200-299).
+ */
ok(): boolean {
+ // TODO: document === 0 case?
return this._status === 0 || (this._status >= 200 && this._status <= 299);
}
+ /**
+ * @returns The status code of the response (e.g., 200 for a success).
+ */
status(): number {
return this._status;
}
+ /**
+ * @returns The status text of the response (e.g. usually an "OK" for a
+ * success).
+ */
statusText(): string {
return this._statusText;
}
+ /**
+ * @returns An object with HTTP headers associated with the response. All
+ * header names are lower-case.
+ */
headers(): Record {
return this._headers;
}
+ /**
+ * @returns {@link SecurityDetails} if the response was received over the
+ * secure connection, or `null` otherwise.
+ */
securityDetails(): SecurityDetails | null {
return this._securityDetails;
}
+ /**
+ * @returns Promise which resolves to a buffer with response body.
+ */
buffer(): Promise {
if (!this._contentPromise) {
this._contentPromise = this._bodyLoadedPromise.then(async (error) => {
@@ -115,28 +159,54 @@ export class HTTPResponse {
return this._contentPromise;
}
+ /**
+ * @returns Promise which resolves to a text representation of response body.
+ */
async text(): Promise {
const content = await this.buffer();
return content.toString('utf8');
}
+ /**
+ *
+ * @returns 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`.
+ */
async json(): Promise {
const content = await this.text();
return JSON.parse(content);
}
+ /**
+ * @returns A matching {@link HTTPRequest} object.
+ */
request(): HTTPRequest {
return this._request;
}
+ /**
+ * @returns True if the response was served from either the browser's disk
+ * cache or memory cache.
+ */
fromCache(): boolean {
return this._fromDiskCache || this._request._fromMemoryCache;
}
+ /**
+ * @returns True if the response was served by a service worker.
+ */
fromServiceWorker(): boolean {
return this._fromServiceWorker;
}
+ /**
+ * @returns A {@link Frame} that initiated this response, or `null` if
+ * navigating to error pages.
+ */
frame(): Frame | null {
return this._request.frame();
}
diff --git a/remote/test/puppeteer/src/common/Input.ts b/remote/test/puppeteer/src/common/Input.ts
index 0f52d700471ed..b395170a71b0e 100644
--- a/remote/test/puppeteer/src/common/Input.ts
+++ b/remote/test/puppeteer/src/common/Input.ts
@@ -22,15 +22,81 @@ type KeyDescription = Required<
Pick
>;
+/**
+ * Keyboard provides an api for managing a virtual keyboard.
+ * The high level api is {@link Keyboard."type"},
+ * which takes raw characters and generates proper keydown, keypress/input,
+ * and keyup events on your page.
+ *
+ * @remarks
+ * For finer control, you can use {@link Keyboard.down},
+ * {@link Keyboard.up}, and {@link Keyboard.sendCharacter}
+ * to manually fire events as if they were generated from a real keyboard.
+ *
+ * On MacOS, keyboard shortcuts like `⌘ A` -\> Select All do not work.
+ * See {@link https://github.com/puppeteer/puppeteer/issues/1313 | #1313}.
+ *
+ * @example
+ * An example of holding down `Shift` in order to select and delete some text:
+ * ```js
+ * await page.keyboard.type('Hello World!');
+ * await page.keyboard.press('ArrowLeft');
+ *
+ * await page.keyboard.down('Shift');
+ * for (let i = 0; i < ' World'.length; i++)
+ * await page.keyboard.press('ArrowLeft');
+ * await page.keyboard.up('Shift');
+ *
+ * await page.keyboard.press('Backspace');
+ * // Result text will end up saying 'Hello!'
+ * ```
+ *
+ * @example
+ * An example of pressing `A`
+ * ```js
+ * await page.keyboard.down('Shift');
+ * await page.keyboard.press('KeyA');
+ * await page.keyboard.up('Shift');
+ * ```
+ *
+ * @public
+ */
export class Keyboard {
- _client: CDPSession;
+ private _client: CDPSession;
+ /** @internal */
_modifiers = 0;
- _pressedKeys = new Set();
+ private _pressedKeys = new Set();
+ /** @internal */
constructor(client: CDPSession) {
this._client = client;
}
+ /**
+ * Dispatches a `keydown` event.
+ *
+ * @remarks
+ * If `key` is a single character and no modifier keys besides `Shift`
+ * are being held down, a `keypress`/`input` event will also generated.
+ * The `text` option can be specified to force an input event to be generated.
+ * If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`,
+ * subsequent key presses will be sent with that modifier active.
+ * To release the modifier key, use {@link Keyboard.up}.
+ *
+ * After the key is pressed once, subsequent calls to
+ * {@link Keyboard.down} will have
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat | repeat}
+ * set to true. To release the key, use {@link Keyboard.up}.
+ *
+ * Modifier keys DO influence {@link Keyboard.down}.
+ * Holding down `Shift` will type the text in upper case.
+ *
+ * @param key - Name of key to press, such as `ArrowLeft`.
+ * See {@link KeyInput} for a list of all key names.
+ *
+ * @param options - An object of options. Accepts text which, if specified,
+ * generates an input event with this text.
+ */
async down(
key: KeyInput,
options: { text?: string } = { text: undefined }
@@ -99,6 +165,13 @@ export class Keyboard {
return description;
}
+ /**
+ * Dispatches a `keyup` event.
+ *
+ * @param key - Name of key to release, such as `ArrowLeft`.
+ * See {@link KeyInput | KeyInput}
+ * for a list of all key names.
+ */
async up(key: KeyInput): Promise {
const description = this._keyDescriptionForString(key);
@@ -114,6 +187,21 @@ export class Keyboard {
});
}
+ /**
+ * Dispatches a `keypress` and `input` event.
+ * This does not send a `keydown` or `keyup` event.
+ *
+ * @remarks
+ * Modifier keys DO NOT effect {@link Keyboard.sendCharacter | Keyboard.sendCharacter}.
+ * Holding down `Shift` will not type the text in upper case.
+ *
+ * @example
+ * ```js
+ * page.keyboard.sendCharacter('嗨');
+ * ```
+ *
+ * @param char - Character to send into the page.
+ */
async sendCharacter(char: string): Promise {
await this._client.send('Input.insertText', { text: char });
}
@@ -122,8 +210,30 @@ export class Keyboard {
return !!keyDefinitions[char];
}
+ /**
+ * Sends a `keydown`, `keypress`/`input`,
+ * and `keyup` event for each character in the text.
+ *
+ * @remarks
+ * To press a special key, like `Control` or `ArrowDown`,
+ * use {@link Keyboard.press}.
+ *
+ * Modifier keys DO NOT effect `keyboard.type`.
+ * Holding down `Shift` will not type the text in upper case.
+ *
+ * @example
+ * ```js
+ * await page.keyboard.type('Hello'); // Types instantly
+ * await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
+ * ```
+ *
+ * @param text - A text to type into a focused element.
+ * @param options - An object of options. Accepts delay which,
+ * if specified, is the time to wait between `keydown` and `keyup` in milliseconds.
+ * Defaults to 0.
+ */
async type(text: string, options: { delay?: number } = {}): Promise {
- const delay = (options && options.delay) || null;
+ const delay = options.delay || null;
for (const char of text) {
if (this.charIsKey(char)) {
await this.press(char, { delay });
@@ -134,6 +244,26 @@ export class Keyboard {
}
}
+ /**
+ * Shortcut for {@link Keyboard.down}
+ * and {@link Keyboard.up}.
+ *
+ * @remarks
+ * If `key` is a single character and no modifier keys besides `Shift`
+ * are being held down, a `keypress`/`input` event will also generated.
+ * The `text` option can be specified to force an input event to be generated.
+ *
+ * Modifier keys DO effect {@link Keyboard.press}.
+ * Holding down `Shift` will type the text in upper case.
+ *
+ * @param key - Name of key to press, such as `ArrowLeft`.
+ * See {@link KeyInput} for a list of all key names.
+ *
+ * @param options - An object of options. Accepts text which, if specified,
+ * generates an input event with this text. Accepts delay which,
+ * if specified, is the time to wait between `keydown` and `keyup` in milliseconds.
+ * Defaults to 0.
+ */
async press(
key: KeyInput,
options: { delay?: number; text?: string } = {}
@@ -145,11 +275,16 @@ export class Keyboard {
}
}
-type MouseButton = 'none' | 'left' | 'right' | 'middle';
-export type MouseButtonInput = Exclude;
+/**
+ * @public
+ */
+export type MouseButton = 'left' | 'right' | 'middle';
-interface MouseOptions {
- button?: MouseButtonInput;
+/**
+ * @public
+ */
+export interface MouseOptions {
+ button?: MouseButton;
clickCount?: number;
}
@@ -211,11 +346,12 @@ interface MouseOptions {
* @public
*/
export class Mouse {
- _client: CDPSession;
- _keyboard: Keyboard;
- _x = 0;
- _y = 0;
- _button: MouseButton = 'none';
+ private _client: CDPSession;
+ private _keyboard: Keyboard;
+ private _x = 0;
+ private _y = 0;
+ private _button: MouseButton | 'none' = 'none';
+
/**
* @internal
*/
@@ -314,10 +450,11 @@ export class Mouse {
/**
* The Touchscreen class exposes touchscreen events.
+ * @public
*/
export class Touchscreen {
- _client: CDPSession;
- _keyboard: Keyboard;
+ private _client: CDPSession;
+ private _keyboard: Keyboard;
/**
* @internal
diff --git a/remote/test/puppeteer/src/common/JSHandle.ts b/remote/test/puppeteer/src/common/JSHandle.ts
index 4273db864cd90..d7b8f66875fca 100644
--- a/remote/test/puppeteer/src/common/JSHandle.ts
+++ b/remote/test/puppeteer/src/common/JSHandle.ts
@@ -23,10 +23,14 @@ import { KeyInput } from './USKeyboardLayout';
import { FrameManager, Frame } from './FrameManager';
import { getQueryHandlerAndSelector } from './QueryHandler';
import Protocol from '../protocol';
+import {
+ EvaluateFn,
+ SerializableOrJSHandle,
+ EvaluateFnReturnType,
+ EvaluateHandleFn,
+ WrapElementHandle,
+} from './EvalTypes';
-/**
- * @public
- */
export interface BoxModel {
content: Array<{ x: number; y: number }>;
padding: Array<{ x: number; y: number }>;
@@ -80,14 +84,44 @@ export function createJSHandle(
}
/**
+ * Represents an in-page JavaScript object. JSHandles can be created with the
+ * {@link Page.evaluateHandle | page.evaluateHandle} method.
+ *
+ * @example
+ * ```js
+ * const windowHandle = await page.evaluateHandle(() => window);
+ * ```
+ *
+ * JSHandle prevents the referenced JavaScript object from being garbage-collected
+ * unless the handle is {@link JSHandle.dispose | disposed}. JSHandles are auto-
+ * disposed when their origin frame gets navigated or the parent context gets destroyed.
+ *
+ * JSHandle instances can be used as arguments for {@link Page.$eval},
+ * {@link Page.evaluate}, and {@link Page.evaluateHandle}.
+ *
* @public
*/
export class JSHandle {
+ /**
+ * @internal
+ */
_context: ExecutionContext;
+ /**
+ * @internal
+ */
_client: CDPSession;
+ /**
+ * @internal
+ */
_remoteObject: Protocol.Runtime.RemoteObject;
+ /**
+ * @internal
+ */
_disposed = false;
+ /**
+ * @internal
+ */
constructor(
context: ExecutionContext,
client: CDPSession,
@@ -98,6 +132,8 @@ export class JSHandle {
this._remoteObject = remoteObject;
}
+ /** Returns the execution context the handle belongs to.
+ */
executionContext(): ExecutionContext {
return this._context;
}
@@ -113,11 +149,12 @@ export class JSHandle {
* expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10');
* ```
*/
- async evaluate(
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
- return await this.executionContext().evaluate(
+
+ async evaluate(
+ pageFunction: T | string,
+ ...args: SerializableOrJSHandle[]
+ ): Promise> {
+ return await this.executionContext().evaluate>(
pageFunction,
this,
...args
@@ -129,20 +166,20 @@ export class JSHandle {
*
* @remarks
*
- * The only difference between `evaluateHandle.evaluate` and
- * `evaluateHandle.evaluateHandle` is that `executionContext.evaluateHandle`
- * returns in-page object (JSHandle).
+ * The only difference between `jsHandle.evaluate` and
+ * `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle`
+ * returns an in-page object (JSHandle).
*
- * 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.
+ * If the function passed to `jsHandle.evaluateHandle` returns a Promise,
+ * then `evaluateHandle.evaluateHandle` waits for the promise to resolve and
+ * returns its value.
*
* See {@link Page.evaluateHandle} for more details.
*/
- async evaluateHandle(
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
+ async evaluateHandle(
+ pageFunction: EvaluateHandleFn,
+ ...args: SerializableOrJSHandle[]
+ ): Promise {
return await this.executionContext().evaluateHandle(
pageFunction,
this,
@@ -150,6 +187,8 @@ export class JSHandle {
);
}
+ /** Fetches a single property from the referenced object.
+ */
async getProperty(propertyName: string): Promise {
const objectHandle = await this.evaluateHandle(
(object: HTMLElement, propertyName: string) => {
@@ -202,7 +241,7 @@ export class JSHandle {
*
* The JSON is generated by running {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify | JSON.stringify}
* on the object in page and consequent {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse} in puppeteer.
- * **NOTE** The method will throw if the referenced object is not stringifiable.
+ * **NOTE** The method throws if the referenced object is not stringifiable.
*/
async jsonValue(): Promise<{}> {
if (this._remoteObject.objectId) {
@@ -217,13 +256,19 @@ export class JSHandle {
return helper.valueFromRemoteObject(this._remoteObject);
}
- /* This always returns null but children can define this and return an ElementHandle */
+ /**
+ * Returns either `null` or the object handle itself, if the object handle is
+ * an instance of {@link ElementHandle}.
+ */
asElement(): ElementHandle | null {
+ // This always returns null, but subclasses can override this and return an
+ // ElementHandle.
return null;
}
/**
- * The method stops referencing the element handle.
+ * Stops referencing the element handle, and resolves when the object handle is
+ * successfully disposed of.
*/
async dispose(): Promise {
if (this._disposed) return;
@@ -231,6 +276,11 @@ export class JSHandle {
await helper.releaseObject(this._client, this._remoteObject);
}
+ /**
+ * Returns a string representation of the JSHandle.
+ *
+ * @remarks Useful during debugging.
+ */
toString(): string {
if (this._remoteObject.objectId) {
const type = this._remoteObject.subtype || this._remoteObject.type;
@@ -260,16 +310,23 @@ export class JSHandle {
* })();
* ```
*
- * ElementHandle prevents DOM element from garbage collection unless the handle is
- * {@link JSHandle.dispose | disposed}. ElementHandles are auto-disposed when their
- * origin frame gets navigated.
+ * ElementHandle prevents the DOM element from being garbage-collected unless the
+ * handle is {@link JSHandle.dispose | disposed}. ElementHandles are auto-disposed
+ * when their origin frame gets navigated.
*
* ElementHandle instances can be used as arguments in {@link Page.$eval} and
* {@link Page.evaluate} 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 `` element, you can type it as
+ * `ElementHandle` and you get some nicer type checks.
+ *
* @public
*/
-export class ElementHandle extends JSHandle {
+export class ElementHandle<
+ ElementType extends Element = Element
+> extends JSHandle {
private _page: Page;
private _frameManager: FrameManager;
@@ -290,7 +347,7 @@ export class ElementHandle extends JSHandle {
this._frameManager = frameManager;
}
- asElement(): ElementHandle | null {
+ asElement(): ElementHandle | null {
return this;
}
@@ -307,46 +364,48 @@ export class ElementHandle extends JSHandle {
}
private async _scrollIntoViewIfNeeded(): Promise {
- const error = await this.evaluate>(
- async (element: HTMLElement, pageJavascriptEnabled: boolean) => {
- if (!element.isConnected) return 'Node is detached from document';
- if (element.nodeType !== Node.ELEMENT_NODE)
- return 'Node is not of type HTMLElement';
- // force-scroll if page's javascript is disabled.
- if (!pageJavascriptEnabled) {
- element.scrollIntoView({
- block: 'center',
- inline: 'center',
- // Chrome still supports behavior: instant but it's not in the spec
- // so TS shouts We don't want to make this breaking change in
- // Puppeteer yet so we'll ignore the line.
- // @ts-ignore
- behavior: 'instant',
- });
- return false;
- }
- const visibleRatio = await new Promise((resolve) => {
- const observer = new IntersectionObserver((entries) => {
- resolve(entries[0].intersectionRatio);
- observer.disconnect();
- });
- observer.observe(element);
+ const error = await this.evaluate<
+ (
+ element: Element,
+ pageJavascriptEnabled: boolean
+ ) => Promise
+ >(async (element, pageJavascriptEnabled) => {
+ if (!element.isConnected) return 'Node is detached from document';
+ if (element.nodeType !== Node.ELEMENT_NODE)
+ return 'Node is not of type HTMLElement';
+ // force-scroll if page's javascript is disabled.
+ if (!pageJavascriptEnabled) {
+ element.scrollIntoView({
+ block: 'center',
+ inline: 'center',
+ // Chrome still supports behavior: instant but it's not in the spec
+ // so TS shouts We don't want to make this breaking change in
+ // Puppeteer yet so we'll ignore the line.
+ // @ts-ignore
+ behavior: 'instant',
});
- if (visibleRatio !== 1.0) {
- element.scrollIntoView({
- block: 'center',
- inline: 'center',
- // Chrome still supports behavior: instant but it's not in the spec
- // so TS shouts We don't want to make this breaking change in
- // Puppeteer yet so we'll ignore the line.
- // @ts-ignore
- behavior: 'instant',
- });
- }
return false;
- },
- this._page.isJavaScriptEnabled()
- );
+ }
+ const visibleRatio = await new Promise((resolve) => {
+ const observer = new IntersectionObserver((entries) => {
+ resolve(entries[0].intersectionRatio);
+ observer.disconnect();
+ });
+ observer.observe(element);
+ });
+ if (visibleRatio !== 1.0) {
+ element.scrollIntoView({
+ block: 'center',
+ inline: 'center',
+ // Chrome still supports behavior: instant but it's not in the spec
+ // so TS shouts We don't want to make this breaking change in
+ // Puppeteer yet so we'll ignore the line.
+ // @ts-ignore
+ behavior: 'instant',
+ });
+ }
+ return false;
+ }, this._page.isJavaScriptEnabled());
if (error) throw new Error(error);
}
@@ -461,11 +520,9 @@ export class ElementHandle extends JSHandle {
'"'
);
- /* TODO(jacktfranklin@): once ExecutionContext is TypeScript, and
- * its evaluate function is properly typed with generics we can
- * return here and remove the typecasting
- */
- return this.evaluate((element: HTMLSelectElement, values: string[]) => {
+ return this.evaluate<
+ (element: HTMLSelectElement, values: string[]) => string[]
+ >((element, values) => {
if (element.nodeName.toLowerCase() !== 'select')
throw new Error('Element is not a element.');
@@ -491,9 +548,9 @@ export class ElementHandle extends JSHandle {
* relative to the {@link https://nodejs.org/api/process.html#process_process_cwd | current working directory}
*/
async uploadFile(...filePaths: string[]): Promise {
- const isMultiple = await this.evaluate(
- (element: HTMLInputElement) => element.multiple
- );
+ const isMultiple = await this.evaluate<
+ (element: HTMLInputElement) => boolean
+ >((element) => element.multiple);
assert(
filePaths.length <= 1 || isMultiple,
'Multiple file uploads only work with '
@@ -531,7 +588,7 @@ export class ElementHandle extends JSHandle {
// not actually update the files in that case, so the solution is to eval the element
// value to a new FileList directly.
if (files.length === 0) {
- await this.evaluate((element: HTMLInputElement) => {
+ await this.evaluate<(element: HTMLInputElement) => void>((element) => {
element.files = new DataTransfer().files;
// Dispatch events for this case because it should behave akin to a user action.
@@ -711,8 +768,8 @@ export class ElementHandle extends JSHandle {
}
/**
- * 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`.
*/
async $(selector: string): Promise {
const defaultHandler = (element: Element, selector: string) =>
@@ -730,8 +787,8 @@ export class ElementHandle extends JSHandle {
}
/**
- * 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 `[]`.
*/
async $$(selector: string): Promise {
const defaultHandler = (element: Element, selector: string) =>
@@ -770,22 +827,36 @@ export class ElementHandle extends JSHandle {
* expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
* ```
*/
- async $eval(
+ async $eval(
selector: string,
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
+ pageFunction: (
+ element: Element,
+ ...args: unknown[]
+ ) => ReturnType | Promise,
+ ...args: SerializableOrJSHandle[]
+ ): Promise> {
const elementHandle = await this.$(selector);
if (!elementHandle)
throw new Error(
`Error: failed to find element matching selector "${selector}"`
);
- const result = await elementHandle.evaluate(
- pageFunction,
- ...args
- );
+ const result = await elementHandle.evaluate<
+ (
+ element: Element,
+ ...args: SerializableOrJSHandle[]
+ ) => ReturnType | Promise
+ >(pageFunction, ...args);
await elementHandle.dispose();
- return result;
+
+ /**
+ * This as is a little unfortunate but helps TS understand the behavour of
+ * `elementHandle.evaluate`. If evalute returns an element it will return an
+ * ElementHandle instance, rather than the plain object. All the
+ * WrapElementHandle type does is wrap ReturnType into
+ * ElementHandle if it is an ElementHandle, or leave it alone as
+ * ReturnType if it isn't.
+ */
+ return result as WrapElementHandle;
}
/**
@@ -813,8 +884,8 @@ export class ElementHandle extends JSHandle {
*/
async $$eval(
selector: string,
- pageFunction: Function | string,
- ...args: unknown[]
+ pageFunction: EvaluateFn | string,
+ ...args: SerializableOrJSHandle[]
): Promise {
const defaultHandler = (element: Element, selector: string) =>
Array.from(element.querySelectorAll(selector));
@@ -827,7 +898,7 @@ export class ElementHandle extends JSHandle {
queryHandler,
updatedSelector
);
- const result = await arrayHandle.evaluate(
+ const result = await arrayHandle.evaluate<(...args: any[]) => ReturnType>(
pageFunction,
...args
);
@@ -841,19 +912,22 @@ export class ElementHandle extends JSHandle {
* @param expression - Expression to {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/evaluate | evaluate}
*/
async $x(expression: string): Promise {
- const arrayHandle = await this.evaluateHandle((element, expression) => {
- const document = element.ownerDocument || element;
- const iterator = document.evaluate(
- expression,
- element,
- null,
- XPathResult.ORDERED_NODE_ITERATOR_TYPE
- );
- const array = [];
- let item;
- while ((item = iterator.iterateNext())) array.push(item);
- return array;
- }, expression);
+ const arrayHandle = await this.evaluateHandle(
+ (element: Document, expression: string) => {
+ const document = element.ownerDocument || element;
+ const iterator = document.evaluate(
+ expression,
+ element,
+ null,
+ XPathResult.ORDERED_NODE_ITERATOR_TYPE
+ );
+ const array = [];
+ let item;
+ while ((item = iterator.iterateNext())) array.push(item);
+ return array;
+ },
+ expression
+ );
const properties = await arrayHandle.getProperties();
await arrayHandle.dispose();
const result = [];
@@ -868,16 +942,18 @@ export class ElementHandle extends JSHandle {
* Resolves to true if the element is visible in the current viewport.
*/
async isIntersectingViewport(): Promise {
- return await this.evaluate>(async (element) => {
- const visibleRatio = await new Promise((resolve) => {
- const observer = new IntersectionObserver((entries) => {
- resolve(entries[0].intersectionRatio);
- observer.disconnect();
+ return await this.evaluate<(element: Element) => Promise>(
+ async (element) => {
+ const visibleRatio = await new Promise((resolve) => {
+ const observer = new IntersectionObserver((entries) => {
+ resolve(entries[0].intersectionRatio);
+ observer.disconnect();
+ });
+ observer.observe(element);
});
- observer.observe(element);
- });
- return visibleRatio > 0;
- });
+ return visibleRatio > 0;
+ }
+ );
}
}
diff --git a/remote/test/puppeteer/src/common/Page.ts b/remote/test/puppeteer/src/common/Page.ts
index 2ded9343f9f21..971bbc9fd4d9c 100644
--- a/remote/test/puppeteer/src/common/Page.ts
+++ b/remote/test/puppeteer/src/common/Page.ts
@@ -15,6 +15,7 @@
*/
import * as fs from 'fs';
+import { promisify } from 'util';
import { EventEmitter } from './EventEmitter';
import * as mime from 'mime';
import { Events } from './Events';
@@ -22,7 +23,7 @@ import { Connection, CDPSession } from './Connection';
import { Dialog } from './Dialog';
import { EmulationManager } from './EmulationManager';
import { Frame, FrameManager } from './FrameManager';
-import { Keyboard, Mouse, Touchscreen, MouseButtonInput } from './Input';
+import { Keyboard, Mouse, Touchscreen, MouseButton } from './Input';
import { Tracing } from './Tracing';
import { assert } from './assert';
import { helper, debugError } from './helper';
@@ -41,9 +42,18 @@ import { FileChooser } from './FileChooser';
import { ConsoleMessage, ConsoleMessageType } from './ConsoleMessage';
import { PuppeteerLifeCycleEvent } from './LifecycleWatcher';
import Protocol from '../protocol';
+import {
+ EvaluateFn,
+ SerializableOrJSHandle,
+ EvaluateHandleFn,
+ WrapElementHandle,
+} from './EvalTypes';
-const writeFileAsync = helper.promisify(fs.writeFile);
+const writeFileAsync = promisify(fs.writeFile);
+/**
+ * @public
+ */
export interface Metrics {
Timestamp?: number;
Documents?: number;
@@ -60,11 +70,56 @@ export interface Metrics {
JSHeapTotalSize?: number;
}
-interface WaitForOptions {
+/**
+ * @public
+ */
+export interface WaitTimeoutOptions {
+ /**
+ * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to
+ * disable the timeout.
+ *
+ * @remarks
+ * The default value can be changed by using the
+ * {@link Page.setDefaultTimeout} method.
+ */
+ timeout?: number;
+}
+
+/**
+ * @public
+ */
+export interface WaitForOptions {
+ /**
+ * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to
+ * disable the timeout.
+ *
+ * @remarks
+ * The default value can be changed by using the
+ * {@link Page.setDefaultTimeout} or {@link Page.setDefaultNavigationTimeout}
+ * methods.
+ */
timeout?: number;
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
}
+/**
+ * @public
+ */
+export interface GeolocationOptions {
+ /**
+ * Latitude between -90 and 90.
+ */
+ longitude: number;
+ /**
+ * Longitude between -180 and 180.
+ */
+ latitude: number;
+ /**
+ * Optional non-negative accuracy value.
+ */
+ accuracy?: number;
+}
+
interface MediaFeature {
name: string;
value: string;
@@ -139,6 +194,8 @@ type VisionDeficiency =
/**
* All the events that a page instance may emit.
+ *
+ * @public
*/
export const enum PageEmittedEvents {
/**
@@ -241,7 +298,8 @@ export class Page extends EventEmitter {
private _viewport: Viewport | null;
private _screenshotTaskQueue: ScreenshotTaskQueue;
private _workers = new Map();
- // TODO: improve this typedef - it's a function that takes a file chooser or something?
+ // TODO: improve this typedef - it's a function that takes a file chooser or
+ // something?
private _fileChooserInterceptors = new Set();
private _disconnectPromise?: Promise;
@@ -367,12 +425,19 @@ export class Page extends EventEmitter {
for (const interceptor of interceptors) interceptor.call(null, fileChooser);
}
+ /**
+ * @returns `true` if the page has JavaScript enabled, `false` otherwise.
+ */
public isJavaScriptEnabled(): boolean {
return this._javascriptEnabled;
}
+ /**
+ * @param options - Optional waiting parameters
+ * @returns Resolves after a page requests a file picker.
+ */
async waitForFileChooser(
- options: { timeout?: number } = {}
+ options: WaitTimeoutOptions = {}
): Promise {
if (!this._fileChooserInterceptors.size)
await this._client.send('Page.setInterceptFileChooserDialog', {
@@ -395,11 +460,19 @@ export class Page extends EventEmitter {
});
}
- async setGeolocation(options: {
- longitude: number;
- latitude: number;
- accuracy?: number;
- }): Promise {
+ /**
+ * Sets the page's geolocation.
+ *
+ * @remarks
+ * Consider using {@link BrowserContext.overridePermissions} to grant
+ * permissions for the page to read its geolocation.
+ *
+ * @example
+ * ```js
+ * await page.setGeolocation({latitude: 59.95, longitude: 30.31667});
+ * ```
+ */
+ async setGeolocation(options: GeolocationOptions): Promise {
const { longitude, latitude, accuracy = 0 } = options;
if (longitude < -180 || longitude > 180)
throw new Error(
@@ -420,14 +493,23 @@ export class Page extends EventEmitter {
});
}
+ /**
+ * @returns A target this page was created from.
+ */
target(): Target {
return this._target;
}
+ /**
+ * @returns The browser this page belongs to.
+ */
browser(): Browser {
return this._target.browser();
}
+ /**
+ * @returns The browser context that the page belongs to
+ */
browserContext(): BrowserContext {
return this._target.browserContext();
}
@@ -446,6 +528,9 @@ export class Page extends EventEmitter {
);
}
+ /**
+ * @returns The page's main frame.
+ */
mainFrame(): Frame {
return this._frameManager.mainFrame();
}
@@ -470,40 +555,150 @@ export class Page extends EventEmitter {
return this._accessibility;
}
+ /**
+ * @returns An array of all frames attached to the page.
+ */
frames(): Frame[] {
return this._frameManager.frames();
}
+ /**
+ * @returns all of the dedicated
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorkers}
+ * associated with the page.
+ */
workers(): WebWorker[] {
return Array.from(this._workers.values());
}
+ /**
+ * @param value - Whether to enable request interception.
+ *
+ * @remarks
+ * Activating request interception enables {@link HTTPRequest.abort},
+ * {@link HTTPRequest.continue} and {@link HTTPRequest.respond} methods. This
+ * provides the capability to modify network requests that are made by a page.
+ *
+ * Once request interception is enabled, every request will stall unless it's
+ * continued, responded or aborted.
+ *
+ * **NOTE** Enabling request interception disables page caching.
+ *
+ * @example
+ * An example of a naïve request interceptor that aborts all image requests:
+ * ```js
+ * const puppeteer = require('puppeteer');
+ * (async () => {
+ * const browser = await puppeteer.launch();
+ * const page = await browser.newPage();
+ * await page.setRequestInterception(true);
+ * page.on('request', interceptedRequest => {
+ * if (interceptedRequest.url().endsWith('.png') ||
+ * interceptedRequest.url().endsWith('.jpg'))
+ * interceptedRequest.abort();
+ * else
+ * interceptedRequest.continue();
+ * });
+ * await page.goto('https://example.com');
+ * await browser.close();
+ * })();
+ * ```
+ */
async setRequestInterception(value: boolean): Promise {
return this._frameManager.networkManager().setRequestInterception(value);
}
+ /**
+ * @param enabled - When `true`, enables offline mode for the page.
+ */
setOfflineMode(enabled: boolean): Promise {
return this._frameManager.networkManager().setOfflineMode(enabled);
}
+ /**
+ * @param timeout - Maximum navigation time in milliseconds.
+ */
setDefaultNavigationTimeout(timeout: number): void {
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
}
+ /**
+ * @param timeout - Maximum time in milliseconds.
+ */
setDefaultTimeout(timeout: number): void {
this._timeoutSettings.setDefaultTimeout(timeout);
}
+ /**
+ * Runs `document.querySelector` within the page. If no element matches the
+ * selector, the return value resolves to `null`.
+ *
+ * @remarks
+ * Shortcut for {@link Frame.$ | Page.mainFrame().$(selector) }.
+ *
+ * @param selector - A
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
+ * to query page for.
+ */
async $(selector: string): Promise {
return this.mainFrame().$(selector);
}
- async evaluateHandle(
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
+ /**
+ * @remarks
+ *
+ * The only difference between {@link Page.evaluate | page.evaluate} and
+ * `page.evaluateHandle` is that `evaluateHandle` will return the value
+ * wrapped in an in-page object.
+ *
+ * If the function passed to `page.evaluteHandle` returns a Promise, the
+ * function will wait for the promise to resolve and return its value.
+ *
+ * You can pass a string instead of a function (although functions are
+ * recommended as they are easier to debug and use with TypeScript):
+ *
+ * @example
+ * ```
+ * const aHandle = await page.evaluateHandle('document')
+ * ```
+ *
+ * @example
+ * {@link JSHandle} instances can be passed as arguments to the `pageFunction`:
+ * ```
+ * const aHandle = await page.evaluateHandle(() => document.body);
+ * const resultHandle = await page.evaluateHandle(body => body.innerHTML, aHandle);
+ * console.log(await resultHandle.jsonValue());
+ * await resultHandle.dispose();
+ * ```
+ *
+ * Most of the time this function returns a {@link JSHandle},
+ * but if `pageFunction` returns a reference to an element,
+ * you instead get an {@link ElementHandle} back:
+ *
+ * @example
+ * ```
+ * const button = await page.evaluateHandle(() => document.querySelector('button'));
+ * // can call `click` because `button` is an `ElementHandle`
+ * await button.click();
+ * ```
+ *
+ * The TypeScript definitions assume that `evaluateHandle` returns
+ * a `JSHandle`, but if you know it's going to return an
+ * `ElementHandle`, pass it as the generic argument:
+ *
+ * ```
+ * const button = await page.evaluateHandle(...);
+ * ```
+ *
+ * @param pageFunction - a function that is run within the page
+ * @param args - arguments to be passed to the pageFunction
+ */
+ async evaluateHandle(
+ pageFunction: EvaluateHandleFn,
+ ...args: SerializableOrJSHandle[]
+ ): Promise {
const context = await this.mainFrame().executionContext();
- return context.evaluateHandle(pageFunction, ...args);
+ return context.evaluateHandle(pageFunction, ...args);
}
async queryObjects(prototypeHandle: JSHandle): Promise {
@@ -511,18 +706,89 @@ export class Page extends EventEmitter {
return context.queryObjects(prototypeHandle);
}
- async $eval(
+ /**
+ * This method runs `document.querySelector` within the page and passes the
+ * result as the first argument to the `pageFunction`.
+ *
+ * @remarks
+ *
+ * If no element is found matching `selector`, the method will throw an error.
+ *
+ * If `pageFunction` returns a promise `$eval` will wait for the promise to
+ * resolve and then return its value.
+ *
+ * @example
+ *
+ * ```
+ * const searchValue = await page.$eval('#search', el => el.value);
+ * const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
+ * const html = await page.$eval('.main-container', el => el.outerHTML);
+ * ```
+ *
+ * If you are using TypeScript, you may have to provide an explicit type to the
+ * first argument of the `pageFunction`.
+ * By default it is typed as `Element`, but you may need to provide a more
+ * specific sub-type:
+ *
+ * @example
+ *
+ * ```
+ * // if you don't provide HTMLInputElement here, TS will error
+ * // as `value` is not on `Element`
+ * const searchValue = await page.$eval('#search', (el: HTMLInputElement) => el.value);
+ * ```
+ *
+ * The compiler should be able to infer the return type
+ * from the `pageFunction` you provide. If it is unable to, you can use the generic
+ * type to tell the compiler what return type you expect from `$eval`:
+ *
+ * @example
+ *
+ * ```
+ * // The compiler can infer the return type in this case, but if it can't
+ * // or if you want to be more explicit, provide it as the generic type.
+ * const searchValue = await page.$eval(
+ * '#search', (el: HTMLInputElement) => el.value
+ * );
+ * ```
+ *
+ * @param selector the
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
+ * to query for
+ * @param pageFunction the function to be evaluated in the page context. Will
+ * be passed the result of `document.querySelector(selector)` as its first
+ * argument.
+ * @param args any additional arguments to pass through to `pageFunction`.
+ *
+ * @returns The result of calling `pageFunction`. If it returns an element it
+ * is wrapped in an {@link ElementHandle}, else the raw value itself is
+ * returned.
+ */
+ async $eval(
selector: string,
- pageFunction: Function | string,
- ...args: unknown[]
- ): Promise {
+ pageFunction: (
+ element: Element,
+ /* Unfortunately this has to be unknown[] because it's hard to get
+ * TypeScript to understand that the arguments will be left alone unless
+ * they are an ElementHandle, in which case they will be unwrapped.
+ * The nice thing about unknown vs any is that unknown will force the user
+ * to type the item before using it to avoid errors.
+ *
+ * TODO(@jackfranklin): We could fix this by using overloads like
+ * DefinitelyTyped does:
+ * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/puppeteer/index.d.ts#L114
+ */
+ ...args: unknown[]
+ ) => ReturnType | Promise,
+ ...args: SerializableOrJSHandle[]
+ ): Promise> {
return this.mainFrame().$eval(selector, pageFunction, ...args);
}
async $$eval(
selector: string,
- pageFunction: Function | string,
- ...args: unknown[]
+ pageFunction: EvaluateFn | string,
+ ...args: SerializableOrJSHandle[]
): Promise {
return this.mainFrame().$$eval(selector, pageFunction, ...args);
}
@@ -1291,7 +1557,7 @@ export class Page extends EventEmitter {
selector: string,
options: {
delay?: number;
- button?: MouseButtonInput;
+ button?: MouseButton;
clickCount?: number;
} = {}
): Promise {
@@ -1330,7 +1596,7 @@ export class Page extends EventEmitter {
timeout?: number;
polling?: string | number;
} = {},
- ...args: unknown[]
+ ...args: SerializableOrJSHandle[]
): Promise {
return this.mainFrame().waitFor(
selectorOrFunctionOrTimeout,
@@ -1367,7 +1633,7 @@ export class Page extends EventEmitter {
timeout?: number;
polling?: string | number;
} = {},
- ...args: unknown[]
+ ...args: SerializableOrJSHandle[]
): Promise {
return this.mainFrame().waitForFunction(pageFunction, options, ...args);
}
diff --git a/remote/test/puppeteer/src/common/Puppeteer.ts b/remote/test/puppeteer/src/common/Puppeteer.ts
index e81ca0af9a145..e4dc0e5322a69 100644
--- a/remote/test/puppeteer/src/common/Puppeteer.ts
+++ b/remote/test/puppeteer/src/common/Puppeteer.ts
@@ -23,9 +23,7 @@ import { ProductLauncher } from '../node/Launcher';
import { BrowserFetcher, BrowserFetcherOptions } from '../node/BrowserFetcher';
import { puppeteerErrors, PuppeteerErrors } from './Errors';
import { ConnectionTransport } from './ConnectionTransport';
-
-import { devicesMap } from './DeviceDescriptors';
-import { DevicesMap } from './DeviceDescriptors';
+import { devicesMap, DevicesMap } from './DeviceDescriptors';
import { Browser } from './Browser';
import {
registerCustomQueryHandler,
@@ -34,19 +32,40 @@ import {
clearQueryHandlers,
QueryHandler,
} from './QueryHandler';
+import { PUPPETEER_REVISIONS } from '../revisions';
/**
* The main Puppeteer class
+ * Puppeteer module provides a method to launch a browser instance.
+ *
+ * @remarks
+ *
+ * @example
+ * The following is a typical example of using Puppeteer to drive automation:
+ * ```js
+ * const puppeteer = require('puppeteer');
+ *
+ * (async () => {
+ * const browser = await puppeteer.launch();
+ * const page = await browser.newPage();
+ * await page.goto('https://www.google.com');
+ * // other actions...
+ * await browser.close();
+ * })();
+ * ```
* @public
*/
export class Puppeteer {
- _projectRoot: string;
+ private _projectRoot: string;
_preferredRevision: string;
_isPuppeteerCore: boolean;
_changedProduct = false;
__productName: string;
_lazyLauncher: ProductLauncher;
+ /**
+ * @internal
+ */
constructor(
projectRoot: string,
preferredRevision: string,
@@ -60,6 +79,31 @@ export class Puppeteer {
this.__productName = productName;
}
+ /**
+ * Launches puppeteer and launches a browser instance with given arguments
+ * and options when specified.
+ *
+ * @remarks
+ *
+ * @example
+ * You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
+ * ```js
+ * const browser = await puppeteer.launch({
+ * ignoreDefaultArgs: ['--mute-audio']
+ * });
+ * ```
+ *
+ * **NOTE** Puppeteer can also be used to control the Chrome browser,
+ * but it works best with the version of Chromium it is bundled with.
+ * There is no guarantee it will work with any other version.
+ * Use `executablePath` option with extreme caution.
+ * If Google Chrome (rather than Chromium) is preferred, a {@link https://www.google.com/chrome/browser/canary.html | Chrome Canary} or {@link https://www.chromium.org/getting-involved/dev-channel | Dev Channel} build is suggested.
+ * In `puppeteer.launch([options])`, any mention of Chromium also applies to Chrome.
+ * See {@link https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/ | this article} for a description of the differences between Chromium and Chrome. {@link https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md | This article} describes some differences for Linux users.
+ *
+ * @param options - Set of configurable options to set on the browser.
+ * @returns Promise which resolves to browser instance.
+ */
launch(
options: LaunchOptions &
ChromeArgOptions &
@@ -69,6 +113,14 @@ export class Puppeteer {
return this._launcher.launch(options);
}
+ /**
+ * This method attaches Puppeteer to an existing browser instance.
+ *
+ * @remarks
+ *
+ * @param options - Set of configurable options to set on the browser.
+ * @returns Promise which resolves to browser instance.
+ */
connect(
options: BrowserOptions & {
browserWSEndpoint?: string;
@@ -81,35 +133,49 @@ export class Puppeteer {
return this._launcher.connect(options);
}
+ /**
+ * @internal
+ */
+ get _productName(): string {
+ return this.__productName;
+ }
+
+ // don't need any TSDoc here - because the getter is internal the setter is too.
set _productName(name: string) {
if (this.__productName !== name) this._changedProduct = true;
this.__productName = name;
}
- get _productName(): string {
- return this.__productName;
- }
-
+ /**
+ * @remarks
+ *
+ * **NOTE** `puppeteer.executablePath()` is affected by the `PUPPETEER_EXECUTABLE_PATH`
+ * and `PUPPETEER_CHROMIUM_REVISION` environment variables.
+ *
+ * @returns A path where Puppeteer expects to find the bundled browser.
+ * The browser binary might not be there if the download was skipped with
+ * the `PUPPETEER_SKIP_DOWNLOAD` environment variable.
+ */
executablePath(): string {
return this._launcher.executablePath();
}
+ /**
+ * @internal
+ */
get _launcher(): ProductLauncher {
if (
!this._lazyLauncher ||
this._lazyLauncher.product !== this._productName ||
this._changedProduct
) {
- // @ts-ignore
- // eslint-disable-next-line @typescript-eslint/no-var-requires
- const packageJson = require('../../package.json');
switch (this._productName) {
case 'firefox':
- this._preferredRevision = packageJson.puppeteer.firefox_revision;
+ this._preferredRevision = PUPPETEER_REVISIONS.firefox;
break;
case 'chrome':
default:
- this._preferredRevision = packageJson.puppeteer.chromium_revision;
+ this._preferredRevision = PUPPETEER_REVISIONS.chromium;
}
this._changedProduct = false;
this._lazyLauncher = Launcher(
@@ -122,26 +188,89 @@ export class Puppeteer {
return this._lazyLauncher;
}
+ /**
+ * @returns The name of the browser that is under automation (`"chrome"` or `"firefox"`)
+ *
+ * @remarks
+ * The product is set by the `PUPPETEER_PRODUCT` environment variable or the `product`
+ * option in `puppeteer.launch([options])` and defaults to `chrome`.
+ * Firefox support is experimental.
+ */
get product(): string {
return this._launcher.product;
}
+ /**
+ * @remarks
+ * @example
+ *
+ * ```js
+ * const puppeteer = require('puppeteer');
+ * const iPhone = puppeteer.devices['iPhone 6'];
+ *
+ * (async () => {
+ * const browser = await puppeteer.launch();
+ * const page = await browser.newPage();
+ * await page.emulate(iPhone);
+ * await page.goto('https://www.google.com');
+ * // other actions...
+ * await browser.close();
+ * })();
+ * ```
+ *
+ * @returns a list of devices to be used with `page.emulate(options)`. Actual list of devices can be found in {@link https://github.com/puppeteer/puppeteer/blob/main/src/DeviceDescriptors.ts | src/DeviceDescriptors.ts}.
+ */
get devices(): DevicesMap {
return devicesMap;
}
+ /**
+ * @remarks
+ *
+ * Puppeteer methods might throw errors if they are unable to fulfill a request.
+ * For example, `page.waitForSelector(selector[, options])` might fail if
+ * the selector doesn't match any nodes during the given timeframe.
+ *
+ * For certain types of errors Puppeteer uses specific error classes.
+ * These classes are available via `puppeteer.errors`
+ * @example
+ * An example of handling a timeout error:
+ * ```js
+ * try {
+ * await page.waitForSelector('.foo');
+ * } catch (e) {
+ * if (e instanceof puppeteer.errors.TimeoutError) {
+ * // Do something if this is a timeout.
+ * }
+ * }
+ * ```
+ */
get errors(): PuppeteerErrors {
return puppeteerErrors;
}
+ /**
+ *
+ * @param options - Set of configurable options to set on the browser.
+ * @returns The default flags that Chromium will be launched with.
+ */
defaultArgs(options: ChromeArgOptions = {}): string[] {
return this._launcher.defaultArgs(options);
}
+ /**
+ *
+ * @param options - Set of configurable options to specify the settings
+ * of the BrowserFetcher.
+ * @returns A new BrowserFetcher instance.
+ */
createBrowserFetcher(options: BrowserFetcherOptions): BrowserFetcher {
return new BrowserFetcher(this._projectRoot, options);
}
+ /**
+ * @internal
+ */
// eslint-disable-next-line @typescript-eslint/camelcase
__experimental_registerCustomQueryHandler(
name: string,
@@ -150,16 +279,25 @@ export class Puppeteer {
registerCustomQueryHandler(name, queryHandler);
}
+ /**
+ * @internal
+ */
// eslint-disable-next-line @typescript-eslint/camelcase
__experimental_unregisterCustomQueryHandler(name: string): void {
unregisterCustomQueryHandler(name);
}
+ /**
+ * @internal
+ */
// eslint-disable-next-line @typescript-eslint/camelcase
__experimental_customQueryHandlers(): Map {
return customQueryHandlers();
}
+ /**
+ * @internal
+ */
// eslint-disable-next-line @typescript-eslint/camelcase
__experimental_clearQueryHandlers(): void {
clearQueryHandlers();
diff --git a/remote/test/puppeteer/src/common/Target.ts b/remote/test/puppeteer/src/common/Target.ts
index 5a80e801494ba..1a280a2b6b526 100644
--- a/remote/test/puppeteer/src/common/Target.ts
+++ b/remote/test/puppeteer/src/common/Target.ts
@@ -22,6 +22,9 @@ import { Browser, BrowserContext } from './Browser';
import { Viewport } from './PuppeteerViewport';
import Protocol from '../protocol';
+/**
+ * @public
+ */
export class Target {
private _targetInfo: Protocol.Target.TargetInfo;
private _browserContext: BrowserContext;
diff --git a/remote/test/puppeteer/src/common/Tracing.ts b/remote/test/puppeteer/src/common/Tracing.ts
index 673310dd1dfeb..15b0b14dd4f0f 100644
--- a/remote/test/puppeteer/src/common/Tracing.ts
+++ b/remote/test/puppeteer/src/common/Tracing.ts
@@ -17,7 +17,10 @@ import { assert } from './assert';
import { helper } from './helper';
import { CDPSession } from './Connection';
-interface TracingOptions {
+/**
+ * @public
+ */
+export interface TracingOptions {
path?: string;
screenshots?: boolean;
categories?: string[];
@@ -35,6 +38,8 @@ interface TracingOptions {
* await page.goto('https://www.google.com');
* await page.tracing.stop();
* ```
+ *
+ * @public
*/
export class Tracing {
_client: CDPSession;
diff --git a/remote/test/puppeteer/src/common/USKeyboardLayout.ts b/remote/test/puppeteer/src/common/USKeyboardLayout.ts
index 69da035557646..feb3a1f7f1bc7 100644
--- a/remote/test/puppeteer/src/common/USKeyboardLayout.ts
+++ b/remote/test/puppeteer/src/common/USKeyboardLayout.ts
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+/**
+ * @internal
+ */
export interface KeyDefinition {
keyCode?: number;
shiftKeyCode?: number;
@@ -25,6 +28,12 @@ export interface KeyDefinition {
location?: number;
}
+/**
+ * All the valid keys that can be passed to functions that take user input, such
+ * as {@link Keyboard.press | keyboard.press }
+ *
+ * @public
+ */
export type KeyInput =
| '0'
| '1'
@@ -282,6 +291,9 @@ export type KeyInput =
| 'VolumeDown'
| 'VolumeUp';
+/**
+ * @internal
+ */
export const keyDefinitions: Readonly> = {
'0': { keyCode: 48, key: '0', code: 'Digit0' },
'1': { keyCode: 49, key: '1', code: 'Digit1' },
diff --git a/remote/test/puppeteer/src/common/WebWorker.ts b/remote/test/puppeteer/src/common/WebWorker.ts
index 4b9e4ab3ff7cc..c74e14899f372 100644
--- a/remote/test/puppeteer/src/common/WebWorker.ts
+++ b/remote/test/puppeteer/src/common/WebWorker.ts
@@ -19,12 +19,20 @@ import { ExecutionContext } from './ExecutionContext';
import { JSHandle } from './JSHandle';
import { CDPSession } from './Connection';
import Protocol from '../protocol';
+import { EvaluateHandleFn, SerializableOrJSHandle } from './EvalTypes';
+/**
+ * @internal
+ */
type ConsoleAPICalledCallback = (
eventType: string,
handles: JSHandle[],
trace: Protocol.Runtime.StackTrace
) => void;
+
+/**
+ * @internal
+ */
type ExceptionThrownCallback = (
details: Protocol.Runtime.ExceptionDetails
) => void;
@@ -123,8 +131,8 @@ export class WebWorker extends EventEmitter {
* non-serializable value, then `worker.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. Shortcut for `await
- * worker.executionContext()).evaluate(pageFunction, ...args)`.
+ * bigint literals.
+ * Shortcut for `await worker.executionContext()).evaluate(pageFunction, ...args)`.
*
* @param pageFunction - Function to be evaluated in the worker context.
* @param args - Arguments to pass to `pageFunction`.
@@ -152,11 +160,11 @@ export class WebWorker extends EventEmitter {
* @param args - Arguments to pass to `pageFunction`.
* @returns Promise which resolves to the return value of `pageFunction`.
*/
- async evaluateHandle(
- pageFunction: Function | string,
- ...args: any[]
+ async evaluateHandle(
+ pageFunction: EvaluateHandleFn,
+ ...args: SerializableOrJSHandle[]
): Promise {
- return (await this._executionContextPromise).evaluateHandle(
+ return (await this._executionContextPromise).evaluateHandle(
pageFunction,
...args
);
diff --git a/remote/test/puppeteer/src/common/helper.ts b/remote/test/puppeteer/src/common/helper.ts
index 71ff4536599f4..20c0529c72ce8 100644
--- a/remote/test/puppeteer/src/common/helper.ts
+++ b/remote/test/puppeteer/src/common/helper.ts
@@ -268,7 +268,6 @@ async function readProtocolStream(
}
export const helper = {
- promisify,
evaluationString,
readProtocolStream,
waitWithTimeout,
diff --git a/remote/test/puppeteer/src/environment.ts b/remote/test/puppeteer/src/environment.ts
new file mode 100644
index 0000000000000..0d2a7a1f125cb
--- /dev/null
+++ b/remote/test/puppeteer/src/environment.ts
@@ -0,0 +1,17 @@
+/**
+ * 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.
+ */
+
+export const isNode = typeof document === 'undefined';
diff --git a/remote/test/puppeteer/src/index-core.ts b/remote/test/puppeteer/src/index-core.ts
new file mode 100644
index 0000000000000..692279f1273f9
--- /dev/null
+++ b/remote/test/puppeteer/src/index-core.ts
@@ -0,0 +1,20 @@
+/**
+ * Copyright 2017 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { initializePuppeteer } from './initialize';
+
+const puppeteer = initializePuppeteer('puppeteer-core');
+export default puppeteer;
diff --git a/remote/test/puppeteer/src/index.ts b/remote/test/puppeteer/src/index.ts
index 6adf9e0b36bf9..bcabc49357841 100644
--- a/remote/test/puppeteer/src/index.ts
+++ b/remote/test/puppeteer/src/index.ts
@@ -15,20 +15,6 @@
*/
import { initializePuppeteer } from './initialize';
-import * as path from 'path';
-const puppeteer = initializePuppeteer({
- packageJson: require(path.join(__dirname, '..', 'package.json')),
- rootDirectory: path.join(__dirname, '..'),
-});
-
-/*
- * Has to be CJS here rather than ESM such that the output file ends with
- * module.exports = puppeteer.
- *
- * If this was export default puppeteer the output would be:
- * exports.default = puppeteer
- * And therefore consuming via require('puppeteer') would break / require the user
- * to access require('puppeteer').default;
- */
-export = puppeteer;
+const puppeteer = initializePuppeteer('puppeteer');
+export default puppeteer;
diff --git a/remote/test/puppeteer/src/initialize.ts b/remote/test/puppeteer/src/initialize.ts
index 73f0c624c38b0..429379c844c4c 100644
--- a/remote/test/puppeteer/src/initialize.ts
+++ b/remote/test/puppeteer/src/initialize.ts
@@ -21,28 +21,19 @@ const api = require('./api');
import { helper } from './common/helper';
import { Puppeteer } from './common/Puppeteer';
+import { PUPPETEER_REVISIONS } from './revisions';
+import pkgDir from 'pkg-dir';
-interface InitOptions {
- packageJson: {
- puppeteer: {
- chromium_revision: string;
- firefox_revision: string;
- };
- name: string;
- };
- rootDirectory: string;
-}
-
-export const initializePuppeteer = (options: InitOptions): Puppeteer => {
- const { packageJson, rootDirectory } = options;
+export const initializePuppeteer = (packageName: string): Puppeteer => {
+ const puppeteerRootDirectory = pkgDir.sync(__dirname);
for (const className in api) {
if (typeof api[className] === 'function')
helper.installAsyncStackHooks(api[className]);
}
- let preferredRevision = packageJson.puppeteer.chromium_revision;
- const isPuppeteerCore = packageJson.name === 'puppeteer-core';
+ let preferredRevision = PUPPETEER_REVISIONS.chromium;
+ const isPuppeteerCore = packageName === 'puppeteer-core';
// puppeteer-core ignores environment variables
const product = isPuppeteerCore
? undefined
@@ -50,10 +41,10 @@ export const initializePuppeteer = (options: InitOptions): Puppeteer => {
process.env.npm_config_puppeteer_product ||
process.env.npm_package_config_puppeteer_product;
if (!isPuppeteerCore && product === 'firefox')
- preferredRevision = packageJson.puppeteer.firefox_revision;
+ preferredRevision = PUPPETEER_REVISIONS.firefox;
const puppeteer = new Puppeteer(
- rootDirectory,
+ puppeteerRootDirectory,
preferredRevision,
isPuppeteerCore,
product
diff --git a/remote/test/puppeteer/src/install.ts b/remote/test/puppeteer/src/install.ts
new file mode 100644
index 0000000000000..57872e93ccaa9
--- /dev/null
+++ b/remote/test/puppeteer/src/install.ts
@@ -0,0 +1,176 @@
+/**
+ * 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.
+ */
+
+import os from 'os';
+import https from 'https';
+import ProgressBar from 'progress';
+import puppeteer from './index';
+import { PUPPETEER_REVISIONS } from './revisions';
+
+const firefoxVersions =
+ 'https://product-details.mozilla.org/1.0/firefox_versions.json';
+
+const supportedProducts = {
+ chrome: 'Chromium',
+ firefox: 'Firefox Nightly',
+} as const;
+
+export async function downloadBrowser() {
+ const downloadHost =
+ process.env.PUPPETEER_DOWNLOAD_HOST ||
+ process.env.npm_config_puppeteer_download_host ||
+ process.env.npm_package_config_puppeteer_download_host;
+ 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 ||
+ PUPPETEER_REVISIONS.chromium
+ );
+ } else if (product === 'firefox') {
+ puppeteer._preferredRevision = PUPPETEER_REVISIONS.firefox;
+ return getFirefoxNightlyVersion(browserFetcher.host()).catch((error) => {
+ console.error(error);
+ process.exit(1);
+ });
+ } else {
+ throw new Error(`Unsupported product ${product}`);
+ }
+ }
+
+ 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;
+
+ function onSuccess(localRevisions: string[]): void {
+ 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]);
+ }
+
+ function onError(error: 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) {
+ 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 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;
+ }
+}
+
+export function logPolitely(toBeLogged) {
+ const logLevel = process.env.npm_config_loglevel;
+ const logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1;
+
+ // eslint-disable-next-line no-console
+ if (!logLevelDisplay) console.log(toBeLogged);
+}
diff --git a/remote/test/puppeteer/src/node/BrowserFetcher.ts b/remote/test/puppeteer/src/node/BrowserFetcher.ts
index 9f5df3cda6ce9..f76cc4c2f35f3 100644
--- a/remote/test/puppeteer/src/node/BrowserFetcher.ts
+++ b/remote/test/puppeteer/src/node/BrowserFetcher.ts
@@ -24,12 +24,13 @@ import * as http from 'http';
import extractZip from 'extract-zip';
import { debug } from '../common/Debug';
+import { promisify } from 'util';
import removeRecursive from 'rimraf';
import * as URL from 'url';
import ProxyAgent from 'https-proxy-agent';
import { getProxyForUrl } from 'proxy-from-env';
import { assert } from '../common/assert';
-import { helper } from '../common/helper';
+
const debugFetcher = debug(`puppeteer:fetcher`);
const downloadURLs = {
@@ -61,12 +62,14 @@ const browserConfig = {
/**
* Supported platforms.
+ * @public
*/
-type Platform = 'linux' | 'mac' | 'win32' | 'win64';
+export type Platform = 'linux' | 'mac' | 'win32' | 'win64';
/**
* Supported products.
+ * @public
*/
-type Product = 'chrome' | 'firefox';
+export type Product = 'chrome' | 'firefox';
function archiveName(
product: Product,
@@ -116,10 +119,10 @@ function handleArm64(): void {
}
});
}
-const readdirAsync = helper.promisify(fs.readdir.bind(fs));
-const mkdirAsync = helper.promisify(fs.mkdir.bind(fs));
-const unlinkAsync = helper.promisify(fs.unlink.bind(fs));
-const chmodAsync = helper.promisify(fs.chmod.bind(fs));
+const readdirAsync = promisify(fs.readdir.bind(fs));
+const mkdirAsync = promisify(fs.mkdir.bind(fs));
+const unlinkAsync = promisify(fs.unlink.bind(fs));
+const chmodAsync = promisify(fs.chmod.bind(fs));
function existsAsync(filePath: string): Promise {
return new Promise((resolve) => {
@@ -127,6 +130,9 @@ function existsAsync(filePath: string): Promise {
});
}
+/**
+ * @public
+ */
export interface BrowserFetcherOptions {
platform?: Platform;
product?: string;
@@ -134,7 +140,10 @@ export interface BrowserFetcherOptions {
host?: string;
}
-interface BrowserFetcherRevisionInfo {
+/**
+ * @public
+ */
+export interface BrowserFetcherRevisionInfo {
folderPath: string;
executablePath: string;
url: string;
diff --git a/remote/test/puppeteer/src/node/BrowserRunner.ts b/remote/test/puppeteer/src/node/BrowserRunner.ts
index c3ae7f47e5fdc..b7b6d8b437943 100644
--- a/remote/test/puppeteer/src/node/BrowserRunner.ts
+++ b/remote/test/puppeteer/src/node/BrowserRunner.ts
@@ -26,8 +26,9 @@ import { WebSocketTransport } from '../common/WebSocketTransport';
import { PipeTransport } from './PipeTransport';
import * as readline from 'readline';
import { TimeoutError } from '../common/Errors';
+import { promisify } from 'util';
-const removeFolderAsync = helper.promisify(removeFolder);
+const removeFolderAsync = promisify(removeFolder);
const debugLauncher = debug('puppeteer:launcher');
const PROCESS_ERROR_EXPLANATION = `Puppeteer was unable to kill the process which ran the browser binary.
This means that, on future Puppeteer launches, Puppeteer might not be able to launch the browser.
diff --git a/remote/test/puppeteer/src/node/LaunchOptions.ts b/remote/test/puppeteer/src/node/LaunchOptions.ts
index 81548c9c26ed0..487020ec27158 100644
--- a/remote/test/puppeteer/src/node/LaunchOptions.ts
+++ b/remote/test/puppeteer/src/node/LaunchOptions.ts
@@ -16,6 +16,11 @@
import { Viewport } from '../common/PuppeteerViewport';
+/**
+ * Launcher options that only apply to Chrome.
+ *
+ * @public
+ */
export interface ChromeArgOptions {
headless?: boolean;
args?: string[];
@@ -23,6 +28,10 @@ export interface ChromeArgOptions {
devtools?: boolean;
}
+/**
+ * Generic launch options that can be passed when launching any browser.
+ * @public
+ */
export interface LaunchOptions {
executablePath?: string;
ignoreDefaultArgs?: boolean | string[];
@@ -35,6 +44,10 @@ export interface LaunchOptions {
pipe?: boolean;
}
+/**
+ * Generic browser options that can be passed when launching any browser.
+ * @public
+ */
export interface BrowserOptions {
ignoreHTTPSErrors?: boolean;
defaultViewport?: Viewport;
diff --git a/remote/test/puppeteer/src/node/Launcher.ts b/remote/test/puppeteer/src/node/Launcher.ts
index d95d6b0fc2413..eb165f19e8ee8 100644
--- a/remote/test/puppeteer/src/node/Launcher.ts
+++ b/remote/test/puppeteer/src/node/Launcher.ts
@@ -24,13 +24,14 @@ import { BrowserFetcher } from './BrowserFetcher';
import { Connection } from '../common/Connection';
import { Browser } from '../common/Browser';
import { assert } from '../common/assert';
-import { helper, debugError } from '../common/helper';
+import { debugError } from '../common/helper';
import { ConnectionTransport } from '../common/ConnectionTransport';
import { WebSocketTransport } from '../common/WebSocketTransport';
import { BrowserRunner } from './BrowserRunner';
+import { promisify } from 'util';
-const mkdtempAsync = helper.promisify(fs.mkdtemp);
-const writeFileAsync = helper.promisify(fs.writeFile);
+const mkdtempAsync = promisify(fs.mkdtemp);
+const writeFileAsync = promisify(fs.writeFile);
import {
ChromeArgOptions,
@@ -38,6 +39,10 @@ import {
BrowserOptions,
} from './LaunchOptions';
+/**
+ * Describes a launcher - a class that is able to create and launch a browser instance.
+ * @public
+ */
export interface ProductLauncher {
launch(object);
connect(object);
@@ -46,6 +51,9 @@ export interface ProductLauncher {
product: string;
}
+/**
+ * @internal
+ */
class ChromeLauncher implements ProductLauncher {
_projectRoot: string;
_preferredRevision: string;
@@ -266,6 +274,9 @@ class ChromeLauncher implements ProductLauncher {
}
}
+/**
+ * @internal
+ */
class FirefoxLauncher implements ProductLauncher {
_projectRoot: string;
_preferredRevision: string;
@@ -765,7 +776,10 @@ function resolveExecutablePath(
return { executablePath: revisionInfo.executablePath, missingText };
}
-function Launcher(
+/**
+ * @internal
+ */
+export default function Launcher(
projectRoot: string,
preferredRevision: string,
isPuppeteerCore: boolean,
@@ -802,5 +816,3 @@ function Launcher(
);
}
}
-
-export default Launcher;
diff --git a/remote/test/puppeteer/src/revisions.ts b/remote/test/puppeteer/src/revisions.ts
new file mode 100644
index 0000000000000..9b307e9dca682
--- /dev/null
+++ b/remote/test/puppeteer/src/revisions.ts
@@ -0,0 +1,25 @@
+/**
+ * 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.
+ */
+
+type Revisions = Readonly<{
+ readonly chromium: string;
+ readonly firefox: string;
+}>;
+
+export const PUPPETEER_REVISIONS: Revisions = {
+ chromium: '756035',
+ firefox: 'latest',
+};
diff --git a/remote/test/puppeteer/test/click.spec.ts b/remote/test/puppeteer/test/click.spec.ts
index e7411b1bd8a7f..9dd77a44d539a 100644
--- a/remote/test/puppeteer/test/click.spec.ts
+++ b/remote/test/puppeteer/test/click.spec.ts
@@ -322,7 +322,7 @@ describe('Page.click', function () {
server.CROSS_PROCESS_PREFIX + '/input/button.html'
);
const frame = page.frames()[1];
- await frame.$eval('button', (button) =>
+ await frame.$eval('button', (button: HTMLElement) =>
button.style.setProperty('position', 'fixed')
);
await frame.click('button');
diff --git a/remote/test/puppeteer/test/elementhandle.spec.ts b/remote/test/puppeteer/test/elementhandle.spec.ts
index f4d7603a9c936..46de86c65c0c7 100644
--- a/remote/test/puppeteer/test/elementhandle.spec.ts
+++ b/remote/test/puppeteer/test/elementhandle.spec.ts
@@ -182,17 +182,11 @@ describe('ElementHandle specs', function () {
const { page, server } = getTestState();
await page.goto(server.PREFIX + '/shadow.html');
- const buttonHandle = await page.evaluateHandle(
+ const buttonHandle = await page.evaluateHandle(
// @ts-expect-error button is expected to be in the page's scope.
() => button
);
- // TODO (@jackfranklin): TS types are off here. evaluateHandle returns a
- // JSHandle but that doesn't have a click() method. In this case it seems
- // to return an ElementHandle. I'm not sure if the tests are wrong here
- // and should use evaluate or if the type of evaluateHandle
- // should change to enable the user to tell us they are expecting an
- // ElementHandle rather than the default JSHandle.
- await (buttonHandle as ElementHandle).click();
+ await buttonHandle.click();
expect(
await page.evaluate(
// @ts-expect-error clicked is expected to be in the page's scope.
diff --git a/remote/test/puppeteer/test/headful.spec.ts b/remote/test/puppeteer/test/headful.spec.ts
index 23bc4f86a76ed..88237c0d2dad4 100644
--- a/remote/test/puppeteer/test/headful.spec.ts
+++ b/remote/test/puppeteer/test/headful.spec.ts
@@ -22,7 +22,7 @@ import expect from 'expect';
import {
getTestState,
describeChromeOnly,
- itFailsWindowsUntilDate,
+ itFailsWindows,
} from './mocha-utils';
import rimraf from 'rimraf';
@@ -91,15 +91,10 @@ describeChromeOnly('headful tests', function () {
expect(pages).toEqual(['about:blank']);
await browser.close();
});
- itFailsWindowsUntilDate(
- /* We have deferred fixing this test on Windows in favour of
- * getting all other Windows tests running on CI. Putting this
- * date in to force us to come back and debug properly in the
- * future.
- */
- new Date('2020-07-01'),
+ itFailsWindows(
'headless should be able to read cookies written by headful',
async () => {
+ /* Needs investigation into why but this fails consistently on Windows CI. */
const { server, puppeteer } = getTestState();
const userDataDir = await mkdtempAsync(TMP_FOLDER);
diff --git a/remote/test/puppeteer/test/input.spec.ts b/remote/test/puppeteer/test/input.spec.ts
index 5bf1e76e54609..b5fa2d04e5ccb 100644
--- a/remote/test/puppeteer/test/input.spec.ts
+++ b/remote/test/puppeteer/test/input.spec.ts
@@ -140,7 +140,7 @@ describe('input tests', function () {
const [fileChooser1, fileChooser2] = await Promise.all([
page.waitForFileChooser(),
page.waitForFileChooser(),
- page.$eval('input', (input) => input.click()),
+ page.$eval('input', (input: HTMLInputElement) => input.click()),
]);
expect(fileChooser1 === fileChooser2).toBe(true);
});
@@ -161,10 +161,18 @@ describe('input tests', function () {
chooser.accept([FILE_TO_UPLOAD]),
new Promise((x) => page.once('metrics', x)),
]);
- expect(await page.$eval('input', (input) => input.files.length)).toBe(1);
- expect(await page.$eval('input', (input) => input.files[0].name)).toBe(
- 'file-to-upload.txt'
- );
+ expect(
+ await page.$eval(
+ 'input',
+ (input: HTMLInputElement) => input.files.length
+ )
+ ).toBe(1);
+ expect(
+ await page.$eval(
+ 'input',
+ (input: HTMLInputElement) => input.files[0].name
+ )
+ ).toBe('file-to-upload.txt');
});
it('should be able to read selected file', async () => {
const { page } = getTestState();
@@ -174,7 +182,7 @@ describe('input tests', function () {
.waitForFileChooser()
.then((chooser) => chooser.accept([FILE_TO_UPLOAD]));
expect(
- await page.$eval('input', async (picker) => {
+ await page.$eval('input', async (picker: HTMLInputElement) => {
picker.click();
await new Promise((x) => (picker.oninput = x));
const reader = new FileReader();
@@ -192,7 +200,7 @@ describe('input tests', function () {
.waitForFileChooser()
.then((chooser) => chooser.accept([FILE_TO_UPLOAD]));
expect(
- await page.$eval('input', async (picker) => {
+ await page.$eval('input', async (picker: HTMLInputElement) => {
picker.click();
await new Promise((x) => (picker.oninput = x));
return picker.files.length;
@@ -200,7 +208,7 @@ describe('input tests', function () {
).toBe(1);
page.waitForFileChooser().then((chooser) => chooser.accept([]));
expect(
- await page.$eval('input', async (picker) => {
+ await page.$eval('input', async (picker: HTMLInputElement) => {
picker.click();
await new Promise((x) => (picker.oninput = x));
return picker.files.length;
@@ -247,7 +255,7 @@ describe('input tests', function () {
await page.setContent(`