From bca7e7e974a74f46cb1949cb434fb678cf359d26 Mon Sep 17 00:00:00 2001 From: Rohan Patnaik Date: Fri, 22 May 2026 14:14:50 +0530 Subject: [PATCH] feat(api): add screencast size option --- playwright/_impl/_screencast.py | 4 +++- playwright/async_api/_generated.py | 8 +++++++- playwright/sync_api/_generated.py | 8 +++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/playwright/_impl/_screencast.py b/playwright/_impl/_screencast.py index 600297203..418cd60cf 100644 --- a/playwright/_impl/_screencast.py +++ b/playwright/_impl/_screencast.py @@ -16,7 +16,7 @@ from pathlib import Path from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Union -from playwright._impl._api_structures import ScreencastFrame +from playwright._impl._api_structures import ScreencastFrame, ViewportSize from playwright._impl._artifact import Artifact from playwright._impl._connection import from_nullable_channel from playwright._impl._disposable import DisposableStub @@ -70,6 +70,7 @@ async def start( onFrame: ScreencastFrameCallback = None, path: Union[str, Path] = None, quality: int = None, + size: ViewportSize = None, ) -> DisposableStub: if self._started: raise Error("Screencast is already started") @@ -80,6 +81,7 @@ async def start( None, { "quality": quality, + "size": size, "sendFrames": bool(onFrame), "record": bool(path), }, diff --git a/playwright/async_api/_generated.py b/playwright/async_api/_generated.py index 229ba6d8c..f812e957e 100644 --- a/playwright/async_api/_generated.py +++ b/playwright/async_api/_generated.py @@ -7692,6 +7692,7 @@ async def start( ] = None, path: typing.Optional[typing.Union[pathlib.Path, str]] = None, quality: typing.Optional[int] = None, + size: typing.Optional[ViewportSize] = None, ) -> "AsyncContextManager": """Screencast.start @@ -7708,6 +7709,8 @@ async def start( Path where the video should be saved when the screencast is stopped. When provided, video recording is started. quality : Union[int, None] The quality of the image, between 0-100. + size : Union[{width: int, height: int}, None] + Output frame size. Returns ------- @@ -7716,7 +7719,10 @@ async def start( return mapping.from_impl( await self._impl_obj.start( - onFrame=self._wrap_handler(on_frame), path=path, quality=quality + onFrame=self._wrap_handler(on_frame), + path=path, + quality=quality, + size=size, ) ) diff --git a/playwright/sync_api/_generated.py b/playwright/sync_api/_generated.py index d2d37baa2..701aab255 100644 --- a/playwright/sync_api/_generated.py +++ b/playwright/sync_api/_generated.py @@ -7768,6 +7768,7 @@ def start( ] = None, path: typing.Optional[typing.Union[pathlib.Path, str]] = None, quality: typing.Optional[int] = None, + size: typing.Optional[ViewportSize] = None, ) -> "SyncContextManager": """Screencast.start @@ -7784,6 +7785,8 @@ def start( Path where the video should be saved when the screencast is stopped. When provided, video recording is started. quality : Union[int, None] The quality of the image, between 0-100. + size : Union[{width: int, height: int}, None] + Output frame size. Returns ------- @@ -7793,7 +7796,10 @@ def start( return mapping.from_impl( self._sync( self._impl_obj.start( - onFrame=self._wrap_handler(on_frame), path=path, quality=quality + onFrame=self._wrap_handler(on_frame), + path=path, + quality=quality, + size=size, ) ) )