From 331bb81820216881a49d912ab1698755db3fdb9d Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Tue, 13 Oct 2020 09:33:31 -0700 Subject: [PATCH] docs: add note about videos saving on context closure (#4126) --- docs/api.md | 6 +++--- docs/verification.md | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index 900e8e978b..5d4cbb9f8b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -220,7 +220,7 @@ Indicates that the browser is connected. - `password` <[string]> - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'. - `logger` <[Logger]> Logger sink for Playwright logging. - - `videosPath` <[string]> Enables video recording for all pages to `videosPath` folder. If not specified, videos are not recorded. + - `videosPath` <[string]> Enables video recording for all pages to `videosPath` folder. If not specified, videos are not recorded. Make sure to await [`browserContext.close`](#browsercontextclose) for videos to be saved. - `videoSize` <[Object]> Specifies dimensions of the automatically recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size. - `width` <[number]> Video frame width. - `height` <[number]> Video frame height. @@ -266,7 +266,7 @@ Creates a new browser context. It won't share cookies/cache with other browser c - `password` <[string]> - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'. - `logger` <[Logger]> Logger sink for Playwright logging. - - `videosPath` <[string]> Enables video recording for all pages to `videosPath` folder. If not specified, videos are not recorded. + - `videosPath` <[string]> Enables video recording for all pages to `videosPath` folder. If not specified, videos are not recorded. Make sure to await [`page.close`](#pagecloseoptions) for videos to be saved. - `videoSize` <[Object]> Specifies dimensions of the automatically recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size. - `width` <[number]> Video frame width. - `height` <[number]> Video frame height. @@ -4280,7 +4280,7 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'. - `username` <[string]> - `password` <[string]> - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'. - - `videosPath` <[string]> Enables video recording for all pages to `videosPath` folder. If not specified, videos are not recorded. + - `videosPath` <[string]> Enables video recording for all pages to `videosPath` folder. If not specified, videos are not recorded. Make sure to await [`browserContext.close`](#browsercontextclose) for videos to be saved. - `videoSize` <[Object]> Specifies dimensions of the automatically recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size. - `width` <[number]> Video frame width. - `height` <[number]> Video frame height. diff --git a/docs/verification.md b/docs/verification.md index 28da1d02c6..272c23e66d 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -12,14 +12,18 @@ ## Videos -Playwright can record videos for all pages in a [browser context](core-concepts.md#browser-contexts). +Playwright can record videos for all pages in a [browser context](core-concepts.md#browser-contexts). Videos are saved upon context closure, so make sure to await `browserContext.close()`. ```js // With browser.newContext() const context = await browser.newContext({ videosPath: 'videos/' }); +// Make sure to await close, so that videos are saved. +await context.close(); // With browser.newPage() const page = await browser.newPage({ videosPath: 'videos/' }); +// Make sure to await close, so that videos are saved. +await page.close(); // [Optional] Specify video size; defaults to viewport size const context = await browser.newContext({ @@ -33,6 +37,7 @@ const context = await browser.newContext({ - [class `BrowserContext`](./api.md#class-browsercontext) - [browser.newContext([options])](./api.md#browsernewcontextoptions) - [browser.newPage([options])](./api.md#browsernewpageoptions) +- [browserContext.close()](./api.md#browsercontextclose) ## Screenshots