UNPKG

playwright-fluent

Version:
18 lines (17 loc) 701 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.recordDownloadsTo = void 0; const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); async function recordDownloadsTo(downloadDirectory, page) { if (!page) { throw new Error(`Cannot record downloads to '${downloadDirectory}' because no browser has been launched`); } page.on('download', async (download) => { const filename = download.suggestedFilename(); const filepath = path_1.default.join(downloadDirectory, filename); download.saveAs(filepath); await download.path(); }); } exports.recordDownloadsTo = recordDownloadsTo;