@sap_oss/wdio-qmate-service 2.19.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -1
- package/.eslintrc.yml +2 -2
- package/lib/reuse/helper/clientsideUI5scripts.js +0 -53
- package/lib/reuse/helper/clientsideUI5scripts.js.map +1 -1
- package/lib/reuse/helper/elementResolving.d.ts +1 -1
- package/lib/reuse/helper/elementResolving.js +3 -2
- package/lib/reuse/helper/elementResolving.js.map +1 -1
- package/lib/reuse/modules/constants.d.ts +2 -0
- package/lib/reuse/modules/constants.js +6 -0
- package/lib/reuse/modules/constants.js.map +1 -0
- package/lib/reuse/modules/mobile/element.js +9 -8
- package/lib/reuse/modules/mobile/element.js.map +1 -1
- package/lib/reuse/modules/mobile/userInteraction.js +8 -7
- package/lib/reuse/modules/mobile/userInteraction.js.map +1 -1
- package/lib/reuse/modules/nonUi5/assertion.js +5 -4
- package/lib/reuse/modules/nonUi5/assertion.js.map +1 -1
- package/lib/reuse/modules/nonUi5/element.js +20 -18
- package/lib/reuse/modules/nonUi5/element.js.map +1 -1
- package/lib/reuse/modules/nonUi5/userInteraction.d.ts +1 -1
- package/lib/reuse/modules/nonUi5/userInteraction.js +13 -12
- package/lib/reuse/modules/nonUi5/userInteraction.js.map +1 -1
- package/lib/reuse/modules/ui5/assertion.js +20 -19
- package/lib/reuse/modules/ui5/assertion.js.map +1 -1
- package/lib/reuse/modules/ui5/confirmationDialog.js +9 -8
- package/lib/reuse/modules/ui5/confirmationDialog.js.map +1 -1
- package/lib/reuse/modules/ui5/control.js +2 -1
- package/lib/reuse/modules/ui5/control.js.map +1 -1
- package/lib/reuse/modules/ui5/element.js +14 -14
- package/lib/reuse/modules/ui5/element.js.map +1 -1
- package/lib/reuse/modules/ui5/footerBar.js +10 -9
- package/lib/reuse/modules/ui5/footerBar.js.map +1 -1
- package/lib/reuse/modules/ui5/mockserver.d.ts +1 -2
- package/lib/reuse/modules/ui5/mockserver.js +2 -3
- package/lib/reuse/modules/ui5/mockserver.js.map +1 -1
- package/lib/reuse/modules/ui5/navigation.js +3 -2
- package/lib/reuse/modules/ui5/navigation.js.map +1 -1
- package/lib/reuse/modules/ui5/navigationBar.js +49 -34
- package/lib/reuse/modules/ui5/navigationBar.js.map +1 -1
- package/lib/reuse/modules/ui5/session.js +30 -33
- package/lib/reuse/modules/ui5/session.js.map +1 -1
- package/lib/reuse/modules/ui5/table.d.ts +2 -2
- package/lib/reuse/modules/ui5/table.js +113 -26
- package/lib/reuse/modules/ui5/table.js.map +1 -1
- package/lib/reuse/modules/ui5/userInteraction.js +42 -28
- package/lib/reuse/modules/ui5/userInteraction.js.map +1 -1
- package/lib/reuse/modules/util/file.js +2 -1
- package/lib/reuse/modules/util/file.js.map +1 -1
- package/lib/scripts/clientsideUI5scripts.js +36 -33
- package/lib/scripts/clientsideUI5scripts.js.map +1 -1
- package/lib/scripts/hooks/before.d.ts +1 -1
- package/lib/scripts/hooks/before.js +7 -0
- package/lib/scripts/hooks/before.js.map +1 -1
- package/lib/scripts/hooks/utils/Ui5ExtensionMocker.d.ts +5 -0
- package/lib/scripts/hooks/utils/Ui5ExtensionMocker.js +42 -0
- package/lib/scripts/hooks/utils/Ui5ExtensionMocker.js.map +1 -0
- package/lib/scripts/hooks/utils/lib.d.ts +1 -0
- package/lib/scripts/hooks/utils/lib.js +13 -18
- package/lib/scripts/hooks/utils/lib.js.map +1 -1
- package/lib/scripts/hooks/utils/locatorCommands.js +5 -12
- package/lib/scripts/hooks/utils/locatorCommands.js.map +1 -1
- package/lib/scripts/locators/qmateLocator.d.ts +1 -1
- package/lib/scripts/locators/qmateLocator.js +686 -1310
- package/lib/scripts/locators/qmateLocator.js.map +1 -1
- package/lib/scripts/locators/qmateLocatorSrc/Locator.d.ts +6 -0
- package/lib/scripts/locators/qmateLocatorSrc/Locator.js +49 -0
- package/lib/scripts/locators/qmateLocatorSrc/Locator.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/Comparator.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/Comparator.js +18 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/Comparator.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/DomPropertiesComparator.d.ts +5 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/DomPropertiesComparator.js +28 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/DomPropertiesComparator.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/ElementPropertiesComparator.d.ts +10 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/ElementPropertiesComparator.js +79 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/ElementPropertiesComparator.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/MetadataComparator.d.ts +3 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/MetadataComparator.js +13 -0
- package/lib/scripts/locators/qmateLocatorSrc/comparators/MetadataComparator.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/AncestorFilter.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/AncestorFilter.js +15 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/AncestorFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/BaseFilter.d.ts +12 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/BaseFilter.js +52 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/BaseFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ChildFilter.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ChildFilter.js +19 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ChildFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/DescendantFilter.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/DescendantFilter.js +21 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/DescendantFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ElementFilter.d.ts +7 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ElementFilter.js +51 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ElementFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/NextSiblingFilter.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/NextSiblingFilter.js +17 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/NextSiblingFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ParentFilter.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ParentFilter.js +18 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/ParentFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/PrevSiblingFilter.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/PrevSiblingFilter.js +17 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/PrevSiblingFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/PropertiesFilter.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/PropertiesFilter.js +17 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/PropertiesFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/SiblingFilter.d.ts +4 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/SiblingFilter.js +15 -0
- package/lib/scripts/locators/qmateLocatorSrc/filters/SiblingFilter.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/index.d.ts +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/index.js +8 -0
- package/lib/scripts/locators/qmateLocatorSrc/index.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/ControlFinder.d.ts +6 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/ControlFinder.js +36 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/ControlFinder.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/FilterFactory.d.ts +5 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/FilterFactory.js +20 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/FilterFactory.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/LocatorDebug.d.ts +11 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/LocatorDebug.js +84 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/LocatorDebug.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/UI5ControlDataInjector.d.ts +7 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/UI5ControlDataInjector.js +63 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/UI5ControlDataInjector.js.map +1 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/UI5ControlHandler.d.ts +15 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/UI5ControlHandler.js +187 -0
- package/lib/scripts/locators/qmateLocatorSrc/utils/UI5ControlHandler.js.map +1 -0
- package/package.json +6 -4
- package/test/core/testIntegration/filters1.spec.js +27 -26
- package/test/helper/utils.js +30 -11
- package/test/reuse/ui5/session/logout.spec.js +1 -1
- package/test/reuse/ui5/table/sortColumnDescending.spec.js +0 -26
- package/test/reuse/ui5/userInteraction/searchFor.spec.js +56 -42
- package/tsconfig.json +2 -2
|
@@ -1,1385 +1,761 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable no-undef */
|
|
2
3
|
/* eslint-disable no-console */
|
|
3
4
|
module.exports = {
|
|
4
5
|
ui5All: function ui5All(ui5Selector, index, opt_parentElement) {
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
// src/scripts/locators/qmateLocatorSrc/utils/LocatorDebug.ts
|
|
7
|
+
var cyrb53 = function (str, seed = 0) {
|
|
8
|
+
let h1 = 3735928559 ^ seed, h2 = 1103547991 ^ seed;
|
|
9
|
+
for (let i = 0, ch; i < str.length; i++) {
|
|
10
|
+
ch = str.charCodeAt(i);
|
|
11
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
12
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
13
|
+
}
|
|
14
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
|
|
15
|
+
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
16
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
|
|
17
|
+
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
18
|
+
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
19
|
+
};
|
|
20
|
+
var LocatorDebug = class _LocatorDebug {
|
|
21
|
+
// Public
|
|
22
|
+
static initializeLogs(ui5Selector) {
|
|
23
|
+
_LocatorDebug.logs = [];
|
|
24
|
+
_LocatorDebug.indentation = "";
|
|
25
|
+
if (!document.qmateLogHashes) {
|
|
26
|
+
document.qmateLogHashes = [];
|
|
27
|
+
}
|
|
28
|
+
_LocatorDebug.debugLog("QmateLocator Debug Logs for Selector:" + JSON.stringify(ui5Selector));
|
|
29
|
+
}
|
|
30
|
+
static debugLog(...messages) {
|
|
31
|
+
_LocatorDebug.logs.push([_LocatorDebug.indentation, ...messages]);
|
|
32
|
+
}
|
|
33
|
+
static beginLog(name, elementCount) {
|
|
34
|
+
_LocatorDebug.indent(true);
|
|
35
|
+
_LocatorDebug.debugLog("Valid ui5Controls before " + name + ":", elementCount);
|
|
36
|
+
}
|
|
37
|
+
static endLog(name, elementCount) {
|
|
38
|
+
_LocatorDebug.debugLog("Valid ui5Controls after " + name + ":", elementCount);
|
|
39
|
+
_LocatorDebug.indent(false);
|
|
40
|
+
}
|
|
41
|
+
static printLogs(finalElementCount) {
|
|
42
|
+
if (finalElementCount > 0) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
_LocatorDebug.debugLog("Result elements:", finalElementCount);
|
|
46
|
+
if (_LocatorDebug.sameLogAlreadyPrinted()) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let fullLog = [];
|
|
50
|
+
for (const log of _LocatorDebug.logs) {
|
|
51
|
+
fullLog = fullLog.concat(log);
|
|
52
|
+
fullLog.push("\n");
|
|
53
|
+
}
|
|
54
|
+
console.warn(...fullLog);
|
|
55
|
+
}
|
|
56
|
+
// Private
|
|
57
|
+
static indent(positive) {
|
|
58
|
+
if (positive)
|
|
59
|
+
_LocatorDebug.indentation += "....";
|
|
60
|
+
else
|
|
61
|
+
_LocatorDebug.indentation = _LocatorDebug.indentation.substring(0, _LocatorDebug.indentation.length - 4);
|
|
62
|
+
}
|
|
63
|
+
static sameLogAlreadyPrinted() {
|
|
64
|
+
const now = /* @__PURE__ */ new Date();
|
|
65
|
+
now.setSeconds(Math.floor(now.getSeconds() / 10) * 10, 0);
|
|
66
|
+
const time = now.toISOString().replace(/T/, " ").replace(/\..+/, "");
|
|
67
|
+
const hash = cyrb53(JSON.stringify(_LocatorDebug.logs) + time);
|
|
68
|
+
if (document.qmateLogHashes.includes(hash)) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
document.qmateLogHashes.push(hash);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
// src/scripts/locators/qmateLocatorSrc/utils/ControlFinder.ts
|
|
76
|
+
var ControlFinder = class _ControlFinder {
|
|
77
|
+
static retrieveUI5Controls(selector, rootElement) {
|
|
78
|
+
const nodes = _ControlFinder.retrieveNodesFromBody(selector, rootElement) || [];
|
|
79
|
+
return _ControlFinder.retrieveValidUI5Controls(nodes);
|
|
80
|
+
}
|
|
81
|
+
static retrieveNodesFromBody(selector, rootElement) {
|
|
82
|
+
let cssSelector = "*";
|
|
83
|
+
if (selector.elementProperties?.id) {
|
|
84
|
+
if (selector.elementProperties.id.includes("*") &&
|
|
85
|
+
!selector.elementProperties.id
|
|
86
|
+
.substring(1, selector.elementProperties.id.length - 1)
|
|
87
|
+
.includes("*")) {
|
|
88
|
+
const idWithoutWildcards = selector.elementProperties.id.replaceAll("*", "");
|
|
89
|
+
LocatorDebug.debugLog("shortened id is '", idWithoutWildcards, "' from '", selector.elementProperties.id, "'");
|
|
90
|
+
cssSelector = `*[id*="${idWithoutWildcards}"]`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (rootElement) {
|
|
94
|
+
return Array.from(rootElement.querySelectorAll(cssSelector));
|
|
95
|
+
}
|
|
96
|
+
const sapBodies = Array.from(document.getElementsByClassName("sapUiBody"));
|
|
97
|
+
return sapBodies.reduce((acc, body) => {
|
|
98
|
+
return acc.concat(Array.from(body.querySelectorAll(cssSelector)));
|
|
99
|
+
}, []);
|
|
100
|
+
}
|
|
101
|
+
static retrieveValidUI5Controls(nodes) {
|
|
102
|
+
return nodes
|
|
103
|
+
.map((node) => _ControlFinder.getUI5Control(node.getAttribute("id")))
|
|
104
|
+
.filter((element) => element);
|
|
105
|
+
}
|
|
106
|
+
static getUI5Control(id) {
|
|
107
|
+
return (sap.ui.core?.Element?.getElementById || sap.ui.getCore().byId)(id);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
// src/scripts/locators/qmateLocatorSrc/utils/UI5ControlHandler.ts
|
|
111
|
+
var UI5ControlHandler = class _UI5ControlHandler {
|
|
112
|
+
static retrieveValidUI5ControlsSubElements(nodes) {
|
|
113
|
+
if (!nodes || nodes.length === 0) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
const aCandidateControls = [];
|
|
117
|
+
Array.prototype.forEach.call(nodes, (node) => {
|
|
118
|
+
const nodeId = node.getAttribute("id");
|
|
119
|
+
const control = ControlFinder.getUI5Control(nodeId);
|
|
120
|
+
if (control) {
|
|
121
|
+
aCandidateControls.push(control);
|
|
20
122
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// 5. Let k be 0.
|
|
24
|
-
var k = 0;
|
|
25
|
-
// 6. Repeat, while k < len
|
|
26
|
-
while (k < len) {
|
|
27
|
-
// a. Let Pk be ! ToString(k).
|
|
28
|
-
// b. Let kValue be ? Get(O, Pk).
|
|
29
|
-
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
|
|
30
|
-
// d. If testResult is true, return k.
|
|
31
|
-
var kValue = o[k];
|
|
32
|
-
if (predicate.call(thisArg, kValue, k, o)) {
|
|
33
|
-
return k;
|
|
34
|
-
}
|
|
35
|
-
// e. Increase k by 1.
|
|
36
|
-
k++;
|
|
123
|
+
else {
|
|
124
|
+
aCandidateControls.push(..._UI5ControlHandler.retrieveValidUI5ControlsSubElements(node.children));
|
|
37
125
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
if (!Object.entries) {
|
|
46
|
-
Object.entries = function (obj) {
|
|
47
|
-
var ownProps = Object.keys(obj), i = ownProps.length, resArray = new Array(i); // preallocate the Array
|
|
48
|
-
while (i--)
|
|
49
|
-
resArray[i] = [ownProps[i], obj[ownProps[i]]];
|
|
50
|
-
return resArray;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
var aCandidateControls = [];
|
|
54
|
-
function isEmptyObject(obj) {
|
|
55
|
-
return Object.entries(obj).length === 0 && obj.constructor === Object;
|
|
56
|
-
}
|
|
57
|
-
function getControlAllProperties(oControl) {
|
|
58
|
-
if (!oControl ||
|
|
59
|
-
!oControl.getMetadata ||
|
|
60
|
-
!oControl.getMetadata() ||
|
|
61
|
-
!oControl.getMetadata().getAllProperties) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return oControl.getMetadata().getAllProperties();
|
|
65
|
-
}
|
|
66
|
-
function getControlAllAggregations(oControl) {
|
|
67
|
-
if (!oControl ||
|
|
68
|
-
!oControl.getMetadata ||
|
|
69
|
-
!oControl.getMetadata() ||
|
|
70
|
-
!oControl.getMetadata().getAllAggregations) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
return oControl.getMetadata().getAllAggregations();
|
|
74
|
-
}
|
|
75
|
-
function getControlAllAssociations(oControl) {
|
|
76
|
-
if (!oControl ||
|
|
77
|
-
!oControl.getMetadata ||
|
|
78
|
-
!oControl.getMetadata() ||
|
|
79
|
-
!oControl.getMetadata().getAllAssociations) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
return oControl.getMetadata().getAllAssociations();
|
|
83
|
-
}
|
|
84
|
-
function getControlProperty(oControl, sPropKey) {
|
|
85
|
-
if (!oControl ||
|
|
86
|
-
!oControl.getProperty ||
|
|
87
|
-
!oControl.getMetadata() ||
|
|
88
|
-
!oControl.getMetadata().getProperty ||
|
|
89
|
-
!oControl.getMetadata().getProperty(sPropKey) ||
|
|
90
|
-
!oControl.getMetadata().getProperty(sPropKey).get) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
return oControl.getMetadata().getProperty(sPropKey).get(oControl);
|
|
94
|
-
}
|
|
95
|
-
function getAggregationProperty(oControl, sPropKey) {
|
|
96
|
-
if (!oControl ||
|
|
97
|
-
!oControl.getAggregation ||
|
|
98
|
-
!oControl.getMetadata() ||
|
|
99
|
-
!oControl.getMetadata().getAggregation ||
|
|
100
|
-
!oControl.getMetadata().getAggregation(sPropKey) ||
|
|
101
|
-
!oControl.getMetadata().getAggregation(sPropKey).get) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
return oControl.getMetadata().getAggregation(sPropKey).get(oControl);
|
|
105
|
-
}
|
|
106
|
-
function getAssociationProperty(oControl, sPropKey) {
|
|
107
|
-
if (!oControl ||
|
|
108
|
-
!oControl.getAssociation ||
|
|
109
|
-
!oControl.getMetadata() ||
|
|
110
|
-
!oControl.getMetadata().getAssociation ||
|
|
111
|
-
!oControl.getMetadata().getAssociation(sPropKey) ||
|
|
112
|
-
!oControl.getMetadata().getAssociation(sPropKey).get) {
|
|
113
|
-
return null;
|
|
126
|
+
});
|
|
127
|
+
return aCandidateControls;
|
|
114
128
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return finalContexts;
|
|
127
|
-
}, {});
|
|
128
|
-
if (bindingContexts && Object.keys(bindingContexts).length > 0) {
|
|
129
|
-
var aKeys = Object.keys(bindingContexts);
|
|
130
|
-
var aBindingContextPaths = [];
|
|
131
|
-
for (let index = 0; index < aKeys.length; index++) {
|
|
132
|
-
if (aKeys[index] === "$cmd")
|
|
133
|
-
continue;
|
|
134
|
-
const oBindingContext = bindingContexts[aKeys[index]];
|
|
135
|
-
if (oBindingContext &&
|
|
136
|
-
oBindingContext.getPath &&
|
|
137
|
-
oBindingContext.getPath())
|
|
138
|
-
aBindingContextPaths.push(oBindingContext.getPath());
|
|
129
|
+
static extractBindingPathAndModelProperty(pathObj) {
|
|
130
|
+
const binding = {
|
|
131
|
+
model: "",
|
|
132
|
+
path: "",
|
|
133
|
+
};
|
|
134
|
+
if (!pathObj?.path)
|
|
135
|
+
return binding;
|
|
136
|
+
binding.path = pathObj.path;
|
|
137
|
+
if (pathObj.path.indexOf(">") !== -1) {
|
|
138
|
+
binding.model = pathObj.path.substring(0, pathObj.path.indexOf(">"));
|
|
139
|
+
binding.path = pathObj.path.substring(pathObj.path.indexOf(">") + 1, pathObj.path.length);
|
|
139
140
|
}
|
|
140
|
-
return
|
|
141
|
+
return binding;
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
if (oControl.getViewName &&
|
|
151
|
-
// eslint-disable-next-line no-undef
|
|
152
|
-
oControl instanceof sap.ui.core.mvc.View &&
|
|
153
|
-
wildCardAndNormalCompare(sViewName, oControl.getViewName())) {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
return isControlInViewName(oControl.getParent(), sViewName);
|
|
143
|
+
static findSiblingControls(control) {
|
|
144
|
+
const parentControl = _UI5ControlHandler.getUI5Parent(control);
|
|
145
|
+
const parentId = parentControl?.getId?.();
|
|
146
|
+
const controlId = control?.getId?.();
|
|
147
|
+
if (!parentControl || !parentId || !controlId) {
|
|
148
|
+
return [];
|
|
158
149
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function isControlInViewId(oControl, sViewId) {
|
|
165
|
-
try {
|
|
166
|
-
// eslint-disable-next-line no-undef
|
|
167
|
-
if (!oControl || !sap.ui.core.Element || !sap.ui.core.mvc.View) {
|
|
168
|
-
return false;
|
|
150
|
+
const parentElement = document.getElementById(parentId);
|
|
151
|
+
if (!parentElement) {
|
|
152
|
+
return [];
|
|
169
153
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
154
|
+
const allSiblingNodes = parentElement.children;
|
|
155
|
+
const aValidControls = _UI5ControlHandler.retrieveValidUI5ControlsSubElements(allSiblingNodes);
|
|
156
|
+
if (!aValidControls || aValidControls.length === 0)
|
|
157
|
+
return [];
|
|
158
|
+
const controlIndx = aValidControls.findIndex((element) => element.getId() === controlId);
|
|
159
|
+
if (controlIndx === -1) {
|
|
160
|
+
throw new Error("Something is very wrong with prev/next control finder");
|
|
175
161
|
}
|
|
176
162
|
else {
|
|
177
|
-
|
|
163
|
+
aValidControls.splice(controlIndx, 1);
|
|
164
|
+
return aValidControls;
|
|
178
165
|
}
|
|
179
166
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// Logic to retrieve the element for chaining
|
|
195
|
-
if (index) {
|
|
196
|
-
if (!isInt(index) && index.nodeType) {
|
|
197
|
-
return index.querySelectorAll("*");
|
|
198
|
-
}
|
|
199
|
-
else if (opt_parentElement && opt_parentElement.nodeType) {
|
|
200
|
-
return opt_parentElement.querySelectorAll("*");
|
|
167
|
+
static findPreviousOrNextControl(control, bIsNext) {
|
|
168
|
+
const oParentControl = _UI5ControlHandler.getUI5Parent(control);
|
|
169
|
+
const sControlId = control?.getId?.();
|
|
170
|
+
const sParentId = oParentControl?.getId?.();
|
|
171
|
+
if (!oParentControl || !sParentId || !sControlId)
|
|
172
|
+
return null;
|
|
173
|
+
const parentElement = document.getElementById(sParentId);
|
|
174
|
+
if (!parentElement)
|
|
175
|
+
return null;
|
|
176
|
+
const aAllSiblingNodes = parentElement.children;
|
|
177
|
+
const aValidControls = _UI5ControlHandler.retrieveValidUI5ControlsSubElements(aAllSiblingNodes);
|
|
178
|
+
const controlIndx = aValidControls.findIndex((element) => element.getId() === sControlId);
|
|
179
|
+
if (controlIndx === -1) {
|
|
180
|
+
console.error("Something is very wrong with prev/next control finder");
|
|
201
181
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (!sapBody || !sapBody[0]) {
|
|
205
|
-
throw new Error("No body found");
|
|
206
|
-
}
|
|
207
|
-
return sapBody[0].querySelectorAll("*");
|
|
208
|
-
}
|
|
209
|
-
function retrieveNodeName(oNode) {
|
|
210
|
-
if (oNode) {
|
|
211
|
-
return oNode.nodeName;
|
|
212
|
-
}
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
function retrieveNodeAttributes(oNode) {
|
|
216
|
-
var domProperties = [];
|
|
217
|
-
if (oNode.attributes && oNode.attributes.length > 0) {
|
|
218
|
-
for (let index = 0; index < oNode.attributes.length; index++) {
|
|
219
|
-
var oElm = oNode.attributes[index];
|
|
220
|
-
if (oElm.nodeName && oElm.nodeValue) {
|
|
221
|
-
var nodeNm = oElm.nodeName;
|
|
222
|
-
var nodeValue = oElm.nodeValue;
|
|
223
|
-
var nodeVN = {};
|
|
224
|
-
nodeVN[nodeNm] = nodeValue;
|
|
225
|
-
domProperties.push(nodeVN);
|
|
226
|
-
}
|
|
182
|
+
if (bIsNext && aValidControls.length - 1 > controlIndx) {
|
|
183
|
+
return aValidControls[controlIndx + 1];
|
|
227
184
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
function retrieveCompositeBindings(oBinding, aBindingInfos) {
|
|
232
|
-
if (!oBinding)
|
|
233
|
-
return;
|
|
234
|
-
if (oBinding.getBindings && oBinding.getBindings() && aBindingInfos) {
|
|
235
|
-
var aBindings = oBinding.getBindings();
|
|
236
|
-
for (let i = 0; i < aBindings.length; i++) {
|
|
237
|
-
for (let j = 0; j < aBindingInfos.length; j++) {
|
|
238
|
-
try {
|
|
239
|
-
if (!aBindings[i].getBindings &&
|
|
240
|
-
aBindingInfos[j].path === aBindings[i].getPath() &&
|
|
241
|
-
aBindings[i].getValue) {
|
|
242
|
-
aBindingInfos[j].value = aBindings[i].getValue();
|
|
243
|
-
}
|
|
244
|
-
else if (aBindings[i].getBindings) {
|
|
245
|
-
retrieveCompositeBindings(aBindings[i], aBindingInfos);
|
|
246
|
-
}
|
|
247
|
-
// eslint-disable-next-line no-empty
|
|
248
|
-
}
|
|
249
|
-
catch (error) {
|
|
250
|
-
}
|
|
251
|
-
}
|
|
185
|
+
else if (!bIsNext && controlIndx > 0) {
|
|
186
|
+
return aValidControls[controlIndx - 1];
|
|
252
187
|
}
|
|
188
|
+
return null;
|
|
253
189
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
190
|
+
static getControlBindingContextPaths(control) {
|
|
191
|
+
if (!control)
|
|
192
|
+
return [];
|
|
193
|
+
const bindingContexts = Object.assign({}, control.oPropagatedProperties?.oBindingContexts, control.oBindingContexts, control.mElementBindingContexts);
|
|
194
|
+
return Object.values(bindingContexts)
|
|
195
|
+
.filter((value) => !!value && value.getPath && typeof value.getPath === "function")
|
|
196
|
+
.map((ctx) => ctx.getPath())
|
|
197
|
+
.filter((path) => path);
|
|
198
|
+
}
|
|
199
|
+
// first navigate up the DOM tree to find the UI5 parent element
|
|
200
|
+
// if none is found try with the ui5 getParent method
|
|
201
|
+
// if none is found return undefined
|
|
202
|
+
static getUI5Parent(control) {
|
|
203
|
+
let domParent = document.getElementById(control.getId?.())?.parentElement;
|
|
204
|
+
while (true) {
|
|
205
|
+
if (!domParent)
|
|
206
|
+
return control.getParent?.();
|
|
207
|
+
const oParentControl = ControlFinder.getUI5Control(domParent.getAttribute("id"));
|
|
208
|
+
if (oParentControl) {
|
|
209
|
+
return oParentControl;
|
|
264
210
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
211
|
+
domParent = domParent.parentElement;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
static getControlProperty(control, propKey) {
|
|
215
|
+
if (!control || !propKey)
|
|
216
|
+
return void 0;
|
|
217
|
+
const metadata = control.getMetadata?.();
|
|
218
|
+
const property = metadata?.getProperty?.(propKey);
|
|
219
|
+
const aggregation = metadata?.getAggregation?.(propKey);
|
|
220
|
+
const association = metadata?.getAssociation?.(propKey);
|
|
221
|
+
return (property ?? aggregation ?? association)?.get?.(control);
|
|
222
|
+
}
|
|
223
|
+
static getControlAllProperties(control) {
|
|
224
|
+
return {
|
|
225
|
+
...control?.getMetadata?.()?.getAllProperties?.(),
|
|
226
|
+
...control?.getMetadata?.()?.getAllAssociations?.(),
|
|
227
|
+
...control?.getMetadata?.()?.getAllAggregations?.(),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
static getBindDataForProperty(control, propKey) {
|
|
231
|
+
const aProperties = _UI5ControlHandler.getControlAllProperties(control);
|
|
232
|
+
if (aProperties.hasOwnProperty(propKey)) {
|
|
233
|
+
return _UI5ControlHandler.getBindingInfos(control, propKey);
|
|
234
|
+
}
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
static createBindingInfo(part) {
|
|
238
|
+
return {
|
|
239
|
+
model: part.model || "",
|
|
240
|
+
path: part.path || "",
|
|
241
|
+
value: "",
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
static getBindingInfos(control, propKey) {
|
|
245
|
+
const bindingInfo = control.getBindingInfo?.(propKey);
|
|
246
|
+
if (!bindingInfo)
|
|
247
|
+
return [];
|
|
248
|
+
const parts = bindingInfo.parts ?? [];
|
|
249
|
+
const infos = [];
|
|
250
|
+
infos.push(...parts
|
|
251
|
+
.filter((part) => part.path)
|
|
252
|
+
.map(_UI5ControlHandler.createBindingInfo));
|
|
253
|
+
if (infos.length === 0 && bindingInfo.path) {
|
|
254
|
+
infos.push(_UI5ControlHandler.createBindingInfo(bindingInfo));
|
|
255
|
+
}
|
|
256
|
+
const binding = control.getBinding?.(propKey);
|
|
257
|
+
if (binding && infos.length > 0) {
|
|
258
|
+
_UI5ControlHandler.retrieveCompositeBindings(binding, infos);
|
|
259
|
+
}
|
|
260
|
+
return infos;
|
|
261
|
+
}
|
|
262
|
+
static retrieveCompositeBindings(binding, bindingInfos) {
|
|
263
|
+
if (binding.getBindings) {
|
|
264
|
+
const subBindings = binding.getBindings() ?? [];
|
|
265
|
+
subBindings.forEach((subBinding) => _UI5ControlHandler.retrieveCompositeBindings(subBinding, bindingInfos));
|
|
266
|
+
}
|
|
267
|
+
else if (binding.getPath && binding.getValue) {
|
|
268
|
+
const info = bindingInfos.find((bi) => bi.path === binding.getPath());
|
|
269
|
+
if (info) {
|
|
270
|
+
info.value = binding.getValue();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
static getUI5Ancestors(control) {
|
|
275
|
+
const MAXIMUM_DEPTH = 500;
|
|
276
|
+
const ancestors = [];
|
|
277
|
+
let parentControl = _UI5ControlHandler.getUI5Parent(control);
|
|
278
|
+
const visited = /* @__PURE__ */ new Set();
|
|
279
|
+
visited.add(control);
|
|
280
|
+
while (parentControl &&
|
|
281
|
+
!visited.has(parentControl) &&
|
|
282
|
+
ancestors.length < MAXIMUM_DEPTH) {
|
|
283
|
+
ancestors.push(parentControl);
|
|
284
|
+
visited.add(parentControl);
|
|
285
|
+
parentControl = _UI5ControlHandler.getUI5Parent(parentControl);
|
|
286
|
+
}
|
|
287
|
+
if (ancestors.length >= MAXIMUM_DEPTH) {
|
|
288
|
+
LocatorDebug.debugLog("Maximum depth reached while retrieving ancestors for control", control.getId?.());
|
|
289
|
+
}
|
|
290
|
+
LocatorDebug.debugLog("found ancestors:" + ancestors.length);
|
|
291
|
+
return ancestors;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
// src/scripts/locators/qmateLocatorSrc/utils/UI5ControlDataInjector.ts
|
|
295
|
+
var UI5ControlDataInjector = class _UI5ControlDataInjector {
|
|
296
|
+
static convertAndInjectDataForProperties(controls) {
|
|
297
|
+
return controls
|
|
298
|
+
.map((control) => {
|
|
299
|
+
const domElement = document.getElementById(control.getId?.());
|
|
300
|
+
_UI5ControlDataInjector.injectDataForProperties(domElement, control);
|
|
301
|
+
return domElement;
|
|
302
|
+
})
|
|
303
|
+
.filter(Boolean);
|
|
304
|
+
}
|
|
305
|
+
static injectDataForProperties(domElement, oControl) {
|
|
306
|
+
if (!domElement || !oControl)
|
|
307
|
+
return;
|
|
308
|
+
_UI5ControlDataInjector.injectBindingContextPaths(domElement, oControl);
|
|
309
|
+
_UI5ControlDataInjector.injectAttributes(domElement, oControl, Object.keys(UI5ControlHandler.getControlAllProperties(oControl)), (key) => UI5ControlHandler.getControlProperty(oControl, key));
|
|
310
|
+
}
|
|
311
|
+
static injectAttributes(domElement, oControl, keys, valueGetter) {
|
|
312
|
+
keys.forEach((key) => {
|
|
313
|
+
domElement.setAttribute(`data-${key}`, valueGetter(key));
|
|
314
|
+
const sBindingDataStr = _UI5ControlDataInjector.getBindingInfoDataString(oControl, key);
|
|
315
|
+
if (sBindingDataStr && sBindingDataStr.trim() !== "") {
|
|
316
|
+
domElement.setAttribute(`data-${key}-path`, sBindingDataStr);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
static injectBindingContextPaths(domElement, oControl) {
|
|
321
|
+
const aBindingPathValues = UI5ControlHandler.getControlBindingContextPaths(oControl);
|
|
322
|
+
domElement.setAttribute("data-bindingContextPath-size", aBindingPathValues.length.toString());
|
|
323
|
+
aBindingPathValues.forEach((sBindingPathValue, i) => {
|
|
324
|
+
domElement.setAttribute(`data-bindingContextPath${i}`, sBindingPathValue);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
static getBindingInfoDataString(oControl, key) {
|
|
328
|
+
if (!oControl.getBindingInfo?.(key))
|
|
329
|
+
return "";
|
|
330
|
+
const aBindingInfos = [];
|
|
331
|
+
const aBindingInfoParts = oControl.getBindingInfo?.(key)?.parts;
|
|
272
332
|
if (aBindingInfoParts && aBindingInfoParts.length > 0) {
|
|
273
333
|
for (let i = 0; i < aBindingInfoParts.length; i++) {
|
|
274
|
-
var sModel = "";
|
|
275
334
|
if (!aBindingInfoParts[i].path)
|
|
276
335
|
continue;
|
|
277
336
|
if (aBindingInfoParts[i].model)
|
|
278
|
-
|
|
279
|
-
aBindingInfos.push(
|
|
280
|
-
model: sModel,
|
|
281
|
-
path: aBindingInfoParts[i].path,
|
|
282
|
-
value: ""
|
|
283
|
-
});
|
|
337
|
+
aBindingInfos.push(aBindingInfoParts[i].model + ">");
|
|
338
|
+
aBindingInfos.push(aBindingInfoParts[i].path || "");
|
|
284
339
|
}
|
|
285
340
|
}
|
|
286
341
|
else {
|
|
287
|
-
|
|
288
|
-
var sBindingDataModelStr = oControl.getBindingInfo(sPropKey).model;
|
|
289
|
-
if (sBindingDataStr) {
|
|
290
|
-
aBindingInfos.push({
|
|
291
|
-
model: sBindingDataModelStr,
|
|
292
|
-
path: sBindingDataStr,
|
|
293
|
-
value: ""
|
|
294
|
-
});
|
|
295
|
-
}
|
|
342
|
+
aBindingInfos.push(oControl.getBindingInfo?.(key)?.path || "");
|
|
296
343
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
var oBinding = oControl.getBinding(sPropKey);
|
|
300
|
-
retrieveCompositeBindings(oBinding, aBindingInfos);
|
|
344
|
+
if (aBindingInfos.length > 0) {
|
|
345
|
+
return aBindingInfos.join();
|
|
301
346
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
try {
|
|
330
|
-
if (aAssociation.hasOwnProperty(sPropKey)) {
|
|
331
|
-
if (!oControl || !sPropKey
|
|
332
|
-
|| !aAssociation.hasOwnProperty(sPropKey)
|
|
333
|
-
|| !oControl.getBindingInfo
|
|
334
|
-
|| !oControl.getBindingInfo(sPropKey))
|
|
335
|
-
return aBindingInfos;
|
|
336
|
-
aBindingInfos = retrieverBindingPaths(oControl, sPropKey);
|
|
347
|
+
else {
|
|
348
|
+
return "";
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
// src/scripts/locators/qmateLocatorSrc/filters/BaseFilter.ts
|
|
353
|
+
var BaseFilter = class {
|
|
354
|
+
constructor(filterFactory, rawElementProperties) {
|
|
355
|
+
this.elementProperties =
|
|
356
|
+
this.convertRawElementPropertiesToElementProperties(rawElementProperties);
|
|
357
|
+
this.filterFactory = filterFactory;
|
|
358
|
+
this.results = /* @__PURE__ */ new Map();
|
|
359
|
+
}
|
|
360
|
+
// Public
|
|
361
|
+
filter(controls) {
|
|
362
|
+
if (Object.keys(this.elementProperties).length === 0 ||
|
|
363
|
+
controls.length === 0) {
|
|
364
|
+
return controls;
|
|
365
|
+
}
|
|
366
|
+
LocatorDebug.beginLog(this.constructor.name, controls.length);
|
|
367
|
+
const filteredControls = this.doFiltering(controls);
|
|
368
|
+
LocatorDebug.endLog(this.constructor.name, filteredControls.length);
|
|
369
|
+
return filteredControls;
|
|
370
|
+
}
|
|
371
|
+
checkSingle(control) {
|
|
372
|
+
if (Object.keys(this.elementProperties).length === 0) {
|
|
373
|
+
return true;
|
|
337
374
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
// Do nothing
|
|
341
|
-
}
|
|
342
|
-
return aBindingInfos;
|
|
343
|
-
}
|
|
344
|
-
function getBindDataForProperty(oControl, sPropKey) {
|
|
345
|
-
var aProperties = getControlAllProperties(oControl);
|
|
346
|
-
var aBindingInfos = [];
|
|
347
|
-
try {
|
|
348
|
-
if (aProperties.hasOwnProperty(sPropKey)) {
|
|
349
|
-
if (!oControl || !sPropKey
|
|
350
|
-
|| !aProperties.hasOwnProperty(sPropKey)
|
|
351
|
-
|| !oControl.getBindingInfo
|
|
352
|
-
|| !oControl.getBindingInfo(sPropKey))
|
|
353
|
-
return aBindingInfos;
|
|
354
|
-
aBindingInfos = retrieverBindingPaths(oControl, sPropKey);
|
|
375
|
+
if (!control) {
|
|
376
|
+
return false;
|
|
355
377
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
retrieveValidUI5ControlsSubElements(chNode.children);
|
|
393
|
-
return false;
|
|
394
|
-
}
|
|
395
|
-
});
|
|
378
|
+
const controlID = control.getId();
|
|
379
|
+
if (!this.results.has(controlID)) {
|
|
380
|
+
this.results.set(controlID, this.doCheckSingle(control));
|
|
381
|
+
}
|
|
382
|
+
return this.results.get(controlID);
|
|
383
|
+
}
|
|
384
|
+
doFiltering(controls) {
|
|
385
|
+
return controls.filter((control) => this.checkSingle(control));
|
|
386
|
+
}
|
|
387
|
+
// Private
|
|
388
|
+
convertRawElementPropertiesToElementProperties(rawElementProperties) {
|
|
389
|
+
let elementProperties = { ...rawElementProperties };
|
|
390
|
+
if (typeof rawElementProperties?.mProperties === "object") {
|
|
391
|
+
elementProperties = {
|
|
392
|
+
...rawElementProperties,
|
|
393
|
+
...rawElementProperties.mProperties,
|
|
394
|
+
};
|
|
395
|
+
delete elementProperties.mProperties;
|
|
396
|
+
}
|
|
397
|
+
return elementProperties;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
// src/scripts/locators/qmateLocatorSrc/filters/AncestorFilter.ts
|
|
401
|
+
var AncestorFilter = class extends BaseFilter {
|
|
402
|
+
doCheckSingle(control) {
|
|
403
|
+
const ancestors = UI5ControlHandler.getUI5Ancestors(control);
|
|
404
|
+
const elementFilter = this.filterFactory.getInstance(ElementFilter, this.elementProperties);
|
|
405
|
+
return ancestors.some((ancestor) => elementFilter.checkSingle(ancestor));
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
// src/scripts/locators/qmateLocatorSrc/filters/DescendantFilter.ts
|
|
409
|
+
var DescendantFilter = class extends BaseFilter {
|
|
410
|
+
doCheckSingle(control) {
|
|
411
|
+
const parentElement = document.getElementById(control.getId?.());
|
|
412
|
+
if (!parentElement) {
|
|
413
|
+
return false;
|
|
396
414
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
415
|
+
const childControls = UI5ControlHandler.retrieveValidUI5ControlsSubElements(parentElement.children);
|
|
416
|
+
const elementFilter = this.filterFactory.getInstance(ElementFilter, this.elementProperties);
|
|
417
|
+
let foundMatch = childControls.some((childControl) => elementFilter.checkSingle(childControl));
|
|
418
|
+
foundMatch ||= childControls.some((childControl) => this.checkSingle(childControl));
|
|
419
|
+
return foundMatch;
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
// src/scripts/locators/qmateLocatorSrc/filters/SiblingFilter.ts
|
|
423
|
+
var SiblingFilter = class extends BaseFilter {
|
|
424
|
+
doCheckSingle(control) {
|
|
425
|
+
const aSiblingControls = UI5ControlHandler.findSiblingControls(control);
|
|
426
|
+
const elementFilter = this.filterFactory.getInstance(ElementFilter, this.elementProperties);
|
|
427
|
+
return aSiblingControls.some((siblingControl) => elementFilter.checkSingle(siblingControl));
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
// src/scripts/locators/qmateLocatorSrc/comparators/Comparator.ts
|
|
431
|
+
var Comparator = class _Comparator {
|
|
432
|
+
// Public
|
|
433
|
+
static compareWithWildCard(sWild, value, toLowerCase = false) {
|
|
434
|
+
const strWild = toLowerCase
|
|
435
|
+
? _Comparator.convertToString(sWild).trim().toLowerCase()
|
|
436
|
+
: _Comparator.convertToString(sWild).trim();
|
|
437
|
+
const strValue = toLowerCase
|
|
438
|
+
? _Comparator.convertToString(value).trim().toLowerCase()
|
|
439
|
+
: _Comparator.convertToString(value).trim();
|
|
440
|
+
const regex = new RegExp("^" +
|
|
441
|
+
strWild
|
|
442
|
+
.replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&")
|
|
443
|
+
.replace(/\*/g, ".*") +
|
|
444
|
+
"$");
|
|
445
|
+
return regex.test(strValue);
|
|
446
|
+
}
|
|
447
|
+
// Private
|
|
448
|
+
static convertToString(value) {
|
|
449
|
+
return (value ?? "").toString();
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
// src/scripts/locators/qmateLocatorSrc/comparators/DomPropertiesComparator.ts
|
|
453
|
+
var DomPropertiesComparator = class _DomPropertiesComparator {
|
|
454
|
+
static compareToDomProperties(properties, control) {
|
|
455
|
+
const node = document.getElementById(control.getId?.());
|
|
456
|
+
if (!properties || !node || typeof properties !== "object") {
|
|
457
|
+
return true;
|
|
410
458
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
if (!oParentControl.getId || !oParentControl.getId())
|
|
441
|
-
return null;
|
|
442
|
-
var sParentId = oParentControl.getId();
|
|
443
|
-
var aAllSiblingNodes = document.getElementById(sParentId).children;
|
|
444
|
-
aCandidateControls = [];
|
|
445
|
-
retrieveValidUI5ControlsSubElements(aAllSiblingNodes);
|
|
446
|
-
var aValidControls = aCandidateControls;
|
|
447
|
-
if (!aValidControls || aValidControls.length === 0)
|
|
448
|
-
return null;
|
|
449
|
-
var oControlIndx = aValidControls.findIndex(function (element) {
|
|
450
|
-
return element.getId() === oControl.getId();
|
|
451
|
-
});
|
|
452
|
-
if (oControlIndx === -1) {
|
|
453
|
-
throw new Error("Something is very wrong with prev/next control finder");
|
|
454
|
-
}
|
|
455
|
-
if (bIsNext && ((aValidControls.length - 1) > oControlIndx)) {
|
|
456
|
-
return aValidControls[oControlIndx + 1];
|
|
457
|
-
}
|
|
458
|
-
else if (!bIsNext && (oControlIndx > 0)) {
|
|
459
|
-
return aValidControls[oControlIndx - 1];
|
|
460
|
-
}
|
|
461
|
-
return null;
|
|
462
|
-
}
|
|
463
|
-
function extractBindingPathAndModelProperty(pathObj) {
|
|
464
|
-
var binding = {
|
|
465
|
-
model: "",
|
|
466
|
-
path: ""
|
|
467
|
-
};
|
|
468
|
-
if (!pathObj || !pathObj.path)
|
|
469
|
-
return binding;
|
|
470
|
-
if (pathObj.path.indexOf(">") !== -1) {
|
|
471
|
-
binding.model = pathObj.path.substring(0, pathObj.path.indexOf(">"));
|
|
472
|
-
binding.path = pathObj.path.substring(pathObj.path.indexOf(">") + 1, pathObj.path.length);
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
binding.path = pathObj.path;
|
|
476
|
-
}
|
|
477
|
-
return binding;
|
|
478
|
-
}
|
|
479
|
-
function compareBindingPathAndModelProperty(key, locatorProperty, oControl) {
|
|
480
|
-
var extrPath = extractBindingPathAndModelProperty(locatorProperty);
|
|
481
|
-
var aBindindInfo = getBindDataForProperty(oControl, key);
|
|
482
|
-
if (aBindindInfo.length === 0) {
|
|
483
|
-
aBindindInfo = getBindDataForAggregation(oControl, key);
|
|
484
|
-
}
|
|
485
|
-
if (aBindindInfo.length === 0) {
|
|
486
|
-
aBindindInfo = getBindDataForAssociation(oControl, key);
|
|
487
|
-
}
|
|
488
|
-
if ((!extrPath.path && aBindindInfo.length > 0) ||
|
|
489
|
-
(!extrPath.path && aBindindInfo.length === 0)) {
|
|
490
|
-
return true;
|
|
491
|
-
}
|
|
492
|
-
else if (extrPath.path && aBindindInfo.length === 0) {
|
|
493
|
-
return false;
|
|
494
|
-
}
|
|
495
|
-
var aCandidatePath = [];
|
|
496
|
-
for (let index = 0; index < aBindindInfo.length; index++) {
|
|
497
|
-
const bindindInfo = aBindindInfo[index];
|
|
498
|
-
if ((extrPath.model && bindindInfo.model)) {
|
|
499
|
-
if ((extrPath.path && (bindindInfo.path !== null && bindindInfo.path !== undefined))
|
|
500
|
-
&& wildCardAndNormalCompare(extrPath.model, bindindInfo.model)) {
|
|
501
|
-
//if(convertToString(bindindInfo.path) === convertToString(extrPath.path))
|
|
502
|
-
if (wildCardAndNormalCompare(extrPath.path, bindindInfo.path))
|
|
503
|
-
aCandidatePath.push(bindindInfo.path);
|
|
459
|
+
const nodeAttributes = _DomPropertiesComparator.retrieveNodeAttributes(node);
|
|
460
|
+
return Object.entries(properties).every(([key, value]) => {
|
|
461
|
+
if (key === "nodeName") {
|
|
462
|
+
return Comparator.compareWithWildCard(node?.nodeName, value, true);
|
|
463
|
+
}
|
|
464
|
+
const valueArray = Array.isArray(value) ? value : [value];
|
|
465
|
+
return valueArray.every((val) => _DomPropertiesComparator.compareAttributeToElementAttributes(key, val, nodeAttributes));
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
static retrieveNodeAttributes(node) {
|
|
469
|
+
return new Map(Array.from(node.attributes, (a) => [a.nodeName, a.nodeValue ?? ""]));
|
|
470
|
+
}
|
|
471
|
+
static compareAttributeToElementAttributes(key, value, nodeAttributes) {
|
|
472
|
+
return Comparator.compareWithWildCard(value, nodeAttributes.get(key));
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
// src/scripts/locators/qmateLocatorSrc/comparators/ElementPropertiesComparator.ts
|
|
476
|
+
var ElementPropertiesComparator = class _ElementPropertiesComparator {
|
|
477
|
+
static compareToProperties(elementProperties, control) {
|
|
478
|
+
return Object.entries(elementProperties ?? {}).every(([key, value]) => {
|
|
479
|
+
if ([
|
|
480
|
+
"domProperties",
|
|
481
|
+
"metadata",
|
|
482
|
+
"ancestorProperties",
|
|
483
|
+
"descendantProperties",
|
|
484
|
+
"siblingProperties",
|
|
485
|
+
"mProperties",
|
|
486
|
+
].includes(key)) {
|
|
487
|
+
return true;
|
|
504
488
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (extrPath.path && (bindindInfo.path !== null && bindindInfo.path !== undefined)) {
|
|
508
|
-
//if(convertToString(bindindInfo.path) === convertToString(extrPath.path))
|
|
509
|
-
if (wildCardAndNormalCompare(extrPath.path, bindindInfo.path)) {
|
|
510
|
-
aCandidatePath.push(bindindInfo.path);
|
|
511
|
-
}
|
|
489
|
+
if (key === "viewName") {
|
|
490
|
+
return _ElementPropertiesComparator.isControlInViewName(control, value);
|
|
512
491
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
return aCandidatePath.length > 0;
|
|
516
|
-
}
|
|
517
|
-
function wildCardAndNormalCompare(sWild, sValue) {
|
|
518
|
-
if ((sValue === undefined || sValue === null)
|
|
519
|
-
&& (sWild === undefined || sWild === null))
|
|
520
|
-
return true;
|
|
521
|
-
else {
|
|
522
|
-
if (sValue === undefined || sValue === null)
|
|
523
|
-
sValue = "";
|
|
524
|
-
if (sWild === undefined || sWild === null)
|
|
525
|
-
sWild = "";
|
|
526
|
-
}
|
|
527
|
-
if (!sWild.trim() || sWild.indexOf("*") === -1) {
|
|
528
|
-
return (convertToString(sWild) === convertToString(sValue));
|
|
529
|
-
}
|
|
530
|
-
var aWilds = convertToString(sWild).trim().split("*");
|
|
531
|
-
sValue = convertToString(sValue);
|
|
532
|
-
for (var i = 0; i < aWilds.length; i++) {
|
|
533
|
-
if (!aWilds[i])
|
|
534
|
-
continue;
|
|
535
|
-
if (sValue.indexOf(aWilds[i]) === -1)
|
|
536
|
-
return false;
|
|
537
|
-
}
|
|
538
|
-
return true;
|
|
539
|
-
}
|
|
540
|
-
function compareAttributeToElementAttributes(sKey, sValue, aNodeAttributes) {
|
|
541
|
-
if (!sKey || !sValue || !aNodeAttributes)
|
|
542
|
-
return false;
|
|
543
|
-
for (let index = 0; index < aNodeAttributes.length; index++) {
|
|
544
|
-
var oElm = aNodeAttributes[index];
|
|
545
|
-
if (oElm) {
|
|
546
|
-
const aAttrKey = Object.keys(oElm);
|
|
547
|
-
const aAttrValue = Object.values(oElm);
|
|
548
|
-
if (aAttrKey && aAttrValue &&
|
|
549
|
-
aAttrKey.length > 0 && aAttrValue.length > 0 &&
|
|
550
|
-
aAttrValue[0] !== undefined && aAttrValue[0] !== null) {
|
|
551
|
-
if (aAttrKey[0] === sKey) {
|
|
552
|
-
var val = aAttrValue[0].toString();
|
|
553
|
-
if (wildCardAndNormalCompare(sValue, val)) {
|
|
554
|
-
return true;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
492
|
+
if (key === "viewId") {
|
|
493
|
+
return _ElementPropertiesComparator.isControlInViewId(control, value);
|
|
557
494
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
return false;
|
|
561
|
-
}
|
|
562
|
-
function compareToDomProperties(oNode, mProperties) {
|
|
563
|
-
var bPass = true;
|
|
564
|
-
if (!mProperties || !oNode) {
|
|
565
|
-
console.log("No dom properties or no node to compare");
|
|
566
|
-
return bPass;
|
|
567
|
-
}
|
|
568
|
-
var aNodeAttributes = retrieveNodeAttributes(oNode);
|
|
569
|
-
for (var key in mProperties) {
|
|
570
|
-
var value = mProperties[key];
|
|
571
|
-
if (value) {
|
|
572
|
-
if (key === "nodeName") {
|
|
573
|
-
const nodeName = retrieveNodeName(oNode);
|
|
574
|
-
bPass = bPass && (nodeName.toLowerCase() === value.toLowerCase());
|
|
495
|
+
if (key === "id") {
|
|
496
|
+
return _ElementPropertiesComparator.compareId(control, value);
|
|
575
497
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
value.map(function (attrValue) {
|
|
579
|
-
bPass = bPass && compareAttributeToElementAttributes(key, attrValue, aNodeAttributes);
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
bPass = bPass && compareAttributeToElementAttributes(key, value, aNodeAttributes);
|
|
584
|
-
}
|
|
498
|
+
if (key === "bindingContextPath") {
|
|
499
|
+
return UI5ControlHandler.getControlBindingContextPaths(control).some((path) => Comparator.compareWithWildCard(value, path));
|
|
585
500
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
return bPass;
|
|
592
|
-
}
|
|
593
|
-
function compareToProperties(mProperties, oControl) {
|
|
594
|
-
var bPass = true;
|
|
595
|
-
if (!mProperties) {
|
|
596
|
-
console.log("No properties to compare");
|
|
597
|
-
return bPass;
|
|
598
|
-
}
|
|
599
|
-
for (var key in mProperties) {
|
|
600
|
-
var value = mProperties[key];
|
|
601
|
-
if (key !== "domProperties" &&
|
|
602
|
-
key !== "metadata" &&
|
|
603
|
-
key !== "ancestorProperties" &&
|
|
604
|
-
key !== "descendantProperties" &&
|
|
605
|
-
key !== "siblingProperties") {
|
|
606
|
-
if (value && Array.isArray(value)) {
|
|
607
|
-
let bIsStringVal = false;
|
|
608
|
-
if (value.length > 0) {
|
|
609
|
-
//Check type
|
|
610
|
-
const stVal = value[0];
|
|
611
|
-
if (typeof stVal === "string") {
|
|
612
|
-
bIsStringVal = true;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
value.map(function (valData) {
|
|
616
|
-
if (bIsStringVal) {
|
|
617
|
-
bPass = bPass && compareArrayStrElements(key, valData, oControl);
|
|
501
|
+
if (Array.isArray(value)) {
|
|
502
|
+
return value.every((val) => {
|
|
503
|
+
if (typeof val === "string") {
|
|
504
|
+
return _ElementPropertiesComparator.compareArrayStrElements(key, val, control);
|
|
618
505
|
}
|
|
619
506
|
else {
|
|
620
|
-
|
|
507
|
+
return _ElementPropertiesComparator.compareBindingPathAndModelProperty(key, val, control);
|
|
621
508
|
}
|
|
622
509
|
});
|
|
623
510
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
else if (key === "bindingContextPath") {
|
|
628
|
-
var aPaths = getControlBindingContextPaths(oControl);
|
|
629
|
-
var bFound = false;
|
|
630
|
-
if (aPaths && aPaths.length) {
|
|
631
|
-
for (let index = 0; index < aPaths.length; index++) {
|
|
632
|
-
if (aPaths[index] && value) {
|
|
633
|
-
bFound = wildCardAndNormalCompare(value, aPaths[index]);
|
|
634
|
-
if (bFound) {
|
|
635
|
-
break;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
bPass = bPass && bFound;
|
|
641
|
-
}
|
|
642
|
-
else if (key === "viewName") {
|
|
643
|
-
bPass = bPass && isControlInViewName(oControl, value);
|
|
644
|
-
}
|
|
645
|
-
else if (key === "viewId") {
|
|
646
|
-
bPass = bPass && isControlInViewId(oControl, value);
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
if (key === "id") {
|
|
650
|
-
var bIdProp = compareId(oControl, value);
|
|
651
|
-
bPass = bPass && bIdProp;
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
var bPropVal = compareProperty(oControl, key, value);
|
|
655
|
-
if (!bPropVal)
|
|
656
|
-
bPropVal = compareAggregation(oControl, key, value);
|
|
657
|
-
if (!bPropVal)
|
|
658
|
-
bPropVal = compareAssociation(oControl, key, value);
|
|
659
|
-
bPass = bPass && bPropVal;
|
|
660
|
-
}
|
|
511
|
+
if (typeof value === "object") {
|
|
512
|
+
return _ElementPropertiesComparator.compareBindingPathAndModelProperty(key, value, control);
|
|
661
513
|
}
|
|
662
|
-
|
|
514
|
+
return _ElementPropertiesComparator.compareProperty(control, key, value);
|
|
515
|
+
});
|
|
663
516
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
var aPropValues = [];
|
|
669
|
-
try {
|
|
670
|
-
aPropValues = getAssociationProperty(oControl, key) || [];
|
|
671
|
-
// eslint-disable-next-line no-empty
|
|
517
|
+
static isControlInViewName(control, viewName) {
|
|
518
|
+
return this.getAncestorViews(control).some((controlToCheck) => {
|
|
519
|
+
return Comparator.compareWithWildCard(viewName, controlToCheck.getViewName?.());
|
|
520
|
+
});
|
|
672
521
|
}
|
|
673
|
-
|
|
522
|
+
static isControlInViewId(control, sViewId) {
|
|
523
|
+
return this.getAncestorViews(control).some((controlToCheck) => {
|
|
524
|
+
return Comparator.compareWithWildCard(sViewId, controlToCheck.getId());
|
|
525
|
+
});
|
|
674
526
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
}
|
|
681
|
-
catch (error) {
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
if (aPropValues.length === 0) {
|
|
685
|
-
try {
|
|
686
|
-
aPropValues = getControlProperty(oControl, key) || [];
|
|
687
|
-
}
|
|
688
|
-
catch (error) {
|
|
689
|
-
// Continue
|
|
690
|
-
}
|
|
527
|
+
static getAncestorViews(control) {
|
|
528
|
+
return [control]
|
|
529
|
+
.concat(UI5ControlHandler.getUI5Ancestors(control))
|
|
530
|
+
.filter((ancestor) => {
|
|
531
|
+
return ancestor instanceof sap.ui.core.mvc.View;
|
|
532
|
+
});
|
|
691
533
|
}
|
|
692
|
-
|
|
693
|
-
(
|
|
694
|
-
|
|
534
|
+
static compareId(control, expectedId) {
|
|
535
|
+
return (expectedId === void 0 ||
|
|
536
|
+
Comparator.compareWithWildCard(expectedId, control.getId?.()));
|
|
695
537
|
}
|
|
696
|
-
|
|
697
|
-
|
|
538
|
+
static compareProperty(control, key, value) {
|
|
539
|
+
const controlVal = UI5ControlHandler.getControlProperty(control, key);
|
|
540
|
+
return Comparator.compareWithWildCard(value, controlVal);
|
|
698
541
|
}
|
|
699
|
-
|
|
700
|
-
const
|
|
701
|
-
if (
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
return bPass;
|
|
718
|
-
}
|
|
719
|
-
function compareProperty(oControl, key, value) {
|
|
720
|
-
var controlVal = null;
|
|
721
|
-
try {
|
|
722
|
-
controlVal = getControlProperty(oControl, key);
|
|
723
|
-
}
|
|
724
|
-
catch (e) {
|
|
725
|
-
// Property doesnt exist
|
|
726
|
-
}
|
|
727
|
-
if (controlVal !== null && controlVal !== undefined && value !== null && value !== undefined) {
|
|
728
|
-
//return convertToString(controlVal) === convertToString(value);
|
|
729
|
-
return wildCardAndNormalCompare(value, controlVal);
|
|
730
|
-
}
|
|
731
|
-
else if ((controlVal === null || controlVal === undefined) && value) {
|
|
732
|
-
return false;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
function getId(oControl) {
|
|
736
|
-
if (!oControl ||
|
|
737
|
-
!oControl.getId) {
|
|
738
|
-
return null;
|
|
739
|
-
}
|
|
740
|
-
return oControl.getId();
|
|
741
|
-
}
|
|
742
|
-
function compareId(oControl, value) {
|
|
743
|
-
var controlVal = null;
|
|
744
|
-
try {
|
|
745
|
-
controlVal = getId(oControl);
|
|
746
|
-
}
|
|
747
|
-
catch (e) {
|
|
748
|
-
// Property doesnt exist
|
|
749
|
-
}
|
|
750
|
-
if (controlVal !== null && controlVal !== undefined && value) {
|
|
751
|
-
//return convertToString(controlVal) === convertToString(value);
|
|
752
|
-
return wildCardAndNormalCompare(value, controlVal);
|
|
753
|
-
}
|
|
754
|
-
else if ((controlVal === null || controlVal === undefined) && value) {
|
|
755
|
-
return false;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
function compareAggregation(oControl, key, value) {
|
|
759
|
-
var controlVal = null;
|
|
760
|
-
try {
|
|
761
|
-
controlVal = getAggregationProperty(oControl, key);
|
|
762
|
-
}
|
|
763
|
-
catch (e) {
|
|
764
|
-
// Aggregation doesnt exist
|
|
765
|
-
}
|
|
766
|
-
if (controlVal !== null && controlVal !== undefined && value) {
|
|
767
|
-
//return convertToString(controlVal) === convertToString(value);
|
|
768
|
-
return wildCardAndNormalCompare(value, controlVal);
|
|
769
|
-
}
|
|
770
|
-
else if ((controlVal === null || controlVal === undefined) && value) {
|
|
771
|
-
return false;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
function compareAssociation(oControl, key, value) {
|
|
775
|
-
var controlVal = null;
|
|
776
|
-
try {
|
|
777
|
-
controlVal = getAssociationProperty(oControl, key);
|
|
778
|
-
}
|
|
779
|
-
catch (e) {
|
|
780
|
-
// Association doesnt exist
|
|
781
|
-
}
|
|
782
|
-
if (controlVal !== null && controlVal !== undefined && value) {
|
|
783
|
-
//return convertToString(controlVal) === convertToString(value);
|
|
784
|
-
return wildCardAndNormalCompare(value, controlVal);
|
|
785
|
-
}
|
|
786
|
-
else if ((controlVal === null || controlVal === undefined) && value) {
|
|
787
|
-
return false;
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
function filterMetadata(elementProperties, oControl) {
|
|
791
|
-
//console.log("Beggining control---->" + controlVal);
|
|
792
|
-
var bPass = true;
|
|
793
|
-
var controlVal = oControl.getMetadata().getName();
|
|
794
|
-
if (!elementProperties)
|
|
795
|
-
return bPass;
|
|
796
|
-
if (!elementProperties.metadata)
|
|
797
|
-
return bPass;
|
|
798
|
-
var metadata = elementProperties.metadata;
|
|
799
|
-
if (!controlVal && metadata) {
|
|
800
|
-
bPass = false;
|
|
801
|
-
return bPass;
|
|
802
|
-
}
|
|
803
|
-
else if (controlVal && metadata) {
|
|
804
|
-
//console.log("Control val---->" + controlVal + " metadata--->"+ metadata);
|
|
805
|
-
bPass = bPass && wildCardAndNormalCompare(metadata, controlVal);
|
|
806
|
-
}
|
|
807
|
-
return bPass;
|
|
808
|
-
}
|
|
809
|
-
function compareToElementProperties(elementProperties, oControl) {
|
|
810
|
-
var bPass = true;
|
|
811
|
-
if ((!elementProperties || isEmptyObject(elementProperties)) && oControl) {
|
|
812
|
-
return bPass;
|
|
813
|
-
}
|
|
814
|
-
else if ((elementProperties && !isEmptyObject(elementProperties)) && !oControl) {
|
|
815
|
-
return false;
|
|
816
|
-
}
|
|
817
|
-
else if ((!elementProperties || isEmptyObject(elementProperties)) && !oControl) {
|
|
818
|
-
return bPass;
|
|
819
|
-
}
|
|
820
|
-
bPass = bPass && filterMetadata(elementProperties, oControl);
|
|
821
|
-
if (!bPass)
|
|
822
|
-
return bPass;
|
|
823
|
-
if (elementProperties && elementProperties.mProperties && typeof elementProperties.mProperties === "object") {
|
|
824
|
-
//if(oControl.getId() === "__box0")
|
|
825
|
-
bPass = bPass && compareToProperties(elementProperties.mProperties, oControl);
|
|
826
|
-
}
|
|
827
|
-
else if (elementProperties && typeof elementProperties === "object"
|
|
828
|
-
&& !elementProperties.mProperties) {
|
|
829
|
-
bPass = bPass && compareToProperties(elementProperties, oControl);
|
|
830
|
-
}
|
|
831
|
-
if (elementProperties.domProperties && typeof elementProperties.domProperties === "object") {
|
|
832
|
-
var oNode = convertToDomElement(oControl);
|
|
833
|
-
bPass = bPass && compareToDomProperties(oNode, elementProperties.domProperties);
|
|
834
|
-
}
|
|
835
|
-
if (bPass) {
|
|
836
|
-
var selectObj = elementProperties;
|
|
837
|
-
if (elementProperties.mProperties) {
|
|
838
|
-
selectObj = elementProperties.mProperties;
|
|
839
|
-
}
|
|
840
|
-
if (selectObj.ancestorProperties) {
|
|
841
|
-
bPass = bPass && compareToAncestorProperties(selectObj.ancestorProperties, oControl);
|
|
842
|
-
}
|
|
843
|
-
if (selectObj.descendantProperties) {
|
|
844
|
-
bPass = bPass && compareToDescendantElementProperties(selectObj.descendantProperties, oControl);
|
|
845
|
-
}
|
|
846
|
-
if (selectObj.siblingProperties) {
|
|
847
|
-
var oParentControl = getValidParentControl(oControl);
|
|
848
|
-
bPass = bPass && compareToSiblingElementProperties(selectObj.siblingProperties, oControl, oParentControl);
|
|
849
|
-
}
|
|
850
|
-
if (selectObj.prevSiblingProperties || selectObj.nextSiblingProperties || selectObj.childProperties || selectObj.parentProperties) {
|
|
851
|
-
throw new Error("Nested properties can only be used for ancestorProperties, descendantProperties or siblingProperties.");
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
return bPass;
|
|
855
|
-
}
|
|
856
|
-
function compareToPrevElementProperties(elementProperties, oControl, oParentControl) {
|
|
857
|
-
var bPass = true;
|
|
858
|
-
if ((!elementProperties || isEmptyObject(elementProperties)) && oParentControl) {
|
|
859
|
-
return bPass;
|
|
860
|
-
}
|
|
861
|
-
else if ((elementProperties && !isEmptyObject(elementProperties)) && !oParentControl) {
|
|
862
|
-
return false;
|
|
863
|
-
}
|
|
864
|
-
else if ((!elementProperties || isEmptyObject(elementProperties)) && !oParentControl) {
|
|
865
|
-
return bPass;
|
|
866
|
-
}
|
|
867
|
-
var oPrevControl = findPrevNextControl(oControl, oParentControl, false);
|
|
868
|
-
if ((!elementProperties || isEmptyObject(elementProperties)) && oPrevControl) {
|
|
869
|
-
return bPass;
|
|
870
|
-
}
|
|
871
|
-
else if ((elementProperties && !isEmptyObject(elementProperties)) && !oPrevControl) {
|
|
872
|
-
return false;
|
|
873
|
-
}
|
|
874
|
-
else if ((!elementProperties || isEmptyObject(elementProperties)) && !oPrevControl) {
|
|
875
|
-
return bPass;
|
|
876
|
-
}
|
|
877
|
-
/*console.log("Previous Property Control Type -->"
|
|
878
|
-
+ oPrevControl.getMetadata().getName()
|
|
879
|
-
+ ", Id-->" + oPrevControl.getId());*/
|
|
880
|
-
return compareToElementProperties(elementProperties, oPrevControl);
|
|
881
|
-
}
|
|
882
|
-
function retrieveValidUI5Controls(nodes) {
|
|
883
|
-
var aCandidateValidControls = [];
|
|
884
|
-
if (!nodes || nodes.length === 0) {
|
|
885
|
-
throw new Error("no node html elements found");
|
|
886
|
-
}
|
|
887
|
-
Array.prototype.filter.call(nodes, function (node) {
|
|
888
|
-
var nodeId = node.getAttribute("id");
|
|
889
|
-
if (!nodeId) {
|
|
890
|
-
return false;
|
|
891
|
-
}
|
|
892
|
-
// eslint-disable-next-line no-undef
|
|
893
|
-
var oControl = sap.ui.getCore().byId(nodeId);
|
|
894
|
-
if (oControl) {
|
|
895
|
-
aCandidateValidControls.push(oControl);
|
|
896
|
-
}
|
|
897
|
-
return oControl;
|
|
898
|
-
});
|
|
899
|
-
return aCandidateValidControls;
|
|
900
|
-
}
|
|
901
|
-
function injectDataForProperties(domElement, oControl) {
|
|
902
|
-
// Inject properties
|
|
903
|
-
var aProperties = Object.keys(getControlAllProperties(oControl));
|
|
904
|
-
Array.prototype.filter.call(aProperties, function (key) {
|
|
905
|
-
var controlVal = getControlProperty(oControl, key);
|
|
906
|
-
domElement.setAttribute("data-" + key, controlVal);
|
|
907
|
-
return domElement;
|
|
908
|
-
});
|
|
909
|
-
// Inject aggregations
|
|
910
|
-
var aAggregation = Object.keys(getControlAllAggregations(oControl));
|
|
911
|
-
Array.prototype.filter.call(aAggregation, function (key) {
|
|
912
|
-
var controlVal = getAggregationProperty(oControl, key);
|
|
913
|
-
domElement.setAttribute("data-" + key, controlVal);
|
|
914
|
-
return domElement;
|
|
915
|
-
});
|
|
916
|
-
// Inject associations
|
|
917
|
-
var aAssociation = Object.keys(getControlAllAssociations(oControl));
|
|
918
|
-
Array.prototype.filter.call(aAssociation, function (key) {
|
|
919
|
-
var controlVal = getAssociationProperty(oControl, key);
|
|
920
|
-
domElement.setAttribute("data-" + key, controlVal);
|
|
921
|
-
return domElement;
|
|
922
|
-
});
|
|
923
|
-
//Inject bindingContextPath
|
|
924
|
-
var aBindingPathValues = getControlBindingContextPaths(oControl);
|
|
925
|
-
if (aBindingPathValues && aBindingPathValues.length > 0) {
|
|
926
|
-
domElement.setAttribute("data-bindingContextPath-size", aBindingPathValues.length);
|
|
927
|
-
for (let index = 0; index < aBindingPathValues.length; index++) {
|
|
928
|
-
const sBindingPathValue = aBindingPathValues[index];
|
|
929
|
-
domElement.setAttribute("data-bindingContextPath" + index, sBindingPathValue);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
else {
|
|
933
|
-
domElement.setAttribute("data-bindingContextPath-size", 0);
|
|
934
|
-
}
|
|
935
|
-
//Inject BindingPath for property
|
|
936
|
-
Array.prototype.filter.call(aProperties, function (key) {
|
|
937
|
-
var oBindingDataStr = getBindingInfoDataString(oControl, key);
|
|
938
|
-
if (oBindingDataStr !== null && oBindingDataStr !== undefined) {
|
|
939
|
-
var sBindingDataStr = oBindingDataStr.toString();
|
|
940
|
-
if (sBindingDataStr && sBindingDataStr.trim() !== "") {
|
|
941
|
-
domElement.setAttribute("data-" + key + "-path", sBindingDataStr);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
else {
|
|
542
|
+
static compareBindingPathAndModelProperty(key, value, control) {
|
|
543
|
+
const extrPath = UI5ControlHandler.extractBindingPathAndModelProperty(value);
|
|
544
|
+
if (!extrPath.path)
|
|
545
|
+
return true;
|
|
546
|
+
const bindingInfo = UI5ControlHandler.getBindDataForProperty(control, key);
|
|
547
|
+
return bindingInfo.some((info) => Comparator.compareWithWildCard(extrPath.path, info.path) &&
|
|
548
|
+
(!extrPath.model ||
|
|
549
|
+
!info.model ||
|
|
550
|
+
Comparator.compareWithWildCard(extrPath.model, info.model)));
|
|
551
|
+
}
|
|
552
|
+
static compareArrayStrElements(key, expectedValue, control) {
|
|
553
|
+
const values = UI5ControlHandler.getControlProperty(control, key) || [];
|
|
554
|
+
if (!values.length && !expectedValue)
|
|
555
|
+
return true;
|
|
556
|
+
if (values.length && !expectedValue)
|
|
945
557
|
return false;
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
558
|
+
return values.some((elem) => Comparator.compareWithWildCard(expectedValue, elem.getId?.() ?? elem, true));
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
// src/scripts/locators/qmateLocatorSrc/comparators/MetadataComparator.ts
|
|
562
|
+
var MetadataComparator = class {
|
|
563
|
+
static compareMetadata(elementProperties, control) {
|
|
564
|
+
const controlMetadata = control.getMetadata().getName();
|
|
565
|
+
const metadata = elementProperties.metadata;
|
|
566
|
+
return (metadata === void 0 ||
|
|
567
|
+
Comparator.compareWithWildCard(metadata, controlMetadata));
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
// src/scripts/locators/qmateLocatorSrc/filters/PropertiesFilter.ts
|
|
571
|
+
var PropertiesFilter = class extends BaseFilter {
|
|
572
|
+
doCheckSingle(control) {
|
|
573
|
+
let pass = MetadataComparator.compareMetadata(this.elementProperties, control);
|
|
574
|
+
pass &&= ElementPropertiesComparator.compareToProperties(this.elementProperties, control);
|
|
575
|
+
pass &&= DomPropertiesComparator.compareToDomProperties(this.elementProperties.domProperties, control);
|
|
576
|
+
return pass;
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
// src/scripts/locators/qmateLocatorSrc/filters/ChildFilter.ts
|
|
580
|
+
var ChildFilter = class extends BaseFilter {
|
|
581
|
+
doCheckSingle(control) {
|
|
582
|
+
const element = document.getElementById(control.getId());
|
|
583
|
+
if (!element) {
|
|
962
584
|
return false;
|
|
963
585
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
domElement.setAttribute("data-" + key + "-path", sBindingDataStr);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
else {
|
|
586
|
+
const childControls = UI5ControlHandler.retrieveValidUI5ControlsSubElements(element.children);
|
|
587
|
+
const elementFilter = this.filterFactory.getInstance(ElementFilter, this.elementProperties);
|
|
588
|
+
return childControls.some((childControl) => elementFilter.checkSingle(childControl));
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
// src/scripts/locators/qmateLocatorSrc/filters/ParentFilter.ts
|
|
592
|
+
var ParentFilter = class extends BaseFilter {
|
|
593
|
+
doCheckSingle(control) {
|
|
594
|
+
const parentControl = UI5ControlHandler.getUI5Parent(control);
|
|
595
|
+
if (!parentControl) {
|
|
596
|
+
console.error(`The parent control of ${control.getId()} is not valid, please check the control`);
|
|
979
597
|
return false;
|
|
980
598
|
}
|
|
981
|
-
return
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
function getBindingInfoDataString(oControl, key) {
|
|
985
|
-
var aBindingInfos = [];
|
|
986
|
-
try {
|
|
987
|
-
if (!oControl || !key
|
|
988
|
-
|| !oControl.getBindingInfo
|
|
989
|
-
|| !oControl.getBindingInfo(key))
|
|
990
|
-
return aBindingInfos;
|
|
991
|
-
var aBindingInfoParts = oControl.getBindingInfo(key).parts;
|
|
992
|
-
if (aBindingInfoParts && aBindingInfoParts.length > 0) {
|
|
993
|
-
for (var i = 0; i < aBindingInfoParts.length; i++) {
|
|
994
|
-
if (!aBindingInfoParts[i].path)
|
|
995
|
-
continue;
|
|
996
|
-
var sJoin = "";
|
|
997
|
-
if (!aBindingInfoParts[i].model)
|
|
998
|
-
sJoin = aBindingInfoParts[i].path;
|
|
999
|
-
else
|
|
1000
|
-
sJoin = aBindingInfoParts[i].model + ">" + aBindingInfoParts[i].path;
|
|
1001
|
-
aBindingInfos.push(sJoin);
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
else {
|
|
1005
|
-
sJoin = oControl.getBindingInfo(key).path;
|
|
1006
|
-
aBindingInfos.push(sJoin);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
catch (e) {
|
|
1010
|
-
// Just ignore and move forward
|
|
1011
|
-
}
|
|
1012
|
-
if (aBindingInfos.length > 0) {
|
|
1013
|
-
return aBindingInfos.join();
|
|
599
|
+
return this.filterFactory
|
|
600
|
+
.getInstance(ElementFilter, this.elementProperties)
|
|
601
|
+
.checkSingle(parentControl);
|
|
1014
602
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
try {
|
|
1022
|
-
if (!oControl || !key
|
|
1023
|
-
|| !oControl.getBindingInfo
|
|
1024
|
-
|| !oControl.getBindingInfo(key)
|
|
1025
|
-
|| !oControl.getBindingInfo(key))
|
|
1026
|
-
return aBindingInfos;
|
|
1027
|
-
var aBindingInfoParts = oControl.getBindingInfo(key).parts;
|
|
1028
|
-
if (aBindingInfoParts && aBindingInfoParts.length > 0) {
|
|
1029
|
-
for (var i = 0; i < aBindingInfoParts.length; i++) {
|
|
1030
|
-
if (!aBindingInfoParts[i].path)
|
|
1031
|
-
continue;
|
|
1032
|
-
var sJoin = "";
|
|
1033
|
-
if (!aBindingInfoParts[i].model)
|
|
1034
|
-
sJoin = aBindingInfoParts[i].path;
|
|
1035
|
-
else
|
|
1036
|
-
sJoin = aBindingInfoParts[i].model + ">" + aBindingInfoParts[i].path;
|
|
1037
|
-
aBindingInfos.push(sJoin);
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
else {
|
|
1041
|
-
sJoin = oControl.getBindingInfo(key).path;
|
|
1042
|
-
aBindingInfos.push(sJoin);
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
catch (e) {
|
|
1046
|
-
// Just ignore and move forward
|
|
1047
|
-
}
|
|
1048
|
-
if (aBindingInfos.length > 0) {
|
|
1049
|
-
return aBindingInfos.join();
|
|
1050
|
-
}
|
|
1051
|
-
else {
|
|
1052
|
-
return null;
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
function getBindingInfoDataAssociationString(oControl, key) {
|
|
1056
|
-
var aBindingInfos = [];
|
|
1057
|
-
try {
|
|
1058
|
-
if (!oControl || !key
|
|
1059
|
-
|| !oControl.getBindingInfo
|
|
1060
|
-
|| !oControl.getBindingInfo(key)
|
|
1061
|
-
|| !oControl.getBindingInfo(key))
|
|
1062
|
-
return aBindingInfos;
|
|
1063
|
-
var aBindingInfoParts = oControl.getBindingInfo(key).parts;
|
|
1064
|
-
if (aBindingInfoParts && aBindingInfoParts.length > 0) {
|
|
1065
|
-
for (var i = 0; i < aBindingInfoParts.length; i++) {
|
|
1066
|
-
if (!aBindingInfoParts[i].path)
|
|
1067
|
-
continue;
|
|
1068
|
-
var sJoin = "";
|
|
1069
|
-
if (!aBindingInfoParts[i].model)
|
|
1070
|
-
sJoin = aBindingInfoParts[i].path;
|
|
1071
|
-
else
|
|
1072
|
-
sJoin = aBindingInfoParts[i].model + ">" + aBindingInfoParts[i].path;
|
|
1073
|
-
aBindingInfos.push(sJoin);
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
else {
|
|
1077
|
-
sJoin = oControl.getBindingInfo(key).path;
|
|
1078
|
-
aBindingInfos.push(sJoin);
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
catch (e) {
|
|
1082
|
-
// Just ignore and move forward
|
|
1083
|
-
}
|
|
1084
|
-
if (aBindingInfos.length > 0) {
|
|
1085
|
-
return aBindingInfos.join();
|
|
1086
|
-
}
|
|
1087
|
-
else {
|
|
1088
|
-
return null;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
function convertToDomElement(oControl) {
|
|
1092
|
-
if (!oControl || !oControl.getId || !oControl.getId()) {
|
|
1093
|
-
return null;
|
|
1094
|
-
}
|
|
1095
|
-
var domElem = document.getElementById(oControl.getId());
|
|
1096
|
-
if (domElem) {
|
|
1097
|
-
return domElem;
|
|
1098
|
-
}
|
|
1099
|
-
return null;
|
|
1100
|
-
}
|
|
1101
|
-
function convertToDomElements(aControls) {
|
|
1102
|
-
var aFoundNodes = [];
|
|
1103
|
-
Array.prototype.filter.call(aControls, function (oControl) {
|
|
1104
|
-
if (!oControl || !oControl.getId || !oControl.getId()) {
|
|
603
|
+
};
|
|
604
|
+
// src/scripts/locators/qmateLocatorSrc/filters/PrevSiblingFilter.ts
|
|
605
|
+
var PrevSiblingFilter = class extends BaseFilter {
|
|
606
|
+
doCheckSingle(control) {
|
|
607
|
+
const prevControl = UI5ControlHandler.findPreviousOrNextControl(control, false);
|
|
608
|
+
if (!prevControl) {
|
|
1105
609
|
return false;
|
|
1106
610
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
aFoundNodes.push(domElem);
|
|
1111
|
-
}
|
|
1112
|
-
return domElem;
|
|
1113
|
-
});
|
|
1114
|
-
return aFoundNodes;
|
|
1115
|
-
}
|
|
1116
|
-
function compareToNextElementProperties(elementProperties, oControl, oParentControl) {
|
|
1117
|
-
var bPass = true;
|
|
1118
|
-
if ((!elementProperties || isEmptyObject(elementProperties)) && oParentControl) {
|
|
1119
|
-
return bPass;
|
|
1120
|
-
}
|
|
1121
|
-
else if ((elementProperties && !isEmptyObject(elementProperties)) && !oParentControl) {
|
|
1122
|
-
return false;
|
|
1123
|
-
}
|
|
1124
|
-
else if ((!elementProperties || isEmptyObject(elementProperties)) && !oParentControl) {
|
|
1125
|
-
return bPass;
|
|
1126
|
-
}
|
|
1127
|
-
var oNextControl = findPrevNextControl(oControl, oParentControl, true);
|
|
1128
|
-
if ((!elementProperties || isEmptyObject(elementProperties)) && oNextControl) {
|
|
1129
|
-
return bPass;
|
|
1130
|
-
}
|
|
1131
|
-
else if ((elementProperties && !isEmptyObject(elementProperties)) && !oNextControl) {
|
|
1132
|
-
return false;
|
|
611
|
+
return this.filterFactory
|
|
612
|
+
.getInstance(ElementFilter, this.elementProperties)
|
|
613
|
+
.checkSingle(prevControl);
|
|
1133
614
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
+ ", bPass-->"+ bPass);*/
|
|
1141
|
-
return compareToElementProperties(elementProperties, oNextControl);
|
|
1142
|
-
}
|
|
1143
|
-
function compareToDescendantElementProperties(elementProperties, oControl) {
|
|
1144
|
-
var bPass = true;
|
|
1145
|
-
if ((!elementProperties || isEmptyObject(elementProperties)) && oControl) {
|
|
1146
|
-
return bPass;
|
|
1147
|
-
}
|
|
1148
|
-
else if ((elementProperties && !isEmptyObject(elementProperties)) && !oControl) {
|
|
1149
|
-
return false;
|
|
1150
|
-
}
|
|
1151
|
-
else if ((!elementProperties || isEmptyObject(elementProperties)) && !oControl) {
|
|
1152
|
-
return bPass;
|
|
1153
|
-
}
|
|
1154
|
-
var aChildrenControls = [];
|
|
1155
|
-
var aAllChildrenNodes = document.getElementById(oControl.getId()).children;
|
|
1156
|
-
aCandidateControls = [];
|
|
1157
|
-
retrieveValidUI5ControlsSubElements(aAllChildrenNodes);
|
|
1158
|
-
var aValidControls = aCandidateControls;
|
|
1159
|
-
if ((elementProperties || !isEmptyObject(elementProperties))
|
|
1160
|
-
&& (!aValidControls || aValidControls.length === 0)) {
|
|
1161
|
-
return false;
|
|
1162
|
-
}
|
|
1163
|
-
else if ((!elementProperties || isEmptyObject(elementProperties))
|
|
1164
|
-
&& (aValidControls && aValidControls.length > 0)) {
|
|
1165
|
-
return bPass;
|
|
1166
|
-
}
|
|
1167
|
-
else if ((!elementProperties || isEmptyObject(elementProperties))
|
|
1168
|
-
&& (!aValidControls || aValidControls.length === 0)) {
|
|
1169
|
-
return bPass;
|
|
1170
|
-
}
|
|
1171
|
-
Array.prototype.filter.call(aValidControls, function (oChildControl) {
|
|
1172
|
-
var bIsEqual = compareToElementProperties(elementProperties, oChildControl);
|
|
1173
|
-
if (bIsEqual) {
|
|
1174
|
-
aChildrenControls.push(oChildControl);
|
|
1175
|
-
}
|
|
1176
|
-
return bIsEqual;
|
|
1177
|
-
});
|
|
1178
|
-
if (aChildrenControls && aChildrenControls.length > 0) {
|
|
1179
|
-
return true;
|
|
1180
|
-
}
|
|
1181
|
-
else {
|
|
1182
|
-
if (!aValidControls)
|
|
615
|
+
};
|
|
616
|
+
// src/scripts/locators/qmateLocatorSrc/filters/NextSiblingFilter.ts
|
|
617
|
+
var NextSiblingFilter = class extends BaseFilter {
|
|
618
|
+
doCheckSingle(control) {
|
|
619
|
+
const nextControl = UI5ControlHandler.findPreviousOrNextControl(control, true);
|
|
620
|
+
if (!nextControl) {
|
|
1183
621
|
return false;
|
|
1184
|
-
for (let index = 0; index < aValidControls.length; index++) {
|
|
1185
|
-
const childControl = aValidControls[index];
|
|
1186
|
-
if (compareToDescendantElementProperties(elementProperties, childControl)) {
|
|
1187
|
-
return true;
|
|
1188
|
-
}
|
|
1189
622
|
}
|
|
1190
|
-
return
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
623
|
+
return this.filterFactory
|
|
624
|
+
.getInstance(ElementFilter, this.elementProperties)
|
|
625
|
+
.checkSingle(nextControl);
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
// src/scripts/locators/qmateLocatorSrc/utils/FilterFactory.ts
|
|
629
|
+
var FilterFactory = class {
|
|
630
|
+
constructor() {
|
|
631
|
+
this.instances = /* @__PURE__ */ new Map();
|
|
632
|
+
}
|
|
633
|
+
getInstance(classType, elementProperties) {
|
|
634
|
+
const key = `${classType.name}-${JSON.stringify(elementProperties)}`;
|
|
635
|
+
if (!this.instances.has(key)) {
|
|
636
|
+
this.instances.set(key, new classType(this, elementProperties));
|
|
637
|
+
}
|
|
638
|
+
return this.instances.get(key);
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
// src/scripts/locators/qmateLocatorSrc/filters/ElementFilter.ts
|
|
642
|
+
var ElementFilter = class _ElementFilter extends BaseFilter {
|
|
643
|
+
doFiltering(controls) {
|
|
644
|
+
this.checkElementProperties();
|
|
645
|
+
let filteredControls = this.filterFactory
|
|
646
|
+
.getInstance(PropertiesFilter, this.elementProperties)
|
|
647
|
+
.filter(controls);
|
|
648
|
+
filteredControls = this.filterFactory
|
|
649
|
+
.getInstance(AncestorFilter, this.elementProperties?.ancestorProperties)
|
|
650
|
+
.filter(filteredControls);
|
|
651
|
+
filteredControls = this.filterFactory
|
|
652
|
+
.getInstance(DescendantFilter, this.elementProperties?.descendantProperties)
|
|
653
|
+
.filter(filteredControls);
|
|
654
|
+
filteredControls = this.filterFactory
|
|
655
|
+
.getInstance(SiblingFilter, this.elementProperties?.siblingProperties)
|
|
656
|
+
.filter(filteredControls);
|
|
657
|
+
return filteredControls;
|
|
658
|
+
}
|
|
659
|
+
doCheckSingle(control) {
|
|
660
|
+
this.checkElementProperties();
|
|
661
|
+
let pass = this.filterFactory
|
|
662
|
+
.getInstance(PropertiesFilter, this.elementProperties)
|
|
663
|
+
.checkSingle(control);
|
|
664
|
+
pass &&= this.filterFactory
|
|
665
|
+
.getInstance(AncestorFilter, this.elementProperties?.ancestorProperties)
|
|
666
|
+
.checkSingle(control);
|
|
667
|
+
pass &&= this.filterFactory
|
|
668
|
+
.getInstance(DescendantFilter, this.elementProperties?.descendantProperties)
|
|
669
|
+
.checkSingle(control);
|
|
670
|
+
pass &&= this.filterFactory
|
|
671
|
+
.getInstance(SiblingFilter, this.elementProperties?.siblingProperties)
|
|
672
|
+
.checkSingle(control);
|
|
673
|
+
return pass;
|
|
674
|
+
}
|
|
675
|
+
checkElementProperties() {
|
|
676
|
+
if (this.elementProperties?.prevSiblingProperties ||
|
|
677
|
+
this.elementProperties?.nextSiblingProperties ||
|
|
678
|
+
this.elementProperties?.childProperties ||
|
|
679
|
+
this.elementProperties?.parentProperties) {
|
|
680
|
+
console.error(`The selector your provided ${JSON.stringify(this.elementProperties)} contains childProperties, parentProperties, prevSiblingProperties or nextSiblingProperties, please provide a valid selector without these properties`);
|
|
681
|
+
throw new Error("Nested properties can only be used for ancestorProperties, descendantProperties or siblingProperties.");
|
|
1225
682
|
}
|
|
1226
|
-
return bIsEqual;
|
|
1227
|
-
});
|
|
1228
|
-
if (aChildrenControls && aChildrenControls.length > 0) {
|
|
1229
|
-
/*console.log("Child Property Control Type -->"
|
|
1230
|
-
+ aChildrenControls[0].getMetadata().getName()
|
|
1231
|
-
+ ", Id-->" + aChildrenControls[0].getId());*/
|
|
1232
|
-
}
|
|
1233
|
-
return aChildrenControls && aChildrenControls.length > 0;
|
|
1234
|
-
}
|
|
1235
|
-
function compareToSiblingElementProperties(elementProperties, oControl, oParentControl) {
|
|
1236
|
-
var bPass = true;
|
|
1237
|
-
if ((!elementProperties || isEmptyObject(elementProperties)) && oParentControl) {
|
|
1238
|
-
return bPass;
|
|
1239
|
-
}
|
|
1240
|
-
else if ((elementProperties && !isEmptyObject(elementProperties)) && !oParentControl) {
|
|
1241
|
-
return false;
|
|
1242
683
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
684
|
+
static filterBySelector(ui5Selector, controls) {
|
|
685
|
+
const filterFactory = new FilterFactory();
|
|
686
|
+
let validUi5Controls = filterFactory
|
|
687
|
+
.getInstance(_ElementFilter, ui5Selector.elementProperties)
|
|
688
|
+
.filter(controls);
|
|
689
|
+
validUi5Controls = filterFactory
|
|
690
|
+
.getInstance(ParentFilter, ui5Selector.parentProperties)
|
|
691
|
+
.filter(validUi5Controls);
|
|
692
|
+
validUi5Controls = filterFactory
|
|
693
|
+
.getInstance(AncestorFilter, ui5Selector.ancestorProperties)
|
|
694
|
+
.filter(validUi5Controls);
|
|
695
|
+
validUi5Controls = filterFactory
|
|
696
|
+
.getInstance(ChildFilter, ui5Selector.childProperties)
|
|
697
|
+
.filter(validUi5Controls);
|
|
698
|
+
validUi5Controls = filterFactory
|
|
699
|
+
.getInstance(DescendantFilter, ui5Selector.descendantProperties)
|
|
700
|
+
.filter(validUi5Controls);
|
|
701
|
+
validUi5Controls = filterFactory
|
|
702
|
+
.getInstance(SiblingFilter, ui5Selector.siblingProperties)
|
|
703
|
+
.filter(validUi5Controls);
|
|
704
|
+
validUi5Controls = filterFactory
|
|
705
|
+
.getInstance(PrevSiblingFilter, ui5Selector.prevSiblingProperties)
|
|
706
|
+
.filter(validUi5Controls);
|
|
707
|
+
validUi5Controls = filterFactory
|
|
708
|
+
.getInstance(NextSiblingFilter, ui5Selector.nextSiblingProperties)
|
|
709
|
+
.filter(validUi5Controls);
|
|
710
|
+
return validUi5Controls;
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
// src/scripts/locators/qmateLocatorSrc/Locator.ts
|
|
714
|
+
var Locator = class _Locator {
|
|
715
|
+
static locate(ui5Selector, rootElement) {
|
|
716
|
+
LocatorDebug.initializeLogs(ui5Selector);
|
|
717
|
+
try {
|
|
718
|
+
_Locator.checkSelector(ui5Selector);
|
|
719
|
+
_Locator.checkUI5Loaded();
|
|
720
|
+
const ui5Controls = ControlFinder.retrieveUI5Controls(ui5Selector, rootElement);
|
|
721
|
+
const validUi5Controls = _Locator.filterControlsBySelector(ui5Controls, ui5Selector);
|
|
722
|
+
const resultElements = UI5ControlDataInjector.convertAndInjectDataForProperties(validUi5Controls);
|
|
723
|
+
LocatorDebug.printLogs(resultElements.length);
|
|
724
|
+
return resultElements;
|
|
1263
725
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
function getValidParentControl(oControl) {
|
|
1268
|
-
if (!oControl || !oControl.getId || !oControl.getId())
|
|
1269
|
-
return null;
|
|
1270
|
-
var oParentControl = null;
|
|
1271
|
-
var domElem = document.getElementById(oControl.getId());
|
|
1272
|
-
if (!domElem)
|
|
1273
|
-
return null;
|
|
1274
|
-
var domParent = domElem.parentElement;
|
|
1275
|
-
for (;;) {
|
|
1276
|
-
if (!domParent)
|
|
1277
|
-
return null;
|
|
1278
|
-
var nodeId = domParent.getAttribute("id");
|
|
1279
|
-
if (nodeId) {
|
|
1280
|
-
// eslint-disable-next-line no-undef
|
|
1281
|
-
oParentControl = sap.ui.getCore().byId(nodeId);
|
|
1282
|
-
if (oParentControl) {
|
|
1283
|
-
/*console.log("Candidate Parent Property Control Type -->"
|
|
1284
|
-
+ oParentControl.getMetadata().getName()
|
|
1285
|
-
+ ", Id-->" + oParentControl.getId());*/
|
|
1286
|
-
return oParentControl;
|
|
1287
|
-
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
console.error("Error in locator:", error.stack);
|
|
728
|
+
throw error;
|
|
1288
729
|
}
|
|
1289
|
-
domParent = domParent.parentElement;
|
|
1290
730
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
731
|
+
static filterControlsBySelector(controls, ui5Selector) {
|
|
732
|
+
LocatorDebug.debugLog("Total ui5Controls:", controls.length);
|
|
733
|
+
const validControls = ElementFilter.filterBySelector(ui5Selector, controls);
|
|
734
|
+
LocatorDebug.debugLog("Valid ui5Controls:", validControls.length);
|
|
735
|
+
return validControls;
|
|
736
|
+
}
|
|
737
|
+
static checkSelector(ui5Selector) {
|
|
738
|
+
if (!ui5Selector) {
|
|
739
|
+
console.error(`The selector your provided ${ui5Selector} is undefined/null, please provide a valid selector`);
|
|
740
|
+
throw new Error(`The selector your provided ${ui5Selector} is undefined/null, please provide a valid selector`);
|
|
1300
741
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
742
|
+
if (!ui5Selector.elementProperties) {
|
|
743
|
+
console.error(`The selector your provided ${JSON.stringify(ui5Selector)} does not contain elementProperties, please provide a valid selector with elementProperties`);
|
|
744
|
+
throw new Error(`The selector your provided ${JSON.stringify(ui5Selector)} does not contain elementProperties, please provide a valid selector with elementProperties`);
|
|
1303
745
|
}
|
|
1304
746
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
return true;
|
|
1310
|
-
}
|
|
1311
|
-
else if ((elementProperties && !isEmptyObject(elementProperties)) && !oControl) {
|
|
1312
|
-
return false;
|
|
1313
|
-
}
|
|
1314
|
-
else if ((!elementProperties || isEmptyObject(elementProperties)) && !oControl) {
|
|
1315
|
-
return true;
|
|
1316
|
-
}
|
|
1317
|
-
var oAncestorControl = oControl;
|
|
1318
|
-
for (;;) {
|
|
1319
|
-
oAncestorControl = getValidParentControl(oAncestorControl);
|
|
1320
|
-
if (!oAncestorControl)
|
|
1321
|
-
return false;
|
|
1322
|
-
if (compareToElementProperties(elementProperties, oAncestorControl)) {
|
|
1323
|
-
return true;
|
|
747
|
+
static checkUI5Loaded() {
|
|
748
|
+
if (!sap.ui?.getCore?.()) {
|
|
749
|
+
console.error("This is not an UI5 App, please use other locators");
|
|
750
|
+
throw new Error("This is not an UI5 App, please use other locators");
|
|
1324
751
|
}
|
|
1325
752
|
}
|
|
753
|
+
};
|
|
754
|
+
// src/scripts/locators/qmateLocatorSrc/index.ts
|
|
755
|
+
function locate(ui5Selector, rootElement) {
|
|
756
|
+
return Locator.locate(ui5Selector, rootElement);
|
|
1326
757
|
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
throw new Error("This is not an UI5 App, please use other locators");
|
|
1330
|
-
}
|
|
1331
|
-
var nodes = retrieveNodesFromBody(index, opt_parentElement);
|
|
1332
|
-
if (!nodes || nodes.length === 0) {
|
|
1333
|
-
throw new Error("no node html elements found");
|
|
1334
|
-
}
|
|
1335
|
-
var aCandidateControl = [];
|
|
1336
|
-
var aValidControls = retrieveValidUI5Controls(nodes);
|
|
1337
|
-
if (aValidControls === null || aValidControls === undefined)
|
|
1338
|
-
return aCandidateControl;
|
|
1339
|
-
if (!ui5Selector) {
|
|
1340
|
-
throw new Error(`The selector your provided ${ui5Selector} is undefined/null, please provide a valid selector`);
|
|
1341
|
-
}
|
|
1342
|
-
if (!ui5Selector.elementProperties) {
|
|
1343
|
-
throw new Error(`The selector your provided ${JSON.stringify(ui5Selector)} does not contain elementProperties, please provide a valid selector with elementProperties`);
|
|
1344
|
-
}
|
|
1345
|
-
//console.log("going in...");
|
|
1346
|
-
Array.prototype.filter.call(aValidControls, function (oControl) {
|
|
1347
|
-
var isNotCandidate = !compareToElementProperties(ui5Selector.elementProperties, oControl);
|
|
1348
|
-
if (isNotCandidate)
|
|
1349
|
-
return false;
|
|
1350
|
-
var oParentControl = getValidParentControl(oControl);
|
|
1351
|
-
if (!oParentControl && ui5Selector.parentProperties) {
|
|
1352
|
-
throw new Error("no parent control found");
|
|
1353
|
-
}
|
|
1354
|
-
var isParentNotCandidate = !compareToElementProperties(ui5Selector.parentProperties, oParentControl);
|
|
1355
|
-
if (isParentNotCandidate)
|
|
1356
|
-
return false;
|
|
1357
|
-
var isAncestorNotCandidate = !compareToAncestorProperties(ui5Selector.ancestorProperties, oControl);
|
|
1358
|
-
if (isAncestorNotCandidate)
|
|
1359
|
-
return false;
|
|
1360
|
-
var isSiblingNotCandidate = !compareToSiblingElementProperties(ui5Selector.siblingProperties, oControl, oParentControl);
|
|
1361
|
-
if (isSiblingNotCandidate)
|
|
1362
|
-
return false;
|
|
1363
|
-
var isPrevSiblingNotCandidate = !compareToPrevElementProperties(ui5Selector.prevSiblingProperties, oControl, oParentControl);
|
|
1364
|
-
if (isPrevSiblingNotCandidate)
|
|
1365
|
-
return false;
|
|
1366
|
-
var isNextSiblingNotCandidate = !compareToNextElementProperties(ui5Selector.nextSiblingProperties, oControl, oParentControl);
|
|
1367
|
-
if (isNextSiblingNotCandidate)
|
|
1368
|
-
return false;
|
|
1369
|
-
var isChildNotCandidate = !compareToChildElementProperties(ui5Selector.childProperties, oControl);
|
|
1370
|
-
if (isChildNotCandidate)
|
|
1371
|
-
return false;
|
|
1372
|
-
var isDescendantNotCandidate = !compareToDescendantElementProperties(ui5Selector.descendantProperties, oControl);
|
|
1373
|
-
if (isDescendantNotCandidate)
|
|
1374
|
-
return false;
|
|
1375
|
-
if (oControl !== null && oControl !== undefined) {
|
|
1376
|
-
aCandidateControl.push(oControl);
|
|
1377
|
-
}
|
|
1378
|
-
return oControl !== null && oControl !== undefined;
|
|
1379
|
-
});
|
|
1380
|
-
aCandidateControl = filterByIndex(aCandidateControl);
|
|
1381
|
-
//console.log("Candidates found --->" + aCandidateControl.length);
|
|
1382
|
-
return convertToDomElements(aCandidateControl);
|
|
1383
|
-
}
|
|
758
|
+
return locate(ui5Selector, index, opt_parentElement);
|
|
759
|
+
},
|
|
1384
760
|
};
|
|
1385
761
|
//# sourceMappingURL=qmateLocator.js.map
|