I want to record what my puppeteer script does when it runs on my server. I found this recording package that should help me capture the browser activity.
Here’s my basic setup:
const puppeteer = require('puppeteer');
const { record } = require('puppeteer-recorder');
var outputDir = 'D:\\projects\\automation\\';
startBrowser();
let mainBrowser;
async function startBrowser() {
mainBrowser = await puppeteer.launch({
headless: false,
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
performTest();
}
async function performTest() {
try {
const newPage = await mainBrowser.newPage();
await newPage.setViewport({width: 1200, height: 900});
await record({
browser: mainBrowser,
page: newPage,
output: outputDir + 'recording.webm',
fps: 30,
frames: 30 * 10, // 10 seconds recording
prepare: function () {},
render: function () {}
});
await newPage.goto('https://www.testsite.com', {timeout: 30000})
.catch(function (err) {
throw new Error('Navigation failed');
});
await newPage.close();
}
catch (error) {
console.log('TEST ERROR:', error);
}
}
But I keep getting this ffmpeg error:
$ node test.js
(node:1234) UnhandledPromiseRejectionWarning: Error: spawn ffmpeg ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:406:19)
I tried installing ffmpeg but it still doesn’t work. What am I missing here?