ff-dom 1.0.18-beta.1 → 1.0.18-beta.2

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/dist/index.cdn.js CHANGED
@@ -462,9 +462,9 @@
462
462
  while (currentNode) {
463
463
  let xpathe = "";
464
464
  let hasUniqueAttr = false;
465
- let attributes = domNode === currentNode ? attributesArray : currentNode.attributes;
465
+ let attributes = domNode === currentNode ? attributesArray ?? currentNode.attributes : currentNode.attributes;
466
466
  // Loop through attributes to check for unique identifiers
467
- for (const attrName of attributes) {
467
+ for (const attrName of Array.from(attributes)) {
468
468
  if (checkBlockedAttributes(attrName, currentNode, isTarget)) {
469
469
  let attrValue = attrName.nodeValue;
470
470
  // Clean up attribute value
@@ -781,7 +781,7 @@
781
781
  }
782
782
  }
783
783
  if (domNode.attributes) {
784
- for (const attrName of domNode.attributes) {
784
+ for (const attrName of Array.from(domNode.attributes)) {
785
785
  if (checkBlockedAttributes(attrName, domNode, isTarget)) {
786
786
  let attrValue = attrName.nodeValue;
787
787
  if (attrValue) {
@@ -993,7 +993,7 @@
993
993
  let currentNode = domNode;
994
994
  while (currentNode && currentNode.nodeType === 1) {
995
995
  const hasUniqueAttr = false;
996
- for (const attrName of currentNode.attributes) {
996
+ for (const attrName of Array.from(currentNode.attributes)) {
997
997
  if (checkBlockedAttributes(attrName, currentNode, isTarget)) {
998
998
  let attrValue = attrName.nodeValue;
999
999
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1099,7 +1099,7 @@
1099
1099
  }
1100
1100
  // BASE CASE #2: Check for unique attributes
1101
1101
  let uniqueAttrFound = false;
1102
- for (const attr of currentNode.attributes) {
1102
+ for (const attr of Array.from(currentNode.attributes)) {
1103
1103
  if (checkBlockedAttributes(attr, currentNode, isTarget)) {
1104
1104
  let attrValue = attr.nodeValue;
1105
1105
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1175,7 +1175,7 @@
1175
1175
  do {
1176
1176
  let uniqueAttrFound = false;
1177
1177
  for (currentNode = st.pop(); currentNode !== null;) {
1178
- for (const attr of currentNode.attributes) {
1178
+ for (const attr of Array.from(currentNode.attributes)) {
1179
1179
  if (checkBlockedAttributes(attr, currentNode, true)) {
1180
1180
  let attrValue = attr.nodeValue;
1181
1181
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1257,7 +1257,7 @@
1257
1257
  const processSibling = (sibling, domNode, docmt, nodeXpath, axis, isTarget) => {
1258
1258
  try {
1259
1259
  if (sibling.hasAttributes()) {
1260
- for (const attr of sibling.attributes) {
1260
+ for (const attr of Array.from(sibling.attributes)) {
1261
1261
  let xpathe = intermediateXpathStep(sibling, {
1262
1262
  name: attr.name,
1263
1263
  value: attr.value,
@@ -1614,7 +1614,7 @@
1614
1614
  const docmt = targetElemt?.ownerDocument || doc;
1615
1615
  const tag = targetElemt.tagName;
1616
1616
  const { attributes } = targetElemt;
1617
- addAllXPathAttributes([...attributes], targetElemt, docmt, isIndex, isTarget);
1617
+ addAllXPathAttributes(Array.from(attributes), targetElemt, docmt, isIndex, isTarget);
1618
1618
  {
1619
1619
  if (xpathData$1.length) {
1620
1620
  const len = xpathData$1.length;
@@ -1633,7 +1633,7 @@
1633
1633
  }
1634
1634
  console.log(xpathData$1);
1635
1635
  if (!xpathData$1.length) {
1636
- addRelativeXpaths(targetElemt, docmt, isIndex, isTarget, [...targetElemt.attributes]);
1636
+ addRelativeXpaths(targetElemt, docmt, isIndex, isTarget, Array.from(targetElemt.attributes));
1637
1637
  }
1638
1638
  return xpathData$1;
1639
1639
  };
@@ -1900,8 +1900,8 @@
1900
1900
  }
1901
1901
  }
1902
1902
  if (refExpectElement[refExpectElement.length - 2].attributes) {
1903
- for (const attrName of refExpectElement[refExpectElement.length - 2]
1904
- .attributes) {
1903
+ for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2]
1904
+ .attributes)) {
1905
1905
  if (checkBlockedAttributes(attrName, refExpectElement[refExpectElement.length - 2], false)) {
1906
1906
  let attrValue = attrName.nodeValue;
1907
1907
  if (attrValue) {
@@ -1927,8 +1927,8 @@
1927
1927
  }
1928
1928
  }
1929
1929
  }
1930
- for (const attrName of refExpectElement[refExpectElement.length - 2]
1931
- .attributes) {
1930
+ for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2]
1931
+ .attributes)) {
1932
1932
  if (checkBlockedAttributes(attrName, refExpectElement[refExpectElement.length - 2], false)) {
1933
1933
  let attrValue = attrName.nodeValue;
1934
1934
  if (attrValue) {
@@ -2078,7 +2078,7 @@
2078
2078
  xpaths1 = [
2079
2079
  {
2080
2080
  key: "",
2081
- value: getRelativeXPath(element, element.ownerDocument, false, false, [...element.attributes]),
2081
+ value: getRelativeXPath(element, element.ownerDocument, false, false, Array.from(element.attributes)),
2082
2082
  },
2083
2083
  ];
2084
2084
  }
@@ -2086,7 +2086,7 @@
2086
2086
  xpaths1 = [
2087
2087
  {
2088
2088
  key: "",
2089
- value: getRelativeXPath(element, element.ownerDocument, true, false, [...element.attributes]),
2089
+ value: getRelativeXPath(element, element.ownerDocument, true, false, Array.from(element.attributes)),
2090
2090
  },
2091
2091
  ];
2092
2092
  xpaths1 = xpaths1?.map((x) => x.value.charAt(0) == "(" &&
package/dist/xpath.mjs CHANGED
@@ -46,8 +46,6 @@ async function createXPathAPI() {
46
46
  return {
47
47
  autoHeal: async (data, htmlString) => {
48
48
  await page?.evaluate((datum, html) => {
49
- // let docmt = (window as any).XpathLib.parseXml(html);
50
- // return (window as any).XpathLib.getElementsFromHTML(datum, docmt);
51
49
  // @ts-ignore
52
50
  let xpathAPI = window.XpathLib.createXPathAPI();
53
51
  let docmt = xpathAPI.xpathUtils.parseXml(html);
@@ -1 +1 @@
1
- {"version":3,"file":"xpath.mjs","sources":["../src/node/xpath.ts"],"sourcesContent":["import { fileURLToPath } from \"url\";\r\nimport path, { join } from \"path\";\r\nimport { readFileSync } from \"fs\";\r\nimport { ElementRecord } from \"../types/locator\";\r\n\r\nconst _filename = fileURLToPath(import.meta.url);\r\nconst _dirname = path.dirname(_filename);\r\n\r\nlet puppeteer: any;\r\n\r\nconst injectScriptPath = join(_dirname, \"index.cdn.js\");\r\nconst injectScript = readFileSync(injectScriptPath, \"utf-8\");\r\n\r\nasync function createXPathAPI() {\r\n puppeteer = await import('puppeteer');\r\n\r\n let browser = await puppeteer.launch({ headless: true });\r\n let page = await browser.newPage();\r\n\r\n const fromHTML = async (html: string) => {\r\n await page?.setContent(html);\r\n await page?.addScriptTag({ content: injectScript });\r\n\r\n page?.on(\r\n \"console\",\r\n async (msg: { type: () => any; text: () => any; args: () => any }) => {\r\n const type = msg.type();\r\n const txt = msg.text();\r\n\r\n const args = msg.args();\r\n if (!args || args.length === 0) {\r\n console.log(`[Browser:${type}]`, txt);\r\n return;\r\n }\r\n\r\n for (let i = 0; i < args.length; i++) {\r\n try {\r\n const arg = args[i];\r\n const obj = arg.remoteObject();\r\n\r\n console.log(obj);\r\n\r\n if (obj.value !== undefined) {\r\n console.log(`[Browser:${type}]`, obj.value);\r\n } else {\r\n const value = await arg.jsonValue().catch(() => txt);\r\n console.log(`[Browser:${type}]`, value);\r\n }\r\n } catch (err) {\r\n console.log(`[Browser:${type}]`, txt);\r\n }\r\n }\r\n }\r\n );\r\n\r\n page?.on(\"pageerror\", (msg: any) => {\r\n console.log(\"error\", msg);\r\n });\r\n\r\n return {\r\n autoHeal: async (data: ElementRecord, htmlString: string) => {\r\n await page?.evaluate((datum: ElementRecord, html: string) => {\r\n // let docmt = (window as any).XpathLib.parseXml(html);\r\n // return (window as any).XpathLib.getElementsFromHTML(datum, docmt);\r\n // @ts-ignore\r\n let xpathAPI = window.XpathLib.createXPathAPI();\r\n let docmt = xpathAPI.xpathUtils.parseXml(html);\r\n return xpathAPI.getElementsFromHTML(datum, docmt);\r\n }, data, htmlString);\r\n },\r\n };\r\n };\r\n\r\n return { fromHTML, browser };\r\n}\r\n\r\nexport default createXPathAPI;\r\n"],"names":[],"mappings":";;;;AAKA,MAAM,SAA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A,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC9B;;;;"}
1
+ {"version":3,"file":"xpath.mjs","sources":["../src/node/xpath.ts"],"sourcesContent":["import { fileURLToPath } from \"url\";\r\nimport path, { join } from \"path\";\r\nimport { readFileSync } from \"fs\";\r\nimport { ElementRecord } from \"../types/locator\";\r\n\r\nconst _filename = fileURLToPath(import.meta.url);\r\nconst _dirname = path.dirname(_filename);\r\n\r\nlet puppeteer: any;\r\n\r\nconst injectScriptPath = join(_dirname, \"index.cdn.js\");\r\nconst injectScript = readFileSync(injectScriptPath, \"utf-8\");\r\n\r\nasync function createXPathAPI() {\r\n puppeteer = await import('puppeteer');\r\n\r\n let browser = await puppeteer.launch({ headless: true });\r\n let page = await browser.newPage();\r\n\r\n const fromHTML = async (html: string) => {\r\n await page?.setContent(html);\r\n await page?.addScriptTag({ content: injectScript });\r\n\r\n page?.on(\r\n \"console\",\r\n async (msg: { type: () => any; text: () => any; args: () => any }) => {\r\n const type = msg.type();\r\n const txt = msg.text();\r\n\r\n const args = msg.args();\r\n if (!args || args.length === 0) {\r\n console.log(`[Browser:${type}]`, txt);\r\n return;\r\n }\r\n\r\n for (let i = 0; i < args.length; i++) {\r\n try {\r\n const arg = args[i];\r\n const obj = arg.remoteObject();\r\n\r\n console.log(obj);\r\n\r\n if (obj.value !== undefined) {\r\n console.log(`[Browser:${type}]`, obj.value);\r\n } else {\r\n const value = await arg.jsonValue().catch(() => txt);\r\n console.log(`[Browser:${type}]`, value);\r\n }\r\n } catch (err) {\r\n console.log(`[Browser:${type}]`, txt);\r\n }\r\n }\r\n }\r\n );\r\n\r\n page?.on(\"pageerror\", (msg: any) => {\r\n console.log(\"error\", msg);\r\n });\r\n\r\n return {\r\n autoHeal: async (data: ElementRecord, htmlString: string) => {\r\n await page?.evaluate((datum: ElementRecord, html: string) => {\r\n // @ts-ignore\r\n let xpathAPI = window.XpathLib.createXPathAPI();\r\n let docmt = xpathAPI.xpathUtils.parseXml(html);\r\n return x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,OAAO,QAAQ,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC;AACnD,gBAAA,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC;YACtB,CAAC;SACF;AACH,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC9B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ff-dom",
3
- "version": "1.0.18-beta.1",
3
+ "version": "1.0.18-beta.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -495,8 +495,8 @@ const getDescendantXpath = (
495
495
  }
496
496
 
497
497
  if (refExpectElement[refExpectElement.length - 2].attributes) {
498
- for (const attrName of refExpectElement[refExpectElement.length - 2]
499
- .attributes) {
498
+ for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2]
499
+ .attributes)) {
500
500
  if (
501
501
  checkBlockedAttributes(attrName, refExpectElement[refExpectElement.length - 2], false)
502
502
  ) {
@@ -546,8 +546,8 @@ const getDescendantXpath = (
546
546
  }
547
547
  }
548
548
 
549
- for (const attrName of refExpectElement[refExpectElement.length - 2]
550
- .attributes) {
549
+ for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2]
550
+ .attributes)) {
551
551
  if (
552
552
  checkBlockedAttributes(attrName, refExpectElement[refExpectElement.length - 2], false)
553
553
  ) {
@@ -787,7 +787,7 @@ const getReferenceElementXpath = (element: HTMLElement | Element) => {
787
787
  xpaths1 = [
788
788
  {
789
789
  key: "",
790
- value: getRelativeXPath(element, element.ownerDocument, false, false, [...element.attributes]),
790
+ value: getRelativeXPath(element, element.ownerDocument, false, false, Array.from(element.attributes)),
791
791
  },
792
792
  ];
793
793
  }
@@ -796,7 +796,7 @@ const getReferenceElementXpath = (element: HTMLElement | Element) => {
796
796
  xpaths1 = [
797
797
  {
798
798
  key: "",
799
- value: getRelativeXPath(element, element.ownerDocument, true, false, [...element.attributes]),
799
+ value: getRelativeXPath(element, element.ownerDocument, true, false, Array.from(element.attributes)),
800
800
  },
801
801
  ];
802
802
  xpaths1 = xpaths1?.map((x) =>
@@ -127,7 +127,7 @@ const getUniqueParentXpath = (
127
127
 
128
128
  while (currentNode && currentNode.nodeType === 1) {
129
129
  const hasUniqueAttr = false;
130
- for (const attrName of currentNode.attributes) {
130
+ for (const attrName of Array.from(currentNode.attributes)) {
131
131
  if (checkBlockedAttributes(attrName, currentNode, isTarget)) {
132
132
  let attrValue = attrName.nodeValue;
133
133
 
@@ -299,7 +299,7 @@ const getParentRelativeXpath = (
299
299
 
300
300
  // BASE CASE #2: Check for unique attributes
301
301
  let uniqueAttrFound = false;
302
- for (const attr of currentNode.attributes) {
302
+ for (const attr of Array.from(currentNode.attributes)) {
303
303
  if (checkBlockedAttributes(attr, currentNode, isTarget)) {
304
304
  let attrValue = attr.nodeValue;
305
305
 
@@ -393,7 +393,7 @@ const getChildRelativeXpath = (
393
393
  do {
394
394
  let uniqueAttrFound = false;
395
395
  for (currentNode = st.pop()!; currentNode !== null; ) {
396
- for (const attr of currentNode.attributes) {
396
+ for (const attr of Array.from(currentNode.attributes)) {
397
397
  if (checkBlockedAttributes(attr, currentNode, true)) {
398
398
  let attrValue = attr.nodeValue;
399
399
 
@@ -522,7 +522,7 @@ const processSibling = (
522
522
  ) => {
523
523
  try {
524
524
  if (sibling.hasAttributes()) {
525
- for (const attr of sibling.attributes) {
525
+ for (const attr of Array.from(sibling.attributes)) {
526
526
  let xpathe = intermediateXpathStep(
527
527
  sibling,
528
528
  {
@@ -1055,7 +1055,7 @@ export const parseDOM = (
1055
1055
  const docmt = targetElemt?.ownerDocument || doc;
1056
1056
  const tag = targetElemt.tagName;
1057
1057
  const { attributes } = targetElemt;
1058
- addAllXPathAttributes([...attributes], targetElemt, docmt, isIndex, isTarget);
1058
+ addAllXPathAttributes(Array.from(attributes), targetElemt, docmt, isIndex, isTarget);
1059
1059
  if (!referenceElementMode) {
1060
1060
  if (xpathData.length) {
1061
1061
  const len = xpathData.length;
@@ -1080,7 +1080,7 @@ export const parseDOM = (
1080
1080
  docmt,
1081
1081
  isIndex,
1082
1082
  isTarget,
1083
- [...targetElemt.attributes]
1083
+ Array.from(targetElemt.attributes)
1084
1084
  );
1085
1085
  }
1086
1086
 
@@ -654,10 +654,10 @@ export const getRelativeXPath = (
654
654
  while (currentNode) {
655
655
  let xpathe: string | undefined = "";
656
656
  let hasUniqueAttr = false;
657
- let attributes = domNode === currentNode ? attributesArray : currentNode.attributes
657
+ let attributes = domNode === currentNode ? attributesArray ?? currentNode.attributes : currentNode.attributes
658
658
 
659
659
  // Loop through attributes to check for unique identifiers
660
- for (const attrName of attributes) {
660
+ for (const attrName of Array.from(attributes)) {
661
661
  if (checkBlockedAttributes(attrName, currentNode, isTarget)) {
662
662
  let attrValue = attrName.nodeValue;
663
663
 
@@ -1119,7 +1119,7 @@ export const getReferenceElementsXpath = (
1119
1119
  }
1120
1120
 
1121
1121
  if (domNode.attributes) {
1122
- for (const attrName of domNode.attributes) {
1122
+ for (const attrName of Array.from(domNode.attributes)) {
1123
1123
  if (checkBlockedAttributes(attrName, domNode, isTarget)) {
1124
1124
  let attrValue = attrName.nodeValue;
1125
1125
  if (attrValue) {