Last active
June 22, 2022 22:04
-
-
Save matthewsimo/f3168051eaf470db63a15def8e76df38 to your computer and use it in GitHub Desktop.
Save video & screenshot for page with playwright
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { chromium } = require("playwright"); // Or 'chromium' or 'firefox'. | |
(async () => { | |
const browser = await chromium.launch({ | |
channel: "chrome-canary", | |
args: ["--enable-unsafe-webgpu"], | |
headless: false, | |
}); | |
const context = await browser.newContext({ | |
recordVideo: { | |
dir: "videos/", | |
size: { | |
width: 1024, | |
height: 1024, | |
}, | |
}, | |
viewport: { | |
width: 1024, | |
height: 1024, | |
}, | |
}); | |
const page = await context.newPage(); | |
await page.goto("http://localhost:3000/basic"); | |
await page.waitForLoadState("domcontentloaded"); | |
await page.screenshot({ path: "webgpu.png", fullPage: true }); | |
await page.waitForTimeout(3000); | |
await browser.close(); | |
})(); | |
// Then run `ffmpeg -i videos/[file].webm video.mp4` to turn to mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make a 3 second video of a page