diff --git a/pytest_playwright/pytest_playwright.py b/pytest_playwright/pytest_playwright.py index db2cf0b..14dee97 100644 --- a/pytest_playwright/pytest_playwright.py +++ b/pytest_playwright/pytest_playwright.py @@ -521,6 +521,11 @@ def did_finish_test(self, failed: bool) -> None: except Error: # Silent catch empty videos. pass + else: + for page in self._all_pages: + # Can be changed to "if page.video" once https://github.com/microsoft/playwright-python/pull/2410 is released and used. + if video_option in ["on", "retain-on-failure"]: + page.video.delete() def on_did_create_browser_context(self, context: BrowserContext) -> None: context.on("page", lambda page: self._all_pages.append(page))