UNPKG

@sap_oss/wdio-qmate-service

Version:

[![REUSE status](https://api.reuse.software/badge/github.com/SAP/wdio-qmate-service)](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[![Node.js CI](https://github.com/SAP/wdio-qmate-service/actions/workflows/node.js.yml/badge.svg)](http

49 lines 2.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Locator = void 0; const ControlFinder_1 = require("./utils/ControlFinder"); const UI5ControlDataInjector_1 = require("./utils/UI5ControlDataInjector"); const LocatorDebug_1 = require("./utils/LocatorDebug"); const ElementFilter_1 = require("./filters/ElementFilter"); class Locator { static locate(ui5Selector, rootElement) { LocatorDebug_1.LocatorDebug.initializeLogs(ui5Selector); try { Locator.checkSelector(ui5Selector); Locator.checkUI5Loaded(); const ui5Controls = ControlFinder_1.ControlFinder.retrieveUI5Controls(ui5Selector, rootElement); const validUi5Controls = Locator.filterControlsBySelector(ui5Controls, ui5Selector); const resultElements = UI5ControlDataInjector_1.UI5ControlDataInjector.convertAndInjectDataForProperties(validUi5Controls); LocatorDebug_1.LocatorDebug.printLogs(resultElements.length); return resultElements; } catch (error) { console.error("Error in locator:", error.stack); throw error; } } static filterControlsBySelector(controls, ui5Selector) { LocatorDebug_1.LocatorDebug.debugLog("Total ui5Controls:", controls.length); const validControls = ElementFilter_1.ElementFilter.filterBySelector(ui5Selector, controls); LocatorDebug_1.LocatorDebug.debugLog("Valid ui5Controls:", validControls.length); return validControls; } static checkSelector(ui5Selector) { if (!ui5Selector) { console.error(`The selector your provided ${ui5Selector} is undefined/null, please provide a valid selector`); throw new Error(`The selector your provided ${ui5Selector} is undefined/null, please provide a valid selector`); } if (!ui5Selector.elementProperties) { console.error(`The selector your provided ${JSON.stringify(ui5Selector)} does not contain elementProperties, please provide a valid selector with elementProperties`); throw new Error(`The selector your provided ${JSON.stringify(ui5Selector)} does not contain elementProperties, please provide a valid selector with elementProperties`); } } static checkUI5Loaded() { if (!sap.ui?.getCore?.()) { console.error("This is not an UI5 App, please use other locators"); throw new Error("This is not an UI5 App, please use other locators"); } } } exports.Locator = Locator; //# sourceMappingURL=Locator.js.map