puppeteer/website/versioned_docs/version-19.7.2/api/puppeteer.elementhandle.screenshot.md
release-please[bot] e0330d82bd
chore: release main (#9716)
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
2023-02-20 18:30:51 +01:00

30 lines
873 B
Markdown

---
sidebar_label: ElementHandle.screenshot
---
# ElementHandle.screenshot() method
This method scrolls element into view if needed, and then uses to take a screenshot of the element. If the element is detached from DOM, the method throws an error.
#### Signature:
```typescript
class ElementHandle {
screenshot(
this: ElementHandle<Element>,
options?: ScreenshotOptions
): Promise<string | Buffer>;
}
```
## Parameters
| Parameter | Type | Description |
| --------- | ------------------------------------------------------------ | ----------------- |
| this | [ElementHandle](./puppeteer.elementhandle.md)&lt;Element&gt; | |
| options | [ScreenshotOptions](./puppeteer.screenshotoptions.md) | <i>(Optional)</i> |
**Returns:**
Promise&lt;string \| Buffer&gt;