ff-dom 1.0.18-beta.4 → 1.0.18-beta.6

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.
@@ -1080,7 +1080,7 @@ const getUniqueParentXpath = (domNode, docmt, node, isTarget, nodeXpath, isIndex
1080
1080
  currentNode = currentNode.parentElement;
1081
1081
  }
1082
1082
  // Final constructed XPath
1083
- const finalXPath = xpathParts.join("");
1083
+ const finalXPath = xpathParts.join("") + nodeXpath;
1084
1084
  let count = getCountOfXPath(finalXPath, domNode, docmt);
1085
1085
  if (count === 1) {
1086
1086
  parentXpathCache.set(domNode, finalXPath); // Cache final result
@@ -2275,7 +2275,7 @@ const getElementsFromHTML = (record, docmt) => {
2275
2275
  tag.remove();
2276
2276
  });
2277
2277
  }
2278
- tempDiv.innerHTML = document.body.innerHTML;
2278
+ tempDiv.innerHTML = document.body?.innerHTML;
2279
2279
  const finalLocatorsSet = new Set();
2280
2280
  let finalLocators = [];
2281
2281
  function createLocator(base, overrides = {}) {
@@ -2378,7 +2378,7 @@ const getElementsFromHTML = (record, docmt) => {
2378
2378
  else if ((locator.name.includes("xpath") ||
2379
2379
  trimmedSelector.startsWith("//")) &&
2380
2380
  !locator.type.match("dynamic")) {
2381
- if (tempDiv.innerHTML) {
2381
+ if (tempDiv?.innerHTML) {
2382
2382
  const normalizedXPath = normalizeXPath(trimmedSelector);
2383
2383
  targetElement = getElementFromXPath(tempDiv, normalizedXPath);
2384
2384
  if (targetElement) {
@@ -2475,17 +2475,16 @@ const getElementsFromHTML = (record, docmt) => {
2475
2475
  });
2476
2476
  });
2477
2477
  }
2478
- const fnValue = parseDOM(targetElement, document, false, true);
2479
- record.locators.forEach((loc) => {
2480
- createLocator(loc, {
2481
- name: 'xpath',
2482
- value: fnValue,
2483
- isRecorded: fnValue?.find((x) => x.value === loc.value)
2484
- ? loc.isRecorded
2485
- : "Y",
2486
- isSelfHealed: fnValue?.find((x) => x.value === loc.value)
2487
- ? loc.isSelfHealed
2488
- : "Y",
2478
+ const xpathResults = parseDOM(targetElement, document, false, true);
2479
+ xpathResults.forEach((result) => {
2480
+ const fnValue = result.value;
2481
+ record.locators.forEach((loc) => {
2482
+ createLocator(loc, {
2483
+ name: 'xpath',
2484
+ value: fnValue,
2485
+ isRecorded: loc.value === fnValue ? loc.isRecorded : 'Y',
2486
+ isSelfHealed: loc.value === fnValue ? loc.isSelfHealed : 'Y',
2487
+ });
2489
2488
  });
2490
2489
  });
2491
2490
  for (const locator of record.locators) {