ff-automationv2 2.2.29 → 2.2.31

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.
Files changed (113) hide show
  1. package/dist/ai/llmcalls/llmAction.js +49 -13
  2. package/dist/ai/llmcalls/parseLlmOputput.js +5 -5
  3. package/dist/ai/llmprompts/promptRegistry.js +4 -0
  4. package/dist/ai/llmprompts/systemPrompts/actionExtractorPrompt.js +39 -11
  5. package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.js +6 -6
  6. package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.js +32 -0
  7. package/dist/ai/llmprompts/systemPrompts/mobileKeywordExtractor.js +17 -8
  8. package/dist/ai/llmprompts/systemPrompts/otpExtractorPrompt.d.ts +1 -0
  9. package/dist/ai/llmprompts/systemPrompts/otpExtractorPrompt.js +22 -0
  10. package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPrompt.js +3 -1
  11. package/dist/ai/llmprompts/systemPrompts/visionPrompt.js +14 -6
  12. package/dist/ai/llmprompts/systemPrompts/visionPromptMobile.js +3 -0
  13. package/dist/ai/llmprompts/userPrompts/userPrompt.js +1 -0
  14. package/dist/automation/actions/executor.d.ts +4 -0
  15. package/dist/automation/actions/executor.js +20 -0
  16. package/dist/automation/actions/interaction/clear/clear.js +1 -1
  17. package/dist/automation/actions/interaction/clear/clearAndEnter.js +1 -1
  18. package/dist/automation/actions/interaction/click/click.js +10 -3
  19. package/dist/automation/actions/interaction/click/clickNtimes.js +1 -1
  20. package/dist/automation/actions/interaction/click/doubleClick.js +1 -1
  21. package/dist/automation/actions/interaction/click/rightClick.js +1 -1
  22. package/dist/automation/actions/interaction/elementlessActions/getOtp.d.ts +2 -0
  23. package/dist/automation/actions/interaction/elementlessActions/getOtp.js +101 -0
  24. package/dist/automation/actions/interaction/enterActions/enterInput.js +11 -6
  25. package/dist/automation/actions/interaction/enterActions/enterInputAndPress.js +2 -2
  26. package/dist/automation/actions/interaction/enterActions/enterusingJs.js +2 -2
  27. package/dist/automation/actions/interaction/enterActions/waitAndEnter.js +1 -1
  28. package/dist/automation/actions/interaction/upload/uploadfile.js +1 -1
  29. package/dist/automation/actions/interaction/verify/VerifyNavigateURL.js +38 -11
  30. package/dist/automation/actions/interface/FireFlinkResponseSchema.d.ts +12 -0
  31. package/dist/automation/actions/interface/FireFlinkResponseSchema.js +19 -3
  32. package/dist/automation/actions/interface/getOtpInterface.d.ts +15 -0
  33. package/dist/automation/actions/interface/getOtpInterface.js +2 -0
  34. package/dist/automation/browserSession/initiateBrowserSession.d.ts +1 -1
  35. package/dist/automation/browserSession/initiateBrowserSession.js +15 -7
  36. package/dist/automation/driverState.d.ts +2 -0
  37. package/dist/automation/driverState.js +4 -0
  38. package/dist/automation/mobileSession/initiateMobileSession.d.ts +4 -5
  39. package/dist/automation/mobileSession/initiateMobileSession.js +83 -19
  40. package/dist/core/constants/allAction.js +5 -1
  41. package/dist/core/constants/supportedActions.js +5 -2
  42. package/dist/core/interfaces/actionInterface.d.ts +4 -0
  43. package/dist/core/interfaces/browserConfigurationInterface.d.ts +0 -4
  44. package/dist/core/interfaces/browserConfigurationInterface.js +0 -1
  45. package/dist/core/interfaces/executionDetails.d.ts +6 -3
  46. package/dist/core/interfaces/fireflinkScriptPayloadInterface.d.ts +22 -16
  47. package/dist/core/interfaces/llmResponseInterface.d.ts +1 -0
  48. package/dist/core/interfaces/promptInterface.d.ts +1 -0
  49. package/dist/core/main/SessionManager.d.ts +9 -0
  50. package/dist/core/main/SessionManager.js +23 -0
  51. package/dist/core/main/actionHandlerFactory.js +261 -64
  52. package/dist/core/main/executionContext.d.ts +7 -1
  53. package/dist/core/main/executionContext.js +94 -3
  54. package/dist/core/main/runAutomationScript.d.ts +1 -0
  55. package/dist/core/main/runAutomationScript.js +912 -304
  56. package/dist/core/main/stepProcessor.js +7 -2
  57. package/dist/core/types/browserType.d.ts +3 -3
  58. package/dist/core/types/browserType.js +2 -2
  59. package/dist/core/types/messageType.d.ts +13 -0
  60. package/dist/core/types/messageType.js +15 -0
  61. package/dist/core/types/promptType.d.ts +2 -1
  62. package/dist/core/types/promptType.js +1 -0
  63. package/dist/domAnalysis/searchBest.js +15 -16
  64. package/dist/domAnalysis/simplifyAndFlatten.js +6 -4
  65. package/dist/fireflinkData/fireflinkLocators/getListOfLocators.d.ts +3 -0
  66. package/dist/fireflinkData/fireflinkLocators/getListOfLocators.js +23 -15
  67. package/dist/fireflinkData/fireflinkLocators/parser/getElementsFromHTML.d.ts +3 -3
  68. package/dist/fireflinkData/fireflinkLocators/parser/getElementsFromHTML.js +134 -118
  69. package/dist/fireflinkData/fireflinkLocators/types/locator.d.ts +11 -1
  70. package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.d.ts +1 -1
  71. package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.js +35 -9
  72. package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.d.ts +10 -10
  73. package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.js +56 -59
  74. package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.d.ts +1 -1
  75. package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.js +53 -29
  76. package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.d.ts +8 -8
  77. package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.js +113 -190
  78. package/dist/fireflinkData/fireflinkLocators/utils/xpath.d.ts +17 -26
  79. package/dist/fireflinkData/fireflinkLocators/utils/xpath.js +314 -786
  80. package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.d.ts +68 -70
  81. package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.js +498 -517
  82. package/dist/fireflinkData/fireflinkScript/appendScriptData.d.ts +1 -1
  83. package/dist/fireflinkData/fireflinkScript/appendScriptData.js +5 -8
  84. package/dist/fireflinkData/fireflinkScript/scriptGenrationData.d.ts +2 -2
  85. package/dist/fireflinkData/fireflinkScript/scriptGenrationData.js +17 -27
  86. package/dist/llmConfig/llmConfiguration.js +13 -6
  87. package/dist/service/api/fireflinkApi.service.d.ts +1 -1
  88. package/dist/service/api/fireflinkApi.service.js +1 -2
  89. package/dist/service/fireflink.service.d.ts +3 -3
  90. package/dist/service/fireflink.service.js +23 -21
  91. package/dist/service/kafka/fireflinkKafka.service.d.ts +1 -2
  92. package/dist/service/kafka/fireflinkKafka.service.js +6 -4
  93. package/dist/tests/test12.d.ts +0 -1
  94. package/dist/tests/test12.js +65 -78
  95. package/dist/tests/testkaf.d.ts +0 -1
  96. package/dist/tests/testkaf.js +51 -55
  97. package/dist/utils/InstancesDetails/getInstancesInfo.js +1 -1
  98. package/dist/utils/browserCap/capability.d.ts +5 -1
  99. package/dist/utils/browserCap/capability.js +91 -15
  100. package/dist/utils/helpers/domSanitizer.d.ts +1 -0
  101. package/dist/utils/helpers/domSanitizer.js +9 -0
  102. package/dist/utils/helpers/enterActionHelper.js +23 -4
  103. package/dist/utils/helpers/xpathcreation.js +2 -2
  104. package/dist/utils/javascript/jsFindElement.d.ts +1 -1
  105. package/dist/utils/javascript/jsFindElement.js +2 -2
  106. package/dist/utils/newTab/newTabTracker.js +18 -6
  107. package/dist/utils/workers/LocatorWorkerInterface.d.ts +22 -0
  108. package/dist/utils/workers/LocatorWorkerInterface.js +2 -0
  109. package/dist/utils/workers/LocatorWorkerPool.d.ts +13 -0
  110. package/dist/utils/workers/LocatorWorkerPool.js +89 -0
  111. package/dist/utils/workers/locatorWorker.d.ts +1 -0
  112. package/dist/utils/workers/locatorWorker.js +44 -0
  113. package/package.json +3 -1
@@ -1,35 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSmartRelations = exports.findRelativeXpath = void 0;
3
+ exports.getAiSmartRelations = exports.findAiRelativeXpath = void 0;
4
4
  const logData_js_1 = require("../../../utils/logger/logData.js");
5
5
  const xpathHelpers_js_1 = require("./xpathHelpers.js");
6
6
  const xpathDataWithIndex = [];
7
7
  let xpathData = [];
8
8
  const reWhiteSpace = /^[\S]+( [\S]+)*$/gi;
9
- const findRelativeXpath = (element1, element2, docmt, xpaths1, xpaths2, isIndex, multiElementReferenceMode = false, allowedRelations = null) => {
9
+ const findAiRelativeXpath = (element1, element2, docmt, xpaths1, xpaths2, isIndex, multiElementReferenceMode = false, allowedRelations = null) => {
10
10
  let finalXpaths = [];
11
- const relations = allowedRelations || [];
12
- const tryRelation = (relation, useIndex) => {
11
+ const aiRelations = allowedRelations || [];
12
+ const tryAiRelation = (relation, useIndex) => {
13
13
  let rel_xpath;
14
14
  if (relation === "descendant" || relation === "descendant-or-self") {
15
15
  rel_xpath =
16
- getDescendantXpath([element1, element2], docmt, xpaths1, xpaths2, relation, useIndex, multiElementReferenceMode) || [];
16
+ getAiDescendantXpath([element1, element2], docmt, xpaths1, xpaths2, relation, useIndex, multiElementReferenceMode) || [];
17
17
  }
18
18
  else {
19
19
  rel_xpath =
20
- getXpathRelationExpression(element1, element2, relation, xpaths1, xpaths2, useIndex, multiElementReferenceMode) || [];
20
+ getAiXpathRelationExpression(element1, element2, relation, xpaths1, xpaths2, useIndex, multiElementReferenceMode) || [];
21
21
  }
22
22
  if (rel_xpath.length) {
23
23
  finalXpaths = finalXpaths.concat(rel_xpath);
24
24
  }
25
25
  };
26
- for (const relation of relations) {
27
- tryRelation(relation, isIndex);
26
+ for (const relation of aiRelations) {
27
+ tryAiRelation(relation, isIndex);
28
28
  }
29
29
  return finalXpaths;
30
30
  };
31
- exports.findRelativeXpath = findRelativeXpath;
32
- const descendantExpression = (refExpectElement, xpath2, relation, docmt, isIndex, expCommonParentXpathElements, step4, refCommonParentXpathElementLength = 0, multiElementReferenceMode = false) => {
31
+ exports.findAiRelativeXpath = findAiRelativeXpath;
32
+ const descendantAiExpression = (refExpectElement, xpath2, relation, docmt, isIndex, expCommonParentXpathElements, step4, refCommonParentXpathElementLength = 0, multiElementReferenceMode = false) => {
33
33
  let finalExpectedElementXpath;
34
34
  if (xpath2.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g)?.length >=
35
35
  expCommonParentXpathElements.length) {
@@ -40,7 +40,7 @@ const descendantExpression = (refExpectElement, xpath2, relation, docmt, isIndex
40
40
  ? expCommonParentXpathElements[expCommonParentXpathElements.length - x]
41
41
  : xpath2Elements[xpath2Elements.length - x]);
42
42
  }
43
- const traverseXpath = getTraverseXpathExpression(`${step4 +
43
+ const traverseXpath = getAiTraverseXpathExpression(`${step4 +
44
44
  (refCommonParentXpathElementLength
45
45
  ? "]".repeat(refCommonParentXpathElementLength)
46
46
  : "")}`, xpaths2Els, refExpectElement[refExpectElement.length - 1], refExpectElement, docmt, relation, isIndex, multiElementReferenceMode);
@@ -52,26 +52,26 @@ const descendantExpression = (refExpectElement, xpath2, relation, docmt, isIndex
52
52
  finalExpectedElementXpath = `//${step4 +
53
53
  (refCommonParentXpathElementLength
54
54
  ? "]".repeat(refCommonParentXpathElementLength)
55
- : "")}/${relation}::${(0, xpathHelpers_js_1.replaceActualAttributes)(xpath2)}`;
56
- let rel_count = (0, xpathHelpers_js_1.getCountOfXPath)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt);
55
+ : "")}/${relation}::${(0, xpathHelpers_js_1.replaceAiActualAttributes)(xpath2)}`;
56
+ let rel_count = (0, xpathHelpers_js_1.getAiCountOfXPath)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt);
57
57
  if (rel_count === 1) {
58
58
  return [
59
59
  {
60
60
  key: `dynamic ${relation}`,
61
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(finalExpectedElementXpath)
61
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(finalExpectedElementXpath)
62
62
  }
63
63
  ];
64
64
  }
65
65
  if (rel_count > 1) {
66
66
  if (isIndex) {
67
- finalExpectedElementXpath = (0, xpathHelpers_js_1.findXpathWithIndex)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt, rel_count);
67
+ finalExpectedElementXpath = (0, xpathHelpers_js_1.findAiXpathWithIndex)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt, rel_count);
68
68
  if (finalExpectedElementXpath) {
69
- rel_count = (0, xpathHelpers_js_1.getCountOfXPath)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt);
69
+ rel_count = (0, xpathHelpers_js_1.getAiCountOfXPath)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt);
70
70
  if (rel_count === 1) {
71
71
  return [
72
72
  {
73
73
  key: `dynamic ${relation} ${isIndex ? " index" : ""}`,
74
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(finalExpectedElementXpath)
74
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(finalExpectedElementXpath)
75
75
  }
76
76
  ];
77
77
  }
@@ -80,18 +80,18 @@ const descendantExpression = (refExpectElement, xpath2, relation, docmt, isIndex
80
80
  }
81
81
  }
82
82
  };
83
- const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation, isIndex = false, multiElementReferenceMode = false) => {
83
+ const getAiDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation, isIndex = false, multiElementReferenceMode = false) => {
84
84
  const refElement = refExpectElement[refExpectElement.length - 2];
85
85
  const expElement = refExpectElement[refExpectElement.length - 1];
86
- const expElementDocmnt = (0, xpathHelpers_js_1.getShadowRoot)(expElement) ?? expElement.ownerDocument;
86
+ const expElementDocmnt = (0, xpathHelpers_js_1.getAiShadowRoot)(expElement) ?? expElement.ownerDocument;
87
87
  const refAbsoluteXpath = xpaths1.find((x) => x?.key?.includes("absolute"))?.value ||
88
- (0, xpathHelpers_js_1.getAbsoluteXPath)(refElement, refElement.ownerDocument);
88
+ (0, xpathHelpers_js_1.getAiAbsoluteXPath)(refElement, refElement.ownerDocument);
89
89
  const refFullXpathElements = [];
90
90
  const refFullXpathElementsWithoutNumber = [];
91
91
  refAbsoluteXpath.split("/").map((x) => refFullXpathElements.push(x));
92
92
  refFullXpathElements.map((x) => refFullXpathElementsWithoutNumber.push(x.replace(/\[([0-9]+)\]/gm, "")));
93
93
  const expAbsoluteXpath = xpaths2.find((x) => x?.key?.includes("absolute"))?.value ||
94
- (0, xpathHelpers_js_1.getAbsoluteXPath)(expElement, expElement.ownerDocument);
94
+ (0, xpathHelpers_js_1.getAiAbsoluteXPath)(expElement, expElement.ownerDocument);
95
95
  const expFullXpathElements = [];
96
96
  const expFullXpathElementsWithoutNumber = [];
97
97
  expAbsoluteXpath.split("/").map((x) => expFullXpathElements.push(x));
@@ -122,14 +122,14 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
122
122
  let nodeXpath2;
123
123
  if (refExpectElement[refExpectElement.length - 2].textContent) {
124
124
  if (!reWhiteSpace.test(refExpectElement[refExpectElement.length - 2].textContent)) {
125
- nodeXpath2 = (0, xpathHelpers_js_1.isSvg)(refExpectElement[refExpectElement.length - 2])
126
- ? `*[local-name()='${refExpectElement[refExpectElement.length - 2].tagName}' and ${(0, xpathHelpers_js_1.getTextXpathFunction)(refExpectElement[refExpectElement.length - 2])})]`
127
- : `${refExpectElement[refExpectElement.length - 2].tagName}[${(0, xpathHelpers_js_1.getTextXpathFunction)(refExpectElement[refExpectElement.length - 2])}]`;
125
+ nodeXpath2 = (0, xpathHelpers_js_1.isAiSvg)(refExpectElement[refExpectElement.length - 2])
126
+ ? `*[local-name()='${refExpectElement[refExpectElement.length - 2].tagName}' and ${(0, xpathHelpers_js_1.getAiTextXpathFunction)(refExpectElement[refExpectElement.length - 2])})]`
127
+ : `${refExpectElement[refExpectElement.length - 2].tagName}[${(0, xpathHelpers_js_1.getAiTextXpathFunction)(refExpectElement[refExpectElement.length - 2])}]`;
128
128
  }
129
129
  else {
130
- nodeXpath2 = (0, xpathHelpers_js_1.isSvg)(refExpectElement[refExpectElement.length - 2])
131
- ? `*[local-name()='${refExpectElement[refExpectElement.length - 2].tagName}' and .=${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.getTextContent)(refExpectElement[refExpectElement.length - 2]))}]`
132
- : `${refExpectElement[refExpectElement.length - 2].tagName}[.=${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.getTextContent)(refExpectElement[refExpectElement.length - 2]))}]`;
130
+ nodeXpath2 = (0, xpathHelpers_js_1.isAiSvg)(refExpectElement[refExpectElement.length - 2])
131
+ ? `*[local-name()='${refExpectElement[refExpectElement.length - 2].tagName}' and .=${(0, xpathHelpers_js_1.escapeAiCharacters)((0, xpathHelpers_js_1.getAiTextContent)(refExpectElement[refExpectElement.length - 2]))}]`
132
+ : `${refExpectElement[refExpectElement.length - 2].tagName}[.=${(0, xpathHelpers_js_1.escapeAiCharacters)((0, xpathHelpers_js_1.getAiTextContent)(refExpectElement[refExpectElement.length - 2]))}]`;
133
133
  }
134
134
  refCommonParentXpathElements[refCommonParentXpathElements.length - 1] =
135
135
  nodeXpath2;
@@ -145,20 +145,20 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
145
145
  xpath2 = xpathData[i].value; // No need to modify the value
146
146
  }
147
147
  if (xpath2) {
148
- return descendantExpression(refExpectElement, xpath2, relation, expElementDocmnt || docmt, isIndex, expCommonParentXpathElements, step4, refCommonParentXpathElementLength, multiElementReferenceMode);
148
+ return descendantAiExpression(refExpectElement, xpath2, relation, expElementDocmnt || docmt, isIndex, expCommonParentXpathElements, step4, refCommonParentXpathElementLength, multiElementReferenceMode);
149
149
  }
150
150
  }
151
151
  }
152
152
  if (refExpectElement[refExpectElement.length - 2].attributes) {
153
153
  for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2].attributes)) {
154
- if ((0, xpathHelpers_js_1.checkBlockedAttributes)(attrName, refExpectElement[refExpectElement.length - 2], false)) {
154
+ if ((0, xpathHelpers_js_1.checkAiBlockedAttributes)(attrName, refExpectElement[refExpectElement.length - 2], false)) {
155
155
  let attrValue = attrName.nodeValue;
156
156
  if (attrValue) {
157
- attrValue = (0, xpathHelpers_js_1.sanitizeAttributeValue)(attrName.name, attrValue);
157
+ attrValue = (0, xpathHelpers_js_1.sanitizeAiAttributeValue)(attrName.name, attrValue);
158
158
  const elementName = attrName.name;
159
- nodeXpath2 = (0, xpathHelpers_js_1.isSvg)(refExpectElement[refExpectElement.length - 2])
160
- ? `*[local-name()='${refExpectElement[refExpectElement.length - 2].tagName}' and @${elementName}=${(0, xpathHelpers_js_1.escapeCharacters)(attrValue)}]`
161
- : `${refExpectElement[refExpectElement.length - 2].tagName}[@${elementName}=${(0, xpathHelpers_js_1.escapeCharacters)(attrValue)}]`;
159
+ nodeXpath2 = (0, xpathHelpers_js_1.isAiSvg)(refExpectElement[refExpectElement.length - 2])
160
+ ? `*[local-name()='${refExpectElement[refExpectElement.length - 2].tagName}' and @${elementName}=${(0, xpathHelpers_js_1.escapeAiCharacters)(attrValue)}]`
161
+ : `${refExpectElement[refExpectElement.length - 2].tagName}[@${elementName}=${(0, xpathHelpers_js_1.escapeAiCharacters)(attrValue)}]`;
162
162
  refCommonParentXpathElements[refCommonParentXpathElements.length - 1] = nodeXpath2;
163
163
  const refCommonParentXpath = refCommonParentXpathElements.join("[");
164
164
  const refCommonParentXpathElementLength = refCommonParentXpathElements.length - 1;
@@ -171,17 +171,17 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
171
171
  else {
172
172
  xpath2 = xpathData[i].value; // No need to modify the value
173
173
  }
174
- return descendantExpression(refExpectElement, xpath2, relation, expElementDocmnt || docmt, isIndex, expCommonParentXpathElements, step4, refCommonParentXpathElementLength, multiElementReferenceMode);
174
+ return descendantAiExpression(refExpectElement, xpath2, relation, expElementDocmnt || docmt, isIndex, expCommonParentXpathElements, step4, refCommonParentXpathElementLength, multiElementReferenceMode);
175
175
  }
176
176
  }
177
177
  }
178
178
  }
179
179
  for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2].attributes)) {
180
- if ((0, xpathHelpers_js_1.checkBlockedAttributes)(attrName, refExpectElement[refExpectElement.length - 2], false)) {
180
+ if ((0, xpathHelpers_js_1.checkAiBlockedAttributes)(attrName, refExpectElement[refExpectElement.length - 2], false)) {
181
181
  const attrValue = attrName.nodeValue;
182
182
  if (attrValue) {
183
- // attrValue = sanitizeAttributeValue(attrName.name, attrValue);
184
- const combinationXpath = (0, xpathHelpers_js_1.getCombinationXpath)(attrName, refExpectElement[refExpectElement.length - 2]);
183
+ // attrValue = sanitizeAiAttributeValue(attrName.name, attrValue);
184
+ const combinationXpath = (0, xpathHelpers_js_1.getAiCombinationXpath)(attrName, refExpectElement[refExpectElement.length - 2]);
185
185
  if (combinationXpath) {
186
186
  if (combinationXpath.startsWith("//")) {
187
187
  nodeXpath2 = combinationXpath.substring(combinationXpath.indexOf("//") + 2);
@@ -201,7 +201,7 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
201
201
  else {
202
202
  xpath2 = xpathData[i].value; // No need to modify the value
203
203
  }
204
- return descendantExpression(refExpectElement, xpath2, relation, expElementDocmnt || docmt, isIndex, expCommonParentXpathElements, step4, refCommonParentXpathElementLength, multiElementReferenceMode);
204
+ return descendantAiExpression(refExpectElement, xpath2, relation, expElementDocmnt || docmt, isIndex, expCommonParentXpathElements, step4, refCommonParentXpathElementLength, multiElementReferenceMode);
205
205
  }
206
206
  }
207
207
  }
@@ -211,7 +211,7 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
211
211
  const refCommonParentXpath = refCommonParentXpathElements.join("[");
212
212
  const refCommonParentXpathElementLength = refCommonParentXpathElements.length - 1;
213
213
  const step4 = refCommonParentXpath;
214
- const traverseXpath = getTraverseXpathExpression(`${step4 +
214
+ const traverseXpath = getAiTraverseXpathExpression(`${step4 +
215
215
  (refCommonParentXpathElementLength
216
216
  ? "]".repeat(refCommonParentXpathElementLength)
217
217
  : "")}`, expCommonParentXpathElements, refExpectElement[refExpectElement.length - 1], refExpectElement, docmt, relation, isIndex, multiElementReferenceMode);
@@ -219,16 +219,16 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
219
219
  return traverseXpath;
220
220
  }
221
221
  };
222
- const getXpathRelationExpression = (element1, element2, relation, xpath1, xpath2, isIndex, multiElementReferenceMode) => {
222
+ const getAiXpathRelationExpression = (element1, element2, relation, xpath1, xpath2, isIndex, multiElementReferenceMode) => {
223
223
  let xpaths1;
224
224
  let xpaths2;
225
- logData_js_1.logger.info("getXpathRelationExpression", relation);
225
+ logData_js_1.logger.info("getAiXpathRelationExpression", relation);
226
226
  const finalXpaths = [];
227
227
  try {
228
228
  xpaths1 = xpath1.filter((x) => !x?.key?.includes("absolute"));
229
229
  xpaths2 = xpath2.filter((x) => !x?.key?.includes("absolute"));
230
230
  if (relation === "ancestor" || relation === "ancestor-or-self") {
231
- const ancestorBridgeXpaths = getAncestorBridgeXpath(element1, element2, relation, xpaths1, xpaths2, isIndex);
231
+ const ancestorBridgeXpaths = getAiAncestorBridgeXpath(element1, element2, relation, xpaths1, xpaths2, isIndex);
232
232
  if (ancestorBridgeXpaths.length) {
233
233
  return ancestorBridgeXpaths;
234
234
  }
@@ -236,19 +236,19 @@ const getXpathRelationExpression = (element1, element2, relation, xpath1, xpath2
236
236
  for (let i = 0; i < xpaths1.length; i++) {
237
237
  for (let j = 0; j < xpaths2.length; j++) {
238
238
  let rel_xpath = `//${xpaths1[i].value.indexOf("//") !== 0
239
- ? (0, xpathHelpers_js_1.replaceActualAttributes)(xpaths1[i].value)
240
- : (0, xpathHelpers_js_1.replaceActualAttributes)(xpaths1[i].value.substring(xpaths1[i].value.indexOf("//") + 2))}/${relation}::${xpaths2[j].value.indexOf("//") !== 0
241
- ? (0, xpathHelpers_js_1.replaceActualAttributes)(xpaths2[j].value)
242
- : (0, xpathHelpers_js_1.replaceActualAttributes)(xpaths2[j].value.substring(xpaths2[j].value.indexOf("//") + 2))}`;
243
- logData_js_1.logger.info("getXpathRelationExpression", rel_xpath);
244
- const rel_count = (0, xpathHelpers_js_1.getCountOfXPath)(rel_xpath, element2, element2.ownerDocument);
239
+ ? (0, xpathHelpers_js_1.replaceAiActualAttributes)(xpaths1[i].value)
240
+ : (0, xpathHelpers_js_1.replaceAiActualAttributes)(xpaths1[i].value.substring(xpaths1[i].value.indexOf("//") + 2))}/${relation}::${xpaths2[j].value.indexOf("//") !== 0
241
+ ? (0, xpathHelpers_js_1.replaceAiActualAttributes)(xpaths2[j].value)
242
+ : (0, xpathHelpers_js_1.replaceAiActualAttributes)(xpaths2[j].value.substring(xpaths2[j].value.indexOf("//") + 2))}`;
243
+ logData_js_1.logger.info("getAiXpathRelationExpression", rel_xpath);
244
+ const rel_count = (0, xpathHelpers_js_1.getAiCountOfXPath)(rel_xpath, element2, element2.ownerDocument);
245
245
  if (rel_count > 1) {
246
246
  if (isIndex) {
247
- rel_xpath = (0, xpathHelpers_js_1.findXpathWithIndex)(rel_xpath, element2, element2.ownerDocument, rel_count);
247
+ rel_xpath = (0, xpathHelpers_js_1.findAiXpathWithIndex)(rel_xpath, element2, element2.ownerDocument, rel_count);
248
248
  if (rel_xpath) {
249
249
  finalXpaths.push({
250
250
  key: `dynamic ${relation}${isIndex ? " index" : ""}`,
251
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(rel_xpath)
251
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(rel_xpath)
252
252
  });
253
253
  return finalXpaths;
254
254
  }
@@ -276,7 +276,7 @@ const getXpathRelationExpression = (element1, element2, relation, xpath1, xpath2
276
276
  else if (rel_count === 1) {
277
277
  finalXpaths.push({
278
278
  key: `dynamic ${relation}`,
279
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(rel_xpath)
279
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(rel_xpath)
280
280
  });
281
281
  return finalXpaths;
282
282
  }
@@ -290,10 +290,10 @@ const getXpathRelationExpression = (element1, element2, relation, xpath1, xpath2
290
290
  : xpaths2[j].value.substring(xpaths2[j].value.indexOf("//") + 2)}`;
291
291
  const xpath2Elements = tempPath.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);
292
292
  if (xpath2Elements.length > 1) {
293
- const traverseXpath = getTraverseXpathExpression(`${xpaths1[i].value.indexOf("//") !== 0
294
- ? (0, xpathHelpers_js_1.replaceActualAttributes)(xpaths1[i].value)
295
- : (0, xpathHelpers_js_1.replaceActualAttributes)(xpaths1[i].value.substring(xpaths1[i].value.indexOf("//") + 2))}`, xpath2Elements, element2, [element1, element2], element2.ownerDocument, relation, isIndex, multiElementReferenceMode);
296
- logData_js_1.logger.info("getXpathRelationExpression traverseXpath", traverseXpath);
293
+ const traverseXpath = getAiTraverseXpathExpression(`${xpaths1[i].value.indexOf("//") !== 0
294
+ ? (0, xpathHelpers_js_1.replaceAiActualAttributes)(xpaths1[i].value)
295
+ : (0, xpathHelpers_js_1.replaceAiActualAttributes)(xpaths1[i].value.substring(xpaths1[i].value.indexOf("//") + 2))}`, xpath2Elements, element2, [element1, element2], element2.ownerDocument, relation, isIndex, multiElementReferenceMode);
296
+ logData_js_1.logger.info("getAiXpathRelationExpression traverseXpath", traverseXpath);
297
297
  if (traverseXpath) {
298
298
  finalXpaths.push(...traverseXpath);
299
299
  return finalXpaths;
@@ -304,13 +304,13 @@ const getXpathRelationExpression = (element1, element2, relation, xpath1, xpath2
304
304
  }
305
305
  }
306
306
  catch (error) {
307
- logData_js_1.logger.error("getXpathRelationExpression Error", error);
307
+ logData_js_1.logger.error("getAiXpathRelationExpression Error", error);
308
308
  }
309
309
  return finalXpaths;
310
310
  };
311
311
  const xpathStepSeparator = /\/(?=(?:[^']*'[^']*')*[^']*$)/g;
312
- const stripXpathPrefix = (xpath) => xpath.indexOf("//") === 0 ? xpath.substring(xpath.indexOf("//") + 2) : xpath;
313
- const getCommonAncestor = (element1, element2) => {
312
+ const stripAiXpathPrefix = (xpath) => xpath.indexOf("//") === 0 ? xpath.substring(xpath.indexOf("//") + 2) : xpath;
313
+ const getAiCommonAncestor = (element1, element2) => {
314
314
  let currentNode = element1;
315
315
  while (currentNode) {
316
316
  if (currentNode.contains(element2)) {
@@ -320,42 +320,42 @@ const getCommonAncestor = (element1, element2) => {
320
320
  }
321
321
  return null;
322
322
  };
323
- const getSingleStepXpath = (element, xpaths) => {
323
+ const getAiSingleStepXpath = (element, xpaths) => {
324
324
  for (const xpath of xpaths) {
325
- const xpathValue = stripXpathPrefix(xpath.value);
325
+ const xpathValue = stripAiXpathPrefix(xpath.value);
326
326
  if (xpathValue && xpathValue.split(xpathStepSeparator).length === 1) {
327
- return (0, xpathHelpers_js_1.replaceActualAttributes)(xpathValue);
327
+ return (0, xpathHelpers_js_1.replaceAiActualAttributes)(xpathValue);
328
328
  }
329
329
  }
330
330
  if (element.textContent) {
331
- const textXpath = (0, xpathHelpers_js_1.getTextXpathFunction)(element);
331
+ const textXpath = (0, xpathHelpers_js_1.getAiTextXpathFunction)(element);
332
332
  if (textXpath) {
333
- return (0, xpathHelpers_js_1.isSvg)(element)
333
+ return (0, xpathHelpers_js_1.isAiSvg)(element)
334
334
  ? `*[local-name()='${element.tagName}' and ${textXpath}]`
335
335
  : `${element.tagName}[${textXpath}]`;
336
336
  }
337
337
  }
338
338
  if (element.attributes) {
339
339
  for (const attrName of Array.from(element.attributes)) {
340
- if ((0, xpathHelpers_js_1.checkBlockedAttributes)(attrName, element, false) &&
340
+ if ((0, xpathHelpers_js_1.checkAiBlockedAttributes)(attrName, element, false) &&
341
341
  attrName.nodeValue) {
342
- return (0, xpathHelpers_js_1.isSvg)(element)
343
- ? `*[local-name()='${element.tagName}' and @${attrName.name}=${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.sanitizeAttributeValue)(attrName.name, attrName.nodeValue))}]`
344
- : `${element.tagName}[@${attrName.name}=${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.sanitizeAttributeValue)(attrName.name, attrName.nodeValue))}]`;
342
+ return (0, xpathHelpers_js_1.isAiSvg)(element)
343
+ ? `*[local-name()='${element.tagName}' and @${attrName.name}=${(0, xpathHelpers_js_1.escapeAiCharacters)((0, xpathHelpers_js_1.sanitizeAiAttributeValue)(attrName.name, attrName.nodeValue))}]`
344
+ : `${element.tagName}[@${attrName.name}=${(0, xpathHelpers_js_1.escapeAiCharacters)((0, xpathHelpers_js_1.sanitizeAiAttributeValue)(attrName.name, attrName.nodeValue))}]`;
345
345
  }
346
346
  }
347
347
  }
348
- return (0, xpathHelpers_js_1.isSvg)(element)
348
+ return (0, xpathHelpers_js_1.isAiSvg)(element)
349
349
  ? `*[local-name()='${element.tagName}']`
350
350
  : element.tagName;
351
351
  };
352
- const getRelativeXpathFromAncestor = (ancestorElement, targetElement, targetXPaths) => {
352
+ const getAiRelativeXpathFromAncestor = (ancestorElement, targetElement, targetXPaths) => {
353
353
  const steps = [];
354
354
  let currentNode = targetElement;
355
355
  while (currentNode && currentNode !== ancestorElement) {
356
356
  const currentStep = currentNode === targetElement
357
- ? getSingleStepXpath(targetElement, targetXPaths)
358
- : (0, xpathHelpers_js_1.isSvg)(currentNode)
357
+ ? getAiSingleStepXpath(targetElement, targetXPaths)
358
+ : (0, xpathHelpers_js_1.isAiSvg)(currentNode)
359
359
  ? `*[local-name()='${currentNode.tagName}']`
360
360
  : currentNode.tagName;
361
361
  steps.unshift(currentStep);
@@ -363,42 +363,42 @@ const getRelativeXpathFromAncestor = (ancestorElement, targetElement, targetXPat
363
363
  }
364
364
  return currentNode === ancestorElement ? steps.join("/") : "";
365
365
  };
366
- const getAncestorBridgeXpath = (element1, element2, relation, xpaths1, xpaths2, isIndex) => {
366
+ const getAiAncestorBridgeXpath = (element1, element2, relation, xpaths1, xpaths2, isIndex) => {
367
367
  const finalXpaths = [];
368
- const commonAncestor = getCommonAncestor(element1, element2);
368
+ const commonAncestor = getAiCommonAncestor(element1, element2);
369
369
  if (!commonAncestor || commonAncestor === element2) {
370
370
  return finalXpaths;
371
371
  }
372
- const ancestorNodeTest = (0, xpathHelpers_js_1.isSvg)(commonAncestor)
372
+ const ancestorNodeTest = (0, xpathHelpers_js_1.isAiSvg)(commonAncestor)
373
373
  ? `*[local-name()='${commonAncestor.tagName}']`
374
374
  : commonAncestor.tagName;
375
- const targetRelativeXpath = getRelativeXpathFromAncestor(commonAncestor, element2, xpaths2);
375
+ const targetRelativeXpath = getAiRelativeXpathFromAncestor(commonAncestor, element2, xpaths2);
376
376
  if (!targetRelativeXpath) {
377
377
  return finalXpaths;
378
378
  }
379
379
  for (const xpath of xpaths1) {
380
- const referenceXpath = stripXpathPrefix(xpath.value);
380
+ const referenceXpath = stripAiXpathPrefix(xpath.value);
381
381
  if (!referenceXpath) {
382
382
  continue;
383
383
  }
384
- let finalExpectedElementXpath = `//${(0, xpathHelpers_js_1.replaceActualAttributes)(referenceXpath)}/${relation}::${ancestorNodeTest}/${targetRelativeXpath}`;
385
- let rel_count = (0, xpathHelpers_js_1.getCountOfXPath)(finalExpectedElementXpath, element2, element2.ownerDocument);
384
+ let finalExpectedElementXpath = `//${(0, xpathHelpers_js_1.replaceAiActualAttributes)(referenceXpath)}/${relation}::${ancestorNodeTest}/${targetRelativeXpath}`;
385
+ let rel_count = (0, xpathHelpers_js_1.getAiCountOfXPath)(finalExpectedElementXpath, element2, element2.ownerDocument);
386
386
  if (rel_count === 1) {
387
387
  finalXpaths.push({
388
388
  key: `dynamic ${relation} bridge`,
389
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(finalExpectedElementXpath)
389
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(finalExpectedElementXpath)
390
390
  });
391
391
  return finalXpaths;
392
392
  }
393
393
  if (rel_count > 1 && isIndex) {
394
- finalExpectedElementXpath = (0, xpathHelpers_js_1.findXpathWithIndex)(finalExpectedElementXpath, element2, element2.ownerDocument, rel_count);
394
+ finalExpectedElementXpath = (0, xpathHelpers_js_1.findAiXpathWithIndex)(finalExpectedElementXpath, element2, element2.ownerDocument, rel_count);
395
395
  rel_count = finalExpectedElementXpath
396
- ? (0, xpathHelpers_js_1.getCountOfXPath)(finalExpectedElementXpath, element2, element2.ownerDocument)
396
+ ? (0, xpathHelpers_js_1.getAiCountOfXPath)(finalExpectedElementXpath, element2, element2.ownerDocument)
397
397
  : 0;
398
398
  if (finalExpectedElementXpath && rel_count === 1) {
399
399
  finalXpaths.push({
400
400
  key: `dynamic ${relation} bridge index`,
401
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(finalExpectedElementXpath)
401
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(finalExpectedElementXpath)
402
402
  });
403
403
  return finalXpaths;
404
404
  }
@@ -406,114 +406,31 @@ const getAncestorBridgeXpath = (element1, element2, relation, xpaths1, xpaths2,
406
406
  }
407
407
  return finalXpaths;
408
408
  };
409
- // const getReferenceElementXpath = (element: HTMLElement | Element) => {
410
- // let xpaths1: {
411
- // key: string;
412
- // value: string;
413
- // }[];
414
- // xpaths1 = parseDOM(element, element.ownerDocument, false, false,platform);
415
- // if (!xpaths1?.length) {
416
- // xpaths1 = parseDOM(element, element.ownerDocument, true, false,platform);
417
- // xpaths1 = xpaths1?.map((x) =>
418
- // x.value.charAt(0) == "(" &&
419
- // findMatchingParenthesis(x.value, 0) + 1 === x.value.lastIndexOf("[")
420
- // ? { key: "", value: removeParenthesis(x.value) }
421
- // : { key: "", value: x.value }
422
- // );
423
- // } else {
424
- // let xpaths = parseDOM(element, element.ownerDocument, true, false,platform);
425
- // if (xpaths?.length) {
426
- // xpaths = xpaths?.map((x) =>
427
- // x.value.charAt(0) == "(" &&
428
- // findMatchingParenthesis(x.value, 0) + 1 === x.value.lastIndexOf("[")
429
- // ? { key: "", value: removeParenthesis(x.value) }
430
- // : { key: "", value: x.value }
431
- // );
432
- // xpaths1 = xpaths1.concat(xpaths);
433
- // }
434
- // }
435
- // if (!xpaths1?.length) {
436
- // xpaths1 = [
437
- // {
438
- // key: "",
439
- // value: getRelativeXPath(
440
- // element,
441
- // element.ownerDocument,
442
- // false,
443
- // false,
444
- // Array.from(element.attributes)
445
- // )
446
- // }
447
- // ];
448
- // }
449
- // if (!xpaths1?.length) {
450
- // xpaths1 = [
451
- // {
452
- // key: "",
453
- // value: getRelativeXPath(
454
- // element,
455
- // element.ownerDocument,
456
- // true,
457
- // false,
458
- // Array.from(element.attributes)
459
- // )
460
- // }
461
- // ];
462
- // xpaths1 = xpaths1?.map((x) =>
463
- // x.value.charAt(0) == "(" &&
464
- // findMatchingParenthesis(x.value, 0) + 1 === x.value.lastIndexOf("[")
465
- // ? { key: "", value: removeParenthesis(x.value) }
466
- // : { key: "", value: x.value }
467
- // );
468
- // }
469
- // if (!xpaths1?.length) {
470
- // xpaths1 = getReferenceElementsXpath(element, element.ownerDocument, false);
471
- // } else {
472
- // const xpaths = getReferenceElementsXpath(
473
- // element,
474
- // element.ownerDocument,
475
- // false
476
- // );
477
- // if (xpaths?.length) {
478
- // xpaths1 = xpaths1.concat(xpaths);
479
- // }
480
- // }
481
- // const referenceXpathElement = getAbsoluteXPath(
482
- // element,
483
- // element.ownerDocument
484
- // );
485
- // xpaths1 = xpaths1.filter((x) => x.value !== referenceXpathElement);
486
- // xpaths1.push({
487
- // key: "absolute xpath",
488
- // value: referenceXpathElement.slice(1)
489
- // });
490
- // return xpaths1;
491
- // };
492
- const getTraverseXpathExpression = (xpathe1, absoluteXpathElements, element2, refExpectElement, docmt, relation, isIndex, multiElementReferenceMode) => {
409
+ const getAiTraverseXpathExpression = (xpathe1, absoluteXpathElements, element2, refExpectElement, docmt, relation, isIndex, multiElementReferenceMode) => {
493
410
  let finalExpectedElementXpath;
494
411
  if (!multiElementReferenceMode) {
495
412
  for (let x = 1; x <= absoluteXpathElements.length; x++) {
496
413
  const xpath2 = absoluteXpathElements
497
414
  .slice(absoluteXpathElements.length - x, absoluteXpathElements.length)
498
415
  .join("/");
499
- finalExpectedElementXpath = `//${xpathe1}/${relation}::${(0, xpathHelpers_js_1.replaceActualAttributes)(xpath2)}`;
500
- const rel_count = (0, xpathHelpers_js_1.getCountOfXPath)(finalExpectedElementXpath, element2, docmt);
416
+ finalExpectedElementXpath = `//${xpathe1}/${relation}::${(0, xpathHelpers_js_1.replaceAiActualAttributes)(xpath2)}`;
417
+ const rel_count = (0, xpathHelpers_js_1.getAiCountOfXPath)(finalExpectedElementXpath, element2, docmt);
501
418
  if (rel_count === 1) {
502
419
  return [
503
420
  {
504
421
  key: `dynamic ${relation}`,
505
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(finalExpectedElementXpath)
422
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(finalExpectedElementXpath)
506
423
  }
507
424
  ];
508
425
  }
509
426
  if (rel_count > 1) {
510
427
  if (isIndex) {
511
- finalExpectedElementXpath = (0, xpathHelpers_js_1.findXpathWithIndex)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt, rel_count);
428
+ finalExpectedElementXpath = (0, xpathHelpers_js_1.findAiXpathWithIndex)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt, rel_count);
512
429
  if (finalExpectedElementXpath) {
513
430
  return [
514
431
  {
515
432
  key: `dynamic ${relation}${isIndex ? " index" : ""}`,
516
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(finalExpectedElementXpath)
433
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(finalExpectedElementXpath)
517
434
  }
518
435
  ];
519
436
  }
@@ -523,24 +440,24 @@ const getTraverseXpathExpression = (xpathe1, absoluteXpathElements, element2, re
523
440
  }
524
441
  else {
525
442
  const xpath2 = absoluteXpathElements.join("/");
526
- finalExpectedElementXpath = `//${xpathe1}/${relation}::${(0, xpathHelpers_js_1.replaceActualAttributes)(xpath2)}`;
527
- const rel_count = (0, xpathHelpers_js_1.getCountOfXPath)(finalExpectedElementXpath, element2, docmt);
443
+ finalExpectedElementXpath = `//${xpathe1}/${relation}::${(0, xpathHelpers_js_1.replaceAiActualAttributes)(xpath2)}`;
444
+ const rel_count = (0, xpathHelpers_js_1.getAiCountOfXPath)(finalExpectedElementXpath, element2, docmt);
528
445
  if (rel_count === 1) {
529
446
  return [
530
447
  {
531
448
  key: `dynamic ${relation}`,
532
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(finalExpectedElementXpath)
449
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(finalExpectedElementXpath)
533
450
  }
534
451
  ];
535
452
  }
536
453
  if (rel_count > 1) {
537
454
  if (isIndex) {
538
- finalExpectedElementXpath = (0, xpathHelpers_js_1.findXpathWithIndex)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt, rel_count);
455
+ finalExpectedElementXpath = (0, xpathHelpers_js_1.findAiXpathWithIndex)(finalExpectedElementXpath, refExpectElement[refExpectElement.length - 1], docmt, rel_count);
539
456
  if (finalExpectedElementXpath) {
540
457
  return [
541
458
  {
542
459
  key: `dynamic ${relation}${isIndex ? " index" : ""}`,
543
- value: (0, xpathHelpers_js_1.replaceTempAttributes)(finalExpectedElementXpath)
460
+ value: (0, xpathHelpers_js_1.replaceAiTempAttributes)(finalExpectedElementXpath)
544
461
  }
545
462
  ];
546
463
  }
@@ -548,17 +465,23 @@ const getTraverseXpathExpression = (xpathe1, absoluteXpathElements, element2, re
548
465
  }
549
466
  }
550
467
  };
551
- const getSmartRelations = (element1, element2) => {
468
+ const getAiSmartRelations = (element1, element2) => {
552
469
  const pos = element1.compareDocumentPosition(element2);
553
470
  const highPriority = [];
554
471
  const mediumPriority = [];
555
472
  const lowPriority = [];
473
+ const NodeConst = element1.ownerDocument?.defaultView?.Node || (typeof Node !== "undefined" ? Node : {
474
+ DOCUMENT_POSITION_PRECEDING: 2,
475
+ DOCUMENT_POSITION_FOLLOWING: 4,
476
+ DOCUMENT_POSITION_CONTAINS: 8,
477
+ DOCUMENT_POSITION_CONTAINED_BY: 16
478
+ });
556
479
  // Ancestor
557
- if (pos & element1.ownerDocument.defaultView.Node.DOCUMENT_POSITION_CONTAINS) {
480
+ if (pos & (NodeConst.DOCUMENT_POSITION_CONTAINS ?? 8)) {
558
481
  highPriority.push("ancestor", "ancestor-or-self", "parent");
559
482
  }
560
483
  // Descendant direct
561
- if (pos & element1.ownerDocument.defaultView.Node.DOCUMENT_POSITION_CONTAINED_BY) {
484
+ if (pos & (NodeConst.DOCUMENT_POSITION_CONTAINED_BY ?? 16)) {
562
485
  highPriority.push("child");
563
486
  }
564
487
  // Siblings
@@ -566,25 +489,25 @@ const getSmartRelations = (element1, element2) => {
566
489
  highPriority.push("following-sibling", "preceding-sibling");
567
490
  }
568
491
  // Directional
569
- if (pos & element1.ownerDocument.defaultView.Node.DOCUMENT_POSITION_FOLLOWING) {
492
+ if (pos & (NodeConst.DOCUMENT_POSITION_FOLLOWING ?? 4)) {
570
493
  mediumPriority.push("following");
571
494
  }
572
- if (pos & element1.ownerDocument.defaultView.Node.DOCUMENT_POSITION_PRECEDING) {
495
+ if (pos & (NodeConst.DOCUMENT_POSITION_PRECEDING ?? 2)) {
573
496
  mediumPriority.push("preceding");
574
497
  }
575
498
  // always include fallback
576
499
  lowPriority.push("descendant", "descendant-or-self");
577
- const relations = [...highPriority, ...mediumPriority, ...lowPriority];
578
- return [...new Set(relations)];
500
+ const aiRelations = [...highPriority, ...mediumPriority, ...lowPriority];
501
+ return [...new Set(aiRelations)];
579
502
  };
580
- exports.getSmartRelations = getSmartRelations;
503
+ exports.getAiSmartRelations = getAiSmartRelations;
581
504
  const referenceXpath = {
582
- findRelativeXpath: exports.findRelativeXpath,
583
- getDescendantXpath,
584
- getAncestorBridgeXpath,
585
- getXpathRelationExpression,
586
- getTraverseXpathExpression,
505
+ findAiRelativeXpath: exports.findAiRelativeXpath,
506
+ getAiDescendantXpath,
507
+ getAiAncestorBridgeXpath,
508
+ getAiXpathRelationExpression,
509
+ getAiTraverseXpathExpression,
587
510
  // getReferenceElementXpath,
588
- getSmartRelations: exports.getSmartRelations
511
+ getAiSmartRelations: exports.getAiSmartRelations
589
512
  };
590
513
  exports.default = referenceXpath;