e2ed
Version:
E2E testing framework over Playwright
20 lines (19 loc) • 918 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.takeElementScreenshot = void 0;
const node_path_1 = require("node:path");
const internal_1 = require("../constants/internal");
const log_1 = require("../utils/log");
/**
* Takes a screenshot of the specified element.
*/
const takeElementScreenshot = async (selector, options = {}) => {
const { path: pathToScreenshot, ...optionsWithoutPath } = options;
(0, log_1.log)('Take a screenshot of the element', { pathToScreenshot, ...optionsWithoutPath, selector }, 5 /* LogEventType.InternalAction */);
if (pathToScreenshot !== undefined) {
// eslint-disable-next-line no-param-reassign
options.path = (0, node_path_1.join)(internal_1.SCREENSHOTS_DIRECTORY_PATH, pathToScreenshot);
}
await selector.getPlaywrightLocator().screenshot(options);
};
exports.takeElementScreenshot = takeElementScreenshot;