Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/src/api/class-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ await browser.CloseAsync();
### option: Browser.newContext.clientCertificates = %%-context-option-clientCertificates-%%
* since: 1.46

### option: Browser.newContext.recordVideoFps = %%-context-option-recordvideo-fps-%%
* since: v1.64

### option: Browser.newContext.storageState = %%-js-python-context-option-storage-state-%%
* since: v1.8

Expand Down Expand Up @@ -292,6 +295,9 @@ testing frameworks should explicitly create [`method: Browser.newContext`] follo
### option: Browser.newPage.clientCertificates = %%-context-option-clientCertificates-%%
* since: 1.46

### option: Browser.newPage.recordVideoFps = %%-context-option-recordvideo-fps-%%
* since: v1.64

### option: Browser.newPage.storageState = %%-js-python-context-option-storage-state-%%
* since: v1.8

Expand Down
3 changes: 3 additions & 0 deletions docs/src/api/class-browsertype.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ Chromium/Chrome: Due to recent Chrome policy changes, automating the default Chr
### option: BrowserType.launchPersistentContext.clientCertificates = %%-context-option-clientCertificates-%%
* since: 1.46

### option: BrowserType.launchPersistentContext.recordVideoFps = %%-context-option-recordvideo-fps-%%
* since: v1.64

## async method: BrowserType.launchServer
* since: v1.8
* langs: js
Expand Down
8 changes: 8 additions & 0 deletions docs/src/api/class-screencast.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ await page.screencast.start({
await page.screencast.stop();
```

### option: Screencast.start.fps
* since: v1.64
- `fps` <[int]>

Frame rate of the video recording in frames per second. Only used together with [`option: Screencast.start.path`]. Defaults to `25`.

Higher frame rates make animations and scrolling smoother at the cost of more CPU spent on encoding. Combine with [`option: Screencast.start.size`] to 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.

### option: Screencast.start.onFrame
* since: v1.59
- `onFrame` <[function]\([Object]\): [Promise]>
Expand Down
8 changes: 8 additions & 0 deletions docs/src/api/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ When set to `minimal`, only record information necessary for routing from HAR. T
Actual picture of each page will be scaled down if necessary to fit the specified size.
- `width` <[int]> Video frame width.
- `height` <[int]> Video frame height.
- `fps` ?<[int]> Frame rate of the recorded videos in frames per second. Defaults to `25`. Firefox and WebKit currently capture up to 25 frames per second.
- `showActions` ?<[Object]> If specified, enables visual annotations on interacted elements during video recording.
- `duration` ?<[float]> How long each annotation is displayed in milliseconds. Defaults to `500`.
- `position` ?<[AnnotatePosition]<"top-left"|"top"|"top-right"|"bottom-left"|"bottom"|"bottom-right">> Position of the action title overlay. Defaults to `"top-right"`.
Expand Down Expand Up @@ -887,6 +888,13 @@ Dimensions of the recorded videos. If not specified the size will be equal to `v
scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450.
Actual picture of each page will be scaled down if necessary to fit the specified size.

## context-option-recordvideo-fps
* langs: csharp, java, python
- alias-python: record_video_fps
- `recordVideoFps` <[int]>

Frame rate of the recorded videos in frames per second. Defaults to `25`. Firefox and WebKit currently capture up to 25 frames per second.

## context-option-proxy
- `proxy` <[Object]>
* alias: Proxy
Expand Down
3 changes: 3 additions & 0 deletions docs/src/test-api/class-testoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ export default defineConfig({
- `size` ?<[Object]> Size of the recorded video. Optional.
- `width` <[int]>
- `height` <[int]>
- `fps` ?<[int]> Frame rate of the recorded video in frames per second. Defaults to `25`.
- `show` ?<[Object]> If specified, visually annotates the video with test information and action highlights.
- `actions` ?<[Object]> Controls visual annotations on interacted elements.
- `duration` ?<[float]> How long each annotation is displayed in milliseconds. Defaults to `500`.
Expand All @@ -749,6 +750,8 @@ See [video modes](../test-use-options.md#video-modes) for a side-by-side compari

To control video size, pass an object with `mode` and `size` properties. If video size is not specified, it will be equal to [`property: TestOptions.viewport`] scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size.

To record smoother video of animations and scrolling, pass `fps`, for example `{ mode: 'on', size: { width: 1920, height: 1080 }, fps: 60 }`. Higher frame rates and sizes use more CPU for encoding. Firefox and WebKit currently capture up to 25 frames per second.

To annotate actions in the video, pass `show` with `action` and/or `test` sub-options. The `action` option controls visual highlights on interacted elements with an optional `delay` in milliseconds (defaults to `500`). The `test` option controls which test information is displayed as a status overlay.

**Usage**
Expand Down
31 changes: 31 additions & 0 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11591,6 +11591,12 @@ export interface Browser {
height: number;
};

/**
* Frame rate of the recorded videos in frames per second. Defaults to `25`. Firefox and WebKit currently capture up
* to 25 frames per second.
*/
fps?: number;

/**
* If specified, enables visual annotations on interacted elements during video recording.
*/
Expand Down Expand Up @@ -17954,6 +17960,12 @@ export interface BrowserType<Unused = {}> {
height: number;
};

/**
* Frame rate of the recorded videos in frames per second. Defaults to `25`. Firefox and WebKit currently capture up
* to 25 frames per second.
*/
fps?: number;

/**
* If specified, enables visual annotations on interacted elements during video recording.
*/
Expand Down Expand Up @@ -18693,6 +18705,7 @@ export interface Screencast {
height: number;
};
quality?: number;
fps?: number;
}): Promise<Disposable>;
/**
* Removes action decorations.
Expand Down Expand Up @@ -24133,6 +24146,12 @@ export interface Electron {
height: number;
};

/**
* Frame rate of the recorded videos in frames per second. Defaults to `25`. Firefox and WebKit currently capture up
* to 25 frames per second.
*/
fps?: number;

/**
* If specified, enables visual annotations on interacted elements during video recording.
*/
Expand Down Expand Up @@ -24848,6 +24867,12 @@ export interface AndroidDevice {
height: number;
};

/**
* Frame rate of the recorded videos in frames per second. Defaults to `25`. Firefox and WebKit currently capture up
* to 25 frames per second.
*/
fps?: number;

/**
* If specified, enables visual annotations on interacted elements during video recording.
*/
Expand Down Expand Up @@ -26067,6 +26092,12 @@ export interface BrowserContextOptions {
height: number;
};

/**
* Frame rate of the recorded videos in frames per second. Defaults to `25`. Firefox and WebKit currently capture up
* to 25 frames per second.
*/
fps?: number;

/**
* If specified, enables visual annotations on interacted elements during video recording.
*/
Expand Down
13 changes: 13 additions & 0 deletions packages/playwright-core/src/client/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ export type AndroidDeviceLaunchBrowserParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -489,6 +490,7 @@ export type AndroidDeviceLaunchBrowserOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -872,6 +874,7 @@ export type BrowserNewContextParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -943,6 +946,7 @@ export type BrowserNewContextOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1017,6 +1021,7 @@ export type BrowserNewContextForReuseParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1088,6 +1093,7 @@ export type BrowserNewContextForReuseOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1201,6 +1207,7 @@ export type BrowserContextInitializer = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1853,6 +1860,7 @@ export type BrowserTypeLaunchPersistentContextParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1937,6 +1945,7 @@ export type BrowserTypeLaunchPersistentContextOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -2039,6 +2048,7 @@ export type ElectronLaunchParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -2078,6 +2088,7 @@ export type ElectronLaunchOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -4498,6 +4509,7 @@ export type PageScreencastStartParams = {
height: number,
},
quality?: number,
fps?: number,
sendFrames?: boolean,
record?: boolean,
};
Expand All @@ -4507,6 +4519,7 @@ export type PageScreencastStartOptions = {
height: number,
},
quality?: number,
fps?: number,
sendFrames?: boolean,
record?: boolean,
};
Expand Down
3 changes: 2 additions & 1 deletion packages/playwright-core/src/client/screencast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Screencast implements api.Screencast {
});
}

async start(options: { onFrame?: (frame: { data: Buffer, timestamp: number, viewportWidth: number, viewportHeight: number }) => Promise<any>|any, path?: string, size?: { width: number, height: number }, quality?: number } = {}): Promise<DisposableStub> {
async start(options: { onFrame?: (frame: { data: Buffer, timestamp: number, viewportWidth: number, viewportHeight: number }) => Promise<any>|any, path?: string, size?: { width: number, height: number }, quality?: number, fps?: number } = {}): Promise<DisposableStub> {
if (this._started)
throw new Error('Screencast is already started');
this._started = true;
Expand All @@ -48,6 +48,7 @@ export class Screencast implements api.Screencast {
const result = await this._page._channel.screencastStart({
size: options.size,
quality: options.quality,
fps: options.fps,
sendFrames: !!options.onFrame,
record: !!options.path,
}, kNoTimeout);
Expand Down
2 changes: 2 additions & 0 deletions packages/playwright-core/src/server/browserContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ export function validateBrowserContextOptions(options: types.BrowserContextOptio
options.viewport = { width: 1280, height: 720 };
if (options.proxy)
options.proxy = normalizeProxySettings(options.proxy);
if (options.recordVideo?.fps !== undefined && options.recordVideo.fps <= 0)
throw new Error(`"recordVideo.fps" must be a positive number, got ${options.recordVideo.fps}`);
verifyGeolocation(options.geolocation);
}

Expand Down
13 changes: 13 additions & 0 deletions packages/playwright-core/src/server/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ export type AndroidDeviceLaunchBrowserParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -490,6 +491,7 @@ export type AndroidDeviceLaunchBrowserOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -873,6 +875,7 @@ export type BrowserNewContextParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -944,6 +947,7 @@ export type BrowserNewContextOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1018,6 +1022,7 @@ export type BrowserNewContextForReuseParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1089,6 +1094,7 @@ export type BrowserNewContextForReuseOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1202,6 +1208,7 @@ export type BrowserContextInitializer = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1854,6 +1861,7 @@ export type BrowserTypeLaunchPersistentContextParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -1938,6 +1946,7 @@ export type BrowserTypeLaunchPersistentContextOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -2040,6 +2049,7 @@ export type ElectronLaunchParams = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -2079,6 +2089,7 @@ export type ElectronLaunchOptions = {
width: number,
height: number,
},
fps?: number,
showActions?: {
duration?: number,
position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right',
Expand Down Expand Up @@ -4499,6 +4510,7 @@ export type PageScreencastStartParams = {
height: number,
},
quality?: number,
fps?: number,
sendFrames?: boolean,
record?: boolean,
};
Expand All @@ -4508,6 +4520,7 @@ export type PageScreencastStartOptions = {
height: number,
},
quality?: number,
fps?: number,
sendFrames?: boolean,
record?: boolean,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ export class PageDispatcher extends Dispatcher<Page, channels.PageChannel, Brows
async screencastStart(params: channels.PageScreencastStartParams, progress?: Progress): Promise<channels.PageScreencastStartResult> {
if (this._screencastClient || this._videoRecorder)
throw new Error('Screencast is already running');
if (params.fps !== undefined && params.fps <= 0)
throw new Error(`"fps" must be a positive number, got ${params.fps}`);

if (params.sendFrames) {
this._screencastClient = {
Expand Down
Loading
Loading