mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: Type for ElementHandle.screenshot (#11274)
This commit is contained in:
parent
bec58dd81a
commit
22aeff1eac
@ -73,7 +73,8 @@ The constructor for this class is marked as internal. Third-party code should no
|
||||
| [isIntersectingViewport(this, options)](./puppeteer.elementhandle.isintersectingviewport.md) | | Resolves to true if the element is visible in the current viewport. If an element is an SVG, we check if the svg owner element is in the viewport instead. See https://crbug.com/963246. |
|
||||
| [isVisible()](./puppeteer.elementhandle.isvisible.md) | | Checks if an element is visible using the same mechanism as [ElementHandle.waitForSelector()](./puppeteer.elementhandle.waitforselector.md). |
|
||||
| [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_1.md) to take a screenshot of the element. If the element is detached from DOM, the method throws an error. |
|
||||
| [screenshot(options)](./puppeteer.elementhandle.screenshot.md) | | This method scrolls element into view if needed, and then uses [Page.screenshot()](./puppeteer.page.screenshot_1.md) to take a screenshot of the element. If the element is detached from DOM, the method throws an error. |
|
||||
| [screenshot(options)](./puppeteer.elementhandle.screenshot_1.md) | | |
|
||||
| [scrollIntoView(this)](./puppeteer.elementhandle.scrollintoview.md) | | Scrolls the element into view using either the automation protocol client or by calling element.scrollIntoView. |
|
||||
| [select(values)](./puppeteer.elementhandle.select.md) | | Triggers a <code>change</code> and <code>input</code> event once all the provided options have been selected. If there's no <code><select></code> element matching <code>selector</code>, 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. |
|
||||
|
@ -11,19 +11,19 @@ This method scrolls element into view if needed, and then uses [Page.screenshot(
|
||||
```typescript
|
||||
class ElementHandle {
|
||||
screenshot(
|
||||
this: ElementHandle<Element>,
|
||||
options?: Readonly<ElementScreenshotOptions>
|
||||
): Promise<string | Buffer>;
|
||||
options: Readonly<ScreenshotOptions> & {
|
||||
encoding: 'base64';
|
||||
}
|
||||
): Promise<string>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ----------------------------------------------------------------------------------- | ------------ |
|
||||
| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | |
|
||||
| options | Readonly<[ElementScreenshotOptions](./puppeteer.elementscreenshotoptions.md)> | _(Optional)_ |
|
||||
| Parameter | Type | Description |
|
||||
| --------- | --------------------------------------------------------------------------------------------------- | ----------- |
|
||||
| options | Readonly<[ScreenshotOptions](./puppeteer.screenshotoptions.md)> & { encoding: 'base64'; } | |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<string \| Buffer>
|
||||
Promise<string>
|
||||
|
23
docs/api/puppeteer.elementhandle.screenshot_1.md
Normal file
23
docs/api/puppeteer.elementhandle.screenshot_1.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
sidebar_label: ElementHandle.screenshot_1
|
||||
---
|
||||
|
||||
# ElementHandle.screenshot() method
|
||||
|
||||
#### Signature:
|
||||
|
||||
```typescript
|
||||
class ElementHandle {
|
||||
screenshot(options?: Readonly<ScreenshotOptions>): Promise<Buffer>;
|
||||
}
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | --------------------------------------------------------------------- | ------------ |
|
||||
| options | Readonly<[ScreenshotOptions](./puppeteer.screenshotoptions.md)> | _(Optional)_ |
|
||||
|
||||
**Returns:**
|
||||
|
||||
Promise<Buffer>
|
@ -1335,6 +1335,10 @@ export abstract class ElementHandle<
|
||||
* {@link Page.(screenshot:2) } to take a screenshot of the element.
|
||||
* If the element is detached from DOM, the method throws an error.
|
||||
*/
|
||||
async screenshot(
|
||||
options: Readonly<ScreenshotOptions> & {encoding: 'base64'}
|
||||
): Promise<string>;
|
||||
async screenshot(options?: Readonly<ScreenshotOptions>): Promise<Buffer>;
|
||||
@throwIfDisposed()
|
||||
@ElementHandle.bindIsolatedHandle
|
||||
async screenshot(
|
||||
|
Loading…
Reference in New Issue
Block a user