systelab-components-wdio-test
Version:
Widgets to be use in the E2E Tests based in WDIO
33 lines (32 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScreenshotAPI = void 0;
const http_status_1 = require("./http-status");
const error_handler_api_1 = require("./error-handler.api");
const wdio_1 = require("../../wdio");
const json_schema_validator_1 = require("./schema/json-schema-validator");
class ScreenshotAPI {
static async takeAll(req, res) {
try {
wdio_1.AutomationEnvironment.setApplication(+req.params.id);
const screenshot = await wdio_1.Browser.takeScreenshot();
return res.status(http_status_1.HttpStatus.OK).json({ screenshot }).send();
}
catch (err) {
return error_handler_api_1.ErrorHandlerAPI.handle(res, err);
}
}
static async takeElement(req, res) {
try {
wdio_1.AutomationEnvironment.setApplication(+req.params.id);
const requestBody = json_schema_validator_1.JSONSchemaValidator.validateBasicElementRequest(req.body);
const element = wdio_1.ElementFinderBuilder.build(requestBody.locators);
const screenshot = await element.takeScreenshot();
return res.status(http_status_1.HttpStatus.OK).json({ screenshot }).send();
}
catch (err) {
return error_handler_api_1.ErrorHandlerAPI.handle(res, err);
}
}
}
exports.ScreenshotAPI = ScreenshotAPI;