From e428eabd586c1d5529201a2ca2fd124bcd853268 Mon Sep 17 00:00:00 2001 From: Arjun Attam Date: Tue, 6 Oct 2020 13:48:09 -0700 Subject: [PATCH 1/2] docs: add videos to verification doc --- docs/verification.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/verification.md b/docs/verification.md index d772c9fda35e2..37dab879b49e7 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -1,6 +1,7 @@ # Verification +- [Videos](#videos) - [Screenshots](#screenshots) - [Console logs](#console-logs) - [Page errors](#page-errors) @@ -9,14 +10,38 @@
+## Videos + +Playwright can record videos for all pages in a [browser context](core-concepts.md#browser-contexts). + +```js +// With browser.newContext +const context = await browser.newContext({ videosPath: 'videos/' }); + +// With browser.newPage +const page = await browser.newPage({ videosPath: 'videos/' }); + +// [Optional] Specify video size; defaults to viewport size +const context = await browser.newContext({ + videosPath: 'videos/', + videoSize: { width: 1920, height: 1080 } +}); +``` + +#### API reference + +- [class `BrowserContext`](./api.md#class-browsercontext) +- [browser.newContext([options])](./api.md#browsernewcontextoptions) +- [browser.newPage([options])](./api.md#browsernewpageoptions) + ## Screenshots ```js // Save to file -await page.screenshot({path: 'screenshot.png'}); +await page.screenshot({ path: 'screenshot.png' }); // Capture full page -await page.screenshot({path: 'screenshot.png', fullPage: true}); +await page.screenshot({ path: 'screenshot.png', fullPage: true }); // Capture into buffer const buffer = await page.screenshot(); @@ -53,7 +78,7 @@ const [msg] = await Promise.all([ page.waitForEvent('console'), // Issue console.log inside the page page.evaluate(() => { - console.log('hello', 42, {foo: 'bar'}); + console.log('hello', 42, { foo: 'bar' }); }), ]); From f02454d05d213623f0b9c733931673819b149376 Mon Sep 17 00:00:00 2001 From: Arjun Attam Date: Wed, 7 Oct 2020 08:59:33 -0700 Subject: [PATCH 2/2] review changes --- docs/verification.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/verification.md b/docs/verification.md index 37dab879b49e7..28da1d02c652f 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -15,16 +15,16 @@ Playwright can record videos for all pages in a [browser context](core-concepts.md#browser-contexts). ```js -// With browser.newContext +// With browser.newContext() const context = await browser.newContext({ videosPath: 'videos/' }); -// With browser.newPage +// With browser.newPage() const page = await browser.newPage({ videosPath: 'videos/' }); // [Optional] Specify video size; defaults to viewport size const context = await browser.newContext({ videosPath: 'videos/', - videoSize: { width: 1920, height: 1080 } + videoSize: { width: 800, height: 600 } }); ```