From 290831fa28050ae3c6524845d5299a4a8b9274c5 Mon Sep 17 00:00:00 2001 From: Mohammed Alkindi Date: Thu, 10 Sep 2026 23:36:47 +0400 Subject: [PATCH] fix(video): return pathlib.Path from Video.path() Video.path() is annotated -> pathlib.Path and the generated API documents it as such, but it returned Artifact.absolute_path, which is the raw initializer string. The wrap was dropped in 0c70108aa when Video moved onto the Artifact abstraction; the sibling Download.path() still wraps via Artifact.path_after_finished(). --- playwright/_impl/_video.py | 2 +- tests/async/test_video.py | 1 + tests/sync/test_video.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/playwright/_impl/_video.py b/playwright/_impl/_video.py index e991803e3..0d64866a7 100644 --- a/playwright/_impl/_video.py +++ b/playwright/_impl/_video.py @@ -40,7 +40,7 @@ async def path(self) -> pathlib.Path: ) if not self._artifact: raise Error("Video recording has not been started.") - return self._artifact.absolute_path + return pathlib.Path(self._artifact.absolute_path) async def save_as(self, path: Union[str, pathlib.Path]) -> None: if self._page._connection._is_sync and not self._page._is_closed: diff --git a/tests/async/test_video.py b/tests/async/test_video.py index 08d757794..4b916d5f0 100644 --- a/tests/async/test_video.py +++ b/tests/async/test_video.py @@ -27,6 +27,7 @@ async def test_should_expose_video_path( await page.goto(server.PREFIX + "/grid.html") assert page.video path = await page.video.path() + assert isinstance(path, Path) assert str(tmp_path) in str(path) await page.context.close() diff --git a/tests/sync/test_video.py b/tests/sync/test_video.py index 3ae1daa21..3fd49ad93 100644 --- a/tests/sync/test_video.py +++ b/tests/sync/test_video.py @@ -32,6 +32,7 @@ def test_should_expose_video_path( video = page.video assert video path = video.path() + assert isinstance(path, Path) assert repr(page.video) == f"