> For the complete documentation index, see [llms.txt](https://mucsi96.gitbook.io/w3c-webdriver/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mucsi96.gitbook.io/w3c-webdriver/screen-capture.md).

# Screen capture

## session.takeScreenshot()

Takes a screenshot of the top-level browsing context’s viewport.

**RETURNS**

Promise\<Buffer>

**EXAMPLES**

```typescript
const screenshot = await session.takeScreenshot();
// screenshot = Buffer containing PNG
```

**SEE ALSO**

* [WebDriver spec](https://www.w3.org/TR/webdriver/#take-screenshot)

## element.takeScreenshot()

Takes a screenshot of the visible region encompassed by the bounding rectangle of an element

**RETURNS**

Promise\<Buffer>

**EXAMPLES**

```typescript
const screenshot = await session.takeScreenshot();
// screenshot = Buffer containing PNG
```

**SEE ALSO**

* [WebDriver spec](https://www.w3.org/TR/webdriver/#take-element-screenshot)
