2023-10-06 14:50:39 +00:00
|
|
|
---
|
|
|
|
sidebar_label: Page.screencast
|
|
|
|
---
|
|
|
|
|
|
|
|
# Page.screencast() method
|
|
|
|
|
|
|
|
Captures a screencast of this [page](./puppeteer.page.md).
|
|
|
|
|
|
|
|
#### Signature:
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
class Page {
|
|
|
|
screencast(options?: Readonly<ScreencastOptions>): Promise<ScreenRecorder>;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2024-03-20 15:03:14 +00:00
|
|
|
<table><thead><tr><th>
|
2023-10-06 14:50:39 +00:00
|
|
|
|
2024-03-20 15:03:14 +00:00
|
|
|
Parameter
|
|
|
|
|
|
|
|
</th><th>
|
|
|
|
|
|
|
|
Type
|
|
|
|
|
|
|
|
</th><th>
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
|
|
|
</th></tr></thead>
|
|
|
|
<tbody><tr><td>
|
|
|
|
|
|
|
|
options
|
|
|
|
|
|
|
|
</td><td>
|
|
|
|
|
|
|
|
Readonly<[ScreencastOptions](./puppeteer.screencastoptions.md)>
|
|
|
|
|
|
|
|
</td><td>
|
|
|
|
|
|
|
|
_(Optional)_ Configures screencast behavior.
|
|
|
|
|
|
|
|
</td></tr>
|
|
|
|
</tbody></table>
|
2023-10-06 14:50:39 +00:00
|
|
|
**Returns:**
|
|
|
|
|
|
|
|
Promise<[ScreenRecorder](./puppeteer.screenrecorder.md)>
|
|
|
|
|
|
|
|
## Remarks
|
|
|
|
|
2023-10-09 15:43:54 +00:00
|
|
|
All recordings will be [WebM](https://www.webmproject.org/) format using the [VP9](https://www.webmproject.org/vp9/) video codec. The FPS is 30.
|
2023-10-06 14:50:39 +00:00
|
|
|
|
2023-10-09 15:43:54 +00:00
|
|
|
You must have [ffmpeg](https://ffmpeg.org/) installed on your system.
|
2023-10-06 14:50:39 +00:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
Recording a [page](./puppeteer.page.md):
|
|
|
|
|
|
|
|
```
|
|
|
|
import puppeteer from 'puppeteer';
|
|
|
|
|
|
|
|
// Launch a browser
|
|
|
|
const browser = await puppeteer.launch();
|
|
|
|
|
|
|
|
// Create a new page
|
|
|
|
const page = await browser.newPage();
|
|
|
|
|
|
|
|
// Go to your site.
|
|
|
|
await page.goto("https://www.example.com");
|
|
|
|
|
|
|
|
// Start recording.
|
|
|
|
const recorder = await page.screencast({path: 'recording.webm'});
|
|
|
|
|
|
|
|
// Do something.
|
|
|
|
|
|
|
|
// Stop recording.
|
|
|
|
await recorder.stop();
|
|
|
|
|
|
|
|
browser.close();
|
|
|
|
```
|