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

764 lines 39.6 kB
"use strict"; /* eslint-disable no-undef */ /* eslint-disable no-console */ module.exports = { ui5All: function ui5All(ui5Selector, index, opt_parentElement) { // src/scripts/locators/qmateLocatorSrc/utils/LocatorDebug.ts var cyrb53 = function (str, seed = 0) { let h1 = 3735928559 ^ seed, h2 = 1103547991 ^ seed; for (let i = 0, ch; i < str.length; i++) { ch = str.charCodeAt(i); h1 = Math.imul(h1 ^ ch, 2654435761); h2 = Math.imul(h2 ^ ch, 1597334677); } h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507); h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909); h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507); h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909); return 4294967296 * (2097151 & h2) + (h1 >>> 0); }; var LocatorDebug = class _LocatorDebug { static logs; static indentation; // Public static initializeLogs(ui5Selector) { _LocatorDebug.logs = []; _LocatorDebug.indentation = ""; if (!document.qmateLogHashes) { document.qmateLogHashes = []; } _LocatorDebug.debugLog("QmateLocator Debug Logs for Selector:" + JSON.stringify(ui5Selector)); } static debugLog(...messages) { _LocatorDebug.logs.push([_LocatorDebug.indentation, ...messages]); } static beginLog(name, elementCount) { _LocatorDebug.indent(true); _LocatorDebug.debugLog("Valid ui5Controls before " + name + ":", elementCount); } static endLog(name, elementCount) { _LocatorDebug.debugLog("Valid ui5Controls after " + name + ":", elementCount); _LocatorDebug.indent(false); } static printLogs(finalElementCount) { if (finalElementCount > 0) { return; } _LocatorDebug.debugLog("Result elements:", finalElementCount); if (_LocatorDebug.sameLogAlreadyPrinted()) { return; } let fullLog = []; for (const log of _LocatorDebug.logs) { fullLog = fullLog.concat(log); fullLog.push("\n"); } console.warn(...fullLog); } // Private static indent(positive) { if (positive) _LocatorDebug.indentation += "...."; else _LocatorDebug.indentation = _LocatorDebug.indentation.substring(0, _LocatorDebug.indentation.length - 4); } static sameLogAlreadyPrinted() { const now = /* @__PURE__ */ new Date(); now.setSeconds(Math.floor(now.getSeconds() / 10) * 10, 0); const time = now.toISOString().replace(/T/, " ").replace(/\..+/, ""); const hash = cyrb53(JSON.stringify(_LocatorDebug.logs) + time); if (document.qmateLogHashes.includes(hash)) { return true; } document.qmateLogHashes.push(hash); return false; } }; // src/scripts/locators/qmateLocatorSrc/utils/ControlFinder.ts var ControlFinder = class _ControlFinder { static retrieveUI5Controls(selector, rootElement) { const nodes = _ControlFinder.retrieveNodesFromBody(selector, rootElement) || []; return _ControlFinder.retrieveValidUI5Controls(nodes); } static retrieveNodesFromBody(selector, rootElement) { let cssSelector = "*"; if (selector.elementProperties?.id) { if (selector.elementProperties.id.includes("*") && !selector.elementProperties.id .substring(1, selector.elementProperties.id.length - 1) .includes("*")) { const idWithoutWildcards = selector.elementProperties.id.replaceAll("*", ""); LocatorDebug.debugLog("shortened id is '", idWithoutWildcards, "' from '", selector.elementProperties.id, "'"); cssSelector = `*[id*="${idWithoutWildcards}"]`; } } if (rootElement) { return Array.from(rootElement.querySelectorAll(cssSelector)); } const sapBodies = Array.from(document.getElementsByClassName("sapUiBody")); return sapBodies.reduce((acc, body) => { return acc.concat(Array.from(body.querySelectorAll(cssSelector))); }, []); } static retrieveValidUI5Controls(nodes) { return nodes .map((node) => _ControlFinder.getUI5Control(node.getAttribute("id"))) .filter((element) => element); } static getUI5Control(id) { return (sap.ui.core?.Element?.getElementById || sap.ui.getCore().byId)(id); } }; // src/scripts/locators/qmateLocatorSrc/utils/UI5ControlHandler.ts var UI5ControlHandler = class _UI5ControlHandler { static retrieveValidUI5ControlsSubElements(nodes) { if (!nodes || nodes.length === 0) { return []; } const aCandidateControls = []; Array.prototype.forEach.call(nodes, (node) => { const nodeId = node.getAttribute("id"); const control = ControlFinder.getUI5Control(nodeId); if (control) { aCandidateControls.push(control); } else { aCandidateControls.push(..._UI5ControlHandler.retrieveValidUI5ControlsSubElements(node.children)); } }); return aCandidateControls; } static extractBindingPathAndModelProperty(pathObj) { const binding = { model: "", path: "", }; if (!pathObj?.path) return binding; binding.path = pathObj.path; if (pathObj.path.indexOf(">") !== -1) { binding.model = pathObj.path.substring(0, pathObj.path.indexOf(">")); binding.path = pathObj.path.substring(pathObj.path.indexOf(">") + 1, pathObj.path.length); } return binding; } static findSiblingControls(control) { const parentControl = _UI5ControlHandler.getUI5Parent(control); const parentId = parentControl?.getId?.(); const controlId = control?.getId?.(); if (!parentControl || !parentId || !controlId) { return []; } const parentElement = document.getElementById(parentId); if (!parentElement) { return []; } const allSiblingNodes = parentElement.children; const aValidControls = _UI5ControlHandler.retrieveValidUI5ControlsSubElements(allSiblingNodes); if (!aValidControls || aValidControls.length === 0) return []; const controlIndx = aValidControls.findIndex((element) => element.getId() === controlId); if (controlIndx === -1) { throw new Error("Something is very wrong with prev/next control finder"); } else { aValidControls.splice(controlIndx, 1); return aValidControls; } } static findPreviousOrNextControl(control, bIsNext) { const oParentControl = _UI5ControlHandler.getUI5Parent(control); const sControlId = control?.getId?.(); const sParentId = oParentControl?.getId?.(); if (!oParentControl || !sParentId || !sControlId) return null; const parentElement = document.getElementById(sParentId); if (!parentElement) return null; const aAllSiblingNodes = parentElement.children; const aValidControls = _UI5ControlHandler.retrieveValidUI5ControlsSubElements(aAllSiblingNodes); const controlIndx = aValidControls.findIndex((element) => element.getId() === sControlId); if (controlIndx === -1) { console.error("Something is very wrong with prev/next control finder"); } if (bIsNext && aValidControls.length - 1 > controlIndx) { return aValidControls[controlIndx + 1]; } else if (!bIsNext && controlIndx > 0) { return aValidControls[controlIndx - 1]; } return null; } static getControlBindingContextPaths(control) { if (!control) return []; const bindingContexts = Object.assign({}, control.oPropagatedProperties?.oBindingContexts, control.oBindingContexts, control.mElementBindingContexts); return Object.values(bindingContexts) .filter((value) => !!value && value.getPath && typeof value.getPath === "function") .map((ctx) => ctx.getPath()) .filter((path) => path); } // first navigate up the DOM tree to find the UI5 parent element // if none is found try with the ui5 getParent method // if none is found return undefined static getUI5Parent(control) { let domParent = document.getElementById(control.getId?.())?.parentElement; while (true) { if (!domParent) return control.getParent?.(); const oParentControl = ControlFinder.getUI5Control(domParent.getAttribute("id")); if (oParentControl) { return oParentControl; } domParent = domParent.parentElement; } } static getControlProperty(control, propKey) { if (!control || !propKey) return void 0; const metadata = control.getMetadata?.(); const property = metadata?.getProperty?.(propKey); const aggregation = metadata?.getAggregation?.(propKey); const association = metadata?.getAssociation?.(propKey); return (property ?? aggregation ?? association)?.get?.(control); } static getControlAllProperties(control) { return { ...control?.getMetadata?.()?.getAllProperties?.(), ...control?.getMetadata?.()?.getAllAssociations?.(), ...control?.getMetadata?.()?.getAllAggregations?.(), }; } static getBindDataForProperty(control, propKey) { const aProperties = _UI5ControlHandler.getControlAllProperties(control); if (aProperties.hasOwnProperty(propKey)) { return _UI5ControlHandler.getBindingInfos(control, propKey); } return []; } static createBindingInfo(part) { return { model: part.model || "", path: part.path || "", value: "", }; } static getBindingInfos(control, propKey) { const bindingInfo = control.getBindingInfo?.(propKey); if (!bindingInfo) return []; const parts = bindingInfo.parts ?? []; const infos = []; infos.push(...parts .filter((part) => part.path) .map(_UI5ControlHandler.createBindingInfo)); if (infos.length === 0 && bindingInfo.path) { infos.push(_UI5ControlHandler.createBindingInfo(bindingInfo)); } const binding = control.getBinding?.(propKey); if (binding && infos.length > 0) { _UI5ControlHandler.retrieveCompositeBindings(binding, infos); } return infos; } static retrieveCompositeBindings(binding, bindingInfos) { if (binding.getBindings) { const subBindings = binding.getBindings() ?? []; subBindings.forEach((subBinding) => _UI5ControlHandler.retrieveCompositeBindings(subBinding, bindingInfos)); } else if (binding.getPath && binding.getValue) { const info = bindingInfos.find((bi) => bi.path === binding.getPath()); if (info) { info.value = binding.getValue(); } } } static getUI5Ancestors(control) { const MAXIMUM_DEPTH = 500; const ancestors = []; let parentControl = _UI5ControlHandler.getUI5Parent(control); const visited = /* @__PURE__ */ new Set(); visited.add(control); while (parentControl && !visited.has(parentControl) && ancestors.length < MAXIMUM_DEPTH) { ancestors.push(parentControl); visited.add(parentControl); parentControl = _UI5ControlHandler.getUI5Parent(parentControl); } if (ancestors.length >= MAXIMUM_DEPTH) { LocatorDebug.debugLog("Maximum depth reached while retrieving ancestors for control", control.getId?.()); } LocatorDebug.debugLog("found ancestors:" + ancestors.length); return ancestors; } }; // src/scripts/locators/qmateLocatorSrc/utils/UI5ControlDataInjector.ts var UI5ControlDataInjector = class _UI5ControlDataInjector { static convertAndInjectDataForProperties(controls) { return controls .map((control) => { const domElement = document.getElementById(control.getId?.()); _UI5ControlDataInjector.injectDataForProperties(domElement, control); return domElement; }) .filter(Boolean); } static injectDataForProperties(domElement, oControl) { if (!domElement || !oControl) return; _UI5ControlDataInjector.injectBindingContextPaths(domElement, oControl); _UI5ControlDataInjector.injectAttributes(domElement, oControl, Object.keys(UI5ControlHandler.getControlAllProperties(oControl)), (key) => UI5ControlHandler.getControlProperty(oControl, key)); } static injectAttributes(domElement, oControl, keys, valueGetter) { keys.forEach((key) => { domElement.setAttribute(`data-${key}`, valueGetter(key)); const sBindingDataStr = _UI5ControlDataInjector.getBindingInfoDataString(oControl, key); if (sBindingDataStr && sBindingDataStr.trim() !== "") { domElement.setAttribute(`data-${key}-path`, sBindingDataStr); } }); } static injectBindingContextPaths(domElement, oControl) { const aBindingPathValues = UI5ControlHandler.getControlBindingContextPaths(oControl); domElement.setAttribute("data-bindingContextPath-size", aBindingPathValues.length.toString()); aBindingPathValues.forEach((sBindingPathValue, i) => { domElement.setAttribute(`data-bindingContextPath${i}`, sBindingPathValue); }); } static getBindingInfoDataString(oControl, key) { if (!oControl.getBindingInfo?.(key)) return ""; const aBindingInfos = []; const aBindingInfoParts = oControl.getBindingInfo?.(key)?.parts; if (aBindingInfoParts && aBindingInfoParts.length > 0) { for (let i = 0; i < aBindingInfoParts.length; i++) { if (!aBindingInfoParts[i].path) continue; if (aBindingInfoParts[i].model) aBindingInfos.push(aBindingInfoParts[i].model + ">"); aBindingInfos.push(aBindingInfoParts[i].path || ""); } } else { aBindingInfos.push(oControl.getBindingInfo?.(key)?.path || ""); } if (aBindingInfos.length > 0) { return aBindingInfos.join(); } else { return ""; } } }; // src/scripts/locators/qmateLocatorSrc/filters/BaseFilter.ts var BaseFilter = class { elementProperties; filterFactory; results; constructor(filterFactory, rawElementProperties) { this.elementProperties = this.convertRawElementPropertiesToElementProperties(rawElementProperties); this.filterFactory = filterFactory; this.results = /* @__PURE__ */ new Map(); } // Public filter(controls) { if (Object.keys(this.elementProperties).length === 0 || controls.length === 0) { return controls; } LocatorDebug.beginLog(this.constructor.name, controls.length); const filteredControls = this.doFiltering(controls); LocatorDebug.endLog(this.constructor.name, filteredControls.length); return filteredControls; } checkSingle(control) { if (Object.keys(this.elementProperties).length === 0) { return true; } if (!control) { return false; } const controlID = control.getId(); if (!this.results.has(controlID)) { this.results.set(controlID, this.doCheckSingle(control)); } return this.results.get(controlID); } doFiltering(controls) { return controls.filter((control) => this.checkSingle(control)); } // Private convertRawElementPropertiesToElementProperties(rawElementProperties) { let elementProperties = { ...rawElementProperties }; if (typeof rawElementProperties?.mProperties === "object") { elementProperties = { ...rawElementProperties, ...rawElementProperties.mProperties, }; delete elementProperties.mProperties; } return elementProperties; } }; // src/scripts/locators/qmateLocatorSrc/filters/AncestorFilter.ts var AncestorFilter = class extends BaseFilter { doCheckSingle(control) { const ancestors = UI5ControlHandler.getUI5Ancestors(control); const elementFilter = this.filterFactory.getInstance(ElementFilter, this.elementProperties); return ancestors.some((ancestor) => elementFilter.checkSingle(ancestor)); } }; // src/scripts/locators/qmateLocatorSrc/filters/DescendantFilter.ts var DescendantFilter = class extends BaseFilter { doCheckSingle(control) { const parentElement = document.getElementById(control.getId?.()); if (!parentElement) { return false; } const childControls = UI5ControlHandler.retrieveValidUI5ControlsSubElements(parentElement.children); const elementFilter = this.filterFactory.getInstance(ElementFilter, this.elementProperties); let foundMatch = childControls.some((childControl) => elementFilter.checkSingle(childControl)); foundMatch ||= childControls.some((childControl) => this.checkSingle(childControl)); return foundMatch; } }; // src/scripts/locators/qmateLocatorSrc/filters/SiblingFilter.ts var SiblingFilter = class extends BaseFilter { doCheckSingle(control) { const aSiblingControls = UI5ControlHandler.findSiblingControls(control); const elementFilter = this.filterFactory.getInstance(ElementFilter, this.elementProperties); return aSiblingControls.some((siblingControl) => elementFilter.checkSingle(siblingControl)); } }; // src/scripts/locators/qmateLocatorSrc/comparators/Comparator.ts var Comparator = class _Comparator { // Public static compareWithWildCard(sWild, value, toLowerCase = false) { const strWild = toLowerCase ? _Comparator.convertToString(sWild).trim().toLowerCase() : _Comparator.convertToString(sWild).trim(); const strValue = toLowerCase ? _Comparator.convertToString(value).trim().toLowerCase() : _Comparator.convertToString(value).trim(); const regex = new RegExp("^" + strWild .replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&") .replace(/\*/g, ".*") + "$", "s"); return regex.test(strValue); } // Private static convertToString(value) { return (value ?? "").toString(); } }; // src/scripts/locators/qmateLocatorSrc/comparators/DomPropertiesComparator.ts var DomPropertiesComparator = class _DomPropertiesComparator { static compareToDomProperties(properties, control) { const node = document.getElementById(control.getId?.()); if (!properties || !node || typeof properties !== "object") { return true; } const nodeAttributes = _DomPropertiesComparator.retrieveNodeAttributes(node); return Object.entries(properties).every(([key, value]) => { if (key === "nodeName") { return Comparator.compareWithWildCard(node?.nodeName, value, true); } const valueArray = Array.isArray(value) ? value : [value]; return valueArray.every((val) => _DomPropertiesComparator.compareAttributeToElementAttributes(key, val, nodeAttributes)); }); } static retrieveNodeAttributes(node) { return new Map(Array.from(node.attributes, (a) => [a.nodeName, a.nodeValue ?? ""])); } static compareAttributeToElementAttributes(key, value, nodeAttributes) { return Comparator.compareWithWildCard(value, nodeAttributes.get(key)); } }; // src/scripts/locators/qmateLocatorSrc/comparators/ElementPropertiesComparator.ts var ElementPropertiesComparator = class _ElementPropertiesComparator { static compareToProperties(elementProperties, control) { return Object.entries(elementProperties ?? {}).every(([key, value]) => { if ([ "domProperties", "metadata", "ancestorProperties", "descendantProperties", "siblingProperties", "mProperties", ].includes(key)) { return true; } if (key === "viewName") { return _ElementPropertiesComparator.isControlInViewName(control, value); } if (key === "viewId") { return _ElementPropertiesComparator.isControlInViewId(control, value); } if (key === "id") { return _ElementPropertiesComparator.compareId(control, value); } if (key === "bindingContextPath") { return UI5ControlHandler.getControlBindingContextPaths(control).some((path) => Comparator.compareWithWildCard(value, path)); } if (Array.isArray(value)) { return value.every((val) => { if (typeof val === "string") { return _ElementPropertiesComparator.compareArrayStrElements(key, val, control); } else { return _ElementPropertiesComparator.compareBindingPathAndModelProperty(key, val, control); } }); } if (typeof value === "object") { return _ElementPropertiesComparator.compareBindingPathAndModelProperty(key, value, control); } return _ElementPropertiesComparator.compareProperty(control, key, value); }); } static isControlInViewName(control, viewName) { return this.getAncestorViews(control).some((controlToCheck) => { return Comparator.compareWithWildCard(viewName, controlToCheck.getViewName?.()); }); } static isControlInViewId(control, sViewId) { return this.getAncestorViews(control).some((controlToCheck) => { return Comparator.compareWithWildCard(sViewId, controlToCheck.getId()); }); } static getAncestorViews(control) { return [control] .concat(UI5ControlHandler.getUI5Ancestors(control)) .filter((ancestor) => { return ancestor instanceof sap.ui.core.mvc.View; }); } static compareId(control, expectedId) { return (expectedId === void 0 || Comparator.compareWithWildCard(expectedId, control.getId?.())); } static compareProperty(control, key, value) { const controlVal = UI5ControlHandler.getControlProperty(control, key); return Comparator.compareWithWildCard(value, controlVal); } static compareBindingPathAndModelProperty(key, value, control) { const extrPath = UI5ControlHandler.extractBindingPathAndModelProperty(value); if (!extrPath.path) return true; const bindingInfo = UI5ControlHandler.getBindDataForProperty(control, key); return bindingInfo.some((info) => Comparator.compareWithWildCard(extrPath.path, info.path) && (!extrPath.model || !info.model || Comparator.compareWithWildCard(extrPath.model, info.model))); } static compareArrayStrElements(key, expectedValue, control) { const values = UI5ControlHandler.getControlProperty(control, key) || []; if (!values.length && !expectedValue) return true; if (values.length && !expectedValue) return false; return values.some((elem) => Comparator.compareWithWildCard(expectedValue, elem.getId?.() ?? elem, true)); } }; // src/scripts/locators/qmateLocatorSrc/comparators/MetadataComparator.ts var MetadataComparator = class { static compareMetadata(elementProperties, control) { const controlMetadata = control.getMetadata().getName(); const metadata = elementProperties.metadata; return (metadata === void 0 || Comparator.compareWithWildCard(metadata, controlMetadata)); } }; // src/scripts/locators/qmateLocatorSrc/filters/PropertiesFilter.ts var PropertiesFilter = class extends BaseFilter { doCheckSingle(control) { let pass = MetadataComparator.compareMetadata(this.elementProperties, control); pass &&= ElementPropertiesComparator.compareToProperties(this.elementProperties, control); pass &&= DomPropertiesComparator.compareToDomProperties(this.elementProperties.domProperties, control); return pass; } }; // src/scripts/locators/qmateLocatorSrc/filters/ChildFilter.ts var ChildFilter = class extends BaseFilter { doCheckSingle(control) { const element = document.getElementById(control.getId()); if (!element) { return false; } const childControls = UI5ControlHandler.retrieveValidUI5ControlsSubElements(element.children); const elementFilter = this.filterFactory.getInstance(ElementFilter, this.elementProperties); return childControls.some((childControl) => elementFilter.checkSingle(childControl)); } }; // src/scripts/locators/qmateLocatorSrc/filters/ParentFilter.ts var ParentFilter = class extends BaseFilter { doCheckSingle(control) { const parentControl = UI5ControlHandler.getUI5Parent(control); if (!parentControl) { console.error(`The parent control of ${control.getId()} is not valid, please check the control`); return false; } return this.filterFactory .getInstance(ElementFilter, this.elementProperties) .checkSingle(parentControl); } }; // src/scripts/locators/qmateLocatorSrc/filters/PrevSiblingFilter.ts var PrevSiblingFilter = class extends BaseFilter { doCheckSingle(control) { const prevControl = UI5ControlHandler.findPreviousOrNextControl(control, false); if (!prevControl) { return false; } return this.filterFactory .getInstance(ElementFilter, this.elementProperties) .checkSingle(prevControl); } }; // src/scripts/locators/qmateLocatorSrc/filters/NextSiblingFilter.ts var NextSiblingFilter = class extends BaseFilter { doCheckSingle(control) { const nextControl = UI5ControlHandler.findPreviousOrNextControl(control, true); if (!nextControl) { return false; } return this.filterFactory .getInstance(ElementFilter, this.elementProperties) .checkSingle(nextControl); } }; // src/scripts/locators/qmateLocatorSrc/utils/FilterFactory.ts var FilterFactory = class { instances = /* @__PURE__ */ new Map(); getInstance(classType, elementProperties) { const key = `${classType.name}-${JSON.stringify(elementProperties)}`; if (!this.instances.has(key)) { this.instances.set(key, new classType(this, elementProperties)); } return this.instances.get(key); } }; // src/scripts/locators/qmateLocatorSrc/filters/ElementFilter.ts var ElementFilter = class _ElementFilter extends BaseFilter { doFiltering(controls) { this.checkElementProperties(); let filteredControls = this.filterFactory .getInstance(PropertiesFilter, this.elementProperties) .filter(controls); filteredControls = this.filterFactory .getInstance(AncestorFilter, this.elementProperties?.ancestorProperties) .filter(filteredControls); filteredControls = this.filterFactory .getInstance(DescendantFilter, this.elementProperties?.descendantProperties) .filter(filteredControls); filteredControls = this.filterFactory .getInstance(SiblingFilter, this.elementProperties?.siblingProperties) .filter(filteredControls); return filteredControls; } doCheckSingle(control) { this.checkElementProperties(); let pass = this.filterFactory .getInstance(PropertiesFilter, this.elementProperties) .checkSingle(control); pass &&= this.filterFactory .getInstance(AncestorFilter, this.elementProperties?.ancestorProperties) .checkSingle(control); pass &&= this.filterFactory .getInstance(DescendantFilter, this.elementProperties?.descendantProperties) .checkSingle(control); pass &&= this.filterFactory .getInstance(SiblingFilter, this.elementProperties?.siblingProperties) .checkSingle(control); return pass; } checkElementProperties() { if (this.elementProperties?.prevSiblingProperties || this.elementProperties?.nextSiblingProperties || this.elementProperties?.childProperties || this.elementProperties?.parentProperties) { console.error(`The selector your provided ${JSON.stringify(this.elementProperties)} contains childProperties, parentProperties, prevSiblingProperties or nextSiblingProperties, please provide a valid selector without these properties`); throw new Error("Nested properties can only be used for ancestorProperties, descendantProperties or siblingProperties."); } } static filterBySelector(ui5Selector, controls) { const filterFactory = new FilterFactory(); let validUi5Controls = filterFactory .getInstance(_ElementFilter, ui5Selector.elementProperties) .filter(controls); validUi5Controls = filterFactory .getInstance(ParentFilter, ui5Selector.parentProperties) .filter(validUi5Controls); validUi5Controls = filterFactory .getInstance(AncestorFilter, ui5Selector.ancestorProperties) .filter(validUi5Controls); validUi5Controls = filterFactory .getInstance(ChildFilter, ui5Selector.childProperties) .filter(validUi5Controls); validUi5Controls = filterFactory .getInstance(DescendantFilter, ui5Selector.descendantProperties) .filter(validUi5Controls); validUi5Controls = filterFactory .getInstance(SiblingFilter, ui5Selector.siblingProperties) .filter(validUi5Controls); validUi5Controls = filterFactory .getInstance(PrevSiblingFilter, ui5Selector.prevSiblingProperties) .filter(validUi5Controls); validUi5Controls = filterFactory .getInstance(NextSiblingFilter, ui5Selector.nextSiblingProperties) .filter(validUi5Controls); return validUi5Controls; } }; // src/scripts/locators/qmateLocatorSrc/Locator.ts var Locator = class _Locator { static locate(ui5Selector, rootElement) { LocatorDebug.initializeLogs(ui5Selector); try { _Locator.checkSelector(ui5Selector); _Locator.checkUI5Loaded(); const ui5Controls = ControlFinder.retrieveUI5Controls(ui5Selector, rootElement); const validUi5Controls = _Locator.filterControlsBySelector(ui5Controls, ui5Selector); const resultElements = UI5ControlDataInjector.convertAndInjectDataForProperties(validUi5Controls); LocatorDebug.printLogs(resultElements.length); return resultElements; } catch (error) { console.error("Error in locator:", error.stack); throw error; } } static filterControlsBySelector(controls, ui5Selector) { LocatorDebug.debugLog("Total ui5Controls:", controls.length); const validControls = ElementFilter.filterBySelector(ui5Selector, controls); 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"); } } }; // src/scripts/locators/qmateLocatorSrc/index.ts function locate(ui5Selector, rootElement) { return Locator.locate(ui5Selector, rootElement); } return locate(ui5Selector, index, opt_parentElement); }, }; //# sourceMappingURL=qmateLocator.js.map