ff-dom 2.0.9 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cdn.js +1 -1
- package/dist/types/browser/browser/xpath.d.ts +43 -3
- package/dist/types/browser/utils/iosSelector.d.ts +7 -0
- package/dist/types/browser/utils/referenceXpath.d.ts +14 -2
- package/dist/types/browser/utils/xpath.d.ts +10 -2
- package/dist/types/browser/utils/xpathHelpers.d.ts +65 -3
- package/dist/types/node/utils/xpath.d.ts +10 -2
- package/dist/types/node/utils/xpathHelpers.d.ts +65 -3
- package/dist/xpath.mjs +1 -1
- package/dist/xpath.mjs.map +1 -1
- package/package.json +71 -71
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},r=(e,t)=>{const{owner:a,contextNode:r}=(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 o=n.get(r);o||(o=new Map,n.set(r,o));const l=o.get(e);if(l)return l;const s=a.evaluate(e,r,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),i={first:s.iterateNext(),second:s.iterateNext()};return o.set(e,i),i};let o,l=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=>/\d/.test(e||""),f=(e,t,n,a=!1)=>{const r=c(t),o=r.filter(e=>!!a||!u(e));return o.length?1===r.length&&1===o.length?[`@class=${N(o[0])}`]:o.map(t=>{const a=p(`contains(@class,${N(t)})`,T(e),e.tagName.toLowerCase());return{token:t,count:U(a,e,n)}}).sort((e,t)=>e.token.length!==t.token.length?e.token.length-t.token.length:e.count-t.count).map(({token:e})=>`contains(@class,${N(e)})`):[]},m=new Set(["data-testid","data-test-id","data-test","data-cy","testid"]),d=(e,t)=>t?"class"===e||"className"===e?c(t).join(" "):t.replace("removePointers","").trim():"",g=e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof Element))return!1;if(T(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(" ")},h=e=>/\d/.test(e),p=(e,t,n)=>t?`//*[local-name()='${n}' and ${e}]`:`//${n}[${e}]`,$=e=>{const t=e?.textContent;return t},y=e=>e?.childNodes[0]?.nodeValue||"",v=(e,t,n,a=!1)=>{try{const{first:o,second:l}=r(e,n);if(!o)return 0;if(!l)return o===t?1:0;if(a&&Array.isArray(t)){let a=0;if(t.includes(o)&&a++,t.includes(l)&&a++,2===a)return 2;const r=(9===n.nodeType?n:n.ownerDocument).evaluate(e,n,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);let s;for(;s=r.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}},N=e=>{if(e){if(-1!==e.indexOf('"'))return`'${e}'`;if(-1!==e.indexOf("'"))return`"${e}"`}return`'${e}'`},b=e=>{const t=e.split("");let n=t.length;const a=[];for(;"["!==t[n-2];)a.push(t[n-2]),n--;a.reverse();let r="";for(let e=0;e<a.length;e++)r+=a[e];const o=r.length+2;let l=e.slice(0,e.length-o);return l=l.startsWith("(")&&l.endsWith(")")?l.slice(1,-1):e,l},x=(e,t,n,a)=>{try{const r=9===n.nodeType?n:n.ownerDocument;let o=0;if(a){if(1===v(`${e}[${a}]`,t,n))return`${e}[${a}]`;if(1===v(`(${e})[${a}]`,t,n))return`(${e})[${a}]`}const l=r.evaluate(e,n,null,XPathResult.ANY_TYPE,null);let s=null;for(;s=l.iterateNext();)if(o++,s.isSameNode(t))return 1===v(`${e}[${o}]`,t,n)?`${e}[${o}]`:1===v(`(${e})[${o}]`,t,n)?`(${e})[${o}]`:void 0}catch(e){console.log(e)}},E=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(),w=e=>e?e.replace(/\s\s+/g," ").trim():e,k=(e,t)=>{const n=w((t||"").trim());if(!e.children.length||n.length<=50)return"";const a=n.split(/\s+/).slice(0,3).join(" ");return a.length>2?`contains(normalize-space(.),${N(a)})`:""},S=e=>{const t=w((e||"").trim());if(!t||!u(t))return{prefix:t,fragment:t};const n=t.split(/[0-9]/)[0].replace(/[₹$€£¥₫₽₩₦₱₲₴₵₡₭₮₺฿៛]+/g,"").trim(),a=n.split(/[^a-zA-Z]+/).map(e=>w(e).trim()).filter(e=>e.length>2&&/[a-zA-Z]/.test(e)).join(" ").trim();return{prefix:n.length>2&&/[a-zA-Z]/.test(n)?n:"",fragment:a.length>2?a:""}},C=e=>S(e).fragment,A=e=>{if(!e||!e?.getRootNode)return null;const t=e.getRootNode();return t&&t?.host?t:null},R=(e,t)=>{const n=e.ownerDocument.implementation.createHTMLDocument("shadow-xpath"),a=n.createElement("div");a.innerHTML=e.innerHTML,n.body.appendChild(a);const r=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},o=Array.isArray(t)?t.map(e=>r(e)).filter(Boolean):[],l=Array.isArray(t)?null:r(null);return{owner:n,contextNode:a,cloneElement:l,cloneElements:o}},O=(e,t,n)=>{const a=d(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 r=s?.find(n=>n.doc===t.ownerDocument&&n.element===t&&n.attributeName===e.name);return!r&&(!(0===e?.name?.indexOf("on")&&e?.name?.length>3)&&("function"!=typeof e.value&&(o=e.name,l=a,(!m.has(o.toLowerCase())||!(e=>/(?:^|[-_:])\d{4,}(?:$|[-_:])/.test(e))(l))&&("class"===e.name||!u(a)))));var o,l},T=e=>e instanceof SVGElement,D=e=>e?e.replace(/\b[a-zA-Z_]*disabled\b/gi,"disabled"):e,P=(e,n,a,r,o,l)=>{if(r){const{tagName:s}=e;let i,c="";const m=[];let d;const g=a.startsWith("@"),$="."===a||"text()"===a,y=$?".":a,b=$&&/\s/.test(r.trim()),x=$?C(r):r,E=$&&u(r)?x:r,S=$?k(e,E):"";if("@class"===a){for(const t of f(e,r,n))if(d=p(t,T(e),e.tagName.toLowerCase()),i=v(d,e,n),1===i&&!o)return d;return}if($&&u(r)&&!x)return;if(r&&(!g||!h(r))&&(d=S?p(S,T(e),e.tagName.toLowerCase()):b?p(`normalize-space(${y})=${N(w(E)).trim()}`,T(e),e.tagName.toLowerCase()):t.test(r)?`//${s}[${a}=${N(E)}]`:p(`normalize-space(${a})=${N(w(E)).trim()}`,T(e),e.tagName.toLowerCase()),i=v(d,e,n),1===i&&!o))return d;if(g&&u(r))return;if(r&&l){const l=r.split(" ");if(l?.length)if(1===l.length){const u=[...new Set(l[0].match(/([^0-9]+)/g))];if(u?.length>=1&&u[0]&&w(u[0].trim())?.length>1&&r.startsWith(u[0])&&(c=t.test(u[0])?`starts-with(${a},${N(u[0]).trim()})`:`starts-with(${a},${N(w(u[0])).trim()})`),u?.length>1&&u[u.length-1]&&w(u[u.length-1].trim())?.length>1&&r.endsWith(u[u.length-1])&&(c=t.test(u[u.length-1])?`ends-with(${a},${N(u[u.length-1]).trim()})`:`ends-with(${a},${N(w(u[u.length-1])).trim()})`),c?.length&&(d=T(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=v(d,e,n),1===i&&!o))return d}else{const u=l.length%2==0?l.length/2:l.length%2,f=l.slice(0,u).join(" ");let m=[...new Set(f.match(/([^0-9]+)/g))];if(m?.length&&m[0]&&w(m[0].trim())?.length&&r.startsWith(m[0])&&(c=t.test(m[0])?`starts-with(${a},${N(m[0]).trim()})`:`starts-with(${a},${N(w(m[0])).trim()})`),c?.length&&(d=T(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=v(d,e,n),1===i&&!o))return d;const g=l.slice(u,l.length-1).join(" ");if(m=[...new Set(g.match(/([^0-9]+)/g))],m?.length&&m[0]&&w(m[0].trim())?.length>3&&r.endsWith(m[0])&&(c=t.test(m[0])?`ends-with(${a},${N(m[0]).trim()})`:`ends-with(${a},${N(w(m[0])).trim()})`),c?.length&&(d=T(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=v(d,e,n),1===i&&!o))return d}}if(r&&l&&h(r)){const l=[...new Set(r.match(/([^0-9]+)/g))];if(l?.length)for(let e=0;e<l?.length;e++)l[e]&&w(l[e].trim())?.length>1&&(t.test(l[e])?m.push(`contains(${a},${N(l[e].trim()).trim()})`):m.push(`contains(${a},${N(w(l[e])).trim()})`));if(m?.length&&(d=T(e)?`//*[local-name()='${s}' and ${m.join(" and ")}]`:`//${s}[${m.join(" and ")}]`,i=v(d,e,n),1===i&&!o))return d}if(d=T(e)?`//*[local-name()='${s}' and text()]`:`//${s}[text()]`,i=v(d,e,n),1===i&&!o)return d}},X=(e,t)=>{try{if(!e)return"";let n=T(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 X(e?.parentElement,t)+n}catch(e){return console.log("xpath",e),""}},L=(e,t,n,a=!1,r)=>{try{if(l.has(e))return l.get(e);const o=[];let s=e;for(;s;){let l="",i=!1,c=e===s?r??s.attributes:s.attributes;for(const e of Array.from(c))if(O(e,s)){const a=d(e.name,e.nodeValue),r=e.name;for(const e of ee(s,r,a)){l=e;let a=0;if(a=v(l,s,t),1===a){o.unshift(D(l)),i=!0;break}if(a>1&&n&&(l=x(l,s,t,a),l)){o.unshift(D(l)),i=!0;break}}}if(s.textContent)if(!a||a&&!h(s.textContent)){let e=new RegExp(/^[\S]+( [\S]+)*$/gi);const a=y(s),r=k(s,a);l=r?p(r,T(s),s.tagName||"*"):e.test(s.textContent)?T(s)?`//*[local-name()='${s.tagName}' and .=${N(a)}]`:`//${s.tagName||"*"}[.=${N(a)}]`:T(s)?`//*[local-name()='${s.tagName}' and normalize-space(.)=${N(a)}]`:`//${s.tagName||"*"}[normalize-space(.)=${N(a)}]`;let o=v(l,s,t);if(1===o)return l;if(o>1&&n)return l=x(l,s,t,o),l}else{let e=[];const a=[...new Set(y(s).match(/([^0-9]+)/g))];let r=new RegExp(/^[\S]+( [\S]+)*$/gi);if(a?.length)for(let t=0;t<a?.length;t++)a[t]&&w(a[t].trim())&&(r.test(a[t])?e.push(`contains(.,${N(a[t].trim()).trim()})`):e.push(`contains(.,${N(w(a[t])).trim()})`));if(e?.length){l=T(s)?`//*[local-name()='${s.tagName}' and ${e.join(" and ")}]`:`//${s.tagName||"*"}[${e.join(" and ")}]`;let a=v(l,s,t);if(1===a)return l;if(a>1&&n)return l=x(l,s,t,a),l}}if(i)break;{let e=T(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}]`}}o.unshift(e)}s=s.parentElement}const i=`${o.join("")}`;return l.set(e,i),i}catch(e){return console.log(e),null}},_=(e,n)=>{const a=[];let r="";if(e&&"function"!=typeof e.nodeValue){if("class"===e.name){const t=n.getRootNode?.()??n.ownerDocument,a=f(n,e.value,t);for(const e of a)if(r=T(n)?`//*[local-name()='${n.tagName}' and ${e}]`:`//${n.tagName}[${e}]`,r)return r;return}if(h(e.value))return;const o=[...new Set(e.value.match(/([^0-9]+)/g))];if(o?.length)for(let n=0;n<o?.length;n++)o[n]&&w(o[n].trim())?.length>2&&(t.test(o[n])?a.push(`contains(@${e.name},${N(o[n].trim())})`):a.push(`contains(@${e.name},${N(w(o[n])).trim()})`));if(a?.length)return r=T(n)?`//*[local-name()='${n.tagName}' and ${a.join(" and ")}]`:`//${n.tagName}[${a.join(" and ")}]`,r}},I=(e,n,a,r)=>{try{const r=a.filter(t=>O(t,e)),o=a=>{const r=d(a.name,a.nodeValue);return r?"class"===a.name?f(e,r,n):u(r)?[]:t.test(r)?[`@${a.name}="${r}"`]:[`normalize-space(@${a.name})="${r}"`]:[]},l=()=>{const n=w($(e)?.trim()||""),a=C(n);if(u(n))return a?[`contains(normalize-space(.),${N(a)})`]:[];if(!n||n.length>80||/^\d+$/.test(n)){const t=k(e,n);return t?[t]:[]}const r=new Set,o=k(e,n);return o?(r.add(o),Array.from(r)):(t.test(n)&&n.length<=40&&!n.includes(" ")&&r.add(`text()=${N(n)}`),n.includes(" ")&&r.add(`normalize-space(.)=${N(w(n))}`),r.add(`contains(text(),${N(n)})`),Array.from(r))},s=(e,t)=>{const n=[],a=(r,o)=>{if(o.length!==t)for(let t=r;t<e.length;t++)o.push(e[t]),a(t+1,o),o.pop();else n.push([...o])};return a(0,[]),n},i=t=>T(e)?`//*[local-name()='${e.tagName}' and ${t.join(" and ")}]`:`//${e.tagName}[${t.join(" and ")}]`,c=()=>{if(!(r.length<2))for(let t=2;t<=r.length;t++){const a=s(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 r=i(a);let l;try{l=v(r,e,n)}catch{continue}if(1===l)return r}}},m=c();if(m)return m;const g=l();if(!g.length||!r.length)return;for(let t=1;t<=r.length;t++){const a=s(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 r=[...a,t],o=i(r);try{if(1===v(o,e,n))return o}catch{continue}}}}}catch(e){console.log(`XPath generation error: ${JSON.stringify(e,null,2)}`)}},z=(e,t,n)=>M(e,t)[0]||"",M=(e,n,a)=>{let r=T(e),o="";if(O(n,e)){let a=d(n.name,n.value);const l=n.name;if("class"===l){const t=e.getRootNode?.()??e.ownerDocument;return f(e,a,t).map(t=>r?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName||"*"}[${t}]`)}if(u(a))return[];o=t.test(a)?r?`*[local-name()='${e.tagName}' and @${l}=${N(a)}]`:`${e.tagName||"*"}[@${l}=${N(a)}]`:r?`*[local-name()='${e.tagName}' and normalize-space(@${l})=${N(a)}]`:`${e.tagName||"*"}[normalize-space(@${l})=${N(a)}]`}return o?[o]:[]},j=(e,n)=>{if(!e.textContent)return"";const a=y(e),r=C(a);if(u(a)&&!r)return"";const o=u(a)?r:a,l=k(e,o);let s;return s=l?p(l,T(e),e.tagName||"*"):u(a)?p(`contains(normalize-space(.),${N(o)})`,T(e),e.tagName||"*"):!t.test(a)||/\s/.test(a.trim())?p(`normalize-space(.)=${N(o)}`,T(e),e.tagName||"*"):T(e)?`//*[local-name()='${e.tagName}' and .=${N(o)}]`:`//${e.tagName||"*"}[.=${N(o)}]`,s},Y=(e,t,n)=>{if(("."===t||"text()"===t)&&u(n)){const{fragment:t}=S(n);return t?p(`contains(normalize-space(.),${N(t)})`,T(e),e.tagName.toLowerCase()):""}return p(`normalize-space(${t})=${N(w(n)).trim()}`,T(e),e.tagName.toLowerCase())},V=(e,t,n)=>{if(("."===t||"text()"===t)&&u(n)){const{prefix:t,fragment:a}=S(n),r=t||a;return r?p(`starts-with(normalize-space(.),${N(r)})`,T(e),e.tagName.toLowerCase()):""}return p(`starts-with(${t},${N(w(n)).trim()})`,T(e),e.tagName.toLowerCase())},q=(e,t,n)=>{if(("."===t||"text()"===t)&&u(n)){const{fragment:t}=S(n);return t?p(`contains(normalize-space(.),${N(t)})`,T(e),e.tagName.toLowerCase()):""}return p(`contains(${t},${N(w(n)).trim()})`,T(e),e.tagName.toLowerCase())},W=(e,n)=>{const a=n.flatMap(n=>(n=>{const a=d(n.name,n.value);if(!a)return[];if("class"===n.name){const t=e.getRootNode?.()??e.ownerDocument;return f(e,a,t)}return u(a)?[]:t.test(a)?[`@${n.name}=${N(a)}`]:[`normalize-space(@${n.name})=${N(a)}`]})(n)).filter(Boolean);if(a.length>=2)return p(`${a[0]} or ${a[1]}`,T(e),e.tagName.toLowerCase());const r=(()=>{const n=w($(e)?.trim()||""),a=C(n);if(u(n))return a?`contains(normalize-space(.),${N(a)})`:null;const r=k(e,n);return r||(!n||n.length>80||/^\d+$/.test(n)?null:t.test(n)&&n.length<=40&&!n.includes(" ")?`text()=${N(n)}`:n.includes(" ")?`normalize-space(.)=${N(n)}`:`contains(text(),${N(n)})`)})();return 1===a.length&&r?p(`${a[0]} or ${r}`,T(e),e.tagName.toLowerCase()):""},U=(e,t,n)=>{try{return v(e,t,n)}catch(e){return 0}},F=(e,t)=>{const n=[],a=new Set,r=Array.from(e.attributes||[]),o=["id","data-testid","data-test","data-qa","name","aria-label","role"],l=[...o.map(e=>r.find(t=>t.name===e)).filter(Boolean),...r.filter(e=>!o.includes(e.name))],s=r=>{r&&!a.has(r)&&Z(r,e,t)&&(a.add(r),n.push(r))};l.forEach(t=>{if(O(t,e))for(const n of ee(e,t.name,t.value))s(n)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const t=j(e);t&&s(t)}if(r.length>1){const n=I(e,t,r);n&&s(n)}return n},H=(e,t)=>{const n=[];let a=t;for(;a&&a!==e;)n.unshift(J(a)),a=a.parentElement;return a===e?n.join("/"):""},G=(e,t)=>{const n=t??(e.getRootNode?.()||e.ownerDocument),a=J(e),r=T(e)?`//*[local-name()='${e.tagName.toLowerCase()}']`:`//${e.tagName.toLowerCase()}`;for(let t=e.parentElement;t;t=t.parentElement){const r=F(t,n);for(const o of r){console.log(`Trying ancestor XPath: ${o}`);const r=`${o}/descendant::${a}`;console.log(`Trying descendant XPath: ${r}`);const l=U(r,e,n);if(console.log(`Match count: ${l}`),1===l&&B(r,n)===e)return console.log(`Selected XPath: ${r}`),r;const s=H(t,e);if(s){const t=`${o}/${s}`;console.log(`Trying descendant XPath: ${t}`);const a=U(t,e,n);if(console.log(`Match count: ${a}`),1===a&&B(t,n)===e)return console.log(`Selected XPath: ${t}`),t}}}console.log(`Trying descendant XPath: ${r}`);const o=U(r,e,n);return console.log(`Match count: ${o}`),1===o&&B(r,n)===e?(console.log(`Selected XPath: ${r}`),r):(console.log("Selected XPath: "),"")},B=(e,t)=>{try{if(n=t,n?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in n){const{owner:n,contextNode:a,cloneElement:r}=R(t);return n.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue||r}return t.evaluate(e,t,null,t.defaultView.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch(e){return null}var n},Z=(e,t,n)=>{try{const{first:a,second:o}=r(e,n);return!!a&&!o&&a===t}catch{return!1}},J=e=>T(e)?`*[local-name()='${e.tagName.toLowerCase()}']`:e.tagName.toLowerCase(),K=(e,t,n)=>{if(!(e instanceof Element))return[];const a=new Set,r=[],o=Array.from(e.attributes||[]).filter(t=>{return t?.value&&(n=t.value,!/\d/.test(n))&&O(t,e);var n}),l=(e,t)=>{t&&!a.has(t)&&(a.add(t),r.push({key:e,value:t}))},s=["id","data-testid","data-test","data-qa","name","aria-label","role"];s.forEach(n=>{const a=o.find(e=>e.name===n);if(a)for(const n of ee(e,a.name,a.value))n&&Z(n,e,t)&&l(`anchor by ${a.name}`,n)}),o.forEach(n=>{if(!s.includes(n.name))for(const a of ee(e,n.name,n.value))a&&Z(a,e,t)&&l(`anchor by ${n.name}`,a)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const n=j(e);n&&Z(n,e,t)&&l("anchor by text",n)}if(o.length>1){const n=I(e,t,o);n&&Z(n,e,t)&&l("anchor by combination",n)}const c=G(e,t);return c&&Z(c,e,t)&&l("anchor by tag",c),r},Q=e=>{const t=$(e)?.trim(),n=C(t);if(t&&u(t))return n?`contains(normalize-space(.),${N(n)})`:void 0;const a=k(e,t);if(a)return a;const r=t?N(E(t)):t;return r?r!==`'${t}'`?`contains(.,${r})`:/\s/.test(t)?`normalize-space(.)='${w(t)}'`:`normalize-space(.)='${t}'`:void 0},ee=(e,t,n)=>{const a=new RegExp(/^[\S]+( [\S]+)*$/gi);let r="";if(n=d(t,n)){if("class"===t){const t=e.getRootNode?.()??e.ownerDocument;return f(e,n,t).map(t=>T(e)?`//*[local-name()='${e.tagName}' and ${t}]`:`//${e.tagName||"*"}[${t}]`)}if(u(n))return[];r=a.test(n)?T(e)?`//*[local-name()='${e.tagName}' and @${t}=${N(n)}]`:`//${e.tagName||"*"}[@${t}=${N(n)}]`:T(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${N(n)})]`:`//${e.tagName||"*"}[contains(@${t},${N(n)})]`}return r?[r]:[]},te=(e,t)=>e?e.replace(/\bdisabled\b/gi,"flndisabled"):e,ne=(e,n,a)=>{let r;const o=[];if(e.textContent&&(!a||a&&!h(e.textContent)))if(t.test(e.textContent)){const t=$(e),n=k(e,t),a=n||(/\s/.test(t.trim())?`normalize-space(.)=${N(w(t))}`:`.=${N(t)}`);r=T(e)?`*[local-name()='${e.tagName}' and ${a}]`:`${e.tagName}[${a}]`,r&&o.push({key:"getReferenceElementsXpath",value:r})}else{const t=Q(e);t&&(r=T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`,o.push({key:"getReferenceElementsXpath",value:r}))}if(e.attributes){const t="IMG"===e.tagName?Array.from(e.attributes).sort((e,t)=>"alt"===e.name?-1:"alt"===t.name?1:0):Array.from(e.attributes);for(const a of t)if(O(a,e)){let t=a.nodeValue;if(t){t=d(a.name,t);const l=a.name;if("class"!==l&&u(t))continue;if("class"===l){const a=f(e,t,n);if(!a.length)continue;for(const t of a)r=T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`,o.push({key:"getReferenceElementsXpath",value:r});continue}r=T(e)?`*[local-name()='${e.tagName}' and @${l}=${N(t)}]`:`${e.tagName}[@${l}=${N(t)}]`,r&&o.push({key:"getReferenceElementsXpath",value:r})}}}if(!o?.length){const t=Array.prototype.slice.call(e.attributes);if(t?.length>1){const t=I(e,n,Array.prototype.slice.call(e.attributes));t&&o.push({key:"getReferenceElementsXpath",value:t})}}if(!o?.length){const t=[];let n;const r=e.tagName;if(e.textContent&&a&&h(e.textContent)){const a=w($(e)).trim();a?.length>1&&t.push(`contains(text(),${N(a)})`),t?.length&&(n=T(e)?`*[local-name()='${r}' and ${t.join(" and ")}]`:`${r}[${t.join(" and ")}]`,n&&o.push({key:"getReferenceElementsXpath",value:n}))}}if(!o?.length){const t=((e,t)=>{const n=Array.prototype.slice.call(e),a=[];try{n.map(e=>{if(O(e,t)){const n=_(e,t);n&&a.push({key:`split xpath by ${e.name}`,value:n})}})}catch(e){console.log(e)}return a})(e.attributes,e);t?.length&&o.concat(t)}return o},ae=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"),re=(e,t)=>{let n=t,a=1;for(;a>0;){const t=e[++n];"("==t?a++:")"==t&&a--}return n};function oe(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",r=t.match(/@([a-z0-9:-]+)/);return{axis:a,attribute:r?.[1]??"none",usesNormalize:t.includes("normalize-space")}}(e);return["XPATH",`axis:${n.axis}`,`attr:${n.attribute}`,`normalize:${n.usesNormalize}`,`shape:${t}`].join("|")}function le(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/ /g,"\\ ")}function se(e,t,n,a){const r=a?.getRootNode?.()??e,o=e=>{try{return Array.from(r.querySelectorAll(e))}catch{return[]}};try{switch(t){case"id":return 1===o(`#${le(n)}`).length;case"name":return 1===o(`[name="${le(n)}"]`).length;case"className":return 1===o(`.${n}`).length;case"tagName":case"cssSelector":return 1===o(n).length;case"linkText":return 1===o("a").filter(e=>e.textContent?.trim()===n).length;case"partialLinkText":return 1===o("a").filter(e=>e.textContent?.includes(n)).length;default:return!1}}catch{return!1}}const ie={parseXml:(e,t)=>window.DOMParser?(new window.DOMParser).parseFromString(e,t):null,getReferenceElementsXpath:ne,getAbsoluteXPath:X,getRelativeXPath:L,getCombinationXpath:_,getAttributeCombinationXpath:I,getElementFromXpath:(e,t,n=!1)=>{let a=t;t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(a=t.host??t);const r=a.nodeType===Node.DOCUMENT_NODE?a:a.ownerDocument;return n?r.evaluate(e,a,null,XPathResult.ANY_TYPE,null):r.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue},isSvg:T,findXpathWithIndex:x,isNumberExist:h,getTextContent:$,getCountOfXPath:v,normalizeXPath:ae,getShadowRoot:A,escapeCharacters:N,removeParenthesis:b,checkBlockedAttributes:O,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:re,deleteGarbageFromInnerText:E,replaceTempAttributes:D,createObserver:e=>{o=new MutationObserver(t=>{t.forEach(t=>{("childList"===t.type||"characterData"===t.type||"attributes"===t.type&&"flndisabled"!==t.attributeName&&!g(t))&&a(t.target),t?.addedNodes?.length&&e(t?.addedNodes),t.target instanceof HTMLElement&&(g(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)=>{o?.observe(e,t)},stopObserver:()=>{o?.disconnect()},modifiedElementAttributes:s,cspEnabled:!1,getXPathPattern:oe,getNormalizedPropertyXPath:Y,getStartsWithPropertyXPath:V,getContainsPropertyXPath:q,getOrAttributesXPath:W,getTagOnlyXPath:G,getFirstMatchedNode:B,isExactUniqueXpath:Z,getAxisNodeTest:J,getUniqueNodeAnchorXpaths:K,escapeAttrValue:le,isUniqueInDOM:se,sanitizeAttributeValue:d,getClassTokenCondition:(e,t,n,a=!1)=>f(e,t,n,a)[0]||null,getClassTokenConditions:f,getXpathStrings:ee,intermediateXpathSteps:M,getContainerTextCondition:k};let ce=[],ue=[],fe=new Map,me=new Map;const de=new Map,ge={andConditions:"and",orConditions:"or",contains:"contains",startsWith:"startsWith",normalizeSpace:"normalizeSpace",axes:"axes",index:"index",hardCodedText:"text",tillTag:"tag"},he=(e,t)=>t.map(t=>({...t,key:t?.key?.includes(e)?t.key:`${e} ${t.key}`.trim()})),pe=(e,t)=>t?e:e.filter(e=>!(e=>/(?:^|\/)[^/\[]+\[\d+\](?=\/|$)/.test(e)||/^\(.+\)\[\d+\]$/.test(e))(e.value)),$e=e=>e?.textContent?.replace(/\s+/g," ")?.trim()||"",ye=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},ve=(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},Ne=(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:()=>ye(e)})),e="previous"===t?e.previousElementSibling:e.nextElementSibling}return n},be=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},xe=(e,t,n,a,r,o,l)=>{const s=J(n),i=[];let c=0;const u=t.includes("descendant")?10:20;for(const r of e){if(c++>u)break;if(i.length>=5)break;const e="node"in r?r.node:r;if(!(e instanceof Element))continue;if(be(e))continue;const f=[()=>K(e,a),()=>{const t=[],n=Array.from(e.attributes||[]).filter(t=>t?.value&&!/\d/.test(t.value)&&O(t,e));for(const a of n){const n=a.value;if(!n)continue;const r=q(e,`@${a.name}`,n);r&&t.push({key:"contains",value:r});const o=V(e,`@${a.name}`,n);o&&t.push({key:"starts-with",value:o})}return t},()=>[{key:"tag",value:G(e,a)}]];for(let r=0;r<f.length;r++){let c=f[r]();if(!c.length)continue;l||(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 r=`${e.value}/${t}::${s}`;if(Z(r,n,a)){if(i.push({key:o,value:r}),i.length>=2)return i;if(i.length>=5)return i}}if(l&&r===f.length-1)for(const r of c){const l=v(r.value,e,a);for(let e=1;e<=Math.min(l,3);e++){const l=`(${r.value})[${e}]/${t}::${s}`;if(Z(l,n,a)){if(i.push({key:o,value:l}),i.length>=2)return i;if(i.length>=5)return i}}}}if("expand"in r&&r.expand){const e=r.expand();let l=0;for(const r of e){if(l++>15)break;if(i.length>=5)break;if(!(r instanceof Element))continue;if(be(r))continue;const e=K(r,a);for(const r of e.slice(0,5)){const e=`${r.value}/${t}::${s}`;if(Z(e,n,a)){if(i.push({key:o,value:e}),i.length>=2)return i;if(i.length>=5)return i}}}}}return i},Ee=(e,t,n,a)=>{const r=[];for(let t=e.parentElement;t;t=t.parentElement)r.push(t);const o=ye(e),l=ve(e,"previous"),s=ve(e,"next"),i=Ne(e,"previous"),c=Ne(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(l),axis:"following-sibling",key:"following-sibling"}],[{nodes:u(r),axis:"child",key:"child"},{nodes:u(o,15),axis:"parent",key:"parent"}],[{nodes:u(r),axis:"descendant",key:"descendant"},{nodes:u(r),axis:"descendant-or-self",key:"descendant-or-self"},{nodes:u(o,10),axis:"ancestor",key:"ancestor"},{nodes:u(o,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 n of f)for(const r of n){const n=xe(r.nodes,r.axis,e,t,0,r.key,a);if(n.length>0)return n}return[]},we=(e,t,n,a,r)=>{const o=(e=>ge[e]||e)(a);return"text"===o?he(a,((e,t,n)=>{if(!$e(e))return[];if("text"===n){const n=j(e)||Xe(e,t,!1,!1);return n?[{key:"xpath by text",value:n}]:[]}return[]})(e,t,o)):["contains","startsWith","normalizeSpace"].includes(o)?he(a,((e,t,n)=>{const a=[],r=Array.from(e.attributes||[]).filter(t=>t?.value&&O(t,e)),o=$e(e),l="contains"===n?q:"startsWith"===n?V:"normalizeSpace"===n?Y:null;if(!l)return a;if(r.forEach(t=>{const r=l(e,`@${t.name}`,t.value);r&&a.push({key:`xpath by ${n} ${t.name}`,value:r})}),o){const t=l(e,".",o);t&&a.push({key:`xpath by ${n} text`,value:t})}return a})(e,0,o)):["and","or"].includes(o)?he(a,((e,t,n,a)=>{const r=Array.from(e.attributes||[]).filter(t=>t?.value&&O(t,e));if("and"===a){const n=I(e,t,r);return n?[{key:"xpath by combination",value:n}]:[]}if("or"===a&&r.length>=1){const t=W(e,r);return t?[{key:"xpath by or",value:t}]:[]}return[]})(e,t,0,o)):"axes"===o?he(a,Ee(e,t,0,!1)):"index"===o?he(a,((e,t)=>{const n=[],a=e.tagName.toLowerCase(),r=Array.from(t.querySelectorAll(a)).indexOf(e)+1;if(r<=0)return[];n.push({key:"xpath by index",value:`(//${a})[${r}]`});let o=e.parentElement;for(;o&&o!==t.body;){if(o.id||o.className){const t=o.id?ee(o,"id",o.id):ee(o,"class",o.className.toString());for(const r of t){const t=Array.from(o.querySelectorAll(a)).indexOf(e)+1;if(t>0){n.push({key:"xpath by index",value:`(${r}//${a})[${t}]`});break}}if(n.length>1)break}o=o.parentElement}return n})(e,t)):"tag"===o?he(a,[{key:"xpath till tag",value:G(e,t)}]):[]},ke=(e,t,n,a,r,o)=>{if(e){let l;l="parent"===o?[`${e}/descendant-or-self::${t}`,`${e}/following::${t}`]:[`${e}/ancestor-or-self::${t}`,`${e}/preceding::${t}`];for(const e of l){fe?.get(e)||fe.set(e,v(e,n,a));const t=fe?.get(e);if(1===t)return e;if(t>1&&(ue.length?t<ue[0].count&&(ue.pop(),ue.push({key:"relative xpath by unique parent "+(r?"index":""),value:e,count:t})):ue.push({key:"relative xpath by unique parent "+(r?"index":""),value:e,count:t})),t>1&&r&&!ce.length){const o=x(e,n,a,t);o&&1===v(o,n,a)&&ce.push({key:"relative xpath by unique parent "+(r?"index":""),value:o})}}}return null},Se=(e,n,a,r,o,l)=>{try{if(de.has(e))return de.get(e);const s=[];let i=e;for(;i&&1===i.nodeType;){const e=!1;for(const e of Array.from(i.attributes))if(O(e,i)){const t=d(e.name,e.nodeValue),r=e.name;for(const e of ee(i,r,t)){let t;try{t=ke(e,o,a,n,l,"parent")}catch(e){continue}if(t)return t}}if(i.textContent&&!i.textContent)if(!r||r&&!h(i.textContent)){let e;e=t.test(i.textContent)?T(i)?`//*[local-name()='${i.tagName}' and .=${N(y(i))}]`:`//${i.tagName||"*"}[.=${N(y(i))}]`:T(i)?`//*[local-name()='${i.tagName}' and normalize-space(.)=${N(y(i))}]`:`//${i.tagName||"*"}[normalize-space(.)=${N(y(i))}]`;const r=ke(e,o,a,n,l,"parent");if(r)return r}else{const e=[],t=[...new Set(y(i).match(/([^0-9]+)/g))],r=new RegExp(/^[\S]+( [\S]+)*$/gi);if(t?.length)for(let n=0;n<t?.length;n++)t[n]&&w(t[n].trim())&&(r.test(t[n])?e.push(`contains(.,${N(t[n].trim()).trim()})`):e.push(`contains(.,${N(w(t[n])).trim()})`));if(e?.length){const t=T(i)?`//*[local-name()='${i.tagName}' and ${e.join(" and ")}]`:`//${i.tagName||"*"}[${e.join(" and ")}]`,r=ke(t,o,a,n,l,"parent");if(r)return r}}if(!e){const e=T(i)?`/*[local-name()='${i.tagName}']`:`/${i.tagName}`;s.unshift(e)}i=i.parentElement}const c=s.join("")+o;if(1===v(c,e,n))return de.set(e,c),c}catch(e){return console.error(e),null}},Ce=(e,t,n,a)=>{const r=new Map;if(r.has(e))return r.get(e);const o=[];let l=e;try{for(;l&&1===l.nodeType;){if(!l.tagName)return"";let e=!1;for(const n of Array.from(l.attributes)){if(O(n,l)){const a=d(n.name,n.nodeValue),r=n.name;for(const n of ee(l,r,a)){let a;try{a=v(n,l,t)}catch(e){continue}if(1===a){o.unshift(n),e=!0;break}}}if(e)break}if(!e&&l.textContent&&!n.textContent){const n=j(l);if(n){if(1===v(n,l,t)){e=!0,o.unshift(n);break}}}if(e)break;{const e=T(l)?`/*[local-name()='${l.tagName}']`:`/${l.tagName}`;o.unshift(e)}l=l.parentElement}const a=o.join("");return r.set(e,a),a}catch(e){return console.log(e),null}},Ae=(e,t,n)=>{const a=[];let r;const o=[];null!=e.firstElementChild&&e.firstElementChild.classList.contains("flntooltip")?o.unshift(e.firstElementChild):null!=e.nextElementSibling&&o.unshift(e.nextElementSibling);for(let t=e.parentElement;null!=t&&1===t.nodeType;t=t.parentElement)t.nextElementSibling&&o.unshift(t.nextElementSibling);try{do{let e=!1;for(r=o.pop();null!==r;){for(const n of Array.from(r.attributes)){if(O(n,r)){const o=d(n.name,n.nodeValue),l=n.name;for(const n of ee(r,l,o)){let o;try{o=v(n,r,t)}catch(e){continue}if(1===o){e=!0,a.push(n);break}}}if(e)break}if(!e&&r.textContent&&!n.textContent){const n=j(r);if(n){if(1===v(n,r,t)){e=!0,a.push(n);break}}}if(e)break;{const e=T(r)?`/*[local-name()='${r.tagName}']`:`/${r.tagName}`;a.push(e),null!=r.firstElementChild?(o.push(r.nextElementSibling),r=r.firstElementChild):r=r.nextElementSibling}}}while(o.length>0);const l=a.join("");return me.set(e,l),l}catch(e){return console.log(e),null}},Re=(e,t,n,a)=>{try{const r=document.querySelector(".flntooltip");for(let o=e.nextElementSibling;null!==o&&o!==r;o=o.nextElementSibling)Oe(o,e,t,a,"preceding-sibling",n);for(let o=e.previousElementSibling;null!==o&&o!==r;o=o.previousElementSibling)Oe(o,e,t,a,"following-sibling",n)}catch(e){return console.error("sibling error",e),null}},Oe=(e,t,n,a,r,o)=>{try{if(e.hasAttributes())for(const t of Array.from(e.attributes)){const l=M(e,{name:t.name,value:t.value},o);for(let t of l){t+=`/${r}::${a}`;const o=v(t,e,n);if(1===o)return void ce.push({key:`xpath by ${r}`,value:t});o>1&&(ue.length?o<ue[0].count&&(ue.pop(),ue.push({key:`relative xpath by ${r}`,value:t,count:o})):ue.push({key:`relative xpath by ${r}`,value:t,count:o}))}}if(!o){let t;if(t=z(e,{name:"text",value:e.textContent}),t){const a=v(t,e,n);if(1===a)return void ce.push({key:`xpath by ${r}`,value:t});a>1&&(ue.length?a<ue[0].count&&(ue.pop(),ue.push({key:`relative xpath by ${r}`,value:t,count:a})):ue.push({key:`relative xpath by ${r}`,value:t,count:a}))}}}catch(e){console.log(`${r} xpath-error`,e)}};function Te(e,t,n,a){const{tagName:r}=t,o=t.textContent.trim();if(!o)return;const l=w(o),s=C(l);if(u(l)&&!s)return;const i=u(l)?s:l,c=k(t,i);for(const a of e)if(O(a,t)){let e=d(a.name,a.nodeValue);const s=`//${r}[@${a.name}='${e}' and ${c||(u(l)?`contains(normalize-space(.),${N(i)})`:/\s/.test(o)?`normalize-space(.)=${N(i)}`:`text()=${N(i)}`)}]`;if(s){if(1==v(s,t,n))return s}}}const De=(e,t,n,a,r)=>{let o;if(o=e.name,O(e,t))return P(t,n,`@${o}`,e.value,a,r)},Pe=(e,t,n,a)=>{let r=e.className;if("string"!=typeof r&&(r=""),r=r?.replace("flndisabled","disabled"),r=d("class",r),r=r?.trim(),r&&O({name:"class",value:r},e))return P(e,t,"@class",r,n,a)},Xe=(e,t,n,a)=>{if(""!=(e.textContent??"").trim()){const r=$(e);if(r)return P(e,t,".",r,n,a)}},Le=(e,t,n,a,r)=>{const o=e;try{o.map(e=>{if("className"!==e.name&&"class"!==e.name&&O(e,t)){const o=De(e,t,n,a,r);o&&ce.push({key:`xpath by ${e.name}${a?" index":""}`,value:o})}});const l=Xe(t,n,a,r);if(l&&ce.push({key:"xpath by text"+(a?" index":""),value:l}),o.find(e=>"className"===e.name)&&O(o?.find(e=>"className"===e.name),t)){let e=Pe(t,n,a,r);e&&ce.push({key:"xpath by class",value:e})}if(!ce.length&&o.length>1){const e=I(t,n,o);e&&ce.push({key:"xpath by combination",value:e})}if(!ce.length){const a=Te(e,t,n);a&&ce.push({key:"xpath by textAttribute",value:a})}}catch(e){console.log(e)}},_e=(e,t,n,a,r=[],o=[])=>{ce=[],console.log(e);const l=e,s=l?.getRootNode?.(),i=s?.nodeType===Node.DOCUMENT_FRAGMENT_NODE,c=i?s:l?.ownerDocument||t,u=l.tagName,{attributes:f}=l,m=r.length>0?r:Array.from(f);if(Le(m,l,c,n,a),o.length){const e=o.flatMap(e=>we(l,c,0,e));return ce=(e=>{const t=new Set;return e.filter(e=>!(!e?.value||t.has(e.value)||(t.add(e.value),0)))})(e.filter(e=>1===v(e.value,l,c))),pe(ce,n)}if(ce.length){const t=ce.length;for(let n=0;n<t;n++){let t=ce[n].value;t="//*"+t.substring(t.indexOf("//")+2+u.length);1===v(t,e,c)&&ce.push({key:`${ce[n].key} regex`,value:t})}}return ce.length||i||(ce=Ee(l,c,0,n)),pe(ce,n)},Ie={parseDOM:_e,getTextXPath:Xe,getUniqueClassName:Pe,attributesBasedXPath:De,addAllXPathAttributes:Le,addRelativeXpaths:(e,t,n,a,r)=>{try{let o,l,s=[];if(ce=[],console.log(r),r)for(const t of r){const n=M(e,{name:t.name,value:t.value},a);console.log(n[0]||"");for(const e of n)e&&s.push(e)}if(e.textContent){let t=z(e,{name:"text",value:e.textContent});console.log(t),t&&s.push(t)}if(s.push(e.tagName),s?.length)for(let r=0;r<s.length;r++)if(!ce.length){if(Re(e,t,a,s[r]),!ce.length&&(o||(o=Ce(e.parentElement,t,e)),console.log(o),o&&(o.includes("@")||o.includes("text()")||o.includes(".="))&&o.match(/\//g)?.length-2<5)){const a=o+`/${s[r]}`,l=v(a,e,t);if(1===l)ce.push({key:"relative xpath by relative parent",value:a});else if(l>1&&n){const r=x(a,e,t,l);r&&1===v(r,e,t)&&ce.push({key:"relative xpath by relative parent "+(n?"index":""),value:r})}}if(!ce.length&&(l||(l=Ae(e,t,e)),l&&(l.includes("@")||l.includes("text()")||l.includes(".=")))){const a=`/${s[r]+l.substring(1)}`,o=v(a,e,t);if(1===o)ce.push({key:"relative xpath by relative child",value:a});else if(o>1&&n){const r=x(a,e,t,o);r&&1===v(r,e,t)&&ce.push({key:"relative xpath by relative parent "+(n?"index":""),value:r})}}if(1===ce?.length&&ce?.[0]?.value?.match(/\[([0-9]+)\]/gm)?.length>3&&e.textContent){const a=Xe(e,t,n,!1);a&&ce.unshift({key:"xpath by text"+(n?"index":""),value:a})}if(!ce.length){let o=Se(e.parentElement,t,e,a,s[r],n);o&&ce.push({key:"xpath by unique parent",value:o})}}return ce}catch(e){console.log(e)}},getXPathUsingAttributeAndText:Te,getSiblingRelativeXPath:Re,getChildRelativeXpath:Ae,getParentRelativeXpath:Ce,getUniqueParentXpath:Se,checkRelativeXpathRelation:ke,buildAxesStrategyXpaths:Ee};let ze=[],Me=[];const je=/^[\S]+( [\S]+)*$/gi,Ye=(e,t,n,a,r,o,l,s=0,i=!1)=>{let c="";if(t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g)?.length>=o.length){const c=[],u=t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);for(let e=1;e<=o.length;e++)c.unshift(e===o.length?o[o.length-e]:u[u.length-e]);const f=st(`${l+(s?"]".repeat(s):"")}`,c,e[e.length-1],e,a,n,r,i);if(f)return f}else{c=`//${l+(s?"]".repeat(s):"")}/${n}::${te(t,e[e.length-1])}`;let o=v(c,e[e.length-1],a);if(1===o)return[{key:`dynamic ${n}`,value:D(c)}];if(o>1&&r&&(c=x(c,e[e.length-1],a,o),c&&(o=v(c,e[e.length-1],a),1===o)))return[{key:`dynamic ${n} ${r?" index":""}`,value:D(c)}]}},Ve=(e,t,n,a,r,o=!1,l=!1)=>{const s=e[e.length-2],i=e[e.length-1],c=A(i)??i.ownerDocument,u=n.find(e=>e?.key?.includes("absolute"))?.value||X(s,s.ownerDocument),f=[],m=[];u.split("/").map(e=>f.push(e)),f.map(e=>m.push(e.replace(/\[([0-9]+)\]/gm,"")));const g=a.find(e=>e?.key?.includes("absolute"))?.value||X(i,i.ownerDocument),h=[],p=[];g.split("/").map(e=>h.push(e)),h.map(e=>p.push(e.replace(/\[([0-9]+)\]/gm,"")));for(var y=0;y<f.length&&f[y]==h[y];y++);const v=[];for(let e=y-1;e<f.length;e++)f[e]&&v.push(m[e]);const b=[];for(let e="descendant"===r?y:y-1;e<h.length;e++)h[e]&&(b.length?b.push(p[e]):b.push(p[e].replace(/\[([0-9]+)\]/gm,"")));let x;if(Me=a,e[e.length-2].textContent){if(je.test(e[e.length-2].textContent)){const t=e[e.length-2],n=$(t),a=k(t,n),r=a||(/\s/.test(n.trim())?`normalize-space(.)=${N(w(n))}`:`.=${N(n)}`);x=T(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${r}]`:`${e[e.length-2].tagName}[${r}]`}else x=T(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${Q(e[e.length-2])})]`:`${e[e.length-2].tagName}[${Q(e[e.length-2])}]`;v[v.length-1]=x;const n=v.join("["),a=v.length-1,s=n;for(let n=0;n<Me.length;n++){let i;if(i=Me[n].value.startsWith("//")?Me[n].value.substring(Me[n].value.indexOf("//")+2):Me[n].value,i){const n=Ye(e,i,r,c||t,o,b,s,a,l);if(n?.length)return n}}}if(e[e.length-2].attributes){for(const n of Array.from(e[e.length-2].attributes))if(O(n,e[e.length-2])){let a=n.nodeValue;if(a){a=d(n.name,a);const s=n.name;x=T(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and @${s}=${N(a)}]`:`${e[e.length-2].tagName}[@${s}=${N(a)}]`,v[v.length-1]=x;const i=v.join("["),u=v.length-1,f=i;for(let n=0;n<Me.length;n++){let a;a=Me[n].value.startsWith("//")?Me[n].value.substring(Me[n].value.indexOf("//")+2):Me[n].value;const s=Ye(e,a,r,c||t,o,b,f,u,l);if(s?.length)return s}}}for(const n of Array.from(e[e.length-2].attributes))if(O(n,e[e.length-2])){let a=n.nodeValue;if(a){a=d(n.name,a);const s=_(n,e[e.length-2]);if(s){x=s.startsWith("//")?s.substring(s.indexOf("//")+2):s,v[v.length-1]=x;const n=v.join("["),a=v.length-1,i=n;for(let n=0;n<Me.length;n++){let s;s=Me[n].value.startsWith("//")?Me[n].value.substring(Me[n].value.indexOf("//")+2):Me[n].value;const u=Ye(e,s,r,c||t,o,b,i,a,l);if(u?.length)return u}}}}}const E=v.join("["),S=v.length-1,C=st(`${E+(S?"]".repeat(S):"")}`,b,e[e.length-1],e,t,r,o,l);if(C)return C},qe=(e,t,n,a,r,o,l)=>{let s,i;console.log("getXpathRelationExpression",n);const c=[];try{if(s=a.filter(e=>!e?.key?.includes("absolute")).filter(t=>nt(t.value,e)),i=r.filter(e=>!e?.key?.includes("absolute")),"ancestor"===n||"ancestor-or-self"===n){const a=lt(e,t,n,s,i,o);if(a.length)return a}for(let a=0;a<s.length;a++)for(let r=0;r<i.length;r++){const l=0!==i[r].value.indexOf("//")?i[r].value:i[r].value.substring(i[r].value.indexOf("//")+2);if(("ancestor"===n||"ancestor-or-self"===n)&&l.split(We).length>1)continue;let u=`//${0!==s[a].value.indexOf("//")?te(s[a].value):te(s[a].value.substring(s[a].value.indexOf("//")+2))}/${n}::${te(l)}`;console.log("getXpathRelationExpression",u);const f=v(u,t,t.ownerDocument);if(f>1){const e=0!==s[a].value.indexOf("//")?te(s[a].value):te(s[a].value.substring(s[a].value.indexOf("//")+2)),r=Qe(e,n,t,i,t.ownerDocument);if(r)return c.push({key:`dynamic ${n}`,value:D(r)}),c;if(o){if(u=x(u,t,t.ownerDocument,f),u)return c.push({key:`dynamic ${n}${o?" index":""}`,value:D(u)}),c}else f>1&&(ze.length?f<ze[0].count&&(ze.pop(),ze.push({key:"relative xpath by relative child "+(o?"index":""),value:u,count:f})):ze.push({key:"relative xpath by relative child "+(o?"index":""),value:u,count:f}))}else if(1===f){if("following"===n&&l.split(We).length>1){const r=0!==s[a].value.indexOf("//")?te(s[a].value):te(s[a].value.substring(s[a].value.indexOf("//")+2)),o=Ke(r,e,t,n,i);if(o)return c.push({key:`dynamic ${n} bridge`,value:D(o)}),c}return c.push({key:`dynamic ${n}`,value:D(u)}),c}}if(!c.length){if("following"===n)for(let a=0;a<s.length;a++){const r=0!==s[a].value.indexOf("//")?te(s[a].value):te(s[a].value.substring(s[a].value.indexOf("//")+2)),o=Ke(r,e,t,n,i);if(o)return c.push({key:`dynamic ${n} bridge`,value:D(o)}),c}for(let a=0;a<s.length;a++)for(let r=0;r<i.length;r++){const u=`${0!==i[r].value.indexOf("//")?i[r].value:i[r].value.substring(i[r].value.indexOf("//")+2)}`.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);if(u.length>1){const r=0!==s[a].value.indexOf("//")?te(s[a].value):te(s[a].value.substring(s[a].value.indexOf("//")+2));if("following"===n){const a=Ke(r,e,t,n,i);if(a)return c.push({key:`dynamic ${n} bridge`,value:D(a)}),c}const f=st(r,u,t,[e,t],t.ownerDocument,n,o,l);if(console.log("getXpathRelationExpression traverseXpath",f),f)return c.push(...f),c}}}}catch(e){console.log(e)}return c},We=/\/(?=(?:[^']*'[^']*')*[^']*$)/g,Ue=e=>0===e.indexOf("//")?e.substring(e.indexOf("//")+2):e,Fe=(e,t)=>He(e,t)[0]||"",He=(e,t)=>{const n=[];let a="";const r=e=>{e&&!n.includes(e)&&n.push(e)};for(const n of t){const t=Ue(n.value);if(t&&1===t.split(We).length){if(t===e.tagName||t===e.tagName.toLowerCase()){a=t;continue}r(te(t))}}for(const t of Ge){const n=e.getAttribute(t);if(!n)continue;const a=Be(t,n);a&&r(T(e)?`*[local-name()='${e.tagName}' and ${a}]`:`${e.tagName}[${a}]`)}if(e.textContent){const t=Q(e);t&&r(T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`)}const o=f(e,e.getAttribute("class"),e.getRootNode?.()??e.ownerDocument,!1);for(const t of o)r(T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`);if(e.attributes)for(const t of Array.from(e.attributes))"class"!==t.name&&O(t,e)&&t.nodeValue&&r(T(e)?`*[local-name()='${e.tagName}' and @${t.name}=${N(d(t.name,t.nodeValue))}]`:`${e.tagName}[@${t.name}=${N(d(t.name,t.nodeValue))}]`);return a&&r(a),r(T(e)?`*[local-name()='${e.tagName}']`:e.tagName),n},Ge=["aria-labelledby","aria-label","role","name","data-testid","data-test","data-qa","data-id","id"],Be=(e,t)=>{const n=d(e,t);return n?/\d/.test(n)?"":`@${e}=${N(n)}`:""},Ze=(e,t,n,a,r,o,l)=>{let s=n.parentElement,i=0;for(;s&&s!==a&&i<6;){i++;for(const t of Ge){const a=s.getAttribute(t);if(!a)continue;const i=Be(t,a);if(!i)continue;const c=T(s)?`*[local-name()='${s.tagName}' and ${i}]`:`${s.tagName}[${i}]`,u=`//${te(e)}/${r}::${o}/descendant::${c}/descendant::${te(l)}`;if(1===v(u,n,n.ownerDocument))return u}s=s.parentElement}return""},Je=["title",...Ge],Ke=(e,t,n,a,r)=>{if("following"!==a)return"";const o=He(n,r);if(!o.length)return"";const l=tt(`//${te(e)}`,t.ownerDocument)||t;let s=n.parentElement,i=0;for(;s&&i<6;){i++;if(l.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING){for(const t of Je){const r=s.getAttribute(t);if(!r)continue;const l=Be(t,r);if(!l)continue;const i=T(s)?`*[local-name()='${s.tagName}' and ${l}]`:`${s.tagName}[${l}]`;for(const t of o){const r=`//${te(e)}/${a}::${i}/descendant::${te(t)}`;if(1===v(r,n,n.ownerDocument))return r}}s=s.parentElement}else s=s.parentElement}return""},Qe=(e,t,n,a,r)=>{if("descendant"!==t&&"descendant-or-self"!==t)return"";for(const o of a){const a=Ue(o.value);if(!a||a.split(We).length>1||/\[\d+\]/.test(a))continue;const l=`//${e}/${t}::${te(a)}`;if(1===v(l,n,r))return l}return""},et=(e,t,n,a)=>{if("descendant"!==t&&"descendant-or-self"!==t)return"";const r=Fe(n,_e(n,n.ownerDocument,!1,!1)||[]);let o=n.parentElement,l=0;for(;o&&l<6;){l++;for(const l of Ge){const s=o.getAttribute(l);if(!s)continue;const i=Be(l,s);if(!i)continue;const c=`//${e}/${t}::${T(o)?`*[local-name()='${o.tagName}' and ${i}]`:`${o.tagName}[${i}]`}/descendant::${te(r)}`;if(1===v(c,n,a))return c}o=o.parentElement}return""},tt=(e,t)=>{try{const n=t.evaluate(e,t,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return n instanceof Element?n:null}catch{return null}},nt=(e,t)=>{const n=Ue(e);if(!n)return!1;try{const e=t.ownerDocument.evaluate(`//${te(n)}`,t.ownerDocument,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);let a=e.iterateNext();for(;a;){if(a===t)return!0;a=e.iterateNext()}}catch{return!1}return!1},at=e=>{const t=e.getAttribute("fill"),n=e.getAttribute("stroke");if(/\d/.test(t||"")||/\d/.test(n||""))return"";const a=t?`@fill=${N(t)}`:n?`@stroke=${N(n)}`:"";return a?`*[local-name()='${e.tagName.toLowerCase()}' and ${a}]`:""},rt=(e,t,n)=>{const a=t.getAttribute("fill"),r=t.getAttribute("stroke"),o=Array.from(e.querySelectorAll(t.tagName.toLowerCase())).slice(0,30);let l=0;for(const e of o){if(a&&e.getAttribute("fill")!==a||!a&&r&&e.getAttribute("stroke")!==r)continue;const t=e.closest(n.tagName.toLowerCase());if(t&&(l++,t!==n||l>1))return!1}return 1===l},ot=(e,t,n,a,r)=>{const o=Array.from(n.querySelectorAll("path,use,circle,rect,polygon,polyline,line")).slice(0,25);if(!o.length)return"";const l=[...(s=a,f(s,s.getAttribute("class"),s.getRootNode?.()??s.ownerDocument).map(e=>`${s.tagName.toLowerCase()}[${e}]`)),a.tagName];var s;for(const t of o){const o=at(t);if(o&&rt(a,t,n))for(const t of l)return`//${te(e)}/${r}::${t}/descendant::${o}/ancestor::${n.tagName.toLowerCase()}`}return""},lt=(e,t,n,a,r,o)=>{const l=[],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 l;const i=T(s)?`*[local-name()='${s.tagName}']`:s.tagName,c=((e,t,n)=>{const a=[];let r=t;for(;r&&r!==e;){const e=r===t?Fe(t,n):T(r)?`*[local-name()='${r.tagName}']`:r.tagName;a.unshift(e),r=r.parentElement}return r===e?a.join("/"):""})(s,t,r);if(!c)return l;const u=c.split(We).length>1?Fe(t,r):"",f=u?((e,t)=>{let n=e,a=0;const r=[],o=new Set(["SECTION","FIELDSET","FORM","ARTICLE","MAIN"]);for(;n&&n.contains(t)&&a<6;){a++;for(const e of Ge){const t=n.getAttribute(e);if(!t)continue;const l=Be(e,t);if(!l)continue;const s=T(n)?`*[local-name()='${n.tagName}' and ${l}]`:`${n.tagName}[${l}]`,i=(o.has(n.tagName)?100:0)+("data-testid"===e?20:0)-a;r.push({nodeTest:s,score:i});break}n=n.parentElement}return r.sort((e,t)=>t.score-e.score)[0]?.nodeTest||""})(s,t):"";for(const e of a){const a=Ue(e.value);if(!a)continue;if(f){const e=`//${te(a)}/${n}::${f}/descendant::${te(u)}`;if(1===v(e,t,t.ownerDocument))return l.push({key:`dynamic ${n} bridge`,value:D(e)}),l}let r=u?`//${te(a)}/${n}::${i}/descendant::${te(u)}`:`//${te(a)}/${n}::${i}/${c}`,m=v(r,t,t.ownerDocument);const d=ot(a,0,t,s,n);if(d)return l.push({key:`dynamic ${n} icon bridge`,value:D(d)}),l;if(1===m)return l.push({key:`dynamic ${n} bridge`,value:D(r)}),l;if(u&&m>1){const e=Ze(a,0,t,s,n,i,u);if(e)return l.push({key:`dynamic ${n} bridge`,value:D(e)}),l;if(r=`//${te(a)}/${n}::${i}/${c}`,m=v(r,t,t.ownerDocument),1===m)return l.push({key:`dynamic ${n} bridge`,value:D(r)}),l}if(m>1&&o&&(r=x(r,t,t.ownerDocument,m),m=r?v(r,t,t.ownerDocument):0,r&&1===m))return l.push({key:`dynamic ${n} bridge index`,value:D(r)}),l}return l},st=(e,t,n,a,r,o,l,s)=>{let i;if(s){const s=t.join("/");i=`//${e}/${o}::${te(s)}`;const c=v(i,n,r);if(1===c)return[{key:`dynamic ${o}`,value:D(i)}];if(c>1&&l&&(i=x(i,a[a.length-1],r,c),i))return[{key:`dynamic ${o}${l?" index":""}`,value:D(i)}]}else for(let s=1;s<=t.length;s++){const c=it(t.slice(t.length-s,t.length).join("/"),n);for(const t of c){i=`//${e}/${o}::${te(t)}`;const s=v(i,n,r);if(1===s){if(t.split(We).length>1||/\[\d+\]/.test(t)){const t=et(e,o,n,r);if(t)return[{key:`dynamic ${o}`,value:D(t)}]}return[{key:`dynamic ${o}`,value:D(i)}]}if(s>1){const t=Qe(e,o,n,_e(n,n.ownerDocument,!1,!1)||[],r);if(t)return[{key:`dynamic ${o}`,value:D(t)}];const c=et(e,o,n,r);if(c)return[{key:`dynamic ${o}`,value:D(c)}];if(l&&(i=x(i,a[a.length-1],r,s),i))return[{key:`dynamic ${o}${l?" index":""}`,value:D(i)}]}}}},it=(e,t)=>{const n=t.getAttribute("class")||"",a=f(t,n,t.getRootNode?.()??t.ownerDocument);if(!a.length)return[e];const r=`${t.tagName}[@class=${N(n)}]`;return e.endsWith(r)?a.map(n=>{const a=`${t.tagName}[${n}]`;return`${e.slice(0,-r.length)}${a}`}):[e]},ct={findRelativeXpath:(e,t,n,a,r,o,l=!1,s=null)=>{let i=[];const c=s||[],u=(o,s)=>{let c=[];c="descendant"===o||"descendant-or-self"===o?Ve([e,t],n,a,r,o,s,l)||[]:qe(e,t,o,a,r,s,l)||[],c.length&&(i=i.concat(c))};for(const e of c)u(e,o);return i},getDescendantXpath:Ve,getAncestorBridgeXpath:lt,getXpathRelationExpression:qe,getTraverseXpathExpression:st,getReferenceElementXpath:e=>{let t=[];t=_e(e,e.ownerDocument,!1,!1);const n=ne(e,e.ownerDocument,!1);if(n?.length&&(t=t?.length?t.concat(n):n),t?.length){let n=_e(e,e.ownerDocument,!0,!1);n?.length&&(n=n?.map(e=>"("==e.value.charAt(0)&&re(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:b(e.value)}:{key:"",value:e.value}),t=t.concat(n))}else t=_e(e,e.ownerDocument,!0,!1),t=t?.map(e=>"("==e.value.charAt(0)&&re(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:b(e.value)}:{key:"",value:e.value});t?.length||(t=[{key:"",value:L(e,e.ownerDocument,!1,!1,Array.from(e.attributes))}]),t?.length||(t=[{key:"",value:L(e,e.ownerDocument,!0,!1,Array.from(e.attributes))}],t=t?.map(e=>"("==e.value.charAt(0)&&re(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:b(e.value)}:{key:"",value:e.value}));const a=Array.from(e.children||[]).map(t=>{const n=$(t)?.trim();if(!n||n!==$(e)?.trim())return null;const a=k(t,n),r=a||(/\s/.test(n)?`normalize-space(.)=${N(w(n))}`:`.=${N(n)}`);return{key:"reference child text",value:`${t.tagName}[${r}]`}}).filter(e=>!!e);a.length&&(t=a.concat(t));const r=X(e,e.ownerDocument);return t=t.filter(e=>e.value!==r),t.push({key:"absolute xpath",value:r.slice(1)}),t},getSmartRelations:(e,t)=>{const n=e.compareDocumentPosition(t),a=[],r=[],o=[];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&&r.push("following"),n&Node.DOCUMENT_POSITION_PRECEDING&&r.push("preceding"),o.push("descendant","descendant-or-self");const l=[...a,...r,...o];return[...new Set(l)]}};let ut=[];const ft=(e,t,n)=>{try{const a=n.querySelectorAll(e);return 1===a.length&&a[0]===t}catch{return!1}},mt=(e,t="single")=>{const n=[],a=e.getRootNode();try{const r=dt(e);if(r&&ft(r,e,a)&&(n.push({key:"cssSelector by id",value:r}),"single"===t))return n;const o=$t(e);o&&ft(o,e,a)&&n.push({key:"cssSelector by class",value:o});const l=pt(e);l&&n.push({key:"cssSelector by name",value:l})}catch(e){console.error(e)}return n},dt=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&&!h(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(" > ")},gt=new Set(["id","class","style"]);function ht(e){return Array.from(e.attributes).filter(e=>!gt.has(e?.name?.toLowerCase())&&e.value&&!h(e.value)).map(e=>{return`[${e.name}="${t=e.value,String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`;var t})}const pt=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 r=ht(e);for(const t of r){const r=`${a}${t}`;if(ft(r,e,n))return r}},$t=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||h(e.className)||ut?.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(" > ")},yt={parseCssSelectors:mt,getIdCssPath:dt,getAttributeCssPath:pt,getClassCssPath:$t,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 r=e.parentNode;if(r){const t=Array.from(r.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(" > ")}},vt=(e,t,n)=>{const a=ae(e);if(Rt(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},Nt=(e,t)=>{try{const n=e.querySelector(t);if(n)return n}catch(e){return console.error("Invalid CSS selector:",t,e),null}return Et(e.body,t)},bt=(e,t,n)=>Nt(t,e)===n,xt=e=>e.name?.toLowerCase().includes("cssselector")??!1,Et=(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=Et(a,t);if(e)return e;if(a&&!t.includes("dynamic"))return a.querySelector(t)}}}catch(e){console.log(e)}return null},wt=e=>e?.id||null,kt=e=>e.className||null,St=e=>e.textContent?.trim()||null,Ct=e=>{const t=e;if(t.hasAttribute("name")){return`${t.getAttribute("name")}`||null}return null},At=["/preceding-sibling","/following-sibling","/parent","/descendant","/ancestor","/self","/ancestor-or-self","/child","/preceding","/following"];function Rt(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 Ot(e,t,n){if(e.includes(t)){const a=e.split(t)[0].trim(),r=n.defaultView;if(!r)return null;if(!e.includes("dynamic")){const t=new r.XPathEvaluator;if(t.evaluate(a,n,null,r.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue){let a;return t.evaluate(e,n,null,r.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 Tt=(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 r=[];function o(e,t={}){const n=e?.value,o=t.value??e?.value,l={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;l.isSelfHealed=s?"Y":t.hasOwnProperty("isSelfHealed")?t.isSelfHealed:((e,t,n)=>t&&n&&t===n?null:"Y")(l.name,n,o),function(e){const t=`${e.name}:${e.value}`;a.has(t)||(a.add(t),r.push(e))}(l)}function l(e,t,n){if(xt(t))return Nt(e,n);if(t.name.includes("id")||n.startsWith("#"))return e.querySelector("#"+le(n));if(t.name.includes("className")||n.startsWith("."))return e.querySelector("."+n);if("name"===t.name){const t=le(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=Rt(e,ae(n));return a&&o(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 r=l(a,t,n);if(r)return r}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)o(e);const u=String(n.value||n.type||"");if(u.includes("dynamic")||u.match("dynamic")||u.includes("{")||u.includes("}")){o(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=l(t,n,a),c||(c=s(t,n,a)),c||(c=Et(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=>xt(e)&&e.value);for(const e of n)vt(e.value,t,c)&&o(e,{isSelfHealed:null});for(const e of a)bt(e.value,t,c)&&o(e,{isSelfHealed:null});const l=r.filter(e=>"xpath"===e.name&&e.value),s=new Set(l.map(e=>oe(e.value))),u=[],m=wt(c);if(m&&!f("id",m)&&!h(m)){const n=e.locators.find(e=>"id"===e.name);se(t,"id",m,c)&&(u.push("id"),o(n,{name:"id",type:"static",isRecorded:"Y",value:m}))}const d=c.tagName;if(d&&!f("tagName",d)){const n=e.locators.find(e=>"tagName"===e.name);se(t,"tagName",d,c)&&(u.push("tagName"),o(n,{name:"tagName",type:"static",isRecorded:"Y",value:d}))}const g=St(c);if(g&&!h(g)){const n=e.locators.find(e=>"linkText"===e.name);se(t,"linkText",g,c)&&(u.push("linkText"),o(n,{name:"linkText",type:"static",isRecorded:"Y",value:g}))}const p=Ct(c);if(p&&!f("name",p)&&!h(p)){const n=e.locators.find(e=>"name"===e.name);se(t,"name",p,c)&&(u.push("name"),o(n,{name:"name",type:"static",isRecorded:"Y",value:p}))}const $=kt(c);if($&&""!==$.trim()&&!$.includes(" ")&&!f("className",$)&&!h($)){const n=e.locators.find(e=>"className"===e.name);se(t,"className",$,c)&&(u.push("className"),o(n,{name:"className",type:"static",isRecorded:"Y",value:$}))}mt(c,"single").forEach(e=>{e.value&&!f("cssSelector",e.value)&&o(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=_e(c,t,!1,!0,y)??[]}catch(e){console.error("Error generating XPath candidates:",e)}if(0!==v?.length){const e=n.filter(e=>!vt(e.value,t,c));let a=0;for(const t of e){if(a>=e.length)break;const n=oe(t.value);if(s.has(n))continue;const r=v.find(e=>e.value&&oe(e.value)===n);r?.value&&(o(t,{name:"xpath",value:r.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=oe(t.value);s.has(n)||(o(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 At)if(a.value.includes(e)){const r=Ot(a.value,e,t);if(r){o(a,{name:"xpath",value:r,isRecorded:""!==n.isRecorded&&null!==n.isRecorded?n.isRecorded:"Y"});break}}}catch(e){console.error("Error processing locator:",n,e)}if(r.length<5){const e=[{name:"id",value:wt(c)},{name:"name",value:Ct(c)},{name:"className",value:kt(c)},{name:"tagName",value:c.tagName},{name:"linkText",value:St(c)}];for(const n of e){if(r.length>4)break;const{name:e,value:a}=n;a&&(h(a)||f(e,a)||"className"===e&&a.includes(" ")||se(t,e,a,c)&&o(void 0,{name:e,type:"static",value:a,isRecorded:"Y",isSelfHealed:"Y"}))}r.length<5&&mt(c,"multiple").forEach(e=>{r.length>4||e.value&&(f("cssSelector",e.value)||se(t,"cssSelector",e.value,c)&&o(void 0,{name:"cssSelector",type:"static",value:e.value,isRecorded:"Y",isSelfHealed:"Y"}))})}const N=r.map(e=>({...e,value:i(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};const Dt={getOptimalClassChain:function e(t,n,a){try{if(!n||1!==n.nodeType||!n.tagName||"XCUIElementTypeApplication"===n.tagName)return"";const r=n.tagName,o=["name","label","value"];for(const e of o){const o=a.find(t=>t.name===e);if(!o)continue;let l=o.value;if(!l)continue;if(l=l.trim().replace(/\s+/g," "),h(l))continue;const s=`//${r}[@${e}="${l}"]`;let i=0;try{i=v(s,n,t)}catch(e){console.log(e);continue}const c=/\s/.test(l);if(1===i)return c?`/${r}[\`${e} CONTAINS "${l}"\`]`:`/${r}[\`${e} == "${l}"\`]`;if(i>1&&n.parentElement){const t=Array.from(n.parentElement.children).filter(e=>e.tagName===r).indexOf(n)+1;return c?`/${r}[\`${e} CONTAINS "${l}"\`][${t}]`:`/${r}[\`${e} == "${l}"\`][${t}]`}}let l=`/${r}`;if(n.parentElement){const e=Array.from(n.parentElement.children).filter(e=>e.tagName===r);if(e.length>1){l+=`[${e.indexOf(n)+1}]`}}return e(t,n.parentElement,a)+l}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=[],r=[];for(let o of n){const n=o.value,l=o.name;if(0!==n.length&&(n&&!h(n))){a.push(`@${l}="${n}"`);const o=`//*[${a.join(" and ")}]`;let s;r.push(`${l} == "${n}"`);try{s=v(o,t,e)}catch(e){console.log(e);continue}if(1===s)return r.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}},Pt=()=>({xpath:Ie,referenceXpaths:ct,xpathUtils:ie,getElementsFromHTML:Tt,cssSelectors:yt,iosSelectors:Dt});e.createXPathAPI=Pt,e.default=Pt,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:
|
|
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,29 @@ 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;
|
|
116
|
+
getClassTokenCondition: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string | null;
|
|
117
|
+
getClassTokenConditions: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string[];
|
|
118
|
+
getXpathStrings: (node: HTMLElement | Element, attrName: string, attrValue: string) => string[];
|
|
119
|
+
intermediateXpathSteps: (targetElemt: HTMLElement | Element, attr: {
|
|
120
|
+
name: string;
|
|
121
|
+
value: string;
|
|
122
|
+
}, isTarget: boolean) => string[];
|
|
123
|
+
getContainerTextCondition: (element: HTMLElement | Element, text: string | null | undefined) => string;
|
|
88
124
|
};
|
|
89
125
|
getElementsFromHTML: (record: import("../types/locator.ts").ElementRecord, docmt: Document) => {
|
|
90
126
|
[key: string]: any;
|
|
@@ -110,5 +146,9 @@ export declare const createXPathAPI: () => {
|
|
|
110
146
|
getClassCssPath: (el: HTMLElement | Element) => string | undefined;
|
|
111
147
|
getAbsoluteCssPath: (el: Element) => string | undefined;
|
|
112
148
|
};
|
|
149
|
+
iosSelectors: {
|
|
150
|
+
getOptimalClassChain: (doc: Document, domNode: HTMLElement | Element | null, uniqueAttributes: Attr[]) => string | null;
|
|
151
|
+
getOptimalPredicateString: (doc: Document, domNode: HTMLElement | Element | null, uniqueAttributes: Attr[]) => string | null;
|
|
152
|
+
};
|
|
113
153
|
};
|
|
114
154
|
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:
|
|
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:
|
|
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,22 @@
|
|
|
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 hasNumericAttributeValue: (value: string | null | undefined) => boolean;
|
|
17
|
+
export declare const getClassTokenConditions: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string[];
|
|
18
|
+
export declare const getClassTokenCondition: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string | null;
|
|
19
|
+
export declare const sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
|
|
9
20
|
export declare const createObserver: (addedNodeCallBack: Function) => void;
|
|
10
21
|
export declare const startObserver: (target: Node, options: MutationObserverInit | undefined) => void;
|
|
11
22
|
export declare const stopObserver: () => void;
|
|
@@ -18,7 +29,19 @@ export declare const escapeCharacters: (text: string) => string;
|
|
|
18
29
|
export declare const removeParenthesis: (xpath: string) => string;
|
|
19
30
|
export declare const findXpathWithIndex: (val: string, node: HTMLElement | Element, docmt: Node, count: number) => string | undefined;
|
|
20
31
|
export declare const replaceWhiteSpaces: (str: string) => string;
|
|
32
|
+
export declare const getContainerTextCondition: (element: HTMLElement | Element, text: string | null | undefined) => string;
|
|
33
|
+
export declare const getStableTargetTextCandidates: (text: string | null | undefined) => {
|
|
34
|
+
prefix: string;
|
|
35
|
+
fragment: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const getStableTargetText: (text: string | null | undefined) => string;
|
|
21
38
|
export declare const getShadowRoot: (el: HTMLElement | Element) => Element | null;
|
|
39
|
+
export declare const createShadowEvaluationContext: (root: ShadowRoot, element?: HTMLElement | Element | (HTMLElement | Element)[]) => {
|
|
40
|
+
owner: Document;
|
|
41
|
+
contextNode: HTMLDivElement;
|
|
42
|
+
cloneElement: Element | null;
|
|
43
|
+
cloneElements: (Element | null)[];
|
|
44
|
+
};
|
|
22
45
|
export declare const checkBlockedAttributes: (attribute: {
|
|
23
46
|
name: string;
|
|
24
47
|
value: string;
|
|
@@ -30,14 +53,31 @@ export declare const getPropertyXPath: (element: HTMLElement | Element, docmt: D
|
|
|
30
53
|
export declare const getAbsoluteXPath: (domNode: HTMLElement | Element | null, docmt: Document) => string;
|
|
31
54
|
export declare const getRelativeXPath: (domNode: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean | undefined, attributesArray: Attr[]) => any;
|
|
32
55
|
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;
|
|
56
|
+
export declare const getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document | ShadowRoot, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
|
|
34
57
|
export declare const intermediateXpathStep: (targetElemt: HTMLElement | Element, attr: {
|
|
35
58
|
name: string;
|
|
36
59
|
value: string;
|
|
37
60
|
}, isTarget: boolean) => string;
|
|
38
|
-
export declare const
|
|
61
|
+
export declare const intermediateXpathSteps: (targetElemt: HTMLElement | Element, attr: {
|
|
62
|
+
name: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}, isTarget: boolean) => string[];
|
|
65
|
+
export declare const getFilteredTextXPath: (node: HTMLElement | Element, docmt: Document | ShadowRoot) => string;
|
|
66
|
+
export declare const getNormalizedPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
|
|
67
|
+
export declare const getStartsWithPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
|
|
68
|
+
export declare const getContainsPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
|
|
69
|
+
export declare const getOrAttributesXPath: (element: HTMLElement | Element, attributes: Attr[]) => string;
|
|
70
|
+
export declare const getTagOnlyXPath: (element: HTMLElement | Element, docmt?: Document | ShadowRoot) => string;
|
|
71
|
+
export declare const getFirstMatchedNode: (xpath: string, docmt: Document | ShadowRoot) => HTMLElement | Element | null;
|
|
72
|
+
export declare const isExactUniqueXpath: (xpath: string, element: HTMLElement | Element, docmt: Document | ShadowRoot) => boolean;
|
|
73
|
+
export declare const getAxisNodeTest: (element: HTMLElement | Element) => string;
|
|
74
|
+
export declare const getUniqueNodeAnchorXpaths: (node: HTMLElement | Element, docmt: Document | ShadowRoot, isTarget: boolean) => {
|
|
75
|
+
key: string;
|
|
76
|
+
value: string;
|
|
77
|
+
}[];
|
|
39
78
|
export declare const getTextXpathFunction: (domNode: HTMLElement | Element) => string | undefined;
|
|
40
79
|
export declare const getXpathString: (node: HTMLElement | Element, attrName: string, attrValue: string) => string;
|
|
80
|
+
export declare const getXpathStrings: (node: HTMLElement | Element, attrName: string, attrValue: string) => string[];
|
|
41
81
|
export declare const replaceActualAttributes: (str: string, element: {
|
|
42
82
|
attributes: any;
|
|
43
83
|
}) => string;
|
|
@@ -67,7 +107,7 @@ export declare const xpathUtils: {
|
|
|
67
107
|
getAbsoluteXPath: (domNode: HTMLElement | Element | null, docmt: Document) => string;
|
|
68
108
|
getRelativeXPath: (domNode: HTMLElement | Element, docmt: Document, isIndex: boolean, isTarget: boolean | undefined, attributesArray: Attr[]) => any;
|
|
69
109
|
getCombinationXpath: (attribute: Attr, domNode: HTMLElement | Element) => string | undefined;
|
|
70
|
-
getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
|
|
110
|
+
getAttributeCombinationXpath: (domNode: HTMLElement | Element, docmt: Document | ShadowRoot, uniqueAttributes: Attr[], isTarget: boolean) => string | undefined;
|
|
71
111
|
getElementFromXpath: (xpath: string, docmt: Node, multi?: boolean) => Node | XPathResult | null;
|
|
72
112
|
isSvg: (element: HTMLElement | Element) => element is SVGElement;
|
|
73
113
|
findXpathWithIndex: (val: string, node: HTMLElement | Element, docmt: Node, count: number) => string | undefined;
|
|
@@ -97,6 +137,28 @@ export declare const xpathUtils: {
|
|
|
97
137
|
}[];
|
|
98
138
|
cspEnabled: boolean;
|
|
99
139
|
getXPathPattern: typeof getXPathPattern;
|
|
140
|
+
getNormalizedPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
|
|
141
|
+
getStartsWithPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
|
|
142
|
+
getContainsPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
|
|
143
|
+
getOrAttributesXPath: (element: HTMLElement | Element, attributes: Attr[]) => string;
|
|
144
|
+
getTagOnlyXPath: (element: HTMLElement | Element, docmt?: Document | ShadowRoot) => string;
|
|
145
|
+
getFirstMatchedNode: (xpath: string, docmt: Document | ShadowRoot) => HTMLElement | Element | null;
|
|
146
|
+
isExactUniqueXpath: (xpath: string, element: HTMLElement | Element, docmt: Document | ShadowRoot) => boolean;
|
|
147
|
+
getAxisNodeTest: (element: HTMLElement | Element) => string;
|
|
148
|
+
getUniqueNodeAnchorXpaths: (node: HTMLElement | Element, docmt: Document | ShadowRoot, isTarget: boolean) => {
|
|
149
|
+
key: string;
|
|
150
|
+
value: string;
|
|
151
|
+
}[];
|
|
100
152
|
escapeAttrValue: typeof escapeAttrValue;
|
|
101
153
|
isUniqueInDOM: typeof isUniqueInDOM;
|
|
154
|
+
sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
|
|
155
|
+
getClassTokenCondition: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string | null;
|
|
156
|
+
getClassTokenConditions: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string[];
|
|
157
|
+
getXpathStrings: (node: HTMLElement | Element, attrName: string, attrValue: string) => string[];
|
|
158
|
+
intermediateXpathSteps: (targetElemt: HTMLElement | Element, attr: {
|
|
159
|
+
name: string;
|
|
160
|
+
value: string;
|
|
161
|
+
}, isTarget: boolean) => string[];
|
|
162
|
+
getContainerTextCondition: (element: HTMLElement | Element, text: string | null | undefined) => string;
|
|
102
163
|
};
|
|
164
|
+
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;
|