ff-dom 2.0.9 → 3.0.0-beta.1

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
@@ -1 +1 @@
1
- !function(e){"use strict";const t=/^[\S]+( [\S]+)*$/i;const n={};let a,l=new Map,r=[];const o=e=>/\d/.test(e),s=e=>{const t=e?.textContent;return t},i=e=>e?.childNodes[0]?.nodeValue||"",c=(e,t,a,l=!1)=>{try{let r;if(void 0!==n[e])r=n[e];else{r=(9===a.nodeType?a:a.ownerDocument).evaluate(`count(${e})`,a,null,XPathResult.NUMBER_TYPE,null).numberValue,n[e]=r}if(l&&Array.isArray(t)){if(r>1){const n=y(e,a,!0);let l,r=0;if(n instanceof XPathResult)for(;(l=n?.iterateNext())&&(!t.includes(l)||(r+=1,2!==r)););if(2!==r)return 0}}else if(1===r){return y(e,a)===t?r:0}return r}catch(t){return console.error(`Error evaluating XPath: ${e}`,t),0}},u=e=>{if(e){if(-1!==e.indexOf('"'))return`'${e}'`;if(-1!==e.indexOf("'"))return`"${e}"`}return`'${e}'`},f=e=>{const t=e.split("");let n=t.length;const a=[];for(;"["!==t[n-2];)a.push(t[n-2]),n--;a.reverse();let l="";for(let e=0;e<a.length;e++)l+=a[e];const r=l.length+2;let o=e.slice(0,e.length-r);return o=o.startsWith("(")&&o.endsWith(")")?o.slice(1,-1):e,o},m=(e,t,n,a)=>{try{const l=9===n.nodeType?n:n.ownerDocument;let r=0;if(a){if(1===c(`${e}[${a}]`,t,n))return`${e}[${a}]`;if(1===c(`(${e})[${a}]`,t,n))return`(${e})[${a}]`}const o=l.evaluate(e,n,null,XPathResult.ANY_TYPE,null);let s;for(;s=o.iterateNext();)if(r++,s.isSameNode(t))return 1===c(`${e}[${r}]`,t,n)?`${e}[${r}]`:1===c(`(${e})[${r}]`,t,n)?`(${e})[${r}]`:void 0}catch(e){console.log(e)}},h=e=>(e=(e=(e=>(e&&=e.split("\n")[0].length>0?e.split("\n")[0]:e.split("\n")[1],e))(e)).split(/[^\u0000-\u00ff]/).reduce((e,t)=>e.length>t.length?e:t,"").trim()).split("/")[0].trim(),g=e=>e?e.replace(/\s\s+/g," ").trim():e,d=e=>{if(!e||!e?.getRootNode)return null;const t=e.getRootNode();return t&&t?.host?t:null},p=(e,t,n)=>{if(!e?.value||"boolean"==typeof e?.value)return!1;if(["true","false","on","off","flntooltip","flutter-highlight-overlay"].some(t=>t===e.value))return!1;if(["type","style","locator-data-tooltip","value"].some(t=>t===e.name))return!1;const a=r?.find(n=>n.doc===t.ownerDocument&&n.element===t&&n.attributeName===e.name);return!a&&(!(0===e?.name?.indexOf("on")&&e?.name?.length>3)&&("function"!=typeof e.value&&(!n||!o(e.value))))},$=e=>e instanceof SVGElement,v=e=>e?e.replace(/\b[a-zA-Z_]*disabled\b/gi,"disabled"):e,y=(e,t,n=!1)=>{let a=t;t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(a=t.host??t);const l=a.nodeType===Node.DOCUMENT_NODE?a:a.ownerDocument;return n?l.evaluate(e,a,null,XPathResult.ANY_TYPE,null):l.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue},N=(e,n,a,l,r,s)=>{if(l){const{tagName:i}=e;let f,m="";const h=[];let d;if(l&&(!s||!o(l))&&(d=t.test(l)?`//${i}[${a}=${u(l)}]`:((e,t,n)=>t?`//*[local-name()='${n}' and ${e}]`:`//${n}[${e}]`)(`normalize-space(${a})=${u(g(l)).trim()}`,$(e),e.tagName.toLowerCase()),f=c(d,e,n),1===f&&!r))return d;if(l&&s){const o=l.split(" ");if(o?.length)if(1===o.length){const s=[...new Set(o[0].match(/([^0-9]+)/g))];if(s?.length>=1&&s[0]&&g(s[0].trim())?.length>1&&l.startsWith(s[0])&&(m=t.test(s[0])?`starts-with(${a},${u(s[0]).trim()})`:`starts-with(${a},${u(g(s[0])).trim()})`),s?.length>1&&s[s.length-1]&&g(s[s.length-1].trim())?.length>1&&l.endsWith(s[s.length-1])&&(m=t.test(s[s.length-1])?`ends-with(${a},${u(s[s.length-1]).trim()})`:`ends-with(${a},${u(g(s[s.length-1])).trim()})`),m?.length&&(d=$(e)?`//*[local-name()='${i}' and ${m}]`:`//${i}[${m}]`,f=c(d,e,n),1===f&&!r))return d}else{const s=o.length%2==0?o.length/2:o.length%2,h=o.slice(0,s).join(" ");let p=[...new Set(h.match(/([^0-9]+)/g))];if(p?.length&&p[0]&&g(p[0].trim())?.length&&l.startsWith(p[0])&&(m=t.test(p[0])?`starts-with(${a},${u(p[0]).trim()})`:`starts-with(${a},${u(g(p[0])).trim()})`),m?.length&&(d=$(e)?`//*[local-name()='${i}' and ${m}]`:`//${i}[${m}]`,f=c(d,e,n),1===f&&!r))return d;const v=o.slice(s,o.length-1).join(" ");if(p=[...new Set(v.match(/([^0-9]+)/g))],p?.length&&p[0]&&g(p[0].trim())?.length>3&&l.endsWith(p[0])&&(m=t.test(p[0])?`ends-with(${a},${u(p[0]).trim()})`:`ends-with(${a},${u(g(p[0])).trim()})`),m?.length&&(d=$(e)?`//*[local-name()='${i}' and ${m}]`:`//${i}[${m}]`,f=c(d,e,n),1===f&&!r))return d}}if(l&&s&&o(l)){const o=[...new Set(l.match(/([^0-9]+)/g))];if(o?.length)for(let e=0;e<o?.length;e++)o[e]&&g(o[e].trim())?.length>1&&(t.test(o[e])?h.push(`contains(${a},${u(o[e].trim()).trim()})`):h.push(`contains(${a},${u(g(o[e])).trim()})`));if(h?.length&&(d=$(e)?`//*[local-name()='${i}' and ${h.join(" and ")}]`:`//${i}[${h.join(" and ")}]`,f=c(d,e,n),1===f&&!r))return d}if(d=$(e)?`//*[local-name()='${i}' and text()]`:`//${i}[text()]`,f=c(d,e,n),1===f&&!r)return d}},b=(e,t)=>{try{if(!e)return"";let n=$(e)?`/*[local-name()='${e.tagName}']`:`/${e.tagName}`;if(e.parentElement){const t=Array.prototype.slice.call(e.parentElement.children,0).filter(t=>t.tagName===e.tagName);if(t.length>1){n+=`[${t.indexOf(e)+1}]`}}else if(e instanceof HTMLElement&&e.offsetParent){const t=Array.prototype.slice.call(e.offsetParent.children,0).filter(t=>t.tagName===e.tagName);if(t.length>1){n+=`[${t.indexOf(e)+1}]`}}return b(e?.parentElement,t)+n}catch(e){return console.log("xpath",e),""}},x=(e,t,n,a=!1,r)=>{try{if(l.has(e))return l.get(e);const s=[];let f=e;for(;f;){let l="",h=!1,d=e===f?r??f.attributes:f.attributes;for(const e of Array.from(d))if(p(e,f,a)){let a=e.nodeValue;a=a?.replace("removePointers","")??"";const r=e.name;l=C(f,r,a);let o=0;if(l&&(o=c(l,f,t),1===o)){s.unshift(v(l)),h=!0;break}if(o>1&&n&&(l=m(l,f,t,o),l)){s.unshift(v(l)),h=!0;break}}if(f.textContent)if(!a||a&&!o(f.textContent)){l=new RegExp(/^[\S]+( [\S]+)*$/gi).test(f.textContent)?$(f)?`//*[local-name()='${f.tagName}' and .=${u(i(f))}]`:`//${f.tagName||"*"}[.=${u(i(f))}]`:$(f)?`//*[local-name()='${f.tagName}' and normalize-space(.)=${u(i(f))}]`:`//${f.tagName||"*"}[normalize-space(.)=${u(i(f))}]`;let e=c(l,f,t);if(1===e)return l;if(e>1&&n)return l=m(l,f,t,e),l}else{let e=[];const a=[...new Set(i(f).match(/([^0-9]+)/g))];let r=new RegExp(/^[\S]+( [\S]+)*$/gi);if(a?.length)for(let t=0;t<a?.length;t++)a[t]&&g(a[t].trim())&&(r.test(a[t])?e.push(`contains(.,${u(a[t].trim()).trim()})`):e.push(`contains(.,${u(g(a[t])).trim()})`));if(e?.length){l=$(f)?`//*[local-name()='${f.tagName}' and ${e.join(" and ")}]`:`//${f.tagName||"*"}[${e.join(" and ")}]`;let a=c(l,f,t);if(1===a)return l;if(a>1&&n)return l=m(l,f,t,a),l}}if(h)break;{let e=$(f)?`/*[local-name()='${f.tagName}']`:`/${f.tagName}`;if(f.parentElement){const t=Array.from(f.parentElement.children).filter(e=>e.tagName===f.tagName);if(t.length>1){e+=`[${t.indexOf(f)+1}]`}}s.unshift(e)}f=f.parentElement}const h=`${s.join("")}`;return l.set(e,h),h}catch(e){return console.log(e),null}},E=(e,n)=>{const a=[];let l="";if(e&&!o(e.value)&&"function"!=typeof e.nodeValue){const r=[...new Set(e.value.match(/([^0-9]+)/g))];if(r?.length)for(let n=0;n<r?.length;n++)r[n]&&g(r[n].trim())?.length>2&&(t.test(r[n])?a.push(`contains(@${e.name},${u(r[n].trim())})`):a.push(`contains(@${e.name},${u(g(r[n])).trim()})`));if(a?.length)return l=$(n)?`//*[local-name()='${n.tagName}' and ${a.join(" and ")}]`:`//${n.tagName}[${a.join(" and ")}]`,l}},S=(e,n,a,l)=>{try{const r=[];if(a.length>1)for(const o of a)if(p(o,e,l)){const a=o.nodeValue;t.test(a)?"class"===o.nodeName?r.push(`contains(@${o.nodeName},"${a}")`):r.push(`@${o.nodeName}="${a}"`):r.push(`normalize-space(@${o.nodeName})="${a}"`);const l=$(e)?`//*[local-name()='${e.tagName}' and ${r.join(" and ")}]`:`//${e.tagName}[${r.join(" and ")}]`;let s;try{s=c(l,e,n)}catch(e){continue}if(1===s&&!l.includes("and"))return"";if(1===s&&l.includes("and"))return l}}catch(e){console.log(`'${JSON.stringify(e,null,2)}'`)}},k=(e,n,a)=>{let l=$(e),r="";if(p(n,e,a)){let a=n.value;a=a.replace("removePointers","");const o=n.name;r=t.test(a)?l?`*[local-name()='${e.tagName}' and @${o}=${u(a)}]`:`${e.tagName||"*"}[@${o}=${u(a)}]`:l?`*[local-name()='${e.tagName}' and normalize-space(@${o})=${u(a)}]`:`${e.tagName||"*"}[normalize-space(@${o})=${u(a)}]`}return r},w=(e,n)=>{if(!e.textContent)return"";const a=i(e);let l;return l=t.test(a)?$(e)?`//*[local-name()='${e.tagName}' and .=${u(a)}]`:`//${e.tagName||"*"}[.=${u(a)}]`:$(e)?`//*[local-name()='${e.tagName}' and normalize-space(.)=${u(a)}]`:`//${e.tagName||"*"}[normalize-space(.)=${u(a)}]`,l},R=e=>{const t=s(e)?.trim(),n=t?u(h(t)):t;if(n)return n!==`'${t}'`?`contains(.,${n})`:`normalize-space(.)='${t}'`},C=(e,t,n)=>{const a=new RegExp(/^[\S]+( [\S]+)*$/gi);let l="";return n&&(l=a.test(n)?"class"===t?$(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${u(n)})]`:`//${e.tagName||"*"}[contains(@${t},${u(n)})]`:$(e)?`//*[local-name()='${e.tagName}' and @${t}=${u(n)}]`:`//${e.tagName||"*"}[@${t}=${u(n)}]`:$(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${u(n)})]`:`//${e.tagName||"*"}[contains(@${t},${u(n)})]`),l},P=(e,t)=>e?e.replace(/\bdisabled\b/gi,"flndisabled"):e,A=(e,n,a)=>{let l;const r=[];if(e.textContent&&(!a||a&&!o(e.textContent))&&(t.test(e.textContent)?(l=$(e)?`*[local-name()='${e.tagName}' and .=${u(s(e))}]`:`${e.tagName}[.=${u(s(e))}]`,l&&r.push({key:"getReferenceElementsXpath",value:l})):(l=$(e)?`*[local-name()='${e.tagName}' and ${R(e)})]`:`${e.tagName}[${R(e)}]`,l&&r.push({key:"getReferenceElementsXpath",value:l}))),e.attributes)for(const t of Array.from(e.attributes))if(p(t,e,a)){let n=t.nodeValue;if(n){n=n.replace("removePointers","");const a=t.name;l="class"===a?$(e)?`*[local-name()='${e.tagName}' and contains(@${a},${u(n)})]`:`${e.tagName}[contains(@${a},${u(n)})]`:$(e)?`*[local-name()='${e.tagName}' and @${a}=${u(n)}]`:`${e.tagName}[@${a}=${u(n)}]`,l&&r.push({key:"getReferenceElementsXpath",value:l})}}if(!r?.length){const t=Array.prototype.slice.call(e.attributes);if(t?.length>1){const t=S(e,n,Array.prototype.slice.call(e.attributes),a);t&&r.push({key:"getReferenceElementsXpath",value:t})}}if(!r?.length){const n=[];let l;const s=$(e);if(e.textContent&&a&&o(e.textContent)){const a=[...new Set(e.textContent.match(/([^0-9]+)/g))];if(a?.length)for(let e=0;e<a?.length;e++)a[e]&&g(a[e].trim())?.length>1&&(t.test(a[e])?n.push(`contains(.,${u(a[e]).trim()})`):n.push(`contains(.,${u(g(a[e])).trim()})`));n?.length&&(l=s?`//*[local-name()='${s}' and ${n.join(" and ")}]`:`//${s}[${n.join(" and ")}]`,l&&r.push({key:"getReferenceElementsXpath",value:l}))}}if(!r?.length){const t=((e,t,n,a)=>{const l=Array.prototype.slice.call(e),r=[];try{l.map(e=>{if(p(e,t,a)){const n=E(e,t);n&&r.push({key:`split xpath by ${e.name}`,value:n})}})}catch(e){console.log(e)}return r})(e.attributes,e,0,a);t?.length&&r.concat(t)}return r},D=e=>e=(e=e.replace(/text\(\)\s*=\s*(['"])(.*?)\1/g,"normalize-space(.)=$1$2$1")).replace(/\.\s*=\s*(['"])(.*?)\1/g,"normalize-space(.)=$1$2$1"),O=(e,t)=>{let n=t,a=1;for(;a>0;){const t=e[++n];"("==t?a++:")"==t&&a--}return n};function X(e){const t=function(e){return e.toLowerCase().replace(/'[^']*'/g,"?").replace(/"[^"]*"/g,"?").replace(/\[\d+\]/g,"[?]").replace(/\/\/[a-z0-9_-]+/g,"//node").replace(/\/[a-z0-9_-]+/g,"/node")}(e),n=function(e){const t=e.toLowerCase(),n=t.match(/(ancestor-or-self|ancestor|descendant-or-self|descendant|following-sibling|preceding-sibling|following|preceding|parent|child|self)::/),a=n?.[1]??"none",l=t.match(/@([a-z0-9:-]+)/);return{axis:a,attribute:l?.[1]??"none",usesNormalize:t.includes("normalize-space")}}(e);return["XPATH",`axis:${n.axis}`,`attr:${n.attribute}`,`normalize:${n.usesNormalize}`,`shape:${t}`].join("|")}function T(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/ /g,"\\ ")}function j(e,t,n,a){const l=a?.getRootNode?.()??e,r=e=>{try{return Array.from(l.querySelectorAll(e))}catch{return[]}};try{switch(t){case"id":return 1===r(`#${T(n)}`).length;case"name":return 1===r(`[name="${T(n)}"]`).length;case"className":return 1===r(`.${n}`).length;case"tagName":case"cssSelector":return 1===r(n).length;case"linkText":return 1===r("a").filter(e=>e.textContent?.trim()===n).length;case"partialLinkText":return 1===r("a").filter(e=>e.textContent?.includes(n)).length;default:return!1}}catch{return!1}}const L={parseXml:(e,t)=>window.DOMParser?(new window.DOMParser).parseFromString(e,t):null,getReferenceElementsXpath:A,getAbsoluteXPath:b,getRelativeXPath:x,getCombinationXpath:E,getAttributeCombinationXpath:S,getElementFromXpath:y,isSvg:$,findXpathWithIndex:m,isNumberExist:o,getTextContent:s,getCountOfXPath:c,normalizeXPath:D,getShadowRoot:d,escapeCharacters:u,removeParenthesis:f,checkBlockedAttributes:p,getRelationship:(e,t)=>{let n=e.compareDocumentPosition(t);return 2===n?"preceding":4===n?"following":8===n?"ancestor":16===n?"descendant":32===n?"self":""},findMatchingParenthesis:O,deleteGarbageFromInnerText:h,replaceTempAttributes:v,createObserver:e=>{a=new MutationObserver(t=>{t.forEach(t=>{t?.addedNodes?.length&&e(t?.addedNodes),t.target instanceof HTMLElement&&("attributes"===t?.type&&"class"===t.attributeName&&($(t.target)&&t.oldValue?.trim()===t.target.classList.value?.trim()||"marked-element-temp"===t.target.classList?.value?.replace(t.oldValue,"").trim()||"marked-element-temp"===t?.oldValue?.replace(t.target.classList?.value,"").trim())||"attributes"!==t?.type||["flndisabled"].includes(t.attributeName)||r.push({url:t.target.baseURI,attributeName:t.attributeName,element:t.target,doc:t.target.ownerDocument}))})})},startObserver:(e,t)=>{a?.observe(e,t)},stopObserver:()=>{a?.disconnect()},modifiedElementAttributes:r,cspEnabled:!1,getXPathPattern:X,escapeAttrValue:T,isUniqueInDOM:j};let Y=[],_=[],V=new Map,I=new Map;const z=new Map,q=(e,t,n,a,l,r)=>{if(e){let o;o="parent"===r?[`${e}/descendant-or-self::${t}`,`${e}/following::${t}`]:[`${e}/ancestor-or-self::${t}`,`${e}/preceding::${t}`];for(const e of o){V?.get(e)||V.set(e,c(e,n,a));const t=V?.get(e);if(1===t)return e;if(t>1&&(_.length?t<_[0].count&&(_.pop(),_.push({key:"relative xpath by unique parent "+(l?"index":""),value:e,count:t})):_.push({key:"relative xpath by unique parent "+(l?"index":""),value:e,count:t})),t>1&&l&&!Y.length){const r=m(e,n,a,t);r&&1===c(r,n,a)&&Y.push({key:"relative xpath by unique parent "+(l?"index":""),value:r})}}}return null},M=(e,n,a,l,r,s)=>{try{if(z.has(e))return z.get(e);const f=[];let m=e;for(;m&&1===m.nodeType;){const e=!1;for(const e of Array.from(m.attributes))if(p(e,m,l)){let t=e.nodeValue;t=t?.replace("removePointers","")??"";const l=e.name,o=C(m,l,t);let i;try{i=q(o,r,a,n,s,"parent")}catch(e){continue}if(i)return i}if(m.textContent&&!m.textContent)if(!l||l&&!o(m.textContent)){let e;e=t.test(m.textContent)?$(m)?`//*[local-name()='${m.tagName}' and .=${u(i(m))}]`:`//${m.tagName||"*"}[.=${u(i(m))}]`:$(m)?`//*[local-name()='${m.tagName}' and normalize-space(.)=${u(i(m))}]`:`//${m.tagName||"*"}[normalize-space(.)=${u(i(m))}]`;const l=q(e,r,a,n,s,"parent");if(l)return l}else{const e=[],t=[...new Set(i(m).match(/([^0-9]+)/g))],l=new RegExp(/^[\S]+( [\S]+)*$/gi);if(t?.length)for(let n=0;n<t?.length;n++)t[n]&&g(t[n].trim())&&(l.test(t[n])?e.push(`contains(.,${u(t[n].trim()).trim()})`):e.push(`contains(.,${u(g(t[n])).trim()})`));if(e?.length){const t=$(m)?`//*[local-name()='${m.tagName}' and ${e.join(" and ")}]`:`//${m.tagName||"*"}[${e.join(" and ")}]`,l=q(t,r,a,n,s,"parent");if(l)return l}}if(!e){const e=$(m)?`/*[local-name()='${m.tagName}']`:`/${m.tagName}`;f.unshift(e)}m=m.parentElement}const h=f.join("")+r;if(1===c(h,e,n))return z.set(e,h),h}catch(e){return console.error(e),null}},W=(e,t,n,a)=>{const l=new Map;if(l.has(e))return l.get(e);const r=[];let o=e;try{for(;o&&1===o.nodeType;){if(!o.tagName)return"";let e=!1;for(const n of Array.from(o.attributes))if(p(n,o,a)){let a=n.nodeValue;a=a?.replace("removePointers","")??"";const l=n.name,s=C(o,l,a);let i;try{i=c(s,o,t)}catch(e){continue}if(1===i){r.unshift(s),e=!0;break}}if(!e&&o.textContent&&!n.textContent){const n=w(o);if(n){if(1===c(n,o,t)){e=!0,r.unshift(n);break}}}if(e)break;{const e=$(o)?`/*[local-name()='${o.tagName}']`:`/${o.tagName}`;r.unshift(e)}o=o.parentElement}const s=r.join("");return l.set(e,s),s}catch(e){return console.log(e),null}},H=(e,t,n)=>{const a=[];let l;const r=[];null!=e.firstElementChild&&e.firstElementChild.classList.contains("flntooltip")?r.unshift(e.firstElementChild):null!=e.nextElementSibling&&r.unshift(e.nextElementSibling);for(let t=e.parentElement;null!=t&&1===t.nodeType;t=t.parentElement)t.nextElementSibling&&r.unshift(t.nextElementSibling);try{do{let e=!1;for(l=r.pop();null!==l;){for(const n of Array.from(l.attributes))if(p(n,l,!0)){let r=n.nodeValue;r=r?.replace("removePointers","")??"";const o=n.name,s=C(l,o,r);let i;try{i=c(s,l,t)}catch(e){continue}if(1===i){e=!0,a.push(s);break}}if(!e&&l.textContent&&!n.textContent){const n=w(l);if(n){if(1===c(n,l,t)){e=!0,a.push(n);break}}}if(e)break;{const e=$(l)?`/*[local-name()='${l.tagName}']`:`/${l.tagName}`;a.push(e),null!=l.firstElementChild?(r.push(l.nextElementSibling),l=l.firstElementChild):l=l.nextElementSibling}}}while(r.length>0);const o=a.join("");return I.set(e,o),o}catch(e){return console.log(e),null}},F=(e,t,n,a)=>{try{const l=document.querySelector(".flntooltip");for(let r=e.nextElementSibling;null!==r&&r!==l;r=r.nextElementSibling)U(r,e,t,a,"preceding-sibling",n);for(let r=e.previousElementSibling;null!==r&&r!==l;r=r.previousElementSibling)U(r,e,t,a,"following-sibling",n)}catch(e){return console.error("sibling error",e),null}},U=(e,t,n,a,l,r)=>{try{if(e.hasAttributes())for(const t of Array.from(e.attributes)){let o=k(e,{name:t.name,value:t.value},r);if(o){o+=`/${l}::${a}`;const t=c(o,e,n);if(1===t)return void Y.push({key:`xpath by ${l}`,value:o});t>1&&(_.length?t<_[0].count&&(_.pop(),_.push({key:`relative xpath by ${l}`,value:o,count:t})):_.push({key:`relative xpath by ${l}`,value:o,count:t}))}}if(!r){let t;if(t=k(e,{name:"text",value:e.textContent},r),t){const a=c(t,e,n);if(1===a)return void Y.push({key:`xpath by ${l}`,value:t});a>1&&(_.length?a<_[0].count&&(_.pop(),_.push({key:`relative xpath by ${l}`,value:t,count:a})):_.push({key:`relative xpath by ${l}`,value:t,count:a}))}}}catch(e){console.log(`${l} xpath-error`,e)}};function B(e,t,n,a){const{tagName:l}=t,r=t.textContent.trim();for(const o of e)if(p(o,t,a)){let e=o.nodeValue;e=e?.replace("removePointers","")??"";const a=`//${l}[@${o.name}='${e}' and text()='${r}']`;if(a){if(1==c(a,t,n))return a}}}const G=(e,t,n,a,l)=>{try{let r,o,s=[];if(Y=[],console.log(l),l)for(const t of l){let n=k(e,{name:t.name,value:t.value},a);console.log(n),n&&s.push(n)}if(e.textContent){let t=k(e,{name:"text",value:e.textContent},a);console.log(t),t&&s.push(t)}if(s.push(e.tagName),s?.length)for(let l=0;l<s.length;l++)if(!Y.length){if(F(e,t,a,s[l]),!Y.length&&(r||(r=W(e.parentElement,t,e,a)),console.log(r),r&&(r.includes("@")||r.includes("text()")||r.includes(".="))&&r.match(/\//g)?.length-2<5)){const a=r+`/${s[l]}`,o=c(a,e,t);if(1===o)Y.push({key:"relative xpath by relative parent",value:a});else if(o>1&&n){const l=m(a,e,t,o);l&&1===c(l,e,t)&&Y.push({key:"relative xpath by relative parent "+(n?"index":""),value:l})}}if(!Y.length&&(o||(o=H(e,t,e)),o&&(o.includes("@")||o.includes("text()")||o.includes(".=")))){const a=`/${s[l]+o.substring(1)}`,r=c(a,e,t);if(1===r)Y.push({key:"relative xpath by relative child",value:a});else if(r>1&&n){const l=m(a,e,t,r);l&&1===c(l,e,t)&&Y.push({key:"relative xpath by relative parent "+(n?"index":""),value:l})}}if(1===Y?.length&&Y?.[0]?.value?.match(/\[([0-9]+)\]/gm)?.length>3&&e.textContent){const a=K(e,t,n,!1);a&&Y.unshift({key:"xpath by text"+(n?"index":""),value:a})}if(!Y.length){let r=M(e.parentElement,t,e,a,s[l],n);r&&Y.push({key:"xpath by unique parent",value:r})}}return Y}catch(e){console.log(e)}},J=(e,t,n,a,l)=>{let r;return r=e.name,N(t,n,`@${r}`,e.value,a,l)},Z=(e,t,n,a)=>{let l=e.className;if("string"!=typeof l&&(l=""),l=l?.replace("flndisabled","disabled"),l=l?.replace("removePointers",""),l=l?.trim(),l)return N(e,t,"@class",l,n,a)},K=(e,t,n,a)=>{if(""!=(e.textContent??"").trim()){const l=s(e);if(l)return N(e,t,".",l,n,a)}},Q=(e,t,n,a,l)=>{const r=e;try{r.map(e=>{if("className"!==e.name&&"class"!==e.name&&p(e,t,l)){const r=J(e,t,n,a,l);r&&Y.push({key:`xpath by ${e.name}${a?" index":""}`,value:r})}});const o=K(t,n,a,l);if(o&&Y.push({key:"xpath by text"+(a?" index":""),value:o}),r.find(e=>"className"===e.name)&&p(r?.find(e=>"className"===e.name),t,l)){let e=Z(t,n,a,l);e&&Y.push({key:"xpath by class",value:e})}if(!Y.length){const a=B(e,t,n,l);a&&Y.push({key:"xpath by textAttribute",value:a})}if(!Y.length&&r.length>1){const e=S(t,n,r,l);e&&Y.push({key:"xpath by combination",value:e})}}catch(e){console.log(e)}},ee=(e,t,n,a,l=[])=>{Y=[],console.log(e);const r=e,o=r?.ownerDocument||t,s=r.tagName,{attributes:i}=r,u=l.length>0?l:Array.from(i);if(Q(u,r,o,n,a),Y.length){const t=Y.length;for(let n=0;n<t;n++){let t=Y[n].value;t="//*"+t.substring(t.indexOf("//")+2+s.length);1===c(t,e,o)&&Y.push({key:`${Y[n].key} regex`,value:t})}}return Y.length||G(r,o,n,a,Array.from(r.attributes)),Y},te={parseDOM:ee,getTextXPath:K,getUniqueClassName:Z,attributesBasedXPath:J,addAllXPathAttributes:Q,addRelativeXpaths:G,getXPathUsingAttributeAndText:B,getSiblingRelativeXPath:F,getChildRelativeXpath:H,getParentRelativeXpath:W,getUniqueParentXpath:M,checkRelativeXpathRelation:q};let ne=[],ae=[];const le=/^[\S]+( [\S]+)*$/gi,re=(e,t,n,a,l,r,o,s=0,i=!1)=>{let u="";if(t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g)?.length>=r.length){const c=[],u=t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);for(let e=1;e<=r.length;e++)c.unshift(e===r.length?r[r.length-e]:u[u.length-e]);const f=ie(`${o+(s?"]".repeat(s):"")}`,c,e[e.length-1],e,a,n,l,i);if(f)return f}else{u=`//${o+(s?"]".repeat(s):"")}/${n}::${P(t,e[e.length-1])}`;let r=c(u,e[e.length-1],a);if(1===r)return[{key:`dynamic ${n}`,value:v(u)}];if(r>1&&l&&(u=m(u,e[e.length-1],a,r),u&&(r=c(u,e[e.length-1],a),1===r)))return[{key:`dynamic ${n} ${l?" index":""}`,value:v(u)}]}},oe=(e,t,n,a,l,r=!1,o=!1)=>{const i=e[e.length-2],c=e[e.length-1],f=d(c)??c.ownerDocument,m=n.find(e=>e?.key?.includes("absolute"))?.value||b(i,i.ownerDocument),h=[],g=[];m.split("/").map(e=>h.push(e)),h.map(e=>g.push(e.replace(/\[([0-9]+)\]/gm,"")));const v=a.find(e=>e?.key?.includes("absolute"))?.value||b(c,c.ownerDocument),y=[],N=[];v.split("/").map(e=>y.push(e)),y.map(e=>N.push(e.replace(/\[([0-9]+)\]/gm,"")));for(var x=0;x<h.length&&h[x]==y[x];x++);const S=[];for(let e=x-1;e<h.length;e++)h[e]&&S.push(g[e]);const k=[];for(let e="descendant"===l?x:x-1;e<y.length;e++)y[e]&&(k.length?k.push(N[e]):k.push(N[e].replace(/\[([0-9]+)\]/gm,"")));let w;if(ae=a,e[e.length-2].textContent){w=le.test(e[e.length-2].textContent)?$(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and .=${u(s(e[e.length-2]))}]`:`${e[e.length-2].tagName}[.=${u(s(e[e.length-2]))}]`:$(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${R(e[e.length-2])})]`:`${e[e.length-2].tagName}[${R(e[e.length-2])}]`,S[S.length-1]=w;const n=S.join("["),a=S.length-1,i=n;for(let n=0;n<ae.length;n++){let s;if(s=ae[n].value.startsWith("//")?ae[n].value.substring(ae[n].value.indexOf("//")+2):ae[n].value,s)return re(e,s,l,f||t,r,k,i,a,o)}}if(e[e.length-2].attributes){for(const n of Array.from(e[e.length-2].attributes))if(p(n,e[e.length-2],!1)){let a=n.nodeValue;if(a){a=a.replace("removePointers","");const s=n.name;w=$(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and @${s}=${u(a)}]`:`${e[e.length-2].tagName}[@${s}=${u(a)}]`,S[S.length-1]=w;const i=S.join("["),c=S.length-1,m=i;for(let n=0;n<ae.length;n++){let a;return a=ae[n].value.startsWith("//")?ae[n].value.substring(ae[n].value.indexOf("//")+2):ae[n].value,re(e,a,l,f||t,r,k,m,c,o)}}}for(const n of Array.from(e[e.length-2].attributes))if(p(n,e[e.length-2],!1)){let a=n.nodeValue;if(a){a=a.replace("removePointers","");const s=E(n,e[e.length-2]);if(s){w=s.startsWith("//")?s.substring(s.indexOf("//")+2):s,S[S.length-1]=w;const n=S.join("["),a=S.length-1,i=n;for(let n=0;n<ae.length;n++){let s;return s=ae[n].value.startsWith("//")?ae[n].value.substring(ae[n].value.indexOf("//")+2):ae[n].value,re(e,s,l,f||t,r,k,i,a,o)}}}}}const C=S.join("["),P=S.length-1,A=ie(`${C+(P?"]".repeat(P):"")}`,k,e[e.length-1],e,t,l,r,o);if(A)return A},se=(e,t,n,a,l,r,o)=>{let s,i;console.log("getXpathRelationExpression",n);const u=[];try{s=a.filter(e=>!e?.key?.includes("absolute")),i=l.filter(e=>!e?.key?.includes("absolute"));for(let e=0;e<s.length;e++)for(let a=0;a<i.length;a++){let l=`//${0!==s[e].value.indexOf("//")?P(s[e].value):P(s[e].value.substring(s[e].value.indexOf("//")+2))}/${n}::${0!==i[a].value.indexOf("//")?P(i[a].value):P(i[a].value.substring(i[a].value.indexOf("//")+2))}`;console.log("getXpathRelationExpression",l);const o=c(l,t,t.ownerDocument);if(o>1)if(r){if(l=m(l,t,t.ownerDocument,o),l)return u.push({key:`dynamic ${n}${r?" index":""}`,value:v(l)}),u}else o>1&&(ne.length?o<ne[0].count&&(ne.pop(),ne.push({key:"relative xpath by relative child "+(r?"index":""),value:l,count:o})):ne.push({key:"relative xpath by relative child "+(r?"index":""),value:l,count:o}));else if(1===o)return u.push({key:`dynamic ${n}`,value:v(l)}),u}if(!u.length)for(let a=0;a<s.length;a++)for(let l=0;l<i.length;l++){const c=`${0!==i[l].value.indexOf("//")?i[l].value:i[l].value.substring(i[l].value.indexOf("//")+2)}`.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);if(c.length>1){const l=ie(`${0!==s[a].value.indexOf("//")?P(s[a].value):P(s[a].value.substring(s[a].value.indexOf("//")+2))}`,c,t,[e,t],t.ownerDocument,n,r,o);if(console.log("getXpathRelationExpression traverseXpath",l),l)return u.concat(l),u}}}catch(e){console.log(e)}return u},ie=(e,t,n,a,l,r,o,s)=>{let i;if(s){const s=t.join("/");i=`//${e}/${r}::${P(s)}`;const u=c(i,n,l);if(1===u)return[{key:`dynamic ${r}`,value:v(i)}];if(u>1&&o&&(i=m(i,a[a.length-1],l,u),i))return[{key:`dynamic ${r}${o?" index":""}`,value:v(i)}]}else for(let s=1;s<=t.length;s++){const u=t.slice(t.length-s,t.length).join("/");i=`//${e}/${r}::${P(u)}`;const f=c(i,n,l);if(1===f)return[{key:`dynamic ${r}`,value:v(i)}];if(f>1&&o&&(i=m(i,a[a.length-1],l,f),i))return[{key:`dynamic ${r}${o?" index":""}`,value:v(i)}]}},ce={findRelativeXpath:(e,t,n,a,l,r,o=!1)=>{const s=e.parentElement,i=t.parentElement;let c,u=[],f=[];if(r&&ne.length){const e=m(ne[0].value,t,t.ownerDocument,ne[0].count);e&&(f=f.concat({key:`${ne[0]?.key?ne[0]?.key:"xpath with "} index`,value:e}),ne.pop())}if(!f.length){for(e.isSameNode(t)&&(u=se(e,t,"self",a,l,r,o),u&&(f=f.concat(u))),c=e.parentElement,c===t&&(u=se(e,t,"parent",a,l,r,o),u&&(f=f.concat(u))),c=e.parentElement;null!==c;){if(c===t&&(u=se(e,t,"ancestor",a,l,r,o),u)){f=f.concat(u);break}c=c.parentNode}c=e;do{if(c===t&&(u=se(e,t,"ancestor-or-self",a,l,r,o),u)){f=f.concat(u);break}c=c.parentNode}while(null!==c);if(s?.isSameNode(i)){for(let n=e.nextElementSibling;null!=n;n=n.nextElementSibling)if(null!=n&&n.isSameNode(t)&&(u=se(e,t,"following-sibling",a,l,r,o),u)){f=f.concat(u);break}for(let n=e.previousElementSibling;null!=n;n=n.previousElementSibling)if(null!=n&&n.isSameNode(t)&&(u=se(e,t,"preceding-sibling",a,l,r,o),u)){f=f.concat(u);break}}if(e?.children?.length)for(let n=e.children[0];null!==n;n=n?.nextElementSibling)if(n===t&&(u=se(e,t,"child",a,l,r,o),u)){f=f.concat(u);break}const m=e.compareDocumentPosition(t);2===m&&(u=se(e,t,"preceding",a,l,r,o)),4===m&&(u=se(e,t,"following",a,l,r,o)),u&&(f=f.concat(u));const h=oe([e,t],n,a,l,"descendant",r,o);h&&(f=f.concat(h));const g=oe([e,t],n,a,l,"descendant-or-self",r,o);g&&(f=f.concat(g))}if(f.length)return f.length>1&&f.sort(function(e,t){return e.value.length-t.value.length}),f.filter(e=>!e.key?.includes("index"))?.length?[f.filter(e=>!e.key?.includes("index"))[0]]:[f[0]]},getDescendantXpath:oe,getXpathRelationExpression:se,getTraverseXpathExpression:ie,getReferenceElementXpath:e=>{let t=[];if(t=ee(e,e.ownerDocument,!1,!1),t?.length){let n=ee(e,e.ownerDocument,!0,!1);n?.length&&(n=n?.map(e=>"("==e.value.charAt(0)&&O(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:f(e.value)}:{key:"",value:e.value}),t=t.concat(n))}else t=ee(e,e.ownerDocument,!0,!1),t=t?.map(e=>"("==e.value.charAt(0)&&O(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:f(e.value)}:{key:"",value:e.value});if(t?.length||(t=[{key:"",value:x(e,e.ownerDocument,!1,!1,Array.from(e.attributes))}]),t?.length||(t=[{key:"",value:x(e,e.ownerDocument,!0,!1,Array.from(e.attributes))}],t=t?.map(e=>"("==e.value.charAt(0)&&O(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:f(e.value)}:{key:"",value:e.value})),t?.length){const n=A(e,e.ownerDocument,!1);n?.length&&(t=t.concat(n))}else t=A(e,e.ownerDocument,!1);const n=b(e,e.ownerDocument);return t=t.filter(e=>e.value!==n),t.push({key:"absolute xpath",value:n.slice(1)}),t}};let ue=[];const fe=(e,t,n)=>{try{const a=n.querySelectorAll(e);return 1===a.length&&a[0]===t}catch{return!1}},me=(e,t="single")=>{const n=[],a=e.getRootNode();try{const l=he(e);if(l&&fe(l,e,a)&&(n.push({key:"cssSelector by id",value:l}),"single"===t))return n;const r=$e(e);r&&fe(r,e,a)&&n.push({key:"cssSelector by class",value:r});const o=pe(e);o&&n.push({key:"cssSelector by name",value:o});const s=ve(e);s&&fe(s,e,a)&&n.push({key:"Absolute cssSelector",value:s})}catch(e){console.error(e)}return n},he=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.tagName.toLowerCase();if(n.includes("style")||n.includes("script"))return;const a=[];for(;e?.nodeType===Node.ELEMENT_NODE;){let t=e.nodeName?.toLowerCase();if(e.id&&!o(e.id)){t+=`#${CSS.escape(e.id)}`,a.unshift(t);break}{let n=e,a=1;if(n.previousElementSibling)for(;n=n.previousElementSibling;)n.nodeName?.toLowerCase()===t&&a++;1!==a&&(t+=`:nth-of-type(${a})`),1===a&&n?.parentElement?.childElementCount>1&&(t+=`:nth-child(${a})`)}a.unshift(t),e=e.parentElement}return a.join(" > ")},ge=new Set(["id","class","style"]);function de(e){return Array.from(e.attributes).filter(e=>!ge.has(e?.name?.toLowerCase())&&e.value&&!o(e.value)).map(e=>{return`[${e.name}="${t=e.value,String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`;var t})}const pe=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.getRootNode(),a=e.tagName.toLowerCase();if("style"===a||"script"===a)return;const l=de(e);for(const t of l){const l=`${a}${t}`;if(fe(l,e,n))return l}},$e=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.tagName.toLowerCase();if(n.includes("style")||n.includes("script"))return;const a=[];for(;e?.nodeType===Node.ELEMENT_NODE;){let t=e.nodeName?.toLowerCase();if("string"!=typeof e.className||!e.className||o(e.className)||ue?.find(t=>t.element===e&&"class"===t.attributeName)){let n=e,a=1;if(n.previousElementSibling)for(;n=n.previousElementSibling;)n.nodeName?.toLowerCase()===t&&a++;1!==a&&(t+=`:nth-of-type(${a})`),1===a&&n?.parentElement?.childElementCount>1&&(t+=`:nth-child(${a})`)}else if(e.classList.remove("marked-element-temp"),e.classList.remove("removePointers"),e.className){t+=`.${e.className.trim().replace(/\s+/g,".")}`,a.unshift(t);break}a.unshift(t),e=e.parentElement}return a.join(" > ")},ve=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=[];for(;e&&e.nodeType===Node.ELEMENT_NODE;){const t=e.tagName.toLowerCase();if("style"===t||"script"===t)return;let a=t;const l=e.parentNode;if(l){const t=Array.from(l.children).filter(t=>t.tagName===e.tagName);t.length>1&&(a+=`:nth-of-type(${t.indexOf(e)+1})`)}n.unshift(a),e=e.parentElement}return n.join(" > ")},ye={parseCssSelectors:me,getIdCssPath:he,getAttributeCssPath:pe,getClassCssPath:$e,getAbsoluteCssPath:ve},Ne=(e,t,n)=>{const a=D(e);if(Ae(t,a)===n)return!0;if(function(e){return/\[(?:\s*\.|\s*contains\s*\(\s*\.|\s*normalize-space\s*\(\s*\.)/.test(e)}(a)){const e=t.evaluate(a,t,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(let t=0;t<e.snapshotLength;t++)if(e.snapshotItem(t)===n)return!0}return!1},be=(e,t)=>{try{const n=e.querySelector(t);if(n)return n}catch(e){return console.error("Invalid CSS selector:",t,e),null}return Se(e.body,t)},xe=(e,t,n)=>be(t,e)===n,Ee=e=>e.name?.toLowerCase().includes("cssselector")??!1,Se=(e,t)=>{const n=Array.from(e.querySelectorAll("*"));try{for(let e=0;e<n.length;e++)if(n[e].shadowRoot){const{shadowRoot:a}=n[e];if(a){const e=Se(a,t);if(e)return e;if(a&&!t.includes("dynamic"))return a.querySelector(t)}}}catch(e){console.log(e)}return null},ke=e=>e?.id||null,we=e=>e.className||null,Re=e=>e.textContent?.trim()||null,Ce=e=>{const t=e;if(t.hasAttribute("name")){return`${t.getAttribute("name")}`||null}return null},Pe=["/preceding-sibling","/following-sibling","/parent","/descendant","/ancestor","/self","/ancestor-or-self","/child","/preceding","/following"];function Ae(e,t){const n=e.defaultView;if(!n)return null;return(new n.XPathEvaluator).evaluate(t,e,null,n.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}function De(e,t,n){if(e.includes(t)){const a=e.split(t)[0].trim(),l=n.defaultView;if(!l)return null;if(!e.includes("dynamic")){const t=new l.XPathEvaluator;if(t.evaluate(a,n,null,l.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue){let a;return t.evaluate(e,n,null,l.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue?(a=e,a):(console.error("Complete Locator is Invalid:",e),a=e,a)}console.error("Source Locator Not Found:",a)}}return null}const Oe=(e,t)=>{const n=t.querySelectorAll("script, style, link[rel='stylesheet'], meta, noscript, embed, object, param, source, svg");n&&n.forEach(e=>{e.remove()});const a=new Set;let l=[];function r(e,t={}){const n=e?.value,r=t.value??e?.value,o={name:t.name??e?.name,type:t.type??e?.type,value:t.value??e?.value,reference:t.reference??e?.reference,status:t.status??e?.status,isRecorded:t.isRecorded??e?.isRecorded},s="Y"===e?.isSelfHealed;o.isSelfHealed=s?"Y":t.hasOwnProperty("isSelfHealed")?t.isSelfHealed:((e,t,n)=>t&&n&&t===n?null:"Y")(o.name,n,r),function(e){const t=`${e.name}:${e.value}`;a.has(t)||(a.add(t),l.push(e))}(o)}function s(e,t,n){if(Ee(t))return be(e,n);if(t.name.includes("id")||n.startsWith("#"))return e.querySelector("#"+T(n));if(t.name.includes("className")||n.startsWith("."))return e.querySelector("."+n);if("name"===t.name){const t=T(n);return e.querySelector(`[name="${t}"]`)}if("tagName"===t.name)return e.querySelector(n);if("linkText"===t.name)return Array.from(e.querySelectorAll("a")).find(e=>e.textContent?.trim()===n)||null;if("partialLinkText"===t.name)return Array.from(e.querySelectorAll("a")).find(e=>e.textContent?.includes(n))||null;if(!t.name.includes("xpath")&&!n.startsWith("//")||t.type.match("dynamic"))return e.querySelector(n);{const a=Ae(e,D(n));return a&&r(t,{value:n,isRecorded:String(t.isRecorded).includes("N")?"N":"Y"}),a}}function i(e,t,n){const a=e.querySelectorAll("iframe");for(const e of a)try{const a=e.contentDocument||e.contentWindow?.document;if(!a)continue;const l=s(a,t,n);if(l)return l}catch{continue}return null}const c=(e,t,n)=>{if(!e)return null;let a=e.trim();return a&&"null"!==a.toLowerCase()?(a=a.replace(/\\"/g,'"').replace(/\\'/g,"'"),a=a.replace(/^['"](.+?)['"]$/,"$1"),a=a.replace(/''/g,"'"),a=a.replace(/\[@(id|name)=['"]{2}(.+?)['"]{2}\]/g,"[@$1='$2']"),"id"!==t&&"name"!==t||(a=a.replace(/['"]/g,"").trim()),"xpath"!==t||"Y"!==n||e.startsWith("//")?!a||/^['"]{2}$/.test(a)?null:a:null):null};e:for(const n of e.locators)try{String(n.isRecorded||"");const u=e.locators.filter(e=>"N"===e.isRecorded);if(u.length>0)for(const e of u)r(e);const f=String(n.value||n.type||"");if(f.includes("dynamic")||f.match("dynamic")||f.includes("{")||f.includes("}")){r(n);continue}if(e.isShared.includes("Y"))break e;try{let u=null;const f=n.value.split(">>>");for(const e of f){if(!t){console.error("Element not found at:",e);break}const a=e.trim();if(u=s(t,n,a),u||(u=i(t,n,a)),u||(u=Se(t.body,a)),!u){console.error("Element not found at:",a);break}}const m=(e,t)=>{const n=`${e}:${t}`;return a.has(n)};if(u){const n=e.locators.filter(e=>"xpath"===e.name&&e.value),a=e.locators.filter(e=>Ee(e)&&e.value);for(const e of n)Ne(e.value,t,u)&&r(e,{isSelfHealed:null});for(const e of a)xe(e.value,t,u)&&r(e,{isSelfHealed:null});const s=l.filter(e=>"xpath"===e.name&&e.value),i=new Set(s.map(e=>X(e.value))),f=[],h=ke(u);if(h&&!m("id",h)&&!o(h)){const n=e.locators.find(e=>"id"===e.name);j(t,"id",h,u)&&(f.push("id"),r(n,{name:"id",type:"static",isRecorded:"Y",value:h}))}const g=u.tagName;if(g&&!m("tagName",g)){const n=e.locators.find(e=>"tagName"===e.name);j(t,"tagName",g,u)&&(f.push("tagName"),r(n,{name:"tagName",type:"static",isRecorded:"Y",value:g}))}const d=Re(u);if(d&&!o(d)){const n=e.locators.find(e=>"linkText"===e.name);j(t,"linkText",d,u)&&(f.push("linkText"),r(n,{name:"linkText",type:"static",isRecorded:"Y",value:d}))}const p=Ce(u);if(p&&!m("name",p)&&!o(p)){const n=e.locators.find(e=>"name"===e.name);j(t,"name",p,u)&&(f.push("name"),r(n,{name:"name",type:"static",isRecorded:"Y",value:p}))}const $=we(u);if($&&""!==$.trim()&&!$.includes(" ")&&!m("className",$)&&!o($)){const n=e.locators.find(e=>"className"===e.name);j(t,"className",$,u)&&(f.push("className"),r(n,{name:"className",type:"static",isRecorded:"Y",value:$}))}me(u,"single").forEach(e=>{e.value&&!m("cssSelector",e.value)&&r(void 0,{name:"cssSelector",value:e.value,type:"static",isRecorded:"Y"})});const v=Array.from(u.attributes).filter(e=>!f.includes(e.name));let y=[];try{y=ee(u,t,!1,!0,v)??[]}catch(e){console.error("Error generating XPath candidates:",e)}if(0!==y?.length){const e=n.filter(e=>!Ne(e.value,t,u));let a=0;for(const t of e){if(a>=e.length)break;const n=X(t.value);if(i.has(n))continue;const l=y.find(e=>e.value&&X(e.value)===n);l?.value&&(r(t,{name:"xpath",value:l.value,type:"static",isRecorded:"Y",isSelfHealed:"Y"}),i.add(n),a++)}if(a<e.length)for(const t of y){if(a>=e.length)break;if(!t.value)continue;const n=X(t.value);i.has(n)||(r(t,{name:"xpath",value:t.value,type:"static",isRecorded:"Y",isSelfHealed:"Y"}),i.add(n),a++)}}for(const n of e.locators)try{for(const a of e.locators)if(a.value)for(const e of Pe)if(a.value.includes(e)){const l=De(a.value,e,t);if(l){r(a,{name:"xpath",value:l,isRecorded:""!==n.isRecorded&&null!==n.isRecorded?n.isRecorded:"Y"});break}}}catch(e){console.error("Error processing locator:",n,e)}if(l.length<5){const e=[{name:"id",value:ke(u)},{name:"name",value:Ce(u)},{name:"className",value:we(u)},{name:"tagName",value:u.tagName},{name:"linkText",value:Re(u)}];for(const n of e){if(l.length>4)break;const{name:e,value:a}=n;a&&(o(a)||m(e,a)||"className"===e&&a.includes(" ")||j(t,e,a,u)&&r(void 0,{name:e,type:"static",value:a,isRecorded:"Y",isSelfHealed:"Y"}))}l.length<5&&me(u,"multiple").forEach(e=>{l.length>4||e.value&&(m("cssSelector",e.value)||j(t,"cssSelector",e.value,u)&&r(void 0,{name:"cssSelector",type:"static",value:e.value,isRecorded:"Y",isSelfHealed:"Y"}))})}const N=l.map(e=>({...e,value:c(e.value,e.name,e.isRecorded)})),b=[{name:`${e.name}`,desc:`${e.desc}`,type:`${e.type}`,locators:N.filter(e=>null!=e?.value&&""!==e.value),isShared:`${e.isShared}`,projectId:`${e.projectId}`,projectType:`${e.projectType}`,isRecorded:`${e.isRecorded}`,folder:`${e.folder}`,parentId:`${e.parentId}`,parentName:`${e.parentName}`,platform:`${e.platform}`,licenseId:`${e.licenseId}`,licenseType:`${e.licenseType}`,userId:`${e.userId}`}];return b}}catch(e){console.error("Error processing locator:",n,e);continue}}catch(e){console.error("Error processing locator:",n,e);continue}return null},Xe=()=>({xpath:te,referenceXpaths:ce,xpathUtils:L,getElementsFromHTML:Oe,cssSelectors:ye});e.createXPathAPI=Xe,e.default=Xe,Object.defineProperty(e,"__esModule",{value:!0})}(this.XpathLib=this.XpathLib||{});
1
+ !function(e){"use strict";const t=/^[\S]+( [\S]+)*$/i;let n=new WeakMap;const a=e=>{e?(e=>{const t=[],n=e=>{e&&!t.includes(e)&&t.push(e)};n(e);const a=e.getRootNode?.();return(a instanceof Document||a instanceof ShadowRoot)&&n(a),n(e.nodeType===Node.DOCUMENT_NODE?e:e.ownerDocument),t})(e).forEach(e=>{n.delete(e)}):n=new WeakMap},l=(e,t)=>{const{owner:a,contextNode:l}=(e=>{const t=9===e.nodeType?e:e.ownerDocument||document;return{owner:t,contextNode:1===e.nodeType||9===e.nodeType||11===e.nodeType?e:t}})(t);let r=n.get(l);r||(r=new Map,n.set(l,r));const o=r.get(e);if(o)return o;const s=a.evaluate(e,l,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),i={first:s.iterateNext(),second:s.iterateNext()};return r.set(e,i),i};let r,o=new Map,s=[];const i=new Set(["marked-element-temp","removePointers"]),c=e=>(e||"").split(/\s+/).map(e=>e.trim()).filter(e=>e&&!i.has(e)).sort(),u=(e,t)=>t?"class"===e||"className"===e?c(t).join(" "):t.replace("removePointers","").trim():"",f=e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof Element))return!1;if(S(e.target)&&e.oldValue?.trim()===e.target.classList.value?.trim())return!0;const t=c(e.oldValue),n=c(e.target.getAttribute("class"));return t.join(" ")===n.join(" ")},m=e=>/\d/.test(e),h=(e,t,n)=>t?`//*[local-name()='${n}' and ${e}]`:`//${n}[${e}]`,d=e=>{const t=e?.textContent;return t},g=e=>e?.childNodes[0]?.nodeValue||"",p=(e,t,n,a=!1)=>{try{const{first:r,second:o}=l(e,n);if(!r)return 0;if(!o)return r===t?1:0;if(a&&Array.isArray(t)){let a=0;if(t.includes(r)&&a++,t.includes(o)&&a++,2===a)return 2;const l=(9===n.nodeType?n:n.ownerDocument).evaluate(e,n,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);let s;for(;s=l.iterateNext();)if(t.includes(s)&&(a++,2===a))return 2;return 0}return 2}catch(t){return console.error(`Error evaluating XPath: ${e}`,t),0}},$=e=>{if(e){if(-1!==e.indexOf('"'))return`'${e}'`;if(-1!==e.indexOf("'"))return`"${e}"`}return`'${e}'`},y=e=>{const t=e.split("");let n=t.length;const a=[];for(;"["!==t[n-2];)a.push(t[n-2]),n--;a.reverse();let l="";for(let e=0;e<a.length;e++)l+=a[e];const r=l.length+2;let o=e.slice(0,e.length-r);return o=o.startsWith("(")&&o.endsWith(")")?o.slice(1,-1):e,o},v=(e,t,n,a)=>{try{const l=9===n.nodeType?n:n.ownerDocument;let r=0;if(a){if(1===p(`${e}[${a}]`,t,n))return`${e}[${a}]`;if(1===p(`(${e})[${a}]`,t,n))return`(${e})[${a}]`}const o=l.evaluate(e,n,null,XPathResult.ANY_TYPE,null);let s=null;for(;s=o.iterateNext();)if(r++,s.isSameNode(t))return 1===p(`${e}[${r}]`,t,n)?`${e}[${r}]`:1===p(`(${e})[${r}]`,t,n)?`(${e})[${r}]`:void 0}catch(e){console.log(e)}},N=e=>(e=(e=(e=>(e&&=e.split("\n")[0].length>0?e.split("\n")[0]:e.split("\n")[1],e))(e)).split(/[^\u0000-\u00ff]/).reduce((e,t)=>e.length>t.length?e:t,"").trim()).split("/")[0].trim(),x=e=>e?e.replace(/\s\s+/g," ").trim():e,b=e=>{if(!e||!e?.getRootNode)return null;const t=e.getRootNode();return t&&t?.host?t:null},E=(e,t)=>{const n=e.ownerDocument.implementation.createHTMLDocument("shadow-xpath"),a=n.createElement("div");a.innerHTML=e.innerHTML,n.body.appendChild(a);const l=t=>{if(!(t&&t instanceof e.ownerDocument.defaultView.Element))return null;const n=((e,t)=>{const n=[];let a=t;for(;a&&a.parentElement;){const e=a.parentElement;n.unshift(Array.from(e.children).indexOf(a)),a=e}return a&&a.parentNode===e?(n.unshift(Array.from(e.children).indexOf(a)),n):null})(e,t);return n?((e,t)=>{let n=e;for(const e of t){const t=n.children.item(e);if(!t)return null;n=t}return n})(a,n):null},r=Array.isArray(t)?t.map(e=>l(e)).filter(Boolean):[],o=Array.isArray(t)?null:l(null);return{owner:n,contextNode:a,cloneElement:o,cloneElements:r}},w=(e,t,n)=>{const a=u(e.name,e.value);if(!a||"boolean"==typeof e?.value)return!1;if(["true","false","on","off","flntooltip","flutter-highlight-overlay"].some(e=>e===a))return!1;if(["style","locator-data-tooltip","value"].some(t=>t===e.name))return!1;const l=s?.find(n=>n.doc===t.ownerDocument&&n.element===t&&n.attributeName===e.name);return!l&&(!(0===e?.name?.indexOf("on")&&e?.name?.length>3)&&("function"!=typeof e.value&&(!n||!m(a))))},S=e=>e instanceof SVGElement,k=e=>e?e.replace(/\b[a-zA-Z_]*disabled\b/gi,"disabled"):e,C=(e,n,a,l,r,o)=>{if(l){const{tagName:s}=e;let i,c="";const u=[];let f;if(l&&(!o||!m(l))&&(f=t.test(l)?`//${s}[${a}=${$(l)}]`:h(`normalize-space(${a})=${$(x(l)).trim()}`,S(e),e.tagName.toLowerCase()),i=p(f,e,n),1===i&&!r))return f;if(l&&o){const o=l.split(" ");if(o?.length)if(1===o.length){const u=[...new Set(o[0].match(/([^0-9]+)/g))];if(u?.length>=1&&u[0]&&x(u[0].trim())?.length>1&&l.startsWith(u[0])&&(c=t.test(u[0])?`starts-with(${a},${$(u[0]).trim()})`:`starts-with(${a},${$(x(u[0])).trim()})`),u?.length>1&&u[u.length-1]&&x(u[u.length-1].trim())?.length>1&&l.endsWith(u[u.length-1])&&(c=t.test(u[u.length-1])?`ends-with(${a},${$(u[u.length-1]).trim()})`:`ends-with(${a},${$(x(u[u.length-1])).trim()})`),c?.length&&(f=S(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=p(f,e,n),1===i&&!r))return f}else{const u=o.length%2==0?o.length/2:o.length%2,m=o.slice(0,u).join(" ");let h=[...new Set(m.match(/([^0-9]+)/g))];if(h?.length&&h[0]&&x(h[0].trim())?.length&&l.startsWith(h[0])&&(c=t.test(h[0])?`starts-with(${a},${$(h[0]).trim()})`:`starts-with(${a},${$(x(h[0])).trim()})`),c?.length&&(f=S(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=p(f,e,n),1===i&&!r))return f;const d=o.slice(u,o.length-1).join(" ");if(h=[...new Set(d.match(/([^0-9]+)/g))],h?.length&&h[0]&&x(h[0].trim())?.length>3&&l.endsWith(h[0])&&(c=t.test(h[0])?`ends-with(${a},${$(h[0]).trim()})`:`ends-with(${a},${$(x(h[0])).trim()})`),c?.length&&(f=S(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=p(f,e,n),1===i&&!r))return f}}if(l&&o&&m(l)){const o=[...new Set(l.match(/([^0-9]+)/g))];if(o?.length)for(let e=0;e<o?.length;e++)o[e]&&x(o[e].trim())?.length>1&&(t.test(o[e])?u.push(`contains(${a},${$(o[e].trim()).trim()})`):u.push(`contains(${a},${$(x(o[e])).trim()})`));if(u?.length&&(f=S(e)?`//*[local-name()='${s}' and ${u.join(" and ")}]`:`//${s}[${u.join(" and ")}]`,i=p(f,e,n),1===i&&!r))return f}if(f=S(e)?`//*[local-name()='${s}' and text()]`:`//${s}[text()]`,i=p(f,e,n),1===i&&!r)return f}},R=(e,t)=>{try{if(!e)return"";let n=S(e)?`/*[local-name()='${e.tagName}']`:`/${e.tagName}`;if(e.parentElement){const t=Array.prototype.slice.call(e.parentElement.children,0).filter(t=>t.tagName===e.tagName);if(t.length>1){n+=`[${t.indexOf(e)+1}]`}}else if(e instanceof HTMLElement&&e.offsetParent){const t=Array.prototype.slice.call(e.offsetParent.children,0).filter(t=>t.tagName===e.tagName);if(t.length>1){n+=`[${t.indexOf(e)+1}]`}}return R(e?.parentElement,t)+n}catch(e){return console.log("xpath",e),""}},O=(e,t,n,a=!1,l)=>{try{if(o.has(e))return o.get(e);const r=[];let s=e;for(;s;){let o="",i=!1,c=e===s?l??s.attributes:s.attributes;for(const e of Array.from(c))if(w(e,s,a)){const a=u(e.name,e.nodeValue),l=e.name;o=F(s,l,a);let c=0;if(o&&(c=p(o,s,t),1===c)){r.unshift(k(o)),i=!0;break}if(c>1&&n&&(o=v(o,s,t,c),o)){r.unshift(k(o)),i=!0;break}}if(s.textContent)if(!a||a&&!m(s.textContent)){o=new RegExp(/^[\S]+( [\S]+)*$/gi).test(s.textContent)?S(s)?`//*[local-name()='${s.tagName}' and .=${$(g(s))}]`:`//${s.tagName||"*"}[.=${$(g(s))}]`:S(s)?`//*[local-name()='${s.tagName}' and normalize-space(.)=${$(g(s))}]`:`//${s.tagName||"*"}[normalize-space(.)=${$(g(s))}]`;let e=p(o,s,t);if(1===e)return o;if(e>1&&n)return o=v(o,s,t,e),o}else{let e=[];const a=[...new Set(g(s).match(/([^0-9]+)/g))];let l=new RegExp(/^[\S]+( [\S]+)*$/gi);if(a?.length)for(let t=0;t<a?.length;t++)a[t]&&x(a[t].trim())&&(l.test(a[t])?e.push(`contains(.,${$(a[t].trim()).trim()})`):e.push(`contains(.,${$(x(a[t])).trim()})`));if(e?.length){o=S(s)?`//*[local-name()='${s.tagName}' and ${e.join(" and ")}]`:`//${s.tagName||"*"}[${e.join(" and ")}]`;let a=p(o,s,t);if(1===a)return o;if(a>1&&n)return o=v(o,s,t,a),o}}if(i)break;{let e=S(s)?`/*[local-name()='${s.tagName}']`:`/${s.tagName}`;if(s.parentElement){const t=Array.from(s.parentElement.children).filter(e=>e.tagName===s.tagName);if(t.length>1){e+=`[${t.indexOf(s)+1}]`}}r.unshift(e)}s=s.parentElement}const i=`${r.join("")}`;return o.set(e,i),i}catch(e){return console.log(e),null}},T=(e,n)=>{const a=[];let l="";if(e&&!m(e.value)&&"function"!=typeof e.nodeValue){const r=[...new Set(e.value.match(/([^0-9]+)/g))];if(r?.length)for(let n=0;n<r?.length;n++)r[n]&&x(r[n].trim())?.length>2&&(t.test(r[n])?a.push(`contains(@${e.name},${$(r[n].trim())})`):a.push(`contains(@${e.name},${$(x(r[n])).trim()})`));if(a?.length)return l=S(n)?`//*[local-name()='${n.tagName}' and ${a.join(" and ")}]`:`//${n.tagName}[${a.join(" and ")}]`,l}},A=(e,n,a,l)=>{try{const r=a.filter(t=>w(t,e,l)),o=a=>{const l=u(a.name,a.nodeValue);if(!l)return[];if("class"===a.name){const t=l.split(/\s+/).map(e=>e.trim()).filter(Boolean);if(!t.length)return[];const a=t.map(t=>{const a=h(`contains(@class,${$(t)})`,S(e),e.tagName.toLowerCase());return{token:t,count:M(a,e,n)}}).sort((e,t)=>e.count!==t.count?e.count-t.count:t.token.length-e.token.length);return a[0]?.token?[`contains(@class,${$(a[0].token)})`]:[]}return t.test(l)?[`@${a.name}="${l}"`]:[`normalize-space(@${a.name})="${l}"`]},s=()=>{const n=x(d(e)?.trim()||"");if(!n||n.length>80||/^\d+$/.test(n))return[];const a=new Set;return t.test(n)&&n.length<=40&&a.add(`text()=${$(n)}`),n.includes(" ")&&a.add(`normalize-space(text())=${$(x(n))}`),a.add(`contains(text(),${$(n)})`),Array.from(a)},i=(e,t)=>{const n=[],a=(l,r)=>{if(r.length!==t)for(let t=l;t<e.length;t++)r.push(e[t]),a(t+1,r),r.pop();else n.push([...r])};return a(0,[]),n},c=t=>S(e)?`//*[local-name()='${e.tagName}' and ${t.join(" and ")}]`:`//${e.tagName}[${t.join(" and ")}]`,f=()=>{if(!(r.length<2))for(let t=2;t<=r.length;t++){const a=i(r,t);for(const t of a){let a=[];for(const e of t){const t=o(e);t.length&&a.push(...t)}if(a.length<2)continue;const l=c(a);let r;try{r=p(l,e,n)}catch{continue}if(1===r)return l}}},m=f();if(m)return m;const g=s();if(!g.length||!r.length)return;for(let t=1;t<=r.length;t++){const a=i(r,t);for(const t of a){let a=[];for(const e of t)a.push(...o(e));if(a.length)for(const t of g){const l=[...a,t],r=c(l);try{if(1===p(r,e,n))return r}catch{continue}}}}}catch(e){console.log(`XPath generation error: ${JSON.stringify(e,null,2)}`)}},D=(e,n,a)=>{let l=S(e),r="";if(w(n,e,a)){let a=u(n.name,n.value);const o=n.name;r=t.test(a)?l?`*[local-name()='${e.tagName}' and @${o}=${$(a)}]`:`${e.tagName||"*"}[@${o}=${$(a)}]`:l?`*[local-name()='${e.tagName}' and normalize-space(@${o})=${$(a)}]`:`${e.tagName||"*"}[normalize-space(@${o})=${$(a)}]`}return r},P=(e,n)=>{if(!e.textContent)return"";const a=g(e);let l;return l=t.test(a)?S(e)?`//*[local-name()='${e.tagName}' and .=${$(a)}]`:`//${e.tagName||"*"}[.=${$(a)}]`:S(e)?`//*[local-name()='${e.tagName}' and normalize-space(.)=${$(a)}]`:`//${e.tagName||"*"}[normalize-space(.)=${$(a)}]`,l},X=(e,t,n)=>h(`normalize-space(${t})=${$(x(n)).trim()}`,S(e),e.tagName.toLowerCase()),L=(e,t,n)=>h(`starts-with(${t},${$(x(n)).trim()})`,S(e),e.tagName.toLowerCase()),_=(e,t,n)=>h(`contains(${t},${$(x(n)).trim()})`,S(e),e.tagName.toLowerCase()),I=(e,n)=>{const a=n.map(n=>(n=>{const a=u(n.name,n.value);if(!a)return null;if("class"===n.name){const t=a.split(/\s+/).map(e=>e.trim()).filter(Boolean),n=e.getRootNode?.()??e.ownerDocument,l=t.map(t=>{const a=h(`contains(@class,${$(t)})`,S(e),e.tagName.toLowerCase());return{token:t,count:M(a,e,n)}}).sort((e,t)=>e.count!==t.count?e.count-t.count:t.token.length-e.token.length)[0]?.token;return l?`contains(@class,${$(l)})`:null}return t.test(a)?`@${n.name}=${$(a)}`:`normalize-space(@${n.name})=${$(a)}`})(n)).filter(Boolean);if(a.length>=2)return h(`${a[0]} or ${a[1]}`,S(e),e.tagName.toLowerCase());const l=(()=>{const n=x(d(e)?.trim()||"");return!n||n.length>80||/^\d+$/.test(n)?null:t.test(n)&&n.length<=40?`text()=${$(n)}`:n.includes(" ")?`normalize-space(text())=${$(n)}`:`contains(text(),${$(n)})`})();return 1===a.length&&l?h(`${a[0]} or ${l}`,S(e),e.tagName.toLowerCase()):""},M=(e,t,n)=>{try{return p(e,t,n)}catch(e){return 0}},j=(e,t)=>{const n=[],a=new Set,l=Array.from(e.attributes||[]),r=["id","data-testid","data-test","data-qa","name","aria-label","role"],o=[...r.map(e=>l.find(t=>t.name===e)).filter(Boolean),...l.filter(e=>!r.includes(e.name))],s=l=>{l&&!a.has(l)&&q(l,e,t)&&(a.add(l),n.push(l))};o.forEach(t=>{if(!w(t,e,!1))return;const n="id"===t.name?`//*[@id=${$(u(t.name,t.value))}]`:F(e,t.name,t.value);n&&s(n)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const t=P(e);t&&s(t)}if(l.length>1){const n=A(e,t,l,!1);n&&s(n)}return n},Y=(e,t)=>{const n=[];let a=t;for(;a&&a!==e;)n.unshift(W(a)),a=a.parentElement;return a===e?n.join("/"):""},z=(e,t)=>{const n=t??(e.getRootNode?.()||e.ownerDocument),a=W(e),l=S(e)?`//*[local-name()='${e.tagName.toLowerCase()}']`:`//${e.tagName.toLowerCase()}`;for(let t=e.parentElement;t;t=t.parentElement){const l=j(t,n);for(const r of l){console.log(`Trying ancestor XPath: ${r}`);const l=`${r}/descendant::${a}`;console.log(`Trying descendant XPath: ${l}`);const o=M(l,e,n);if(console.log(`Match count: ${o}`),1===o&&V(l,n)===e)return console.log(`Selected XPath: ${l}`),l;const s=Y(t,e);if(s){const t=`${r}/${s}`;console.log(`Trying descendant XPath: ${t}`);const a=M(t,e,n);if(console.log(`Match count: ${a}`),1===a&&V(t,n)===e)return console.log(`Selected XPath: ${t}`),t}}}console.log(`Trying descendant XPath: ${l}`);const r=M(l,e,n);return console.log(`Match count: ${r}`),1===r&&V(l,n)===e?(console.log(`Selected XPath: ${l}`),l):(console.log("Selected XPath: "),"")},V=(e,t)=>{try{if(n=t,n?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in n){const{owner:n,contextNode:a,cloneElement:l}=E(t);return n.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue||l}return t.evaluate(e,t,null,t.defaultView.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch(e){return null}var n},q=(e,t,n)=>{try{const{first:a,second:r}=l(e,n);return!!a&&!r&&a===t}catch{return!1}},W=e=>S(e)?`*[local-name()='${e.tagName.toLowerCase()}']`:e.tagName.toLowerCase(),U=(e,t,n)=>{if(!(e instanceof Element))return[];const a=new Set,l=[],r=Array.from(e.attributes||[]).filter(t=>{return t?.value&&(a=t.value,!/\d/.test(a))&&w(t,e,n);var a}),o=(e,t)=>{t&&!a.has(t)&&(a.add(t),l.push({key:e,value:t}))},s=["id","data-testid","data-test","data-qa","name","aria-label","role"];s.forEach(n=>{const a=r.find(e=>e.name===n);if(!a)return;const l="id"===n?`//*[@id='${a.value}']`:F(e,a.name,a.value);l&&q(l,e,t)&&o(`anchor by ${a.name}`,l)}),r.forEach(n=>{if(s.includes(n.name))return;const a=F(e,n.name,n.value);a&&q(a,e,t)&&o(`anchor by ${n.name}`,a)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const n=P(e);n&&q(n,e,t)&&o("anchor by text",n)}if(r.length>1){const a=A(e,t,r,n);a&&q(a,e,t)&&o("anchor by combination",a)}const c=z(e,t);return c&&q(c,e,t)&&o("anchor by tag",c),l},H=e=>{const t=d(e)?.trim(),n=t?$(N(t)):t;if(n)return n!==`'${t}'`?`contains(.,${n})`:`normalize-space(.)='${t}'`},F=(e,t,n)=>{const a=new RegExp(/^[\S]+( [\S]+)*$/gi);let l="";return(n=u(t,n))&&(l=a.test(n)?"class"===t?S(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${$(n)})]`:`//${e.tagName||"*"}[contains(@${t},${$(n)})]`:S(e)?`//*[local-name()='${e.tagName}' and @${t}=${$(n)}]`:`//${e.tagName||"*"}[@${t}=${$(n)}]`:S(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${$(n)})]`:`//${e.tagName||"*"}[contains(@${t},${$(n)})]`),l},B=(e,t)=>e?e.replace(/\bdisabled\b/gi,"flndisabled"):e,G=(e,n,a)=>{let l;const r=[];if(e.textContent&&(!a||a&&!m(e.textContent))&&(t.test(e.textContent)?(l=S(e)?`*[local-name()='${e.tagName}' and .=${$(d(e))}]`:`${e.tagName}[.=${$(d(e))}]`,l&&r.push({key:"getReferenceElementsXpath",value:l})):(l=S(e)?`*[local-name()='${e.tagName}' and ${H(e)})]`:`${e.tagName}[${H(e)}]`,l&&r.push({key:"getReferenceElementsXpath",value:l}))),e.attributes)for(const t of Array.from(e.attributes))if(w(t,e,a)){let n=t.nodeValue;if(n){n=u(t.name,n);const a=t.name;l="class"===a?S(e)?`*[local-name()='${e.tagName}' and contains(@${a},${$(n)})]`:`${e.tagName}[contains(@${a},${$(n)})]`:S(e)?`*[local-name()='${e.tagName}' and @${a}=${$(n)}]`:`${e.tagName}[@${a}=${$(n)}]`,l&&r.push({key:"getReferenceElementsXpath",value:l})}}if(!r?.length){const t=Array.prototype.slice.call(e.attributes);if(t?.length>1){const t=A(e,n,Array.prototype.slice.call(e.attributes),a);t&&r.push({key:"getReferenceElementsXpath",value:t})}}if(!r?.length){const n=[];let l;const o=S(e);if(e.textContent&&a&&m(e.textContent)){const a=[...new Set(e.textContent.match(/([^0-9]+)/g))];if(a?.length)for(let e=0;e<a?.length;e++)a[e]&&x(a[e].trim())?.length>1&&(t.test(a[e])?n.push(`contains(.,${$(a[e]).trim()})`):n.push(`contains(.,${$(x(a[e])).trim()})`));n?.length&&(l=o?`//*[local-name()='${o}' and ${n.join(" and ")}]`:`//${o}[${n.join(" and ")}]`,l&&r.push({key:"getReferenceElementsXpath",value:l}))}}if(!r?.length){const t=((e,t,n,a)=>{const l=Array.prototype.slice.call(e),r=[];try{l.map(e=>{if(w(e,t,a)){const n=T(e,t);n&&r.push({key:`split xpath by ${e.name}`,value:n})}})}catch(e){console.log(e)}return r})(e.attributes,e,0,a);t?.length&&r.concat(t)}return r},J=e=>e=(e=e.replace(/text\(\)\s*=\s*(['"])(.*?)\1/g,"normalize-space(.)=$1$2$1")).replace(/\.\s*=\s*(['"])(.*?)\1/g,"normalize-space(.)=$1$2$1"),Z=(e,t)=>{let n=t,a=1;for(;a>0;){const t=e[++n];"("==t?a++:")"==t&&a--}return n};function K(e){const t=function(e){return e.toLowerCase().replace(/'[^']*'/g,"?").replace(/"[^"]*"/g,"?").replace(/\[\d+\]/g,"[?]").replace(/\/\/[a-z0-9_-]+/g,"//node").replace(/\/[a-z0-9_-]+/g,"/node")}(e),n=function(e){const t=e.toLowerCase(),n=t.match(/(ancestor-or-self|ancestor|descendant-or-self|descendant|following-sibling|preceding-sibling|following|preceding|parent|child|self)::/),a=n?.[1]??"none",l=t.match(/@([a-z0-9:-]+)/);return{axis:a,attribute:l?.[1]??"none",usesNormalize:t.includes("normalize-space")}}(e);return["XPATH",`axis:${n.axis}`,`attr:${n.attribute}`,`normalize:${n.usesNormalize}`,`shape:${t}`].join("|")}function Q(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/ /g,"\\ ")}function ee(e,t,n,a){const l=a?.getRootNode?.()??e,r=e=>{try{return Array.from(l.querySelectorAll(e))}catch{return[]}};try{switch(t){case"id":return 1===r(`#${Q(n)}`).length;case"name":return 1===r(`[name="${Q(n)}"]`).length;case"className":return 1===r(`.${n}`).length;case"tagName":case"cssSelector":return 1===r(n).length;case"linkText":return 1===r("a").filter(e=>e.textContent?.trim()===n).length;case"partialLinkText":return 1===r("a").filter(e=>e.textContent?.includes(n)).length;default:return!1}}catch{return!1}}const te={parseXml:(e,t)=>window.DOMParser?(new window.DOMParser).parseFromString(e,t):null,getReferenceElementsXpath:G,getAbsoluteXPath:R,getRelativeXPath:O,getCombinationXpath:T,getAttributeCombinationXpath:A,getElementFromXpath:(e,t,n=!1)=>{let a=t;t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(a=t.host??t);const l=a.nodeType===Node.DOCUMENT_NODE?a:a.ownerDocument;return n?l.evaluate(e,a,null,XPathResult.ANY_TYPE,null):l.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue},isSvg:S,findXpathWithIndex:v,isNumberExist:m,getTextContent:d,getCountOfXPath:p,normalizeXPath:J,getShadowRoot:b,escapeCharacters:$,removeParenthesis:y,checkBlockedAttributes:w,getRelationship:(e,t)=>{let n=e.compareDocumentPosition(t);return 2===n?"preceding":4===n?"following":8===n?"ancestor":16===n?"descendant":32===n?"self":""},findMatchingParenthesis:Z,deleteGarbageFromInnerText:N,replaceTempAttributes:k,createObserver:e=>{r=new MutationObserver(t=>{t.forEach(t=>{("childList"===t.type||"characterData"===t.type||"attributes"===t.type&&"flndisabled"!==t.attributeName&&!f(t))&&a(t.target),t?.addedNodes?.length&&e(t?.addedNodes),t.target instanceof HTMLElement&&(f(t)||"attributes"!==t?.type||["flndisabled"].includes(t.attributeName)||s.push({url:t.target.baseURI,attributeName:t.attributeName,element:t.target,doc:t.target.ownerDocument}))})})},startObserver:(e,t)=>{r?.observe(e,t)},stopObserver:()=>{r?.disconnect()},modifiedElementAttributes:s,cspEnabled:!1,getXPathPattern:K,getNormalizedPropertyXPath:X,getStartsWithPropertyXPath:L,getContainsPropertyXPath:_,getOrAttributesXPath:I,getTagOnlyXPath:z,getFirstMatchedNode:V,isExactUniqueXpath:q,getAxisNodeTest:W,getUniqueNodeAnchorXpaths:U,escapeAttrValue:Q,isUniqueInDOM:ee,sanitizeAttributeValue:u};let ne=[],ae=[],le=new Map,re=new Map;const oe=new Map,se={andConditions:"and",orConditions:"or",contains:"contains",startsWith:"startsWith",normalizeSpace:"normalizeSpace",axes:"axes",index:"index",hardCodedText:"text",tillTag:"tag"},ie=(e,t)=>t.map(t=>({...t,key:t?.key?.includes(e)?t.key:`${e} ${t.key}`.trim()})),ce=e=>e?.textContent?.replace(/\s+/g," ")?.trim()||"",ue=e=>{if(!(e&&e instanceof Element))return[];const t=[],n=Array.from(e.children||[]);for(;n.length;){const e=n.shift();e.classList?.contains("flntooltip")||(t.push(e),n.push(...Array.from(e.children||[])))}return t},fe=(e,t)=>{const n=[];let a="previous"===t?e.previousElementSibling:e.nextElementSibling;for(;a;)a.classList?.contains("flntooltip")||n.push(a),a="previous"===t?a.previousElementSibling:a.nextElementSibling;return n},me=(e,t)=>{const n=[];for(let a=e;a?.parentElement;a=a.parentElement){let e="previous"===t?a.previousElementSibling:a.nextElementSibling;for(;e;)e.classList?.contains("flntooltip")||(n.push(e),n.push({node:e,expand:()=>ue(e)})),e="previous"===t?e.previousElementSibling:e.nextElementSibling}return n},he=e=>{if(!(e instanceof Element))return!0;const t=e.textContent?.trim();return!e.id&&!e.className&&0===e.attributes.length&&(!t||t.length>60)&&e.children.length>2},de=(e,t,n,a,l,r,o)=>{const s=W(n),i=[];let c=0;const u=t.includes("descendant")?10:20;for(const f of e){if(c++>u)break;if(i.length>=5)break;const e="node"in f?f.node:f;if(!(e instanceof Element))continue;if(he(e))continue;const m=[()=>U(e,a,l),()=>{const t=[],n=Array.from(e.attributes||[]).filter(t=>t?.value&&!/\d/.test(t.value)&&w(t,e,l));for(const a of n){const n=a.value;if(!n)continue;const l=_(e,`@${a.name}`,n);l&&t.push({key:"contains",value:l});const r=L(e,`@${a.name}`,n);r&&t.push({key:"starts-with",value:r})}return t},()=>[{key:"tag",value:z(e,a)}]];for(let l=0;l<m.length;l++){let c=m[l]();if(!c.length)continue;o||(c=c.filter(e=>!/\[\d+\]/.test(e.value)));const u=new Set;c=c.filter(e=>!u.has(e.value)&&(u.add(e.value),!0)),c=c.slice(0,5);for(const e of c){const l=`${e.value}/${t}::${s}`;if(q(l,n,a)){if(i.push({key:r,value:l}),i.length>=2)return i;if(i.length>=5)return i}}if(o&&l===m.length-1)for(const l of c){const o=p(l.value,e,a);for(let e=1;e<=Math.min(o,3);e++){const o=`(${l.value})[${e}]/${t}::${s}`;if(q(o,n,a)){if(i.push({key:r,value:o}),i.length>=2)return i;if(i.length>=5)return i}}}}if("expand"in f&&f.expand){const e=f.expand();let o=0;for(const c of e){if(o++>15)break;if(i.length>=5)break;if(!(c instanceof Element))continue;if(he(c))continue;const e=U(c,a,l);for(const l of e.slice(0,5)){const e=`${l.value}/${t}::${s}`;if(q(e,n,a)){if(i.push({key:r,value:e}),i.length>=2)return i;if(i.length>=5)return i}}}}}return i},ge=(e,t,n,a)=>{const l=[];for(let t=e.parentElement;t;t=t.parentElement)l.push(t);const r=ue(e),o=fe(e,"previous"),s=fe(e,"next"),i=me(e,"previous"),c=me(e,"next"),u=(e,t=20)=>e.length>t?e.slice(0,t):e,f=[[{nodes:u(s),axis:"preceding-sibling",key:"preceding-sibling"},{nodes:u(o),axis:"following-sibling",key:"following-sibling"}],[{nodes:u(l),axis:"child",key:"child"},{nodes:u(r,15),axis:"parent",key:"parent"}],[{nodes:u(l),axis:"descendant",key:"descendant"},{nodes:u(l),axis:"descendant-or-self",key:"descendant-or-self"},{nodes:u(r,10),axis:"ancestor",key:"ancestor"},{nodes:u(r,10),axis:"ancestor-or-self",key:"ancestor-or-self"}],[{nodes:u(i),axis:"following",key:"following"},{nodes:u(c),axis:"preceding",key:"preceding"}]];for(const l of f)for(const r of l){const l=de(r.nodes,r.axis,e,t,n,r.key,a);if(l.length>0)return l}return[]},pe=(e,t,n,a,l)=>{const r=(e=>se[e]||e)(a);return"text"===r?ie(a,((e,t,n)=>{if(!ce(e))return[];if("text"===n){const n=P(e)||ke(e,t,!1,!1);return n?[{key:"xpath by text",value:n}]:[]}return[]})(e,t,r)):["contains","startsWith","normalizeSpace"].includes(r)?ie(a,((e,t,n)=>{const a=[],l=Array.from(e.attributes||[]).filter(n=>n?.value&&w(n,e,t)),r=ce(e),o="contains"===n?_:"startsWith"===n?L:"normalizeSpace"===n?X:null;if(!o)return a;if(l.forEach(t=>{const l=o(e,`@${t.name}`,t.value);l&&a.push({key:`xpath by ${n} ${t.name}`,value:l})}),r){const t=o(e,".",r);t&&a.push({key:`xpath by ${n} text`,value:t})}return a})(e,n,r)):["and","or"].includes(r)?ie(a,((e,t,n,a)=>{const l=Array.from(e.attributes||[]).filter(t=>t?.value&&w(t,e,n));if("and"===a){const a=A(e,t,l,n);return a?[{key:"xpath by combination",value:a}]:[]}if("or"===a&&l.length>=1){const t=I(e,l);return t?[{key:"xpath by or",value:t}]:[]}return[]})(e,t,n,r)):"axes"===r?ie(a,ge(e,t,n,!1)):"index"===r?ie(a,((e,t)=>{const n=[],a=e.tagName.toLowerCase(),l=Array.from(t.querySelectorAll(a)).indexOf(e)+1;if(l<=0)return[];n.push({key:"xpath by index",value:`(//${a})[${l}]`});let r=e.parentElement;for(;r&&r!==t.body;){if(r.id||r.className){const t=r.className?.toString().split(" ").map(e=>e.trim()).find(Boolean),l=r.id?`//${r.tagName.toLowerCase()}[@id='${r.id}']`:t?`//${r.tagName.toLowerCase()}[contains(@class,'${t}')]`:"";if(!l){r=r.parentElement;continue}const o=Array.from(r.querySelectorAll(a)).indexOf(e)+1;if(o>0){n.push({key:"xpath by index",value:`(${l}//${a})[${o}]`});break}}r=r.parentElement}return n})(e,t)):"tag"===r?ie(a,[{key:"xpath till tag",value:z(e,t)}]):[]},$e=(e,t,n,a,l,r)=>{if(e){let o;o="parent"===r?[`${e}/descendant-or-self::${t}`,`${e}/following::${t}`]:[`${e}/ancestor-or-self::${t}`,`${e}/preceding::${t}`];for(const e of o){le?.get(e)||le.set(e,p(e,n,a));const t=le?.get(e);if(1===t)return e;if(t>1&&(ae.length?t<ae[0].count&&(ae.pop(),ae.push({key:"relative xpath by unique parent "+(l?"index":""),value:e,count:t})):ae.push({key:"relative xpath by unique parent "+(l?"index":""),value:e,count:t})),t>1&&l&&!ne.length){const r=v(e,n,a,t);r&&1===p(r,n,a)&&ne.push({key:"relative xpath by unique parent "+(l?"index":""),value:r})}}}return null},ye=(e,n,a,l,r,o)=>{try{if(oe.has(e))return oe.get(e);const s=[];let i=e;for(;i&&1===i.nodeType;){const e=!1;for(const e of Array.from(i.attributes))if(w(e,i,l)){const t=u(e.name,e.nodeValue),l=e.name,s=F(i,l,t);let c;try{c=$e(s,r,a,n,o,"parent")}catch(e){continue}if(c)return c}if(i.textContent&&!i.textContent)if(!l||l&&!m(i.textContent)){let e;e=t.test(i.textContent)?S(i)?`//*[local-name()='${i.tagName}' and .=${$(g(i))}]`:`//${i.tagName||"*"}[.=${$(g(i))}]`:S(i)?`//*[local-name()='${i.tagName}' and normalize-space(.)=${$(g(i))}]`:`//${i.tagName||"*"}[normalize-space(.)=${$(g(i))}]`;const l=$e(e,r,a,n,o,"parent");if(l)return l}else{const e=[],t=[...new Set(g(i).match(/([^0-9]+)/g))],l=new RegExp(/^[\S]+( [\S]+)*$/gi);if(t?.length)for(let n=0;n<t?.length;n++)t[n]&&x(t[n].trim())&&(l.test(t[n])?e.push(`contains(.,${$(t[n].trim()).trim()})`):e.push(`contains(.,${$(x(t[n])).trim()})`));if(e?.length){const t=S(i)?`//*[local-name()='${i.tagName}' and ${e.join(" and ")}]`:`//${i.tagName||"*"}[${e.join(" and ")}]`,l=$e(t,r,a,n,o,"parent");if(l)return l}}if(!e){const e=S(i)?`/*[local-name()='${i.tagName}']`:`/${i.tagName}`;s.unshift(e)}i=i.parentElement}const c=s.join("")+r;if(1===p(c,e,n))return oe.set(e,c),c}catch(e){return console.error(e),null}},ve=(e,t,n,a)=>{const l=new Map;if(l.has(e))return l.get(e);const r=[];let o=e;try{for(;o&&1===o.nodeType;){if(!o.tagName)return"";let e=!1;for(const n of Array.from(o.attributes))if(w(n,o,a)){const a=u(n.name,n.nodeValue),l=n.name,s=F(o,l,a);let i;try{i=p(s,o,t)}catch(e){continue}if(1===i){r.unshift(s),e=!0;break}}if(!e&&o.textContent&&!n.textContent){const n=P(o);if(n){if(1===p(n,o,t)){e=!0,r.unshift(n);break}}}if(e)break;{const e=S(o)?`/*[local-name()='${o.tagName}']`:`/${o.tagName}`;r.unshift(e)}o=o.parentElement}const s=r.join("");return l.set(e,s),s}catch(e){return console.log(e),null}},Ne=(e,t,n)=>{const a=[];let l;const r=[];null!=e.firstElementChild&&e.firstElementChild.classList.contains("flntooltip")?r.unshift(e.firstElementChild):null!=e.nextElementSibling&&r.unshift(e.nextElementSibling);for(let t=e.parentElement;null!=t&&1===t.nodeType;t=t.parentElement)t.nextElementSibling&&r.unshift(t.nextElementSibling);try{do{let e=!1;for(l=r.pop();null!==l;){for(const n of Array.from(l.attributes))if(w(n,l,!0)){const r=u(n.name,n.nodeValue),o=n.name,s=F(l,o,r);let i;try{i=p(s,l,t)}catch(e){continue}if(1===i){e=!0,a.push(s);break}}if(!e&&l.textContent&&!n.textContent){const n=P(l);if(n){if(1===p(n,l,t)){e=!0,a.push(n);break}}}if(e)break;{const e=S(l)?`/*[local-name()='${l.tagName}']`:`/${l.tagName}`;a.push(e),null!=l.firstElementChild?(r.push(l.nextElementSibling),l=l.firstElementChild):l=l.nextElementSibling}}}while(r.length>0);const o=a.join("");return re.set(e,o),o}catch(e){return console.log(e),null}},xe=(e,t,n,a)=>{try{const l=document.querySelector(".flntooltip");for(let r=e.nextElementSibling;null!==r&&r!==l;r=r.nextElementSibling)be(r,e,t,a,"preceding-sibling",n);for(let r=e.previousElementSibling;null!==r&&r!==l;r=r.previousElementSibling)be(r,e,t,a,"following-sibling",n)}catch(e){return console.error("sibling error",e),null}},be=(e,t,n,a,l,r)=>{try{if(e.hasAttributes())for(const t of Array.from(e.attributes)){let o=D(e,{name:t.name,value:t.value},r);if(o){o+=`/${l}::${a}`;const t=p(o,e,n);if(1===t)return void ne.push({key:`xpath by ${l}`,value:o});t>1&&(ae.length?t<ae[0].count&&(ae.pop(),ae.push({key:`relative xpath by ${l}`,value:o,count:t})):ae.push({key:`relative xpath by ${l}`,value:o,count:t}))}}if(!r){let t;if(t=D(e,{name:"text",value:e.textContent},r),t){const a=p(t,e,n);if(1===a)return void ne.push({key:`xpath by ${l}`,value:t});a>1&&(ae.length?a<ae[0].count&&(ae.pop(),ae.push({key:`relative xpath by ${l}`,value:t,count:a})):ae.push({key:`relative xpath by ${l}`,value:t,count:a}))}}}catch(e){console.log(`${l} xpath-error`,e)}};function Ee(e,t,n,a){const{tagName:l}=t,r=t.textContent.trim();if(r)for(const o of e)if(w(o,t,a)){let e=u(o.name,o.nodeValue);const a=`//${l}[@${o.name}='${e}' and text()='${r}']`;if(a){if(1==p(a,t,n))return a}}}const we=(e,t,n,a,l)=>{let r;return r=e.name,C(t,n,`@${r}`,e.value,a,l)},Se=(e,t,n,a)=>{let l=e.className;if("string"!=typeof l&&(l=""),l=l?.replace("flndisabled","disabled"),l=u("class",l),l=l?.trim(),l)return C(e,t,"@class",l,n,a)},ke=(e,t,n,a)=>{if(""!=(e.textContent??"").trim()){const l=d(e);if(l)return C(e,t,".",l,n,a)}},Ce=(e,t,n,a,l)=>{const r=e;try{r.map(e=>{if("className"!==e.name&&"class"!==e.name&&w(e,t,l)){const r=we(e,t,n,a,l);r&&ne.push({key:`xpath by ${e.name}${a?" index":""}`,value:r})}});const o=ke(t,n,a,l);if(o&&ne.push({key:"xpath by text"+(a?" index":""),value:o}),r.find(e=>"className"===e.name)&&w(r?.find(e=>"className"===e.name),t,l)){let e=Se(t,n,a,l);e&&ne.push({key:"xpath by class",value:e})}if(!ne.length&&r.length>1){const e=A(t,n,r,l);e&&ne.push({key:"xpath by combination",value:e})}if(!ne.length){const a=Ee(e,t,n,l);a&&ne.push({key:"xpath by textAttribute",value:a})}}catch(e){console.log(e)}},Re=(e,t,n,a,l=[],r=[])=>{ne=[],console.log(e);const o=e,s=o?.getRootNode?.(),i=s?.nodeType===Node.DOCUMENT_FRAGMENT_NODE,c=i?s:o?.ownerDocument||t,u=o.tagName,{attributes:f}=o,m=l.length>0?l:Array.from(f);if(Ce(m,o,c,n,a),r.length){const e=r.flatMap(e=>pe(o,c,a,e));return ne=(e=>{const t=new Set;return e.filter(e=>!(!e?.value||t.has(e.value)||(t.add(e.value),0)))})(e.filter(e=>1===p(e.value,o,c))),ne}if(ne.length){const t=ne.length;for(let n=0;n<t;n++){let t=ne[n].value;t="//*"+t.substring(t.indexOf("//")+2+u.length);1===p(t,e,c)&&ne.push({key:`${ne[n].key} regex`,value:t})}}return ne.length||i||(ne=ge(o,c,a,n)),ne},Oe={parseDOM:Re,getTextXPath:ke,getUniqueClassName:Se,attributesBasedXPath:we,addAllXPathAttributes:Ce,addRelativeXpaths:(e,t,n,a,l)=>{try{let r,o,s=[];if(ne=[],console.log(l),l)for(const t of l){let n=D(e,{name:t.name,value:t.value},a);console.log(n),n&&s.push(n)}if(e.textContent){let t=D(e,{name:"text",value:e.textContent},a);console.log(t),t&&s.push(t)}if(s.push(e.tagName),s?.length)for(let l=0;l<s.length;l++)if(!ne.length){if(xe(e,t,a,s[l]),!ne.length&&(r||(r=ve(e.parentElement,t,e,a)),console.log(r),r&&(r.includes("@")||r.includes("text()")||r.includes(".="))&&r.match(/\//g)?.length-2<5)){const a=r+`/${s[l]}`,o=p(a,e,t);if(1===o)ne.push({key:"relative xpath by relative parent",value:a});else if(o>1&&n){const l=v(a,e,t,o);l&&1===p(l,e,t)&&ne.push({key:"relative xpath by relative parent "+(n?"index":""),value:l})}}if(!ne.length&&(o||(o=Ne(e,t,e)),o&&(o.includes("@")||o.includes("text()")||o.includes(".=")))){const a=`/${s[l]+o.substring(1)}`,r=p(a,e,t);if(1===r)ne.push({key:"relative xpath by relative child",value:a});else if(r>1&&n){const l=v(a,e,t,r);l&&1===p(l,e,t)&&ne.push({key:"relative xpath by relative parent "+(n?"index":""),value:l})}}if(1===ne?.length&&ne?.[0]?.value?.match(/\[([0-9]+)\]/gm)?.length>3&&e.textContent){const a=ke(e,t,n,!1);a&&ne.unshift({key:"xpath by text"+(n?"index":""),value:a})}if(!ne.length){let r=ye(e.parentElement,t,e,a,s[l],n);r&&ne.push({key:"xpath by unique parent",value:r})}}return ne}catch(e){console.log(e)}},getXPathUsingAttributeAndText:Ee,getSiblingRelativeXPath:xe,getChildRelativeXpath:Ne,getParentRelativeXpath:ve,getUniqueParentXpath:ye,checkRelativeXpathRelation:$e,buildAxesStrategyXpaths:ge};let Te=[],Ae=[];const De=/^[\S]+( [\S]+)*$/gi,Pe=(e,t,n,a,l,r,o,s=0,i=!1)=>{let c="";if(t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g)?.length>=r.length){const c=[],u=t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);for(let e=1;e<=r.length;e++)c.unshift(e===r.length?r[r.length-e]:u[u.length-e]);const f=Ye(`${o+(s?"]".repeat(s):"")}`,c,e[e.length-1],e,a,n,l,i);if(f)return f}else{c=`//${o+(s?"]".repeat(s):"")}/${n}::${B(t,e[e.length-1])}`;let r=p(c,e[e.length-1],a);if(1===r)return[{key:`dynamic ${n}`,value:k(c)}];if(r>1&&l&&(c=v(c,e[e.length-1],a,r),c&&(r=p(c,e[e.length-1],a),1===r)))return[{key:`dynamic ${n} ${l?" index":""}`,value:k(c)}]}},Xe=(e,t,n,a,l,r=!1,o=!1)=>{const s=e[e.length-2],i=e[e.length-1],c=b(i)??i.ownerDocument,f=n.find(e=>e?.key?.includes("absolute"))?.value||R(s,s.ownerDocument),m=[],h=[];f.split("/").map(e=>m.push(e)),m.map(e=>h.push(e.replace(/\[([0-9]+)\]/gm,"")));const g=a.find(e=>e?.key?.includes("absolute"))?.value||R(i,i.ownerDocument),p=[],y=[];g.split("/").map(e=>p.push(e)),p.map(e=>y.push(e.replace(/\[([0-9]+)\]/gm,"")));for(var v=0;v<m.length&&m[v]==p[v];v++);const N=[];for(let e=v-1;e<m.length;e++)m[e]&&N.push(h[e]);const x=[];for(let e="descendant"===l?v:v-1;e<p.length;e++)p[e]&&(x.length?x.push(y[e]):x.push(y[e].replace(/\[([0-9]+)\]/gm,"")));let E;if(Ae=a,e[e.length-2].textContent){E=De.test(e[e.length-2].textContent)?S(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and .=${$(d(e[e.length-2]))}]`:`${e[e.length-2].tagName}[.=${$(d(e[e.length-2]))}]`:S(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${H(e[e.length-2])})]`:`${e[e.length-2].tagName}[${H(e[e.length-2])}]`,N[N.length-1]=E;const n=N.join("["),a=N.length-1,s=n;for(let n=0;n<Ae.length;n++){let i;if(i=Ae[n].value.startsWith("//")?Ae[n].value.substring(Ae[n].value.indexOf("//")+2):Ae[n].value,i)return Pe(e,i,l,c||t,r,x,s,a,o)}}if(e[e.length-2].attributes){for(const n of Array.from(e[e.length-2].attributes))if(w(n,e[e.length-2],!1)){let a=n.nodeValue;if(a){a=u(n.name,a);const s=n.name;E=S(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and @${s}=${$(a)}]`:`${e[e.length-2].tagName}[@${s}=${$(a)}]`,N[N.length-1]=E;const i=N.join("["),f=N.length-1,m=i;for(let n=0;n<Ae.length;n++){let a;return a=Ae[n].value.startsWith("//")?Ae[n].value.substring(Ae[n].value.indexOf("//")+2):Ae[n].value,Pe(e,a,l,c||t,r,x,m,f,o)}}}for(const n of Array.from(e[e.length-2].attributes))if(w(n,e[e.length-2],!1)){let a=n.nodeValue;if(a){a=u(n.name,a);const s=T(n,e[e.length-2]);if(s){E=s.startsWith("//")?s.substring(s.indexOf("//")+2):s,N[N.length-1]=E;const n=N.join("["),a=N.length-1,i=n;for(let n=0;n<Ae.length;n++){let s;return s=Ae[n].value.startsWith("//")?Ae[n].value.substring(Ae[n].value.indexOf("//")+2):Ae[n].value,Pe(e,s,l,c||t,r,x,i,a,o)}}}}}const k=N.join("["),C=N.length-1,O=Ye(`${k+(C?"]".repeat(C):"")}`,x,e[e.length-1],e,t,l,r,o);if(O)return O},Le=(e,t,n,a,l,r,o)=>{let s,i;console.log("getXpathRelationExpression",n);const c=[];try{if(s=a.filter(e=>!e?.key?.includes("absolute")),i=l.filter(e=>!e?.key?.includes("absolute")),"ancestor"===n||"ancestor-or-self"===n){const a=je(e,t,n,s,i,r);if(a.length)return a}for(let e=0;e<s.length;e++)for(let a=0;a<i.length;a++){let l=`//${0!==s[e].value.indexOf("//")?B(s[e].value):B(s[e].value.substring(s[e].value.indexOf("//")+2))}/${n}::${0!==i[a].value.indexOf("//")?B(i[a].value):B(i[a].value.substring(i[a].value.indexOf("//")+2))}`;console.log("getXpathRelationExpression",l);const o=p(l,t,t.ownerDocument);if(o>1)if(r){if(l=v(l,t,t.ownerDocument,o),l)return c.push({key:`dynamic ${n}${r?" index":""}`,value:k(l)}),c}else o>1&&(Te.length?o<Te[0].count&&(Te.pop(),Te.push({key:"relative xpath by relative child "+(r?"index":""),value:l,count:o})):Te.push({key:"relative xpath by relative child "+(r?"index":""),value:l,count:o}));else if(1===o)return c.push({key:`dynamic ${n}`,value:k(l)}),c}if(!c.length)for(let a=0;a<s.length;a++)for(let l=0;l<i.length;l++){const u=`${0!==i[l].value.indexOf("//")?i[l].value:i[l].value.substring(i[l].value.indexOf("//")+2)}`.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);if(u.length>1){const l=Ye(`${0!==s[a].value.indexOf("//")?B(s[a].value):B(s[a].value.substring(s[a].value.indexOf("//")+2))}`,u,t,[e,t],t.ownerDocument,n,r,o);if(console.log("getXpathRelationExpression traverseXpath",l),l)return c.push(...l),c}}}catch(e){console.log(e)}return c},_e=/\/(?=(?:[^']*'[^']*')*[^']*$)/g,Ie=e=>0===e.indexOf("//")?e.substring(e.indexOf("//")+2):e,Me=(e,t)=>{for(const e of t){const t=Ie(e.value);if(t&&1===t.split(_e).length)return B(t)}if(e.textContent){const t=H(e);if(t)return S(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`}if(e.attributes)for(const t of Array.from(e.attributes))if(w(t,e,!1)&&t.nodeValue)return S(e)?`*[local-name()='${e.tagName}' and @${t.name}=${$(u(t.name,t.nodeValue))}]`:`${e.tagName}[@${t.name}=${$(u(t.name,t.nodeValue))}]`;return S(e)?`*[local-name()='${e.tagName}']`:e.tagName},je=(e,t,n,a,l,r)=>{const o=[],s=((e,t)=>{let n=e;for(;n;){if(n.contains(t))return n;n=n.parentElement}return null})(e,t);if(!s||s===t)return o;const i=S(s)?`*[local-name()='${s.tagName}']`:s.tagName,c=((e,t,n)=>{const a=[];let l=t;for(;l&&l!==e;){const e=l===t?Me(t,n):S(l)?`*[local-name()='${l.tagName}']`:l.tagName;a.unshift(e),l=l.parentElement}return l===e?a.join("/"):""})(s,t,l);if(!c)return o;for(const e of a){const a=Ie(e.value);if(!a)continue;let l=`//${B(a)}/${n}::${i}/${c}`,s=p(l,t,t.ownerDocument);if(1===s)return o.push({key:`dynamic ${n} bridge`,value:k(l)}),o;if(s>1&&r&&(l=v(l,t,t.ownerDocument,s),s=l?p(l,t,t.ownerDocument):0,l&&1===s))return o.push({key:`dynamic ${n} bridge index`,value:k(l)}),o}return o},Ye=(e,t,n,a,l,r,o,s)=>{let i;if(s){const s=t.join("/");i=`//${e}/${r}::${B(s)}`;const c=p(i,n,l);if(1===c)return[{key:`dynamic ${r}`,value:k(i)}];if(c>1&&o&&(i=v(i,a[a.length-1],l,c),i))return[{key:`dynamic ${r}${o?" index":""}`,value:k(i)}]}else for(let s=1;s<=t.length;s++){const c=t.slice(t.length-s,t.length).join("/");i=`//${e}/${r}::${B(c)}`;const u=p(i,n,l);if(1===u)return[{key:`dynamic ${r}`,value:k(i)}];if(u>1&&o&&(i=v(i,a[a.length-1],l,u),i))return[{key:`dynamic ${r}${o?" index":""}`,value:k(i)}]}},ze={findRelativeXpath:(e,t,n,a,l,r,o=!1,s=null)=>{let i=[];const c=s||[],u=(r,s)=>{let c=[];c="descendant"===r||"descendant-or-self"===r?Xe([e,t],n,a,l,r,s,o)||[]:Le(e,t,r,a,l,s,o)||[],c.length&&(i=i.concat(c))};for(const e of c)u(e,r);return i},getDescendantXpath:Xe,getAncestorBridgeXpath:je,getXpathRelationExpression:Le,getTraverseXpathExpression:Ye,getReferenceElementXpath:e=>{let t=[];if(t=Re(e,e.ownerDocument,!1,!1),t?.length){let n=Re(e,e.ownerDocument,!0,!1);n?.length&&(n=n?.map(e=>"("==e.value.charAt(0)&&Z(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:y(e.value)}:{key:"",value:e.value}),t=t.concat(n))}else t=Re(e,e.ownerDocument,!0,!1),t=t?.map(e=>"("==e.value.charAt(0)&&Z(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:y(e.value)}:{key:"",value:e.value});if(t?.length||(t=[{key:"",value:O(e,e.ownerDocument,!1,!1,Array.from(e.attributes))}]),t?.length||(t=[{key:"",value:O(e,e.ownerDocument,!0,!1,Array.from(e.attributes))}],t=t?.map(e=>"("==e.value.charAt(0)&&Z(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:y(e.value)}:{key:"",value:e.value})),t?.length){const n=G(e,e.ownerDocument,!1);n?.length&&(t=t.concat(n))}else t=G(e,e.ownerDocument,!1);const n=R(e,e.ownerDocument);return t=t.filter(e=>e.value!==n),t.push({key:"absolute xpath",value:n.slice(1)}),t},getSmartRelations:(e,t)=>{const n=e.compareDocumentPosition(t),a=[],l=[],r=[];n&Node.DOCUMENT_POSITION_CONTAINS&&a.push("ancestor","ancestor-or-self","parent"),n&Node.DOCUMENT_POSITION_CONTAINED_BY&&a.push("child"),e.parentElement===t.parentElement&&a.push("following-sibling","preceding-sibling"),n&Node.DOCUMENT_POSITION_FOLLOWING&&l.push("following"),n&Node.DOCUMENT_POSITION_PRECEDING&&l.push("preceding"),r.push("descendant","descendant-or-self");const o=[...a,...l,...r];return[...new Set(o)]}};let Ve=[];const qe=(e,t,n)=>{try{const a=n.querySelectorAll(e);return 1===a.length&&a[0]===t}catch{return!1}},We=(e,t="single")=>{const n=[],a=e.getRootNode();try{const l=Ue(e);if(l&&qe(l,e,a)&&(n.push({key:"cssSelector by id",value:l}),"single"===t))return n;const r=Ge(e);r&&qe(r,e,a)&&n.push({key:"cssSelector by class",value:r});const o=Be(e);o&&n.push({key:"cssSelector by name",value:o})}catch(e){console.error(e)}return n},Ue=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.tagName.toLowerCase();if(n.includes("style")||n.includes("script"))return;const a=[];for(;e?.nodeType===Node.ELEMENT_NODE;){let t=e.nodeName?.toLowerCase();if(e.id&&!m(e.id)){t+=`#${CSS.escape(e.id)}`,a.unshift(t);break}{let n=e,a=1;if(n.previousElementSibling)for(;n=n.previousElementSibling;)n.nodeName?.toLowerCase()===t&&a++;1!==a&&(t+=`:nth-of-type(${a})`),1===a&&n?.parentElement?.childElementCount>1&&(t+=`:nth-child(${a})`)}a.unshift(t),e=e.parentElement}return a.join(" > ")},He=new Set(["id","class","style"]);function Fe(e){return Array.from(e.attributes).filter(e=>!He.has(e?.name?.toLowerCase())&&e.value&&!m(e.value)).map(e=>{return`[${e.name}="${t=e.value,String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`;var t})}const Be=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.getRootNode(),a=e.tagName.toLowerCase();if("style"===a||"script"===a)return;const l=Fe(e);for(const t of l){const l=`${a}${t}`;if(qe(l,e,n))return l}},Ge=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.tagName.toLowerCase();if(n.includes("style")||n.includes("script"))return;const a=[];for(;e?.nodeType===Node.ELEMENT_NODE;){let t=e.nodeName?.toLowerCase();if("string"!=typeof e.className||!e.className||m(e.className)||Ve?.find(t=>t.element===e&&"class"===t.attributeName)){let n=e,a=1;if(n.previousElementSibling)for(;n=n.previousElementSibling;)n.nodeName?.toLowerCase()===t&&a++;1!==a&&(t+=`:nth-of-type(${a})`),1===a&&n?.parentElement?.childElementCount>1&&(t+=`:nth-child(${a})`)}else if(e.classList.remove("marked-element-temp"),e.classList.remove("removePointers"),e.className){t+=`.${e.className.trim().replace(/\s+/g,".")}`,a.unshift(t);break}a.unshift(t),e=e.parentElement}return a.join(" > ")},Je={parseCssSelectors:We,getIdCssPath:Ue,getAttributeCssPath:Be,getClassCssPath:Ge,getAbsoluteCssPath:e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=[];for(;e&&e.nodeType===Node.ELEMENT_NODE;){const t=e.tagName.toLowerCase();if("style"===t||"script"===t)return;let a=t;const l=e.parentNode;if(l){const t=Array.from(l.children).filter(t=>t.tagName===e.tagName);t.length>1&&(a+=`:nth-of-type(${t.indexOf(e)+1})`)}n.unshift(a),e=e.parentElement}return n.join(" > ")}},Ze=(e,t,n)=>{const a=J(e);if(st(t,a)===n)return!0;if(function(e){return/\[(?:\s*\.|\s*contains\s*\(\s*\.|\s*normalize-space\s*\(\s*\.)/.test(e)}(a)){const e=t.evaluate(a,t,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(let t=0;t<e.snapshotLength;t++)if(e.snapshotItem(t)===n)return!0}return!1},Ke=(e,t)=>{try{const n=e.querySelector(t);if(n)return n}catch(e){return console.error("Invalid CSS selector:",t,e),null}return tt(e.body,t)},Qe=(e,t,n)=>Ke(t,e)===n,et=e=>e.name?.toLowerCase().includes("cssselector")??!1,tt=(e,t)=>{const n=Array.from(e.querySelectorAll("*"));try{for(let e=0;e<n.length;e++)if(n[e].shadowRoot){const{shadowRoot:a}=n[e];if(a){const e=tt(a,t);if(e)return e;if(a&&!t.includes("dynamic"))return a.querySelector(t)}}}catch(e){console.log(e)}return null},nt=e=>e?.id||null,at=e=>e.className||null,lt=e=>e.textContent?.trim()||null,rt=e=>{const t=e;if(t.hasAttribute("name")){return`${t.getAttribute("name")}`||null}return null},ot=["/preceding-sibling","/following-sibling","/parent","/descendant","/ancestor","/self","/ancestor-or-self","/child","/preceding","/following"];function st(e,t){const n=e.defaultView;if(!n)return null;return(new n.XPathEvaluator).evaluate(t,e,null,n.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}function it(e,t,n){if(e.includes(t)){const a=e.split(t)[0].trim(),l=n.defaultView;if(!l)return null;if(!e.includes("dynamic")){const t=new l.XPathEvaluator;if(t.evaluate(a,n,null,l.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue){let a;return t.evaluate(e,n,null,l.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue?(a=e,a):(console.error("Complete Locator is Invalid:",e),a=e,a)}console.error("Source Locator Not Found:",a)}}return null}const ct=(e,t)=>{const n=t.querySelectorAll("script, style, link[rel='stylesheet'], meta, noscript, embed, object, param, source, svg");n&&n.forEach(e=>{e.remove()});const a=new Set;let l=[];function r(e,t={}){const n=e?.value,r=t.value??e?.value,o={name:t.name??e?.name,type:t.type??e?.type,value:t.value??e?.value,reference:t.reference??e?.reference,status:t.status??e?.status,isRecorded:t.isRecorded??e?.isRecorded},s="Y"===e?.isSelfHealed;o.isSelfHealed=s?"Y":t.hasOwnProperty("isSelfHealed")?t.isSelfHealed:((e,t,n)=>t&&n&&t===n?null:"Y")(o.name,n,r),function(e){const t=`${e.name}:${e.value}`;a.has(t)||(a.add(t),l.push(e))}(o)}function o(e,t,n){if(et(t))return Ke(e,n);if(t.name.includes("id")||n.startsWith("#"))return e.querySelector("#"+Q(n));if(t.name.includes("className")||n.startsWith("."))return e.querySelector("."+n);if("name"===t.name){const t=Q(n);return e.querySelector(`[name="${t}"]`)}if("tagName"===t.name)return e.querySelector(n);if("linkText"===t.name)return Array.from(e.querySelectorAll("a")).find(e=>e.textContent?.trim()===n)||null;if("partialLinkText"===t.name)return Array.from(e.querySelectorAll("a")).find(e=>e.textContent?.includes(n))||null;if(!t.name.includes("xpath")&&!n.startsWith("//")||t.type.match("dynamic"))return e.querySelector(n);{const a=st(e,J(n));return a&&r(t,{value:n,isRecorded:String(t.isRecorded).includes("N")?"N":"Y"}),a}}function s(e,t,n){const a=e.querySelectorAll("iframe");for(const e of a)try{const a=e.contentDocument||e.contentWindow?.document;if(!a)continue;const l=o(a,t,n);if(l)return l}catch{continue}return null}const i=(e,t,n)=>{if(!e)return null;let a=e.trim();return a&&"null"!==a.toLowerCase()?(a=a.replace(/\\"/g,'"').replace(/\\'/g,"'"),a=a.replace(/^['"](.+?)['"]$/,"$1"),a=a.replace(/''/g,"'"),a=a.replace(/\[@(id|name)=['"]{2}(.+?)['"]{2}\]/g,"[@$1='$2']"),"id"!==t&&"name"!==t||(a=a.replace(/['"]/g,"").trim()),"xpath"!==t||"Y"!==n||e.startsWith("//")?!a||/^['"]{2}$/.test(a)?null:a:null):null};e:for(const n of e.locators)try{String(n.isRecorded||"");const c=e.locators.filter(e=>"N"===e.isRecorded);if(c.length>0)for(const e of c)r(e);const u=String(n.value||n.type||"");if(u.includes("dynamic")||u.match("dynamic")||u.includes("{")||u.includes("}")){r(n);continue}if(e.isShared.includes("Y"))break e;try{let c=null;const u=n.value.split(">>>");for(const e of u){if(!t){console.error("Element not found at:",e);break}const a=e.trim();if(c=o(t,n,a),c||(c=s(t,n,a)),c||(c=tt(t.body,a)),!c){console.error("Element not found at:",a);break}}const f=(e,t)=>{const n=`${e}:${t}`;return a.has(n)};if(c){const n=e.locators.filter(e=>"xpath"===e.name&&e.value),a=e.locators.filter(e=>et(e)&&e.value);for(const e of n)Ze(e.value,t,c)&&r(e,{isSelfHealed:null});for(const e of a)Qe(e.value,t,c)&&r(e,{isSelfHealed:null});const o=l.filter(e=>"xpath"===e.name&&e.value),s=new Set(o.map(e=>K(e.value))),u=[],h=nt(c);if(h&&!f("id",h)&&!m(h)){const n=e.locators.find(e=>"id"===e.name);ee(t,"id",h,c)&&(u.push("id"),r(n,{name:"id",type:"static",isRecorded:"Y",value:h}))}const d=c.tagName;if(d&&!f("tagName",d)){const n=e.locators.find(e=>"tagName"===e.name);ee(t,"tagName",d,c)&&(u.push("tagName"),r(n,{name:"tagName",type:"static",isRecorded:"Y",value:d}))}const g=lt(c);if(g&&!m(g)){const n=e.locators.find(e=>"linkText"===e.name);ee(t,"linkText",g,c)&&(u.push("linkText"),r(n,{name:"linkText",type:"static",isRecorded:"Y",value:g}))}const p=rt(c);if(p&&!f("name",p)&&!m(p)){const n=e.locators.find(e=>"name"===e.name);ee(t,"name",p,c)&&(u.push("name"),r(n,{name:"name",type:"static",isRecorded:"Y",value:p}))}const $=at(c);if($&&""!==$.trim()&&!$.includes(" ")&&!f("className",$)&&!m($)){const n=e.locators.find(e=>"className"===e.name);ee(t,"className",$,c)&&(u.push("className"),r(n,{name:"className",type:"static",isRecorded:"Y",value:$}))}We(c,"single").forEach(e=>{e.value&&!f("cssSelector",e.value)&&r(void 0,{name:"cssSelector",value:e.value,type:"static",isRecorded:"Y"})});const y=Array.from(c.attributes).filter(e=>!u.includes(e.name));let v=[];try{v=Re(c,t,!1,!0,y)??[]}catch(e){console.error("Error generating XPath candidates:",e)}if(0!==v?.length){const e=n.filter(e=>!Ze(e.value,t,c));let a=0;for(const t of e){if(a>=e.length)break;const n=K(t.value);if(s.has(n))continue;const l=v.find(e=>e.value&&K(e.value)===n);l?.value&&(r(t,{name:"xpath",value:l.value,type:"static",isRecorded:"Y",isSelfHealed:"Y"}),s.add(n),a++)}if(a<e.length)for(const t of v){if(a>=e.length)break;if(!t.value)continue;const n=K(t.value);s.has(n)||(r(t,{name:"xpath",value:t.value,type:"static",isRecorded:"Y",isSelfHealed:"Y"}),s.add(n),a++)}}for(const n of e.locators)try{for(const a of e.locators)if(a.value)for(const e of ot)if(a.value.includes(e)){const l=it(a.value,e,t);if(l){r(a,{name:"xpath",value:l,isRecorded:""!==n.isRecorded&&null!==n.isRecorded?n.isRecorded:"Y"});break}}}catch(e){console.error("Error processing locator:",n,e)}if(l.length<5){const e=[{name:"id",value:nt(c)},{name:"name",value:rt(c)},{name:"className",value:at(c)},{name:"tagName",value:c.tagName},{name:"linkText",value:lt(c)}];for(const n of e){if(l.length>4)break;const{name:e,value:a}=n;a&&(m(a)||f(e,a)||"className"===e&&a.includes(" ")||ee(t,e,a,c)&&r(void 0,{name:e,type:"static",value:a,isRecorded:"Y",isSelfHealed:"Y"}))}l.length<5&&We(c,"multiple").forEach(e=>{l.length>4||e.value&&(f("cssSelector",e.value)||ee(t,"cssSelector",e.value,c)&&r(void 0,{name:"cssSelector",type:"static",value:e.value,isRecorded:"Y",isSelfHealed:"Y"}))})}const N=l.map(e=>({...e,value:i(e.value,e.name,e.isRecorded)})),x=[{name:`${e.name}`,desc:`${e.desc}`,type:`${e.type}`,locators:N.filter(e=>null!=e?.value&&""!==e.value),isShared:`${e.isShared}`,projectId:`${e.projectId}`,projectType:`${e.projectType}`,isRecorded:`${e.isRecorded}`,folder:`${e.folder}`,parentId:`${e.parentId}`,parentName:`${e.parentName}`,platform:`${e.platform}`,licenseId:`${e.licenseId}`,licenseType:`${e.licenseType}`,userId:`${e.userId}`}];return x}}catch(e){console.error("Error processing locator:",n,e);continue}}catch(e){console.error("Error processing locator:",n,e);continue}return null};const ut={getOptimalClassChain:function e(t,n,a){try{if(!n||1!==n.nodeType||!n.tagName||"XCUIElementTypeApplication"===n.tagName)return"";const l=n.tagName,r=["name","label","value"];for(const e of r){const r=a.find(t=>t.name===e);if(!r)continue;let o=r.value;if(!o)continue;if(o=o.trim().replace(/\s+/g," "),m(o))continue;const s=`//${l}[@${e}="${o}"]`;let i=0;try{i=p(s,n,t)}catch(e){console.log(e);continue}const c=/\s/.test(o);if(1===i)return c?`/${l}[\`${e} CONTAINS "${o}"\`]`:`/${l}[\`${e} == "${o}"\`]`;if(i>1&&n.parentElement){const t=Array.from(n.parentElement.children).filter(e=>e.tagName===l).indexOf(n)+1;return c?`/${l}[\`${e} CONTAINS "${o}"\`][${t}]`:`/${l}[\`${e} == "${o}"\`][${t}]`}}let o=`/${l}`;if(n.parentElement){const e=Array.from(n.parentElement.children).filter(e=>e.tagName===l);if(e.length>1){o+=`[${e.indexOf(n)+1}]`}}return e(t,n.parentElement,a)+o}catch(e){return console.log(`Unable to generate optimal -ios class chain : ${JSON.stringify(e)}`),null}},getOptimalPredicateString:function(e,t,n){try{if(!t?.tagName||1!==t?.nodeType||"XCUIElementTypeApplication"===t?.tagName)return"";let a=[],l=[];for(let r of n){const n=r.value,o=r.name;if(0!==n.length&&(n&&!m(n))){a.push(`@${o}="${n}"`);const r=`//*[${a.join(" and ")}]`;let s;l.push(`${o} == "${n}"`);try{s=p(r,t,e)}catch(e){console.log(e);continue}if(1===s)return l.join(" AND ")}}}catch(e){console.log(`The most optimal '-ios predicate string' could not be determined because an error was thrown: '${JSON.stringify(e,null,2)}'`)}return null}},ft=()=>({xpath:Oe,referenceXpaths:ze,xpathUtils:te,getElementsFromHTML:ct,cssSelectors:Je,iosSelectors:ut});e.createXPathAPI=ft,e.default=ft,Object.defineProperty(e,"__esModule",{value:!0})}(this.XpathLib=this.XpathLib||{});
@@ -1,6 +1,6 @@
1
1
  export declare const createXPathAPI: () => {
2
2
  xpath: {
3
- parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[]) => {
3
+ parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[], strategies?: string[]) => {
4
4
  key: string;
5
5
  value: string;
6
6
  }[];
@@ -18,9 +18,13 @@ export declare const createXPathAPI: () => {
18
18
  getParentRelativeXpath: (domNode: HTMLElement, docmt: Document, node: HTMLElement | Element, isTarget: boolean) => any;
19
19
  getUniqueParentXpath: (domNode: HTMLElement, docmt: Document, node: HTMLElement | Element, isTarget: boolean, nodeXpath: string, isIndex: boolean) => any;
20
20
  checkRelativeXpathRelation: (nodeXpath1: string, nodeXpath2: string, targetElemt: HTMLElement | Element, docmt: Document, isIndex: boolean, relationType: string) => string | null;
21
+ buildAxesStrategyXpaths: (element: HTMLElement | Element, docmt: Document, isTarget: boolean, isIndex: boolean) => {
22
+ key: string;
23
+ value: string;
24
+ }[];
21
25
  };
22
26
  referenceXpaths: {
23
- findRelativeXpath: (element1: HTMLElement | Element, element2: HTMLElement | Element, docmt: Document, xpaths1: any[], xpaths2: any[], isIndex: boolean, multiElementReferenceMode?: boolean) => any[] | undefined;
27
+ findRelativeXpath: (element1: Element, element2: Element, docmt: Document, xpaths1: any[], xpaths2: any[], isIndex: boolean, multiElementReferenceMode?: boolean, allowedRelations?: string[] | null) => any[];
24
28
  getDescendantXpath: (refExpectElement: Array<HTMLElement | Element>, docmt: Document, xpaths1: {
25
29
  key: string;
26
30
  value: string;
@@ -31,6 +35,16 @@ export declare const createXPathAPI: () => {
31
35
  key: string;
32
36
  value: string;
33
37
  }[] | undefined;
38
+ getAncestorBridgeXpath: (element1: HTMLElement | Element, element2: HTMLElement | Element, relation: "ancestor" | "ancestor-or-self", xpaths1: {
39
+ key: string;
40
+ value: string;
41
+ }[], xpaths2: {
42
+ key: string;
43
+ value: string;
44
+ }[], isIndex: boolean) => {
45
+ key: string;
46
+ value: string;
47
+ }[];
34
48
  getXpathRelationExpression: (element1: HTMLElement | Element, element2: HTMLElement | Element, relation: string, xpath1: any[], xpath2: any[], isIndex: boolean, multiElementReferenceMode: boolean) => {
35
49
  key: string;
36
50
  value: any;
@@ -43,6 +57,7 @@ export declare const createXPathAPI: () => {
43
57
  key: string;
44
58
  value: string;
45
59
  }[];
60
+ getSmartRelations: (element1: HTMLElement | Element, element2: HTMLElement | Element) => string[];
46
61
  };
47
62
  xpathUtils: {
48
63
  parseXml: (xmlStr: string, type: DOMParserSupportedType) => Document | null;
@@ -53,7 +68,7 @@ export declare const createXPathAPI: () => {
53
68
  getAbsoluteXPath: (domNode: HTMLElement | Element | null, docmt: Document) => string;
54
69
  getRelativeXPath: (domNode: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean | undefined, attributesArray: Attr[]) => any;
55
70
  getCombinationXpath: (attribute: Attr, domNode: HTMLElement | Element) => string | undefined;
56
- getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
71
+ getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document | ShadowRoot, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
57
72
  getElementFromXpath: (xpath: string, docmt: Node, multi?: boolean) => Node | XPathResult | null;
58
73
  isSvg: (element: HTMLElement | Element) => element is SVGElement;
59
74
  findXpathWithIndex: (val: string, node: HTMLElement | Element, docmt: Node, count: number) => string | undefined;
@@ -83,8 +98,21 @@ export declare const createXPathAPI: () => {
83
98
  }[];
84
99
  cspEnabled: boolean;
85
100
  getXPathPattern: typeof import("../utils/xpathHelpers.ts").getXPathPattern;
101
+ getNormalizedPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
102
+ getStartsWithPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
103
+ getContainsPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
104
+ getOrAttributesXPath: (element: HTMLElement | Element, attributes: Attr[]) => string;
105
+ getTagOnlyXPath: (element: HTMLElement | Element, docmt?: Document | ShadowRoot) => string;
106
+ getFirstMatchedNode: (xpath: string, docmt: Document | ShadowRoot) => HTMLElement | Element | null;
107
+ isExactUniqueXpath: (xpath: string, element: HTMLElement | Element, docmt: Document | ShadowRoot) => boolean;
108
+ getAxisNodeTest: (element: HTMLElement | Element) => string;
109
+ getUniqueNodeAnchorXpaths: (node: HTMLElement | Element, docmt: Document | ShadowRoot, isTarget: boolean) => {
110
+ key: string;
111
+ value: string;
112
+ }[];
86
113
  escapeAttrValue: typeof import("../utils/xpathHelpers.ts").escapeAttrValue;
87
114
  isUniqueInDOM: typeof import("../utils/xpathHelpers.ts").isUniqueInDOM;
115
+ sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
88
116
  };
89
117
  getElementsFromHTML: (record: import("../types/locator.ts").ElementRecord, docmt: Document) => {
90
118
  [key: string]: any;
@@ -110,5 +138,9 @@ export declare const createXPathAPI: () => {
110
138
  getClassCssPath: (el: HTMLElement | Element) => string | undefined;
111
139
  getAbsoluteCssPath: (el: Element) => string | undefined;
112
140
  };
141
+ iosSelectors: {
142
+ getOptimalClassChain: (doc: Document, domNode: HTMLElement | Element | null, uniqueAttributes: Attr[]) => string | null;
143
+ getOptimalPredicateString: (doc: Document, domNode: HTMLElement | Element | null, uniqueAttributes: Attr[]) => string | null;
144
+ };
113
145
  };
114
146
  export default createXPathAPI;
@@ -0,0 +1,7 @@
1
+ declare function getOptimalClassChain(doc: Document, domNode: HTMLElement | Element | null, uniqueAttributes: Attr[]): string | null;
2
+ declare function getOptimalPredicateString(doc: Document, domNode: HTMLElement | Element | null, uniqueAttributes: Attr[]): string | null;
3
+ export declare const iosSelectors: {
4
+ getOptimalClassChain: typeof getOptimalClassChain;
5
+ getOptimalPredicateString: typeof getOptimalPredicateString;
6
+ };
7
+ export {};
@@ -1,6 +1,7 @@
1
- export declare const findRelativeXpath: (element1: HTMLElement | Element, element2: HTMLElement | Element, docmt: Document, xpaths1: any[], xpaths2: any[], isIndex: boolean, multiElementReferenceMode?: boolean) => any[] | undefined;
1
+ export declare const findRelativeXpath: (element1: Element, element2: Element, docmt: Document, xpaths1: any[], xpaths2: any[], isIndex: boolean, multiElementReferenceMode?: boolean, allowedRelations?: string[] | null) => any[];
2
+ export declare const getSmartRelations: (element1: HTMLElement | Element, element2: HTMLElement | Element) => string[];
2
3
  declare const referenceXpath: {
3
- findRelativeXpath: (element1: HTMLElement | Element, element2: HTMLElement | Element, docmt: Document, xpaths1: any[], xpaths2: any[], isIndex: boolean, multiElementReferenceMode?: boolean) => any[] | undefined;
4
+ findRelativeXpath: (element1: Element, element2: Element, docmt: Document, xpaths1: any[], xpaths2: any[], isIndex: boolean, multiElementReferenceMode?: boolean, allowedRelations?: string[] | null) => any[];
4
5
  getDescendantXpath: (refExpectElement: Array<HTMLElement | Element>, docmt: Document, xpaths1: {
5
6
  key: string;
6
7
  value: string;
@@ -11,6 +12,16 @@ declare const referenceXpath: {
11
12
  key: string;
12
13
  value: string;
13
14
  }[] | undefined;
15
+ getAncestorBridgeXpath: (element1: HTMLElement | Element, element2: HTMLElement | Element, relation: "ancestor" | "ancestor-or-self", xpaths1: {
16
+ key: string;
17
+ value: string;
18
+ }[], xpaths2: {
19
+ key: string;
20
+ value: string;
21
+ }[], isIndex: boolean) => {
22
+ key: string;
23
+ value: string;
24
+ }[];
14
25
  getXpathRelationExpression: (element1: HTMLElement | Element, element2: HTMLElement | Element, relation: string, xpath1: any[], xpath2: any[], isIndex: boolean, multiElementReferenceMode: boolean) => {
15
26
  key: string;
16
27
  value: any;
@@ -23,5 +34,6 @@ declare const referenceXpath: {
23
34
  key: string;
24
35
  value: string;
25
36
  }[];
37
+ getSmartRelations: (element1: HTMLElement | Element, element2: HTMLElement | Element) => string[];
26
38
  };
27
39
  export default referenceXpath;
@@ -1,13 +1,17 @@
1
+ export declare const generateIndexedXpaths: (element: Element, docmt: Document) => {
2
+ key: string;
3
+ value: string;
4
+ }[];
1
5
  declare function getXPathUsingAttributeAndText(attributes: Attr[], targetElemt: HTMLElement | Element, docmt: Document, isTarget: boolean): string | undefined;
2
6
  export declare const attributesBasedXPath: (attr: Attr, targetElemt: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean) => string | undefined;
3
7
  export declare const getUniqueClassName: (element: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean) => string | undefined;
4
8
  export declare const getTextXPath: (element: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean) => string | undefined;
5
- export declare const parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[]) => {
9
+ export declare const parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[], strategies?: string[]) => {
6
10
  key: string;
7
11
  value: string;
8
12
  }[];
9
13
  declare const xpath: {
10
- parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[]) => {
14
+ parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[], strategies?: string[]) => {
11
15
  key: string;
12
16
  value: string;
13
17
  }[];
@@ -25,5 +29,9 @@ declare const xpath: {
25
29
  getParentRelativeXpath: (domNode: HTMLElement, docmt: Document, node: HTMLElement | Element, isTarget: boolean) => any;
26
30
  getUniqueParentXpath: (domNode: HTMLElement, docmt: Document, node: HTMLElement | Element, isTarget: boolean, nodeXpath: string, isIndex: boolean) => any;
27
31
  checkRelativeXpathRelation: (nodeXpath1: string, nodeXpath2: string, targetElemt: HTMLElement | Element, docmt: Document, isIndex: boolean, relationType: string) => string | null;
32
+ buildAxesStrategyXpaths: (element: HTMLElement | Element, docmt: Document, isTarget: boolean, isIndex: boolean) => {
33
+ key: string;
34
+ value: string;
35
+ }[];
28
36
  };
29
37
  export default xpath;
@@ -1,11 +1,19 @@
1
1
  export declare const reWhiteSpace: RegExp;
2
2
  export declare let cspEnabled: boolean;
3
+ export declare const timeLog: (label: string, start: number) => void;
4
+ type EvalResult = {
5
+ first: Node | null;
6
+ second: Node | null;
7
+ };
8
+ export declare const clearXPathEvalCache: (node?: Node | null) => void;
9
+ export declare const evaluateXPathOnce: (xpath: string, docmt: Node) => EvalResult;
3
10
  export declare let modifiedElementAttributes: {
4
11
  url: string | null;
5
12
  attributeName: string | null;
6
13
  element: HTMLElement | Element;
7
14
  doc: Document;
8
15
  }[];
16
+ export declare const sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
9
17
  export declare const createObserver: (addedNodeCallBack: Function) => void;
10
18
  export declare const startObserver: (target: Node, options: MutationObserverInit | undefined) => void;
11
19
  export declare const stopObserver: () => void;
@@ -19,6 +27,12 @@ export declare const removeParenthesis: (xpath: string) => string;
19
27
  export declare const findXpathWithIndex: (val: string, node: HTMLElement | Element, docmt: Node, count: number) => string | undefined;
20
28
  export declare const replaceWhiteSpaces: (str: string) => string;
21
29
  export declare const getShadowRoot: (el: HTMLElement | Element) => Element | null;
30
+ export declare const createShadowEvaluationContext: (root: ShadowRoot, element?: HTMLElement | Element | (HTMLElement | Element)[]) => {
31
+ owner: Document;
32
+ contextNode: HTMLDivElement;
33
+ cloneElement: Element | null;
34
+ cloneElements: (Element | null)[];
35
+ };
22
36
  export declare const checkBlockedAttributes: (attribute: {
23
37
  name: string;
24
38
  value: string;
@@ -30,12 +44,24 @@ export declare const getPropertyXPath: (element: HTMLElement | Element, docmt: D
30
44
  export declare const getAbsoluteXPath: (domNode: HTMLElement | Element | null, docmt: Document) => string;
31
45
  export declare const getRelativeXPath: (domNode: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean | undefined, attributesArray: Attr[]) => any;
32
46
  export declare const getCombinationXpath: (attribute: Attr, domNode: HTMLElement | Element) => string | undefined;
33
- export declare const getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
47
+ export declare const getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document | ShadowRoot, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
34
48
  export declare const intermediateXpathStep: (targetElemt: HTMLElement | Element, attr: {
35
49
  name: string;
36
50
  value: string;
37
51
  }, isTarget: boolean) => string;
38
- export declare const getFilteredTextXPath: (node: HTMLElement | Element, docmt: Document) => string;
52
+ export declare const getFilteredTextXPath: (node: HTMLElement | Element, docmt: Document | ShadowRoot) => string;
53
+ export declare const getNormalizedPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
54
+ export declare const getStartsWithPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
55
+ export declare const getContainsPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
56
+ export declare const getOrAttributesXPath: (element: HTMLElement | Element, attributes: Attr[]) => string;
57
+ export declare const getTagOnlyXPath: (element: HTMLElement | Element, docmt?: Document | ShadowRoot) => string;
58
+ export declare const getFirstMatchedNode: (xpath: string, docmt: Document | ShadowRoot) => HTMLElement | Element | null;
59
+ export declare const isExactUniqueXpath: (xpath: string, element: HTMLElement | Element, docmt: Document | ShadowRoot) => boolean;
60
+ export declare const getAxisNodeTest: (element: HTMLElement | Element) => string;
61
+ export declare const getUniqueNodeAnchorXpaths: (node: HTMLElement | Element, docmt: Document | ShadowRoot, isTarget: boolean) => {
62
+ key: string;
63
+ value: string;
64
+ }[];
39
65
  export declare const getTextXpathFunction: (domNode: HTMLElement | Element) => string | undefined;
40
66
  export declare const getXpathString: (node: HTMLElement | Element, attrName: string, attrValue: string) => string;
41
67
  export declare const replaceActualAttributes: (str: string, element: {
@@ -67,7 +93,7 @@ export declare const xpathUtils: {
67
93
  getAbsoluteXPath: (domNode: HTMLElement | Element | null, docmt: Document) => string;
68
94
  getRelativeXPath: (domNode: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean | undefined, attributesArray: Attr[]) => any;
69
95
  getCombinationXpath: (attribute: Attr, domNode: HTMLElement | Element) => string | undefined;
70
- getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
96
+ getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document | ShadowRoot, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
71
97
  getElementFromXpath: (xpath: string, docmt: Node, multi?: boolean) => Node | XPathResult | null;
72
98
  isSvg: (element: HTMLElement | Element) => element is SVGElement;
73
99
  findXpathWithIndex: (val: string, node: HTMLElement | Element, docmt: Node, count: number) => string | undefined;
@@ -97,6 +123,20 @@ export declare const xpathUtils: {
97
123
  }[];
98
124
  cspEnabled: boolean;
99
125
  getXPathPattern: typeof getXPathPattern;
126
+ getNormalizedPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
127
+ getStartsWithPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
128
+ getContainsPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
129
+ getOrAttributesXPath: (element: HTMLElement | Element, attributes: Attr[]) => string;
130
+ getTagOnlyXPath: (element: HTMLElement | Element, docmt?: Document | ShadowRoot) => string;
131
+ getFirstMatchedNode: (xpath: string, docmt: Document | ShadowRoot) => HTMLElement | Element | null;
132
+ isExactUniqueXpath: (xpath: string, element: HTMLElement | Element, docmt: Document | ShadowRoot) => boolean;
133
+ getAxisNodeTest: (element: HTMLElement | Element) => string;
134
+ getUniqueNodeAnchorXpaths: (node: HTMLElement | Element, docmt: Document | ShadowRoot, isTarget: boolean) => {
135
+ key: string;
136
+ value: string;
137
+ }[];
100
138
  escapeAttrValue: typeof escapeAttrValue;
101
139
  isUniqueInDOM: typeof isUniqueInDOM;
140
+ sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
102
141
  };
142
+ export {};
@@ -1,13 +1,17 @@
1
+ export declare const generateIndexedXpaths: (element: Element, docmt: Document) => {
2
+ key: string;
3
+ value: string;
4
+ }[];
1
5
  declare function getXPathUsingAttributeAndText(attributes: Attr[], targetElemt: HTMLElement | Element, docmt: Document, isTarget: boolean): string | undefined;
2
6
  export declare const attributesBasedXPath: (attr: Attr, targetElemt: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean) => string | undefined;
3
7
  export declare const getUniqueClassName: (element: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean) => string | undefined;
4
8
  export declare const getTextXPath: (element: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean) => string | undefined;
5
- export declare const parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[]) => {
9
+ export declare const parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[], strategies?: string[]) => {
6
10
  key: string;
7
11
  value: string;
8
12
  }[];
9
13
  declare const xpath: {
10
- parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[]) => {
14
+ parseDOM: (element: HTMLElement | Element, doc: Document, isIndex: boolean, isTarget: boolean, includedAttributes?: Attr[], strategies?: string[]) => {
11
15
  key: string;
12
16
  value: string;
13
17
  }[];
@@ -25,5 +29,9 @@ declare const xpath: {
25
29
  getParentRelativeXpath: (domNode: HTMLElement, docmt: Document, node: HTMLElement | Element, isTarget: boolean) => any;
26
30
  getUniqueParentXpath: (domNode: HTMLElement, docmt: Document, node: HTMLElement | Element, isTarget: boolean, nodeXpath: string, isIndex: boolean) => any;
27
31
  checkRelativeXpathRelation: (nodeXpath1: string, nodeXpath2: string, targetElemt: HTMLElement | Element, docmt: Document, isIndex: boolean, relationType: string) => string | null;
32
+ buildAxesStrategyXpaths: (element: HTMLElement | Element, docmt: Document, isTarget: boolean, isIndex: boolean) => {
33
+ key: string;
34
+ value: string;
35
+ }[];
28
36
  };
29
37
  export default xpath;