ff-dom 1.0.18-beta.3 → 1.0.18-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ff-dom",
3
- "version": "1.0.18-beta.3",
3
+ "version": "1.0.18-beta.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -408,19 +408,18 @@ const getElementsFromHTML = (
408
408
  });
409
409
  }
410
410
 
411
- const fnValue = parseDOM(targetElement, document, false, true);
412
- record.locators.forEach((loc) => {
413
- createLocator(loc, {
414
- name: 'xpath',
415
- value: fnValue,
416
- isRecorded: fnValue?.find((x) => x.value === loc.value)
417
- ? loc.isRecorded
418
- : "Y",
419
- isSelfHealed: fnValue?.find((x) => x.value === loc.value)
420
- ? loc.isSelfHealed
421
- : "Y",
411
+ const xpathResults = parseDOM(targetElement, document, false, true);
412
+ xpathResults.forEach((result) => {
413
+ const fnValue = result.value;
414
+ record.locators.forEach((loc) => {
415
+ createLocator(loc, {
416
+ name: 'xpath',
417
+ value: fnValue,
418
+ isRecorded: loc.value === fnValue ? loc.isRecorded : 'Y',
419
+ isSelfHealed: loc.value === fnValue ? loc.isSelfHealed : 'Y',
420
+ });
422
421
  });
423
- });
422
+ })
424
423
 
425
424
  for (const locator of record.locators) {
426
425
  try {
@@ -440,7 +439,7 @@ const getElementsFromHTML = (
440
439
  value: relativeXpath,
441
440
  isRecorded:
442
441
  locator.isRecorded !== "" &&
443
- locator.isRecorded !== null
442
+ locator.isRecorded !== null
444
443
  ? locator.isRecorded
445
444
  : "Y",
446
445
  });
@@ -167,24 +167,21 @@ const getUniqueParentXpath = (
167
167
 
168
168
  if (!reWhiteSpace.test(currentNode.textContent)) {
169
169
  xpathe = isSvg(currentNode)
170
- ? `//*[local-name()='${
171
- currentNode.tagName
172
- }' and normalize-space(.)=${escapeCharacters(
173
- getFilteredText(currentNode)
174
- )}]`
175
- : `//${
176
- currentNode.tagName || "*"
177
- }[normalize-space(.)=${escapeCharacters(
178
- getFilteredText(currentNode)
179
- )}]`;
170
+ ? `//*[local-name()='${currentNode.tagName
171
+ }' and normalize-space(.)=${escapeCharacters(
172
+ getFilteredText(currentNode)
173
+ )}]`
174
+ : `//${currentNode.tagName || "*"
175
+ }[normalize-space(.)=${escapeCharacters(
176
+ getFilteredText(currentNode)
177
+ )}]`;
180
178
  } else {
181
179
  xpathe = isSvg(currentNode)
182
- ? `//*[local-name()='${
183
- currentNode.tagName
184
- }' and .=${escapeCharacters(getFilteredText(currentNode))}]`
180
+ ? `//*[local-name()='${currentNode.tagName
181
+ }' and .=${escapeCharacters(getFilteredText(currentNode))}]`
185
182
  : `//${currentNode.tagName || "*"}[.=${escapeCharacters(
186
- getFilteredText(currentNode)
187
- )}]`;
183
+ getFilteredText(currentNode)
184
+ )}]`;
188
185
  }
189
186
 
190
187
  const othersWithAttr = checkRelativeXpathRelation(
@@ -226,12 +223,11 @@ const getUniqueParentXpath = (
226
223
 
227
224
  if (combinePattern?.length) {
228
225
  const xpathe = isSvg(currentNode)
229
- ? `//*[local-name()='${
230
- currentNode.tagName
231
- }' and ${combinePattern.join(" and ")}]`
226
+ ? `//*[local-name()='${currentNode.tagName
227
+ }' and ${combinePattern.join(" and ")}]`
232
228
  : `//${currentNode.tagName || "*"}[${combinePattern.join(
233
- " and "
234
- )}]`;
229
+ " and "
230
+ )}]`;
235
231
  const othersWithAttr = checkRelativeXpathRelation(
236
232
  xpathe,
237
233
  nodeXpath,
@@ -263,7 +259,7 @@ const getUniqueParentXpath = (
263
259
  }
264
260
 
265
261
  // Final constructed XPath
266
- const finalXPath = xpathParts.join("");
262
+ const finalXPath = xpathParts.join("") + nodeXpath;
267
263
  let count = getCountOfXPath(finalXPath, domNode, docmt);
268
264
  if (count === 1) {
269
265
  parentXpathCache.set(domNode, finalXPath); // Cache final result
@@ -392,7 +388,7 @@ const getChildRelativeXpath = (
392
388
  try {
393
389
  do {
394
390
  let uniqueAttrFound = false;
395
- for (currentNode = st.pop()!; currentNode !== null; ) {
391
+ for (currentNode = st.pop()!; currentNode !== null;) {
396
392
  for (const attr of Array.from(currentNode.attributes)) {
397
393
  if (checkBlockedAttributes(attr, currentNode, true)) {
398
394
  let attrValue = attr.nodeValue;
@@ -745,12 +741,11 @@ const addRelativeXpaths = (
745
741
  if (
746
742
  relativeXpathIndex &&
747
743
  getCountOfXPath(relativeXpathIndex, targetElemt, docmt) ===
748
- 1
744
+ 1
749
745
  ) {
750
746
  xpathData.push({
751
- key: `relative xpath by relative parent ${
752
- isIndex ? "index" : ""
753
- }`,
747
+ key: `relative xpath by relative parent ${isIndex ? "index" : ""
748
+ }`,
754
749
  value: relativeXpathIndex,
755
750
  });
756
751
  }
@@ -759,18 +754,16 @@ const addRelativeXpaths = (
759
754
  if (count < xpathDataWithIndex[0].count) {
760
755
  xpathDataWithIndex.pop();
761
756
  xpathDataWithIndex.push({
762
- key: `relative xpath by relative parent ${
763
- isIndex ? "index" : ""
764
- }`,
757
+ key: `relative xpath by relative parent ${isIndex ? "index" : ""
758
+ }`,
765
759
  value: fullRelativeXpath,
766
760
  count,
767
761
  });
768
762
  }
769
763
  } else {
770
764
  xpathDataWithIndex.push({
771
- key: `relative xpath by relative parent ${
772
- isIndex ? "index" : ""
773
- }`,
765
+ key: `relative xpath by relative parent ${isIndex ? "index" : ""
766
+ }`,
774
767
  value: fullRelativeXpath,
775
768
  count,
776
769
  });
@@ -794,9 +787,8 @@ const addRelativeXpaths = (
794
787
  relativeChildXpath.includes("text()") ||
795
788
  relativeChildXpath.includes(".="))
796
789
  ) {
797
- const fullRelativeXpath = `/${
798
- nodeXpath[i] + relativeChildXpath.substring(1)
799
- }`;
790
+ const fullRelativeXpath = `/${nodeXpath[i] + relativeChildXpath.substring(1)
791
+ }`;
800
792
  const count = getCountOfXPath(
801
793
  fullRelativeXpath,
802
794
  targetElemt,
@@ -818,12 +810,11 @@ const addRelativeXpaths = (
818
810
  if (
819
811
  relativeXpathIndex &&
820
812
  getCountOfXPath(relativeXpathIndex, targetElemt, docmt) ===
821
- 1
813
+ 1
822
814
  ) {
823
815
  xpathData.push({
824
- key: `relative xpath by relative parent ${
825
- isIndex ? "index" : ""
826
- }`,
816
+ key: `relative xpath by relative parent ${isIndex ? "index" : ""
817
+ }`,
827
818
  value: relativeXpathIndex,
828
819
  });
829
820
  }
@@ -832,18 +823,16 @@ const addRelativeXpaths = (
832
823
  if (count < xpathDataWithIndex[0].count) {
833
824
  xpathDataWithIndex.pop();
834
825
  xpathDataWithIndex.push({
835
- key: `relative xpath by relative child ${
836
- isIndex ? "index" : ""
837
- }`,
826
+ key: `relative xpath by relative child ${isIndex ? "index" : ""
827
+ }`,
838
828
  value: fullRelativeXpath,
839
829
  count,
840
830
  });
841
831
  }
842
832
  } else {
843
833
  xpathDataWithIndex.push({
844
- key: `relative xpath by relative child ${
845
- isIndex ? "index" : ""
846
- }`,
834
+ key: `relative xpath by relative child ${isIndex ? "index" : ""
835
+ }`,
847
836
  value: fullRelativeXpath,
848
837
  count,
849
838
  });