Screencast
Added in: v1.59Interface for capturing screencast frames from a page.
Methods
screencast.hideActions()
Added in: v1.59 asyncRemoves action decorations.
screencast.hideOverlays()
Added in: v1.59 asyncHides overlays without removing them.
screencast.showActions()
Added in: v1.59 asyncEnables visual annotations on interacted elements. Returns a disposable that stops showing actions when disposed.
Arguments
cursor"none" | "pointer"(optional) Added in: v1.61Cursor decoration shown for pointer actions.
"pointer"(the default) renders a mouse pointer that animates from the previous action point to the next one."none"disables the cursor decoration.How long each annotation is displayed in milliseconds. Defaults to
500.Font size of the action title in pixels. Defaults to
24.position"top-left" | "top" | "top-right" | "bottom-left" | "bottom" | "bottom-right"(optional)Position of the action title overlay. Defaults to
"top-right".styleObject(optional) Added in: v1.64Styles of the action decorations. All decorations fade out over
duration.Usage
jsawait page.screencast.showActions({ style: { point: 'width: 20px; height: 20px; border-radius: 50%; background: red', highlight: 'outline: 2px solid #333; background: rgba(0, 128, 255, .15)', title: 'font-size: 16px', }, });pointstring(optional) Added in: v1.64CSS declarations for the marker at the action point. The marker is positioned at the action point, has zero size and is centered on the point, so its size and look come from this style. Not shown when omitted.
highlightstring(optional) Added in: v1.64CSS declarations for the box that covers the target element. The box is positioned and sized to the element bounds. Not shown when omitted.
titlestring(optional) Added in: v1.64CSS declarations for the action title, for example
'font-size: 32px; background: #333'. The title is placed according toposition.
Returns
Promise<Disposable>
screencast.showChapter()
Added in: v1.59 asyncShows a chapter overlay with a title and optional description, centered on the page with a blurred backdrop. Useful for narrating video recordings. The overlay is removed after the specified duration, or 2000ms.
Arguments
Title text displayed prominently in the overlay.
screencast.showOverlay()
Added in: v1.59 asyncAdds an overlay with the given HTML content. The overlay is displayed on top of the page until removed. Returns a disposable that removes the overlay when disposed.
Arguments
HTML content for the overlay.
Returns
Promise<Disposable>
screencast.showOverlays()
Added in: v1.59 asyncShows overlays.
screencast.start()
Added in: v1.59 asyncStarts the screencast. When path is provided, it saves video recording to the specified file. When onFrame is provided, delivers JPEG-encoded frames to the callback. Both can be used together.
Usage
// Record video
await page.screencast.start({ path: 'video.webm', size: { width: 1280, height: 800 } });
// ... perform actions ...
await page.screencast.stop();// Capture frames
await page.screencast.start({
onFrame: ({ data, timestamp, viewportWidth, viewportHeight }) => {
console.log(`frame size: ${data.length} (${viewportWidth}x${viewportHeight}) at ${timestamp}`);
},
size: { width: 800, height: 600 },
});
// ... perform actions ...
await page.screencast.stop();Arguments
fpsint(optional) Added in: v1.64Frame rate of the video recording in frames per second. Only used together with
path. Defaults to25.Higher frame rates make animations and scrolling smoother at the cost of more CPU spent on encoding. Combine with
sizeto record high resolution videos. The video can only contain as many distinct frames as the browser produces; Firefox and WebKit currently capture up to 25 frames per second.onFramefunction(Object): Promise(optional)Callback that receives JPEG-encoded frame data along with the page viewport size at the time of capture.
dataBufferJPEG-encoded frame data.
timestampfloatThe timestamp of when the frame was presented by the browser, in milliseconds since the Unix epoch.
viewportWidthintWidth of the page viewport at the time the frame was captured.
viewportHeightintHeight of the page viewport at the time the frame was captured.
Path where the video should be saved when the screencast is stopped. When provided, video recording is started.
The quality of the image, between 0-100.
Specifies the dimensions of screencast frames. The actual frame is scaled to preserve the page's aspect ratio and may be smaller than these bounds. If a screencast is already active (e.g. started by tracing or video recording), the existing configuration takes precedence and the frame size may exceed these bounds or this option may be ignored. If not specified the size will be equal to page viewport scaled down to fit into 800×800.
widthintMax frame width in pixels.
heightintMax frame height in pixels.
Returns
Promise<Disposable>
screencast.stop()
Added in: v1.59 asyncStops the screencast and video recording if active. If a video was being recorded, saves it to the path specified in screencast.start().