You can use the following code to record the screen of a headless browser:
const puppeteer = require('puppeteer');
const fs = require('fs');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('<https://example.com>');
const video = await page.video.startRecording();
await page.waitForTimeout(5000);
await video.stop();
const buffer = await video.saveAsBuffer();
fs.writeFileSync('video.webm', buffer);
await browser.close();
})();
This code uses the puppeteer
library to launch a headless browser, navigate to a website, and record the screen. The video is saved as a webm
file.
ソース: Bing との会話 2023/12/4 (1) ヘッドレスブラウザ Chrome + Chromy で操作した内容を録画する .... https://qiita.com/zaru/items/d4de5c2654044db25795. (2) Chromeの操作を記録してPuppeteerやPlaywrightのコードに .... https://gigazine.net/news/20210102-headless-recorder/. (3) ヘッドレスブラウザ Chrome + Chromy で操作した内容を録画する .... https://bing.com/search?q=ヘッドレスブラウザ+画面録画. (4) undefined. https://chrome.google.com/webstore/detail/headless-recorder/djeegiggegleadkkbgopoonhjimgehda. (5) undefined. https://www.google.com/search?q=gigazine&oq=gigazine&aqs=chrome.0.69i59j35i39j0l5j5.6142j0j7&sourceid=chrome&ie=UTF-8. (6) undefined. https://github.com/checkly/headless-recorder. (7) github.com. https://github.com/AppointmentGuru/ssg-deployer/tree/441b29664cc755413579d0c2ccb9fd5195494a8a/README-old.md. (8) github.com. https://github.com/ehmad11/ke-live/tree/c5e7688c6e9eaf427c5e408a69515f52ab81b38f/index.js. (9) github.com. https://github.com/telmanagababov/puppeteer-samples/tree/62cd51f763ced766dad43d19f780abb911b4cfa7/evaluate-script%2Fmain.js.