Back to Puppeteer

Page.screencast() method

docs/api/puppeteer.page.screencast.md

19.2.21.3 KB
Original Source

Page.screencast() method

Captures a screencast of this page.

Signature

typescript
class Page {
  screencast(options?: Readonly<ScreencastOptions>): Promise<ScreenRecorder>;
}

Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

options

</td><td>

Readonly<ScreencastOptions>

</td><td>

(Optional) Configures screencast behavior.

</td></tr> </tbody></table>

Returns:

Promise<ScreenRecorder>

Remarks

By default, all recordings will be WebM format using the VP9 video codec, with a frame rate of 30 FPS.

You must have ffmpeg installed on your system.

Example

Recording a page:

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();