Innovenergy_trunk/frontend/node_modules/testcafe-browser-tools/lib/api/screenshot.js

35 lines
4.5 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const find_window_1 = __importDefault(require("./find-window"));
const os_family_1 = __importDefault(require("os-family"));
const exec_1 = require("../utils/exec");
const ensure_directory_1 = __importDefault(require("../utils/ensure-directory"));
const binaries_1 = __importDefault(require("../binaries"));
/**
* Takes a screenshot of the browser window where the specified web page is opened.
* @function
* @async
* @name screenshot
* @param {string | object} windowDescriptor - Specifies the title of the web page opened in the window or a descriptor returned by findWindow.
* @param {string} screenshotPath - Specifies the full path to the screenshot file. For example, D:\Temp\chrome-screenshot.jpg.
*/
async function default_1(windowDescriptor, screenshotPath) {
if (!await ensure_directory_1.default(screenshotPath))
return;
var windowDescription = typeof windowDescriptor === 'string' ? await find_window_1.default(windowDescriptor) : windowDescriptor;
if (!windowDescription)
return;
var screenshotArguments = void 0;
if (os_family_1.default.win)
screenshotArguments = [windowDescription.hwnd, windowDescription.browser];
else if (os_family_1.default.mac)
screenshotArguments = [windowDescription.cocoaId];
else
screenshotArguments = [windowDescription.windowId];
await exec_1.execFile(binaries_1.default.screenshot, screenshotArguments.concat(screenshotPath));
}
exports.default = default_1;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NyZWVuc2hvdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hcGkvc2NyZWVuc2hvdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLGdFQUF1QztBQUN2QywwREFBMkI7QUFDM0Isd0NBQXlDO0FBQ3pDLGlGQUF3RDtBQUN4RCwyREFBbUM7QUFHbkM7Ozs7Ozs7R0FPRztBQUNZLEtBQUssb0JBQVcsZ0JBQWdCLEVBQUUsY0FBYztJQUM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