UNPKG

webdriverio

Version:

Next-gen browser and mobile automation test framework for Node.js

27 lines (19 loc) 764 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = saveRecordingScreen; var _fs = _interopRequireDefault(require("fs")); var _utils = require("../../utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } async function saveRecordingScreen(filepath) { if (typeof filepath !== 'string') { throw new Error('saveRecordingScreen expects a filepath'); } const absoluteFilepath = (0, _utils.getAbsoluteFilepath)(filepath); (0, _utils.assertDirectoryExists)(absoluteFilepath); const videoBuffer = await this.stopRecordingScreen(); const video = Buffer.from(videoBuffer, 'base64'); _fs.default.writeFileSync(absoluteFilepath, video); return video; }