Skip to content

Commit 71414c3

Browse files
committed
docs(screenshot): note webp limitation on WebKit macOS
1 parent 6f43ad7 commit 71414c3

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

docs/src/api/params.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,8 @@ saved to the disk.
12891289
## screenshot-option-type
12901290
- `type` <[ScreenshotType]<"png"|"jpeg"|"webp">>
12911291

1292-
Specify screenshot type, defaults to `png`.
1292+
Specify screenshot type, defaults to `png`. The `webp` type is not supported in
1293+
WebKit on macOS because macOS CoreGraphics does not provide a webp encoder.
12931294

12941295
## screenshot-option-mask
12951296
- `mask` <[Array]<[Locator]>>

packages/playwright-client/types/types.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12311,7 +12311,8 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
1231112311
timeout?: number;
1231212312

1231312313
/**
12314-
* Specify screenshot type, defaults to `png`.
12314+
* Specify screenshot type, defaults to `png`. The `webp` type is not supported in WebKit on macOS because macOS
12315+
* CoreGraphics does not provide a webp encoder.
1231512316
*/
1231612317
type?: "png"|"jpeg"|"webp";
1231712318
}): Promise<Buffer>;
@@ -24122,7 +24123,8 @@ export interface LocatorScreenshotOptions {
2412224123
timeout?: number;
2412324124

2412424125
/**
24125-
* Specify screenshot type, defaults to `png`.
24126+
* Specify screenshot type, defaults to `png`. The `webp` type is not supported in WebKit on macOS because macOS
24127+
* CoreGraphics does not provide a webp encoder.
2412624128
*/
2412724129
type?: "png"|"jpeg"|"webp";
2412824130
}
@@ -24795,7 +24797,8 @@ export interface PageScreenshotOptions {
2479524797
timeout?: number;
2479624798

2479724799
/**
24798-
* Specify screenshot type, defaults to `png`.
24800+
* Specify screenshot type, defaults to `png`. The `webp` type is not supported in WebKit on macOS because macOS
24801+
* CoreGraphics does not provide a webp encoder.
2479924802
*/
2480024803
type?: "png"|"jpeg"|"webp";
2480124804
}

packages/playwright-core/src/tools/backend/screenshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import type * as playwright from '../../..';
3030
type ImageFormat = 'png' | 'jpeg' | 'webp';
3131

3232
const screenshotSchema = optionalElementSchema.extend({
33-
type: z.enum(['png', 'jpeg', 'webp']).optional().describe('Image format for the screenshot. If unset, inferred from the filename extension, otherwise png.'),
33+
type: z.enum(['png', 'jpeg', 'webp']).optional().describe('Image format for the screenshot. If unset, inferred from the filename extension, otherwise png. Note: `webp` is not supported in WebKit on macOS.'),
3434
filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg|webp}` if not specified. Prefer relative file names to stay within the output directory.'),
3535
fullPage: z.boolean().optional().describe('When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.'),
3636
});

packages/playwright-core/src/tools/cli-daemon/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ const screenshot = declareCommand({
790790
}),
791791
options: z.object({
792792
filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg|webp}` if not specified.'),
793-
type: z.enum(['png', 'jpeg', 'webp']).optional().describe('Image format. If unset, inferred from the filename extension, otherwise png.'),
793+
type: z.enum(['png', 'jpeg', 'webp']).optional().describe('Image format. If unset, inferred from the filename extension, otherwise png. webp is not supported in WebKit on macOS.'),
794794
['full-page']: z.boolean().optional().describe('When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.'),
795795
}),
796796
toolName: 'browser_take_screenshot',

packages/playwright-core/types/types.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12311,7 +12311,8 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
1231112311
timeout?: number;
1231212312

1231312313
/**
12314-
* Specify screenshot type, defaults to `png`.
12314+
* Specify screenshot type, defaults to `png`. The `webp` type is not supported in WebKit on macOS because macOS
12315+
* CoreGraphics does not provide a webp encoder.
1231512316
*/
1231612317
type?: "png"|"jpeg"|"webp";
1231712318
}): Promise<Buffer>;
@@ -24122,7 +24123,8 @@ export interface LocatorScreenshotOptions {
2412224123
timeout?: number;
2412324124

2412424125
/**
24125-
* Specify screenshot type, defaults to `png`.
24126+
* Specify screenshot type, defaults to `png`. The `webp` type is not supported in WebKit on macOS because macOS
24127+
* CoreGraphics does not provide a webp encoder.
2412624128
*/
2412724129
type?: "png"|"jpeg"|"webp";
2412824130
}
@@ -24795,7 +24797,8 @@ export interface PageScreenshotOptions {
2479524797
timeout?: number;
2479624798

2479724799
/**
24798-
* Specify screenshot type, defaults to `png`.
24800+
* Specify screenshot type, defaults to `png`. The `webp` type is not supported in WebKit on macOS because macOS
24801+
* CoreGraphics does not provide a webp encoder.
2479924802
*/
2480024803
type?: "png"|"jpeg"|"webp";
2480124804
}

0 commit comments

Comments
 (0)