Skip to content

Commit

Permalink
fix: page.video should be None if not recording
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Apr 16, 2024
1 parent d12ce3b commit f983642
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions playwright/_impl/_page.py
Expand Up @@ -1068,6 +1068,11 @@ async def pdf(
def video(
self,
) -> Optional[Video]:
# Note: we are creating Video object lazily, because we do not know
# BrowserContextOptions when constructing the page - it is assigned
# too late during launchPersistentContext.
if not self._browser_context._options.get("recordVideo"):
return None
if not self._video:
self._video = Video(self)
return self._video
Expand Down
8 changes: 8 additions & 0 deletions tests/async/test_video.py
Expand Up @@ -76,3 +76,11 @@ async def test_should_not_error_if_page_not_closed_before_save_as(
await saved
await page.context.close()
assert os.path.exists(out_path)


async def test_should_be_None_if_not_recording(
browser: Browser, tmpdir: Path, server: Server
) -> None:
page = await browser.new_page()
assert page.video is None
await page.close()

0 comments on commit f983642

Please sign in to comment.