ff-dom 1.0.7 → 1.0.9

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.
@@ -179,10 +179,11 @@ const getElementsFromHTML = (name, desc, type, locators, isShared, projectId, pr
179
179
  locators: for (const locator of locators) {
180
180
  try {
181
181
  let relativeXpath = null;
182
- if (locator.value.includes("dynamic") ||
183
- locator.type.match("dynamic") ||
184
- locator.value.includes("{") ||
185
- locator.value.includes("}")) {
182
+ const isDynamic = String(locator.value || locator.type || "");
183
+ if (isDynamic.includes("dynamic") ||
184
+ isDynamic.match("dynamic") ||
185
+ isDynamic.includes("{") ||
186
+ isDynamic.includes("}")) {
186
187
  finalLocators.push({
187
188
  name: locator.name,
188
189
  type: locator.type,
@@ -193,7 +194,8 @@ const getElementsFromHTML = (name, desc, type, locators, isShared, projectId, pr
193
194
  });
194
195
  continue;
195
196
  }
196
- if (locator.isRecorded.includes("N") || locator.isRecorded.match("N")) {
197
+ const isRecorded = String(locator.isRecorded || "");
198
+ if (isRecorded.includes("N") || isRecorded.match("N")) {
197
199
  finalLocators.push({
198
200
  name: locator.name,
199
201
  type: locator.type,
@@ -202,7 +204,6 @@ const getElementsFromHTML = (name, desc, type, locators, isShared, projectId, pr
202
204
  status: locator.status,
203
205
  isRecorded: locator.isRecorded,
204
206
  });
205
- continue;
206
207
  }
207
208
  if (isShared.includes("Y")) {
208
209
  break locators;
@@ -429,12 +430,19 @@ const getElementsFromHTML = (name, desc, type, locators, isShared, projectId, pr
429
430
  console.error("Error processing locator:", locator, error);
430
431
  }
431
432
  }
433
+ let uniqueLocators = new Map();
434
+ finalLocators.forEach((loc) => {
435
+ if (!uniqueLocators.has(loc.value)) {
436
+ uniqueLocators.set(loc.value, loc);
437
+ }
438
+ });
439
+ let ffLoc = Array.from(uniqueLocators.values());
432
440
  const jsonResult = [
433
441
  {
434
442
  name: `${name}`,
435
443
  desc: `${desc}`,
436
444
  type: `${type}`,
437
- locators: finalLocators.filter((locator) => locator.hasOwnProperty("value") &&
445
+ locators: ffLoc.filter((locator) => locator.hasOwnProperty("value") &&
438
446
  (locator === null || locator === void 0 ? void 0 : locator.value) !== null &&
439
447
  locator.value !== ""),
440
448
  isShared: `${isShared}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ff-dom",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -279,11 +279,12 @@ const getElementsFromHTML = (
279
279
  locators: for (const locator of locators) {
280
280
  try {
281
281
  let relativeXpath: string | null = null;
282
+ const isDynamic = String(locator.value || locator.type || "");
282
283
  if (
283
- locator.value.includes("dynamic") ||
284
- locator.type.match("dynamic") ||
285
- locator.value.includes("{") ||
286
- locator.value.includes("}")
284
+ isDynamic.includes("dynamic") ||
285
+ isDynamic.match("dynamic") ||
286
+ isDynamic.includes("{") ||
287
+ isDynamic.includes("}")
287
288
  ) {
288
289
  finalLocators.push({
289
290
  name: locator.name,
@@ -295,7 +296,10 @@ const getElementsFromHTML = (
295
296
  });
296
297
  continue;
297
298
  }
298
- if (locator.isRecorded.includes("N") || locator.isRecorded.match("N")) {
299
+ const isRecorded = String(locator.isRecorded || "");
300
+
301
+ if (isRecorded.includes("N") || isRecorded.match("N")) {
302
+
299
303
  finalLocators.push({
300
304
  name: locator.name,
301
305
  type: locator.type,
@@ -304,7 +308,6 @@ const getElementsFromHTML = (
304
308
  status: locator.status,
305
309
  isRecorded: locator.isRecorded,
306
310
  });
307
- continue;
308
311
  }
309
312
  if (isShared.includes("Y")) {
310
313
  break locators;
@@ -561,12 +564,22 @@ const getElementsFromHTML = (
561
564
  console.error("Error processing locator:", locator, error);
562
565
  }
563
566
  }
567
+
568
+ let uniqueLocators = new Map();
569
+ finalLocators.forEach((loc) => {
570
+ if (!uniqueLocators.has(loc.value)) {
571
+ uniqueLocators.set(loc.value, loc);
572
+ }
573
+ });
574
+
575
+ let ffLoc = Array.from(uniqueLocators.values());
576
+
564
577
  const jsonResult = [
565
578
  {
566
579
  name: `${name}`,
567
580
  desc: `${desc}`,
568
581
  type: `${type}`,
569
- locators: finalLocators.filter(
582
+ locators: ffLoc.filter(
570
583
  (locator) =>
571
584
  locator.hasOwnProperty("value") &&
572
585
  locator?.value !== null &&