` and you get some nicer type checks.
@@ -41,40 +41,35 @@ The constructor for this class is marked as internal. Third-party code should no
## Methods
-| Method | Modifiers | Description |
-| -------------------------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| [$(selector)](./puppeteer.elementhandle._.md) | | Runs element.querySelector
within the page. |
-| [$(selector)](./puppeteer.elementhandle.__1.md) | | |
-| [$$(selector)](./puppeteer.elementhandle.__.md) | | Runs element.querySelectorAll
within the page. |
-| [$$(selector)](./puppeteer.elementhandle.___1.md) | | |
-| [$$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_1.md) | | |
-| [$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.
|
-| [$eval(selector, pageFunction, args)](./puppeteer.elementhandle._eval_1.md) | | |
-| [$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. |
-| [asElement()](./puppeteer.elementhandle.aselement.md) | | |
-| [boundingBox()](./puppeteer.elementhandle.boundingbox.md) | | This method returns the bounding box of the element (relative to the main frame), or null
if the element is not visible. |
-| [boxModel()](./puppeteer.elementhandle.boxmodel.md) | | This method returns boxes of the element, or null
if the element is not visible. |
-| [click(options)](./puppeteer.elementhandle.click.md) | | This method scrolls element into view if needed, and then uses [Page.mouse](./puppeteer.page.mouse.md) to click in the center of the element. If the element is detached from DOM, the method throws an error. |
-| [clickablePoint(offset)](./puppeteer.elementhandle.clickablepoint.md) | | Returns the middle point within an element unless a specific offset is provided. |
-| [contentFrame()](./puppeteer.elementhandle.contentframe.md) | | Resolves to the content frame for element handles referencing iframe nodes, or null otherwise |
-| [drag(target)](./puppeteer.elementhandle.drag.md) | | This method creates and captures a dragevent from the element. |
-| [dragAndDrop(target, options)](./puppeteer.elementhandle.draganddrop.md) | | This method triggers a dragenter, dragover, and drop on the element. |
-| [dragEnter(data)](./puppeteer.elementhandle.dragenter.md) | | This method creates a dragenter
event on the element. |
-| [dragOver(data)](./puppeteer.elementhandle.dragover.md) | | This method creates a dragover
event on the element. |
-| [drop(data)](./puppeteer.elementhandle.drop.md) | | This method triggers a drop on the element. |
-| [focus()](./puppeteer.elementhandle.focus.md) | | Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element. |
-| [hover()](./puppeteer.elementhandle.hover.md) | | This method scrolls element into view if needed, and then uses [Page.mouse](./puppeteer.page.mouse.md) to hover over the center of the element. If the element is detached from DOM, the method throws an error. |
-| [isIntersectingViewport(options)](./puppeteer.elementhandle.isintersectingviewport.md) | | Resolves to true if the element is visible in the current viewport. |
-| [press(key, options)](./puppeteer.elementhandle.press.md) | | Focuses the element, and then uses [Keyboard.down()](./puppeteer.keyboard.down.md) and [Keyboard.up()](./puppeteer.keyboard.up.md). |
-| [screenshot(options)](./puppeteer.elementhandle.screenshot.md) | | This method scrolls element into view if needed, and then uses [Page.screenshot()](./puppeteer.page.screenshot.md) to take a screenshot of the element. If the element is detached from DOM, the method throws an error. |
-| [select(values)](./puppeteer.elementhandle.select.md) | | Triggers a change
and input
event once all the provided options have been selected. If there's no <select>
element matching selector
, the method throws an error. |
-| [tap()](./puppeteer.elementhandle.tap.md) | | This method scrolls element into view if needed, and then uses [Touchscreen.tap()](./puppeteer.touchscreen.tap.md) to tap in the center of the element. If the element is detached from DOM, the method throws an error. |
-| [type(text, options)](./puppeteer.elementhandle.type.md) | | Focuses the element, and then sends a keydown
, keypress
/input
, and keyup
event for each character in the text.
To press a special key, like Control
or ArrowDown
, use [ElementHandle.press()](./puppeteer.elementhandle.press.md).
|
-| [uploadFile(this, filePaths)](./puppeteer.elementhandle.uploadfile.md) | | This method expects elementHandle
to point to an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). |
-| [waitForSelector(selector, options)](./puppeteer.elementhandle.waitforselector.md) | | Wait for the selector
to appear within the element. If at the moment of calling the method the selector
already exists, the method will return immediately. If the selector
doesn't appear after the timeout
milliseconds of waiting, the function will throw.
This method does not work across navigations or if the element is detached from DOM.
|
-| [waitForSelector(selector, options)](./puppeteer.elementhandle.waitforselector_1.md) | | |
-| [waitForXPath(xpath, options)](./puppeteer.elementhandle.waitforxpath.md) | | Wait for the xpath
within the element. If at the moment of calling the method the xpath
already exists, the method will return immediately. If the xpath
doesn't appear after the timeout
milliseconds of waiting, the function will throw.
If xpath
starts with //
instead of .//
, the dot will be appended automatically.
This method works across navigation
|
+| Method | Modifiers | Description |
+| -------------------------------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [$(selector)](./puppeteer.elementhandle._.md) | | Runs element.querySelector
within the page. |
+| [$$(selector)](./puppeteer.elementhandle.__.md) | | Runs element.querySelectorAll
within the page. |
+| [$$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. |
+| [asElement()](./puppeteer.elementhandle.aselement.md) | | |
+| [boundingBox()](./puppeteer.elementhandle.boundingbox.md) | | This method returns the bounding box of the element (relative to the main frame), or null
if the element is not visible. |
+| [boxModel()](./puppeteer.elementhandle.boxmodel.md) | | This method returns boxes of the element, or null
if the element is not visible. |
+| [click(this, options)](./puppeteer.elementhandle.click.md) | | This method scrolls element into view if needed, and then uses [Page.mouse](./puppeteer.page.mouse.md) to click in the center of the element. If the element is detached from DOM, the method throws an error. |
+| [clickablePoint(offset)](./puppeteer.elementhandle.clickablepoint.md) | | Returns the middle point within an element unless a specific offset is provided. |
+| [contentFrame()](./puppeteer.elementhandle.contentframe.md) | | Resolves to the content frame for element handles referencing iframe nodes, or null otherwise |
+| [drag(this, target)](./puppeteer.elementhandle.drag.md) | | This method creates and captures a dragevent from the element. |
+| [dragAndDrop(this, target, options)](./puppeteer.elementhandle.draganddrop.md) | | This method triggers a dragenter, dragover, and drop on the element. |
+| [dragEnter(this, data)](./puppeteer.elementhandle.dragenter.md) | | This method creates a dragenter
event on the element. |
+| [dragOver(this, data)](./puppeteer.elementhandle.dragover.md) | | This method creates a dragover
event on the element. |
+| [drop(this, data)](./puppeteer.elementhandle.drop.md) | | This method triggers a drop on the element. |
+| [focus()](./puppeteer.elementhandle.focus.md) | | Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element. |
+| [hover(this)](./puppeteer.elementhandle.hover.md) | | This method scrolls element into view if needed, and then uses [Page.mouse](./puppeteer.page.mouse.md) to hover over the center of the element. If the element is detached from DOM, the method throws an error. |
+| [isIntersectingViewport(this, options)](./puppeteer.elementhandle.isintersectingviewport.md) | | Resolves to true if the element is visible in the current viewport. |
+| [press(key, options)](./puppeteer.elementhandle.press.md) | | Focuses the element, and then uses [Keyboard.down()](./puppeteer.keyboard.down.md) and [Keyboard.up()](./puppeteer.keyboard.up.md). |
+| [screenshot(this, options)](./puppeteer.elementhandle.screenshot.md) | | This method scrolls element into view if needed, and then uses [Page.screenshot()](./puppeteer.page.screenshot.md) to take a screenshot of the element. If the element is detached from DOM, the method throws an error. |
+| [select(values)](./puppeteer.elementhandle.select.md) | | Triggers a change
and input
event once all the provided options have been selected. If there's no <select>
element matching selector
, the method throws an error. |
+| [tap(this)](./puppeteer.elementhandle.tap.md) | | This method scrolls element into view if needed, and then uses [Touchscreen.tap()](./puppeteer.touchscreen.tap.md) to tap in the center of the element. If the element is detached from DOM, the method throws an error. |
+| [type(text, options)](./puppeteer.elementhandle.type.md) | | Focuses the element, and then sends a keydown
, keypress
/input
, and keyup
event for each character in the text.
To press a special key, like Control
or ArrowDown
, use [ElementHandle.press()](./puppeteer.elementhandle.press.md).
|
+| [uploadFile(this, filePaths)](./puppeteer.elementhandle.uploadfile.md) | | This method expects elementHandle
to point to an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). |
+| [waitForSelector(selector, options)](./puppeteer.elementhandle.waitforselector.md) | | Wait for the selector
to appear within the element. If at the moment of calling the method the selector
already exists, the method will return immediately. If the selector
doesn't appear after the timeout
milliseconds of waiting, the function will throw.
This method does not work across navigations or if the element is detached from DOM.
|
+| [waitForXPath(xpath, options)](./puppeteer.elementhandle.waitforxpath.md) | | Wait for the xpath
within the element. If at the moment of calling the method the xpath
already exists, the method will return immediately. If the xpath
doesn't appear after the timeout
milliseconds of waiting, the function will throw.
If xpath
starts with //
instead of .//
, the dot will be appended automatically.
This method works across navigation
|
```ts
const puppeteer = require('puppeteer');
diff --git a/docs/api/puppeteer.elementhandle.screenshot.md b/docs/api/puppeteer.elementhandle.screenshot.md
index 1445c73b858..02559169edd 100644
--- a/docs/api/puppeteer.elementhandle.screenshot.md
+++ b/docs/api/puppeteer.elementhandle.screenshot.md
@@ -10,15 +10,19 @@ This method scrolls element into view if needed, and then uses [Page.screenshot(
```typescript
class ElementHandle {
- screenshot(options?: ScreenshotOptions): Promise;
+ screenshot(
+ this: ElementHandle,
+ options?: ScreenshotOptions
+ ): Promise;
}
```
## Parameters
-| Parameter | Type | Description |
-| --------- | ----------------------------------------------------- | ----------------- |
-| options | [ScreenshotOptions](./puppeteer.screenshotoptions.md) | (Optional) |
+| Parameter | Type | Description |
+| --------- | ------------------------------------------------------------ | ----------------- |
+| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | |
+| options | [ScreenshotOptions](./puppeteer.screenshotoptions.md) | (Optional) |
**Returns:**
diff --git a/docs/api/puppeteer.elementhandle.tap.md b/docs/api/puppeteer.elementhandle.tap.md
index 64b3215827c..6676560252a 100644
--- a/docs/api/puppeteer.elementhandle.tap.md
+++ b/docs/api/puppeteer.elementhandle.tap.md
@@ -10,10 +10,16 @@ This method scrolls element into view if needed, and then uses [Touchscreen.tap(
```typescript
class ElementHandle {
- tap(): Promise;
+ tap(this: ElementHandle): Promise;
}
```
+## Parameters
+
+| Parameter | Type | Description |
+| --------- | ------------------------------------------------------------ | ----------- |
+| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | |
+
**Returns:**
Promise<void>
diff --git a/docs/api/puppeteer.elementhandle.waitforselector.md b/docs/api/puppeteer.elementhandle.waitforselector.md
index 9b6ffc3d4c6..22617c4b184 100644
--- a/docs/api/puppeteer.elementhandle.waitforselector.md
+++ b/docs/api/puppeteer.elementhandle.waitforselector.md
@@ -12,10 +12,10 @@ This method does not work across navigations or if the element is detached from
```typescript
class ElementHandle {
- waitForSelector(
+ waitForSelector(
selector: Selector,
options?: Exclude
- ): Promise | null>;
+ ): Promise> | null>;
}
```
@@ -28,7 +28,7 @@ class ElementHandle {
**Returns:**
-Promise<[ElementHandle](./puppeteer.elementhandle.md)<HTMLElementTagNameMap\[Selector\]> \| null>
+Promise<[ElementHandle](./puppeteer.elementhandle.md)<[NodeFor](./puppeteer.nodefor.md)<Selector>> \| null>
Promise which resolves when element specified by selector string is added to DOM. Resolves to `null` if waiting for hidden: `true` and selector is not found in DOM.
diff --git a/docs/api/puppeteer.elementhandle.waitforselector_1.md b/docs/api/puppeteer.elementhandle.waitforselector_1.md
deleted file mode 100644
index 55185a844a6..00000000000
--- a/docs/api/puppeteer.elementhandle.waitforselector_1.md
+++ /dev/null
@@ -1,27 +0,0 @@
----
-sidebar_label: ElementHandle.waitForSelector_1
----
-
-# ElementHandle.waitForSelector() method
-
-**Signature:**
-
-```typescript
-class ElementHandle {
- waitForSelector(
- selector: string,
- options?: Exclude
- ): Promise;
-}
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --------- | -------------------------------------------------------------------------------------- | ----------------- |
-| selector | string | |
-| options | Exclude<[WaitForSelectorOptions](./puppeteer.waitforselectoroptions.md), 'root'> | (Optional) |
-
-**Returns:**
-
-Promise<[ElementHandle](./puppeteer.elementhandle.md) \| null>
diff --git a/docs/api/puppeteer.elementhandle.waitforxpath.md b/docs/api/puppeteer.elementhandle.waitforxpath.md
index 2875398516f..631eefcb14b 100644
--- a/docs/api/puppeteer.elementhandle.waitforxpath.md
+++ b/docs/api/puppeteer.elementhandle.waitforxpath.md
@@ -41,7 +41,7 @@ class ElementHandle {
hidden?: boolean;
timeout?: number;
}
- ): Promise;
+ ): Promise | null>;
}
```
@@ -54,7 +54,7 @@ class ElementHandle {
**Returns:**
-Promise<[ElementHandle](./puppeteer.elementhandle.md) \| null>
+Promise<[ElementHandle](./puppeteer.elementhandle.md)<Node> \| null>
Promise which resolves when element specified by xpath string is added to DOM. Resolves to `null` if waiting for `hidden: true` and xpath is not found in DOM.
diff --git a/docs/api/puppeteer.frame._.md b/docs/api/puppeteer.frame._.md
index 034456d3c16..1e29bcb8e25 100644
--- a/docs/api/puppeteer.frame._.md
+++ b/docs/api/puppeteer.frame._.md
@@ -10,9 +10,9 @@ This method queries the frame for the given selector.
```typescript
class Frame {
- $(
+ $(
selector: Selector
- ): Promise | null>;
+ ): Promise> | null>;
}
```
@@ -24,6 +24,6 @@ class Frame {
**Returns:**
-Promise<[ElementHandle](./puppeteer.elementhandle.md)<HTMLElementTagNameMap\[Selector\]> \| null>
+Promise<[ElementHandle](./puppeteer.elementhandle.md)<[NodeFor](./puppeteer.nodefor.md)<Selector>> \| null>
A promise which resolves to an `ElementHandle` pointing at the element, or `null` if it was not found.
diff --git a/docs/api/puppeteer.frame.__.md b/docs/api/puppeteer.frame.__.md
index c02c5bbf9f9..7b296cbd2c1 100644
--- a/docs/api/puppeteer.frame.__.md
+++ b/docs/api/puppeteer.frame.__.md
@@ -10,9 +10,9 @@ This runs `document.querySelectorAll` in the frame and returns the result.
```typescript
class Frame {
- $$(
+ $$(
selector: Selector
- ): Promise[]>;
+ ): Promise>>>;
}
```
@@ -24,6 +24,6 @@ class Frame {
**Returns:**
-Promise<[ElementHandle](./puppeteer.elementhandle.md)<HTMLElementTagNameMap\[Selector\]>\[\]>
+Promise<Array<[ElementHandle](./puppeteer.elementhandle.md)<[NodeFor](./puppeteer.nodefor.md)<Selector>>>>
An array of element handles pointing to the found frame elements.
diff --git a/docs/api/puppeteer.frame.__1.md b/docs/api/puppeteer.frame.__1.md
deleted file mode 100644
index 48ce3de54a7..00000000000
--- a/docs/api/puppeteer.frame.__1.md
+++ /dev/null
@@ -1,23 +0,0 @@
----
-sidebar_label: Frame.$_1
----
-
-# Frame.$() method
-
-**Signature:**
-
-```typescript
-class Frame {
- $(selector: string): Promise;
-}
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --------- | ------ | ----------- |
-| selector | string | |
-
-**Returns:**
-
-Promise<[ElementHandle](./puppeteer.elementhandle.md) \| null>
diff --git a/docs/api/puppeteer.frame.___1.md b/docs/api/puppeteer.frame.___1.md
deleted file mode 100644
index d148e9d0939..00000000000
--- a/docs/api/puppeteer.frame.___1.md
+++ /dev/null
@@ -1,23 +0,0 @@
----
-sidebar_label: Frame.$$_1
----
-
-# Frame.$$() method
-
-**Signature:**
-
-```typescript
-class Frame {
- $$(selector: string): Promise;
-}
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --------- | ------ | ----------- |
-| selector | string | |
-
-**Returns:**
-
-Promise<[ElementHandle](./puppeteer.elementhandle.md)\[\]>
diff --git a/docs/api/puppeteer.frame.__eval.md b/docs/api/puppeteer.frame.__eval.md
index 8825657cd2f..6db54e4ed69 100644
--- a/docs/api/puppeteer.frame.__eval.md
+++ b/docs/api/puppeteer.frame.__eval.md
@@ -9,11 +9,11 @@ sidebar_label: Frame.$$eval
```typescript
class Frame {
$$eval<
- Selector extends keyof HTMLElementTagNameMap,
+ Selector extends string,
Params extends unknown[],
Func extends EvaluateFunc<
- [HTMLElementTagNameMap[Selector][], ...Params]
- > = EvaluateFunc<[HTMLElementTagNameMap[Selector][], ...Params]>
+ [Array>, ...Params]
+ > = EvaluateFunc<[Array>, ...Params]>
>(
selector: Selector,
pageFunction: Func | string,
diff --git a/docs/api/puppeteer.frame.__eval_1.md b/docs/api/puppeteer.frame.__eval_1.md
deleted file mode 100644
index fd02722ce28..00000000000
--- a/docs/api/puppeteer.frame.__eval_1.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-sidebar_label: Frame.$$eval_1
----
-
-# Frame.$$eval() method
-
-**Signature:**
-
-```typescript
-class Frame {
- $$eval<
- Params extends unknown[],
- Func extends EvaluateFunc<[Element[], ...Params]> = EvaluateFunc<
- [Element[], ...Params]
- >
- >(
- selector: string,
- pageFunction: Func | string,
- ...args: Params
- ): Promise>>;
-}
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| ------------ | -------------- | ----------- |
-| selector | string | |
-| pageFunction | Func \| string | |
-| args | Params | |
-
-**Returns:**
-
-Promise<Awaited<ReturnType<Func>>>
diff --git a/docs/api/puppeteer.frame._eval.md b/docs/api/puppeteer.frame._eval.md
index ccaf91df46e..28ead092bb7 100644
--- a/docs/api/puppeteer.frame._eval.md
+++ b/docs/api/puppeteer.frame._eval.md
@@ -9,11 +9,11 @@ sidebar_label: Frame.$eval
```typescript
class Frame {
$eval<
- Selector extends keyof HTMLElementTagNameMap,
+ Selector extends string,
Params extends unknown[],
Func extends EvaluateFunc<
- [HTMLElementTagNameMap[Selector], ...Params]
- > = EvaluateFunc<[HTMLElementTagNameMap[Selector], ...Params]>
+ [ElementHandle>, ...Params]
+ > = EvaluateFunc<[ElementHandle>, ...Params]>
>(
selector: Selector,
pageFunction: Func | string,
diff --git a/docs/api/puppeteer.frame._eval_1.md b/docs/api/puppeteer.frame._eval_1.md
deleted file mode 100644
index 9e149a07df9..00000000000
--- a/docs/api/puppeteer.frame._eval_1.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-sidebar_label: Frame.$eval_1
----
-
-# Frame.$eval() method
-
-**Signature:**
-
-```typescript
-class Frame {
- $eval<
- Params extends unknown[],
- Func extends EvaluateFunc<[Element, ...Params]> = EvaluateFunc<
- [Element, ...Params]
- >
- >(
- selector: string,
- pageFunction: Func | string,
- ...args: Params
- ): Promise>>;
-}
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| ------------ | -------------- | ----------- |
-| selector | string | |
-| pageFunction | Func \| string | |
-| args | Params | |
-
-**Returns:**
-
-Promise<Awaited<ReturnType<Func>>>
diff --git a/docs/api/puppeteer.frame._x.md b/docs/api/puppeteer.frame._x.md
index edb13f7cbbd..e2290048e6d 100644
--- a/docs/api/puppeteer.frame._x.md
+++ b/docs/api/puppeteer.frame._x.md
@@ -10,7 +10,7 @@ This method evaluates the given XPath expression and returns the results.
```typescript
class Frame {
- $x(expression: string): Promise;
+ $x(expression: string): Promise>>;
}
```
@@ -22,4 +22,4 @@ class Frame {
**Returns:**
-Promise<[ElementHandle](./puppeteer.elementhandle.md)\[\]>
+Promise<Array<[ElementHandle](./puppeteer.elementhandle.md)<Node>>>
diff --git a/docs/api/puppeteer.frame.addscripttag.md b/docs/api/puppeteer.frame.addscripttag.md
index 41fae9af064..3baf564eabf 100644
--- a/docs/api/puppeteer.frame.addscripttag.md
+++ b/docs/api/puppeteer.frame.addscripttag.md
@@ -10,7 +10,9 @@ Adds a `