@dev-blinq/cucumber_client 1.0.1348-dev → 1.0.1349-dev
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.
|
@@ -15,7 +15,7 @@ ${e.stack}`,{e:{n:e.name,m:e.message,s:l}}}if(Ql(e))return{d:e.toJSON()};if(Xl(e
|
|
|
15
15
|
})()`);return new n(this,t)}async viewportRatio(e){return await new Promise(t=>{let n=new IntersectionObserver(r=>{t(r[0].intersectionRatio),n.disconnect()});n.observe(e),this.utils.builtins.requestAnimationFrame(()=>{})})}getElementBorderWidth(e){if(e.nodeType!==Node.ELEMENT_NODE||!e.ownerDocument||!e.ownerDocument.defaultView)return{left:0,top:0};let t=e.ownerDocument.defaultView.getComputedStyle(e);return{left:parseInt(t.borderLeftWidth||"",10),top:parseInt(t.borderTopWidth||"",10)}}describeIFrameStyle(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return"error:notconnected";let t=e.ownerDocument.defaultView;for(let r=e;r;r=ge(r))if(t.getComputedStyle(r).transform!=="none")return"transformed";let n=t.getComputedStyle(e);return{left:parseInt(n.borderLeftWidth||"",10)+parseInt(n.paddingLeft||"",10),top:parseInt(n.borderTopWidth||"",10)+parseInt(n.paddingTop||"",10)}}retarget(e,t){let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;if(!n)return null;if(t==="none")return n;if(!n.matches("input, textarea, select")&&!n.isContentEditable&&(t==="button-link"?n=n.closest("button, [role=button], a, [role=link]")||n:n=n.closest("button, [role=button], [role=checkbox], [role=radio]")||n),t==="follow-label"&&!n.matches("a, input, textarea, button, select, [role=link], [role=button], [role=checkbox], [role=radio]")&&!n.isContentEditable){let r=n.closest("label");r&&r.control&&(n=r.control)}return n}async checkElementStates(e,t){if(t.includes("stable")){let n=await this._checkElementIsStable(e);if(n===!1)return{missingState:"stable"};if(n==="error:notconnected")return"error:notconnected"}for(let n of t)if(n!=="stable"){let r=this.elementState(e,n);if(r.received==="error:notconnected")return"error:notconnected";if(!r.matches)return{missingState:n}}}async _checkElementIsStable(e){let t=Symbol("continuePolling"),n,r=0,o=0,u=()=>{let v=this.retarget(e,"no-follow-label");if(!v)return"error:notconnected";let m=this.utils.builtins.performance.now();if(this._stableRafCount>1&&m-o<15)return t;o=m;let y=v.getBoundingClientRect(),w={x:y.top,y:y.left,width:y.width,height:y.height};if(n){if(!(w.x===n.x&&w.y===n.y&&w.width===n.width&&w.height===n.height))return!1;if(++r>=this._stableRafCount)return!0}return n=w,t},l,h,p=new Promise((v,m)=>{l=v,h=m}),b=()=>{try{let v=u();v!==t?l(v):this.utils.builtins.requestAnimationFrame(b)}catch(v){h(v)}};return this.utils.builtins.requestAnimationFrame(b),p}_createAriaRefEngine(){return{queryAll:(t,n)=>{var r,o;let u=(o=(r=this._lastAriaSnapshot)==null?void 0:r.elements)==null?void 0:o.get(n);return u&&u.isConnected?[u]:[]}}}elementState(e,t){let n=this.retarget(e,["visible","hidden"].includes(t)?"none":"follow-label");if(!n||!n.isConnected)return t==="hidden"?{matches:!0,received:"hidden"}:{matches:!1,received:"error:notconnected"};if(t==="visible"||t==="hidden"){let r=Ge(n);return{matches:t==="visible"?r:!r,received:r?"visible":"hidden"}}if(t==="disabled"||t==="enabled"){let r=tn(n);return{matches:t==="disabled"?r:!r,received:r?"disabled":"enabled"}}if(t==="editable"){let r=tn(n),o=Oo(n);if(o==="error")throw this.createStacklessError("Element is not an <input>, <textarea>, <select> or [contenteditable] and does not have a role allowing [aria-readonly]");return{matches:!r&&!o,received:r?"disabled":o?"readOnly":"editable"}}if(t==="checked"||t==="unchecked"){let r=t==="checked",o=Lo(n);if(o==="error")throw this.createStacklessError("Not a checkbox or radio button");return{matches:r===o,received:o?"checked":"unchecked"}}if(t==="indeterminate"){let r=Io(n);if(r==="error")throw this.createStacklessError("Not a checkbox or radio button");return{matches:r==="mixed",received:r===!0?"checked":r===!1?"unchecked":"mixed"}}throw this.createStacklessError(`Unexpected element state "${t}"`)}selectOptions(e,t){let n=this.retarget(e,"follow-label");if(!n)return"error:notconnected";if(n.nodeName.toLowerCase()!=="select")throw this.createStacklessError("Element is not a <select> element");let r=n,o=[...r.options],u=[],l=t.slice();for(let h=0;h<o.length;h++){let p=o[h],b=v=>{if(v instanceof Node)return p===v;let m=!0;return v.valueOrLabel!==void 0&&(m=m&&(v.valueOrLabel===p.value||v.valueOrLabel===p.label)),v.value!==void 0&&(m=m&&v.value===p.value),v.label!==void 0&&(m=m&&v.label===p.label),v.index!==void 0&&(m=m&&v.index===h),m};if(l.some(b))if(u.push(p),r.multiple)l=l.filter(v=>!b(v));else{l=[];break}}return l.length?"error:optionsnotfound":(r.value=void 0,u.forEach(h=>h.selected=!0),r.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})),u.map(h=>h.value))}fill(e,t){let n=this.retarget(e,"follow-label");if(!n)return"error:notconnected";if(n.nodeName.toLowerCase()==="input"){let r=n,o=r.type.toLowerCase(),u=new Set(["color","date","time","datetime-local","month","range","week"]);if(!new Set(["","email","number","password","search","tel","text","url"]).has(o)&&!u.has(o))throw this.createStacklessError(`Input of type "${o}" cannot be filled`);if(o==="number"&&(t=t.trim(),isNaN(Number(t))))throw this.createStacklessError("Cannot type text into input[type=number]");if(u.has(o)){if(t=t.trim(),r.focus(),r.value=t,r.value!==t)throw this.createStacklessError("Malformed value");return n.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),n.dispatchEvent(new Event("change",{bubbles:!0})),"done"}}else if(n.nodeName.toLowerCase()!=="textarea"){if(!n.isContentEditable)throw this.createStacklessError("Element is not an <input>, <textarea> or [contenteditable] element")}return this.selectText(n),"needsinput"}selectText(e){let t=this.retarget(e,"follow-label");if(!t)return"error:notconnected";if(t.nodeName.toLowerCase()==="input"){let o=t;return o.select(),o.focus(),"done"}if(t.nodeName.toLowerCase()==="textarea"){let o=t;return o.selectionStart=0,o.selectionEnd=o.value.length,o.focus(),"done"}let n=t.ownerDocument.createRange();n.selectNodeContents(t);let r=t.ownerDocument.defaultView.getSelection();return r&&(r.removeAllRanges(),r.addRange(n)),t.focus(),"done"}_activelyFocused(e){let t=e.getRootNode().activeElement,n=t===e&&!!e.ownerDocument&&e.ownerDocument.hasFocus();return{activeElement:t,isFocused:n}}focusNode(e,t){if(!e.isConnected)return"error:notconnected";if(e.nodeType!==Node.ELEMENT_NODE)throw this.createStacklessError("Node is not an element");let{activeElement:n,isFocused:r}=this._activelyFocused(e);if(e.isContentEditable&&!r&&n&&n.blur&&n.blur(),e.focus(),e.focus(),t&&!r&&e.nodeName.toLowerCase()==="input")try{e.setSelectionRange(0,0)}catch{}return"done"}blurNode(e){if(!e.isConnected)return"error:notconnected";if(e.nodeType!==Node.ELEMENT_NODE)throw this.createStacklessError("Node is not an element");return e.blur(),"done"}setInputFiles(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"Node is not of type HTMLElement";let n=e;if(n.nodeName!=="INPUT")return"Not an <input> element";let r=n;if((r.getAttribute("type")||"").toLowerCase()!=="file")return"Not an input[type=file] element";let u=t.map(h=>{let p=Uint8Array.from(atob(h.buffer),b=>b.charCodeAt(0));return new File([p],h.name,{type:h.mimeType,lastModified:h.lastModifiedMs})}),l=new DataTransfer;for(let h of u)l.items.add(h);r.files=l.files,r.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),r.dispatchEvent(new Event("change",{bubbles:!0}))}expectHitTarget(e,t){let n=[],r=t;for(;r;){let m=Yr(r);if(!m||(n.push(m),m.nodeType===9))break;r=m.host}let o;for(let m=n.length-1;m>=0;m--){let y=n[m],w=y.elementsFromPoint(e.x,e.y),A=y.elementFromPoint(e.x,e.y);if(A&&w[0]&&ge(A)===w[0]){let $=this.window.getComputedStyle(A);($==null?void 0:$.display)==="contents"&&w.unshift(A)}w[0]&&w[0].shadowRoot===y&&w[1]===A&&w.shift();let I=w[0];if(!I||(o=I,m&&I!==n[m-1].host))break}let u=[],l=[];for(;o&&o!==t;)u.push(o),l.push(["sticky","fixed"].includes(this.window.getComputedStyle(o).position)),o=ge(o);if(o===t)return"done";let h=this.previewNode(u[0]||this.document.documentElement),p=l.some(m=>m),b,v=t;for(;v;){let m=u.indexOf(v);if(m!==-1){m>1&&(b=this.previewNode(u[m-1])),p=l.slice(0,m).some(y=>y);break}v=ge(v)}return b?{hitTargetDescription:`${h} from ${b} subtree`,hasPositionStickyOrFixed:p}:{hitTargetDescription:h,hasPositionStickyOrFixed:p}}setupHitTargetInterceptor(e,t,n,r){let o=this.retarget(e,"button-link");if(!o||!o.isConnected)return"error:notconnected";if(n){let b=this.expectHitTarget(n,o);if(b!=="done")return JSON.stringify(b)}if(t==="drag")return{stop:()=>"done"};let u={hover:this._hoverHitTargetInterceptorEvents,tap:this._tapHitTargetInterceptorEvents,mouse:this._mouseHitTargetInterceptorEvents}[t],l,h=b=>{if(!u.has(b.type)||!b.isTrusted)return;let v=this.window.TouchEvent&&b instanceof this.window.TouchEvent?b.touches[0]:b;l===void 0&&v&&(l=this.expectHitTarget({x:v.clientX,y:v.clientY},o)),(r||l!=="done"&&l!==void 0)&&(b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation())},p=()=>(this._hitTargetInterceptor===h&&(this._hitTargetInterceptor=void 0),l||"done");return this._hitTargetInterceptor=h,{stop:p}}dispatchEvent(e,t,n){var r,o,u;let l,h={bubbles:!0,cancelable:!0,composed:!0,...n};switch(this._eventTypes.get(t)){case"mouse":l=new MouseEvent(t,h);break;case"keyboard":l=new KeyboardEvent(t,h);break;case"touch":{if(this._browserName==="webkit"){let p=v=>{var m,y;if(v instanceof Touch)return v;let w=v.pageX;w===void 0&&v.clientX!==void 0&&(w=v.clientX+(((m=this.document.scrollingElement)==null?void 0:m.scrollLeft)||0));let A=v.pageY;return A===void 0&&v.clientY!==void 0&&(A=v.clientY+(((y=this.document.scrollingElement)==null?void 0:y.scrollTop)||0)),this.document.createTouch(this.window,v.target??e,v.identifier,w,A,v.screenX,v.screenY,v.radiusX,v.radiusY,v.rotationAngle,v.force)},b=v=>v instanceof TouchList||!v?v:this.document.createTouchList(...v.map(p));h.target??=e,h.touches=b(h.touches),h.targetTouches=b(h.targetTouches),h.changedTouches=b(h.changedTouches),l=new TouchEvent(t,h)}else h.target??=e,h.touches=(r=h.touches)==null?void 0:r.map(p=>p instanceof Touch?p:new Touch({...p,target:p.target??e})),h.targetTouches=(o=h.targetTouches)==null?void 0:o.map(p=>p instanceof Touch?p:new Touch({...p,target:p.target??e})),h.changedTouches=(u=h.changedTouches)==null?void 0:u.map(p=>p instanceof Touch?p:new Touch({...p,target:p.target??e})),l=new TouchEvent(t,h);break}case"pointer":l=new PointerEvent(t,h);break;case"focus":l=new FocusEvent(t,h);break;case"drag":l=new DragEvent(t,h);break;case"wheel":l=new WheelEvent(t,h);break;case"deviceorientation":try{l=new DeviceOrientationEvent(t,h)}catch{let{bubbles:p,cancelable:b,alpha:v,beta:m,gamma:y,absolute:w}=h;l=this.document.createEvent("DeviceOrientationEvent"),l.initDeviceOrientationEvent(t,p,b,v,m,y,w)}break;case"devicemotion":try{l=new DeviceMotionEvent(t,h)}catch{let{bubbles:p,cancelable:b,acceleration:v,accelerationIncludingGravity:m,rotationRate:y,interval:w}=h;l=this.document.createEvent("DeviceMotionEvent"),l.initDeviceMotionEvent(t,p,b,v,m,y,w)}break;default:l=new Event(t,h);break}e.dispatchEvent(l)}previewNode(e){if(e.nodeType===Node.TEXT_NODE)return Pn(`#text=${e.nodeValue||""}`);if(e.nodeType!==Node.ELEMENT_NODE)return Pn(`<${e.nodeName.toLowerCase()} />`);let t=e,n=[];for(let h=0;h<t.attributes.length;h++){let{name:p,value:b}=t.attributes[h];p!=="style"&&(!b&&this._booleanAttributes.has(p)?n.push(` ${p}`):n.push(` ${p}="${b}"`))}n.sort((h,p)=>h.length-p.length);let r=Mr(n.join(""),500);if(this._autoClosingTags.has(t.nodeName))return Pn(`<${t.nodeName.toLowerCase()}${r}/>`);let o=t.childNodes,u=!1;if(o.length<=5){u=!0;for(let h=0;h<o.length;h++)u=u&&o[h].nodeType===Node.TEXT_NODE}let l=u?t.textContent||"":o.length?"\u2026":"";return Pn(`<${t.nodeName.toLowerCase()}${r}>${Mr(l,50)}</${t.nodeName.toLowerCase()}>`)}strictModeViolationError(e,t){let n=t.slice(0,10).map(o=>({preview:this.previewNode(o),selector:this.generateSelectorSimple(o)})),r=n.map((o,u)=>`
|
|
16
16
|
${u+1}) ${o.preview} aka ${Qt(this._sdkLanguage,o.selector)}`);return n.length<t.length&&r.push(`
|
|
17
17
|
...`),this.createStacklessError(`strict mode violation: ${Qt(this._sdkLanguage,je(e))} resolved to ${t.length} elements:${r.join("")}
|
|
18
|
-
`)}createStacklessError(e){if(this._browserName==="firefox"){let n=new Error("Error: "+e);return n.stack="",n}let t=new Error(e);return delete t.stack,t}createHighlight(){return new Or(this)}maskSelectors(e,t){this._highlight&&this.hideHighlight(),this._highlight=new Or(this),this._highlight.install();let n=[];for(let r of e)n.push(this.querySelectorAll(r,this.document.documentElement));this._highlight.maskElements(n.flat(),t)}highlight(e){this._highlight||(this._highlight=new Or(this),this._highlight.install()),this._highlight.runHighlightOnRaf(e)}hideHighlight(){this._highlight&&(this._highlight.uninstall(),delete this._highlight)}markTargetElements(e,t){var n,r;((n=this._markedElements)==null?void 0:n.callId)!==t&&(this._markedElements=void 0);let o=((r=this._markedElements)==null?void 0:r.elements)||new Set,u=new CustomEvent("__playwright_unmark_target__",{bubbles:!0,cancelable:!0,detail:t,composed:!0});for(let h of o)e.has(h)||h.dispatchEvent(u);let l=new CustomEvent("__playwright_mark_target__",{bubbles:!0,cancelable:!0,detail:t,composed:!0});for(let h of e)o.has(h)||h.dispatchEvent(l);this._markedElements={callId:t,elements:e}}_setupGlobalListenersRemovalDetection(){let e="__playwright_global_listeners_check__",t=!1,n=()=>t=!0;this.window.addEventListener(e,n),new MutationObserver(r=>{if(r.some(u=>Array.from(u.addedNodes).includes(this.document.documentElement))&&(t=!1,this.window.dispatchEvent(new CustomEvent(e)),!t)){this.window.addEventListener(e,n);for(let u of this.onGlobalListenersRemoved)u()}}).observe(this.document,{childList:!0})}_setupHitTargetInterceptors(){let e=n=>{var r;return(r=this._hitTargetInterceptor)==null?void 0:r.call(this,n)},t=()=>{for(let n of this._allHitTargetInterceptorEvents)this.window.addEventListener(n,e,{capture:!0,passive:!1})};t(),this.onGlobalListenersRemoved.add(t)}async expect(e,t,n){return t.expression==="to.have.count"||t.expression.endsWith(".array")?this.expectArray(n,t):e?await this.expectSingleElement(e,t):!t.isNot&&t.expression==="to.be.hidden"?{matches:!0}:t.isNot&&t.expression==="to.be.visible"?{matches:!1}:!t.isNot&&t.expression==="to.be.detached"?{matches:!0}:t.isNot&&t.expression==="to.be.attached"?{matches:!1}:t.isNot&&t.expression==="to.be.in.viewport"?{matches:!1}:{matches:t.isNot,missingReceived:!0}}async expectSingleElement(e,t){var n;let r=t.expression;{let o;if(r==="to.have.attribute"){let u=e.hasAttribute(t.expressionArg);o={matches:u,received:u?"attribute present":"attribute not present"}}else if(r==="to.be.checked"){let{checked:u,indeterminate:l}=t.expectedValue;if(l){if(u!==void 0)throw this.createStacklessError("Can't assert indeterminate and checked at the same time");o=this.elementState(e,"indeterminate")}else o=this.elementState(e,u===!1?"unchecked":"checked")}else if(r==="to.be.disabled")o=this.elementState(e,"disabled");else if(r==="to.be.editable")o=this.elementState(e,"editable");else if(r==="to.be.readonly")o=this.elementState(e,"editable"),o.matches=!o.matches;else if(r==="to.be.empty")if(e.nodeName==="INPUT"||e.nodeName==="TEXTAREA"){let u=e.value;o={matches:!u,received:u?"notEmpty":"empty"}}else{let u=(n=e.textContent)==null?void 0:n.trim();o={matches:!u,received:u?"notEmpty":"empty"}}else if(r==="to.be.enabled")o=this.elementState(e,"enabled");else if(r==="to.be.focused"){let u=this._activelyFocused(e).isFocused;o={matches:u,received:u?"focused":"inactive"}}else r==="to.be.hidden"?o=this.elementState(e,"hidden"):r==="to.be.visible"?o=this.elementState(e,"visible"):r==="to.be.attached"?o={matches:!0,received:"attached"}:r==="to.be.detached"&&(o={matches:!1,received:"attached"});if(o){if(o.received==="error:notconnected")throw this.createStacklessError("Element is not connected");return o}}if(r==="to.have.property"){let o=e,u=t.expressionArg.split(".");for(let p=0;p<u.length-1;p++){if(typeof o!="object"||!(u[p]in o))return{received:void 0,matches:!1};o=o[u[p]]}let l=o[u[u.length-1]],h=Hr(l,t.expectedValue);return{received:l,matches:h}}if(r==="to.be.in.viewport"){let o=await this.viewportRatio(e);return{received:`viewport ratio ${o}`,matches:o>0&&o>(t.expectedNumber??0)-1e-9}}if(r==="to.have.values"){if(e=this.retarget(e,"follow-label"),e.nodeName!=="SELECT"||!e.multiple)throw this.createStacklessError("Not a select element with a multiple attribute");let o=[...e.selectedOptions].map(u=>u.value);return o.length!==t.expectedText.length?{received:o,matches:!1}:{received:o,matches:o.map((u,l)=>new Dn(t.expectedText[l]).matches(u)).every(Boolean)}}if(r==="to.match.aria"){let o=al(e,t.expectedValue);return{received:o.received,matches:!!o.matches.length}}{let o;if(r==="to.have.attribute.value"){let u=e.getAttribute(t.expressionArg);if(u===null)return{received:null,matches:!1};o=u}else if(["to.have.class","to.contain.class"].includes(r)){if(!t.expectedText)throw this.createStacklessError("Expected text is not provided for "+r);return{received:e.classList.toString(),matches:new Dn(t.expectedText[0]).matchesClassList(this,e.classList,r==="to.contain.class")}}else if(r==="to.have.css")o=this.window.getComputedStyle(e).getPropertyValue(t.expressionArg);else if(r==="to.have.id")o=e.id;else if(r==="to.have.text")o=t.useInnerText?e.innerText:Ee(new Map,e).full;else if(r==="to.have.accessible.name")o=At(e,!1);else if(r==="to.have.accessible.description")o=Pr(e,!1);else if(r==="to.have.accessible.error.message")o=Co(e);else if(r==="to.have.role")o=ue(e)||"";else if(r==="to.have.title")o=this.document.title;else if(r==="to.have.url")o=this.document.location.href;else if(r==="to.have.value"){if(e=this.retarget(e,"follow-label"),e.nodeName!=="INPUT"&&e.nodeName!=="TEXTAREA"&&e.nodeName!=="SELECT")throw this.createStacklessError("Not an input element");o=e.value}if(o!==void 0&&t.expectedText){let u=new Dn(t.expectedText[0]);return{received:o,matches:u.matches(o)}}}throw this.createStacklessError("Unknown expect matcher: "+r)}expectArray(e,t){let n=t.expression;if(n==="to.have.count"){let h=e.length,p=h===t.expectedNumber;return{received:h,matches:p}}if(!t.expectedText)throw this.createStacklessError("Expected text is not provided for "+n);if(["to.have.class.array","to.contain.class.array"].includes(n)){let h=e.map(v=>v.classList),p=h.map(String);if(h.length!==t.expectedText.length)return{received:p,matches:!1};let b=this._matchSequentially(t.expectedText,h,(v,m)=>v.matchesClassList(this,m,n==="to.contain.class.array"));return{received:p,matches:b}}if(!["to.contain.text.array","to.have.text.array"].includes(n))throw this.createStacklessError("Unknown expect matcher: "+n);let r=e.map(h=>t.useInnerText?h.innerText:Ee(new Map,h).full),o=n!=="to.contain.text.array";if(!(r.length===t.expectedText.length||!o))return{received:r,matches:!1};let l=this._matchSequentially(t.expectedText,r,(h,p)=>h.matches(p));return{received:r,matches:l}}_matchSequentially(e,t,n){let r=e.map(l=>new Dn(l)),o=0,u=0;for(;o<r.length&&u<t.length;)n(r[o],t[u])&&++o,++u;return o===r.length}};function Pn(e){return e.replace(/\n/g,"\u21B5").replace(/\t/g,"\u21C6")}function ou(e){if(e=e.substring(1,e.length-1),!e.includes("\\"))return e;let t=[],n=0;for(;n<e.length;)e[n]==="\\"&&n+1<e.length&&n++,t.push(e[n++]);return t.join("")}function qn(e,t){if(e[0]==="/"&&e.lastIndexOf("/")>0){let o=e.lastIndexOf("/"),u=new RegExp(e.substring(1,o),e.substring(o+1));return{matcher:l=>u.test(l.full),kind:"regex"}}let n=t?JSON.parse.bind(JSON):ou,r=!1;return e.length>1&&e[0]==='"'&&e[e.length-1]==='"'?(e=n(e),r=!0):t&&e.length>1&&e[0]==='"'&&e[e.length-2]==='"'&&e[e.length-1]==="i"?(e=n(e.substring(0,e.length-1)),r=!1):t&&e.length>1&&e[0]==='"'&&e[e.length-2]==='"'&&e[e.length-1]==="s"?(e=n(e.substring(0,e.length-1)),r=!0):e.length>1&&e[0]==="'"&&e[e.length-1]==="'"&&(e=n(e),r=!0),e=ve(e),r?t?{kind:"strict",matcher:u=>u.normalized===e}:{matcher:u=>!e&&!u.immediate.length?!0:u.immediate.some(l=>ve(l)===e),kind:"strict"}:(e=e.toLowerCase(),{kind:"lax",matcher:o=>o.normalized.toLowerCase().includes(e)})}var Dn=class{_string;_substring;_regex;_normalizeWhiteSpace;_ignoreCase;constructor(e){if(this._normalizeWhiteSpace=e.normalizeWhiteSpace,this._ignoreCase=e.ignoreCase,this._string=e.matchSubstring?void 0:this.normalize(e.string),this._substring=e.matchSubstring?this.normalize(e.string):void 0,e.regexSource){let t=new Set((e.regexFlags||"").split(""));e.ignoreCase===!1&&t.delete("i"),e.ignoreCase===!0&&t.add("i"),this._regex=new RegExp(e.regexSource,[...t].join(""))}}matches(e){return this._regex||(e=this.normalize(e)),this._string!==void 0?e===this._string:this._substring!==void 0?e.includes(this._substring):this._regex?!!this._regex.test(e):!1}matchesClassList(e,t,n){if(n){if(this._regex)throw e.createStacklessError("Partial matching does not support regular expressions. Please provide a string value.");return this._string.split(/\s+/g).filter(Boolean).every(r=>t.contains(r))}return this.matches(t.toString())}normalize(e){return e&&(this._normalizeWhiteSpace&&(e=ve(e)),this._ignoreCase&&(e=e.toLocaleLowerCase()),e)}};function Hr(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!Hr(e[r],t[r]))return!1;return!0}if(e instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;++r)if(!t.hasOwnProperty(n[r]))return!1;for(let r of n)if(!Hr(e[r],t[r]))return!1;return!0}return typeof e=="number"&&typeof t=="number"?isNaN(e)&&isNaN(t):!1}var Me={selectorUtils:zi,roleUtils:to,domUtils:Eo,selectorGenerator:qo,stringUtils:Ji,InjectedScript:iu},pa=function(){if(!Me.InjectedScript)throw new Error("InjectedScript is not available yet.");let e=Me.InjectedScript,t=this.options||{sdkLanguage:"javascript",testIdAttributeName:"blinq-test-id",stableRafCount:0,browserName:"chromium",inputFileRoleTextbox:!1,customEngines:[],isUnderTest:!0};return new e(window,t)};var au=["slot","alt","name","placeholder","title","aria-label","aria-placeholder","role","data-testid","data-cy"];function cu(e){return`"${e.replace(/["\\]/g,t=>"\\"+t)}"`}function lu(e){return/^[a-zA-Z][a-zA-Z0-9\-\_]+$/.test(e)?"#"+e:`[id=${cu(e)}]`}function uu(e){let t="";for(let n=0;n<e.length;n++)t+=hu(e,n);return t}function hu(e,t){let n=e.charCodeAt(t);return n===0?"\uFFFD":n>=1&&n<=31||n>=48&&n<=57&&(t===0||t===1&&e.charCodeAt(0)===45)?"\\"+n.toString(16)+" ":t===0&&n===45&&e.length===1?"\\"+e.charAt(t):n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122?e.charAt(t):"\\"+e.charAt(t)}function fu(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,"$1$2\\$3").replace(/>>/g,"\\>\\>")}var Ts=class{constructor(t,n={}){this.locatorStrategies={text:"basic",no_text:"no_text",custom:"custom",context:"context",digitIgnore:"ignore_digit",text_with_index:"text_with_index"},this.options=n,this.dom_Parent=new Ai,this.PW=Me,this.injectedScript=t,this.cache=new Map}generateUniqueCSSSelector(t,n){var y;let r=(n==null?void 0:n.root)||window.document,o=(n==null?void 0:n.separator)||" > ",u=(n==null?void 0:n.isunique)||(w=>this.getMatchingElements(w,n).length===1),l=(n==null?void 0:n.noCSSId)||!1;if(!(t instanceof Element)||!r.contains(t))return"";let h="",p=t.getAttribute("id");if(p&&!/\d/.test(p)&&!l&&(h=lu(p),u(h))||t.tagName&&(h=t.tagName.toLowerCase()+h,u(h)))return h;let b=Array.from(t.classList).filter(w=>!/\d/.test(w));if(b.length&&(h+=b.map(w=>"."+uu(w)).join(""),u(h)))return h;for(let w of au)if(t.hasAttribute(w)){let A=t.getAttribute(w);if(A===""||/\d/.test(A))continue;A=A.replace(/[!"#$%&'()*+,./:;<=>?@[\]^`{|}~]/g,"\\$&"),h+=`[${w}=${this.PW.stringUtils.escapeForAttributeSelector(A)}]`}if(u(h)||t===r)return h;let v=t.parentElement;if(v){if(v!==r&&(t.assignedSlot&&(v=t.assignedSlot.parentElement??t.assignedSlot.parentNode.host),v&&v!==r&&(h=this.generateUniqueCSSSelector(v,n)+o+h,u(h))))return h}else if(t.parentNode instanceof ShadowRoot){let w=t.parentNode.host;if(w&&w!==r&&(h=this.generateUniqueCSSSelector(w,n)+" >>> "+h,u(h)))return h}let m=(y=t.parentElement)==null?void 0:y.children;if(m){for(let w=0;w<m.length;w++)if(m[w]===t)return h+`:nth-child(${w+1})`}return""}getMatchingElements(t,n={}){let{root:r=window.document,prefix:o,visible:u=!0}=n;return u&&(t=`${t} >> visible=true`),o&&(t=`${o} >> ${t}`),this.injectedScript.querySelectorAll(this.injectedScript.parseSelector(t),r)}getLocatorStrategies(){return this.locatorStrategies}getTextLocators(t,n){let r=this.injectedScript,o=this.PW.selectorGenerator.buildTextCandidates(r,t,n),u=[];for(let l of o){let h=0,p=[];for(let m of l){let{engine:y,selector:w}=m;y==="css"?p.push(w):p.push(`${y}=${w}`),h+=m.score}let b=p.join(" >> "),v=h/l.length;u.push({css:b,score:v})}return u}getNoTextLocators(t,n){let r=this.injectedScript,o=this.PW.selectorGenerator.buildNoTextCandidates(r,t,n);for(let u of o)u.engine==="css"?u.css=u.selector:u.css=`${u.engine}=${u.selector}`,delete u.engine,delete u.selector;return o}getCustomLocators(t,n){let{customAttributes:r=[]}=this.options;if(!r||!Array.isArray(r))return console.error("Custom attributes must be an array"),[];let o=[],u=[];for(let l of r){if(!l||typeof l!="string"){console.error("Custom attribute must be a string");continue}let h=t.getAttribute(l);h!==null&&(u.push(l),o.push({css:`[${l}=${this.PW.stringUtils.escapeForAttributeSelector(h)}]`,score:1,priority:1}))}return o}getContextLocators(t,n){if(!n||!Array.isArray(n))return console.error("Locators must be an array"),[];let r=[];try{let o=new Set;for(let u of n){let l=u.css;if(!l||typeof l!="string"){console.error("Locator must have a valid css selector");continue}let p=this.injectedScript.parseSelector(l).parts;if(!p||!Array.isArray(p)||p.length===0){console.error("Locator must have a valid css selector");continue}if(p.length<3)continue;let b=p[0];if(b.name!=="internal:text")continue;let v=b.body;if(!v||typeof v!="string"||v.length===0){console.error("Locator must have a valid text in the first part to be a context locator");continue}let m=p[1];if(m.name!=="xpath")continue;let y=m.body;if(!y||typeof y!="string"||y.length===0)continue;let w=m.body;if(!w||typeof w!="string"||w.length===0)continue;let A=/(\.\.)(\/\.\.)*/;try{if(A.test(w)){let $=w.split("..").length-1,U=l.indexOf(w),B=l.substring(U+w.length+3).trim();if(B.length===0)continue;let V=`internal:text=${v}`,te=this.getMatchingElements(V,{});if(te.length!==1){console.error("Context locator must have exactly one element matching the text part");continue}let ne=te[0],ee=this.injectedScript.utils.elementText(new Map,ne).full,ie=`${V} >> xpath=${y} >> ${B}`,ke=this.getMatchingElements(ie,{});if(ke.length!==1){console.error("Context locator must have exactly one element matching the full selector");continue}if(ke[0]!==t){console.error("Context locator must have the text element as the full element");continue}if(!o.has(ee)){o.add(ee);let se={css:B,climb:$,text:ee,priority:1};u.index!==void 0&&(se.index=u.index),r.push(se)}}}catch(I){console.error("Error parsing climb string:",I);continue}}}catch(o){console.error("Error generating context locators:",o)}return r.sort((o,u)=>o.text.length-u.text.length),r}getDigitIgnoreLocators(t,n){let r=[];try{if(!n||!Array.isArray(n))return console.error("Locators must be an array"),[];for(let o of n){let u=o.css;if(!u||typeof u!="string"){console.error("Locator must have a valid css selector");continue}let h=this.injectedScript.parseSelector(u).parts;if(!h||!Array.isArray(h)||h.length===0){console.error("Locator must have a valid css selector");continue}let p="",b=!1;for(let v of h){if(v.name!=="internal:text"){p+=`${v.name==="css"?"":v.name+"="}${v.source} >> `;continue}if(typeof v.body!="string"||v.body.length===0){p+=`${v.name==="css"?"":v.name+"="}${v.source} >> `;continue}let m=v.body,y=/\d+/g;b=y.test(m);let w=this.PW.stringUtils.escapeRegExp(m.substring(1,m.length-2)),A=new RegExp(w);p+=`internal:text=${fu(A).replace(y,"\\d+")} >> `}if(b&&(p.endsWith(" >> ")&&(p=p.slice(0,-4)),p)){let v=this.getMatchingElements(p,{});if(v.length!==1){console.error("Digit ignore locator must have exactly one element matching the final selector");continue}if(v[0]!==t){console.error("Digit ignore locator must match the original element");continue}r.push({css:p,priority:o.priority||1})}}}catch(o){console.error("Error generating digit ignore locators:",o)}return r}getTextwithIndexLocators(t){if(!t||!Array.isArray(t))return console.error("Locators must be an array"),[];let n=[];try{for(let r of t){if(!r||!r.css||typeof r.css!="string"){console.error("Locator must have a valid css selector");continue}let o=r.index;typeof o!="number"||o<0||n.push(r)}}catch(r){console.error("Error getting text with index locators:",r)}return n}getXPathSelector(t){if(typeof t!="number"||t<0)return console.error("Climb must be a non-negative integer"),"";if(t===0)return"";let n="xpath=..";if(t===1)return n;for(let r=1;r<t;r++)n+="/..";return n}categorizeLocators(t,n,r){let o=[],u=[];try{for(let l of n){let h=this.getMatchingElements(l.css,r);if(h.length===0){console.warn(`No elements found for locator: ${l.css}`);continue}else if(h.length===1){if(t===h[0])l.priority=1,o.push(l);else if(t.contains(h[0])){l.priority=1;let p=this.dom_Parent.getClimbCountToParent(h[0],t),b=this.getXPathSelector(p),v=`${l.css} >> ${b}`;l.css=v,o.push(l)}}else l.priority=2,l.elements=h,u.push(l)}}catch(l){console.error("Error categorizing locators:",l)}return{unique:o,nonUnique:u}}getUniqueLocators(t,n=this.getNoTextLocators,r={}){return this.getUniqueLocators2(t,n,r)}getUniqueLocators1(t,n=this.getNoTextLocators,r={}){try{let{maxLocators:o=5,root:u=window.document.body,next:l="LCA",minLocators:h=3}=r;if(!t)return[];if(t===u)return t===window.document.documentElement?[{css:"html",score:1,priority:1},{css:":root",score:1,priority:1}]:[{css:":root",score:1,priority:1}];console.log("Generating locators for element:",t);let p=n(t,r);if(console.log("Generated locators:",p),!p||!Array.isArray(p))return console.error("Locator generator did not return an array of locators"),[];console.log("Categorizing locators for element:",t);let b=this.categorizeLocators(t,p,r);console.log("Categorized locators:",b);let{unique:v,nonUnique:m}=b,y=[];if(v.length>0&&y.push(...v),y.length>=o)return y.slice(0,o);let w=null;for(let A of m){let I=A.css??A.selector,$=A.elements||this.getMatchingElements(I,r);if(l==="parent"?w=this.dom_Parent.getActualParent(t):w=this.dom_Parent.findBranchingParent($,t),w&&w!==t)if(u.contains(w)){let U=this.getUniqueLocators(w,n,{...r,root:u});for(let B of U){if(y.length>=o)return y.slice(0,o);let te=`${B.css??B.selector} >> ${I}`,ne=this.getMatchingElements(te,r),ee=(B.score+A.score)/2+100;if(ne.length===1&&ne[0]===t)B.css=te,B.score=ee,B.priority=1,y.push(B);else{let ie=ne.indexOf(t);ie!==-1&&ie<5&&(B.css=te,B.index=ie,B.priority=2,B.score=ee,y.push(B))}}}else{let U=$.indexOf(t);U!==-1&&U<5&&(A.index=U,A.priority=2,y.push(A))}else{let U=$.indexOf(t);U!==-1&&U<5&&(A.index=U,A.priority=2,y.push(A))}delete A.elements,delete A.strategy,delete A.engine,delete A.selector}if(y.length<h&&u&&u.contains(t)){let A=this.dom_Parent.getActualParent(t),I=this.getUniqueLocators(A,n,{...r,root:u});y.push(...I)}return y.sort((A,I)=>A.score-I.score),console.log("Final locators:",y,t),console.groupEnd(),y.slice(0,o)}catch(o){return console.error("Error in getUniqueLocators:",o),[]}}getUniqueLocators2(t,n=this.getNoTextLocators,r={}){try{let{maxLocators:o=5,root:u=window.document.body}=r;if(!t)return[];if(t===u)return t===window.document.documentElement?[{css:"html",score:1,priority:1},{css:":root",score:1,priority:1}]:[{css:":root",score:1,priority:1}];console.log("Generating locators for element:",t);let l=n(t,r);if(console.log("Generated locators:",l),!l||!Array.isArray(l))return console.error("Locator generator did not return an array of locators"),[];console.log("Categorizing locators for element:",t);let h=this.categorizeLocators(t,l,r);console.log("Categorized locators:",h);let{unique:p,nonUnique:b}=h,v=[];if(p.length>0&&v.push(...p),v.length>=o)return v.slice(0,o);let m=new Map,y=this.dom_Parent.getFullAncestorChainToRoot(t,u);y.shift();let w=[];for(let I of y){let $=n(I,r);if(!$||!Array.isArray($)||$.length===0)continue;let U=this.categorizeLocators(I,$,r);if(w.push({element:I,locators:U}),m.set(I,U),U.unique.length>0)break}let A=w[w.length-1];for(let I of b){let $=I.css??I.selector;if((I.elements||this.getMatchingElements($,r)).length===0){console.warn(`No elements found for locator: ${$}`);continue}for(let B of A.locators.unique){let V=`${B.css} >> ${$}`,te=this.getMatchingElements(V,r);if(te.length===1&&te[0]===t){let ne=(B.score+I.score)/2+100,ee={...B,css:V,score:ne,priority:1};v.push(ee)}else{let ne=te.indexOf(t);if(ne!==-1&&ne<5){let ee=(B.score+I.score)/2,ie={...B,css:V,index:ne,score:ee+200,priority:2};v.push(ie)}}}}return v.sort((I,$)=>I.score-$.score),console.log("Final locators:",v,t),console.groupEnd(),v.slice(0,o)}catch(o){return console.error("Error in getUniqueLocators:",o),[]}}getElementLocators(t,n={}){var r;try{let{excludeText:o=!1}=n,u={};if((r=this.options)!=null&&r.customAttributes){console.groupCollapsed("Generating Custom locators for element:",t);let v=this.getUniqueLocators(t,this.getCustomLocators.bind(this),n);v.length>0&&(u[this.locatorStrategies.custom]=v)}if(console.groupEnd(),!o){console.groupCollapsed("Generating Text locators for element:",t);let v=this.getUniqueLocators(t,this.getTextLocators.bind(this),n);console.groupEnd(),v.length>0&&(u[this.locatorStrategies.text]=v);let m=this.getTextwithIndexLocators(v);m.length>0&&(u[this.locatorStrategies.text_with_index]=m);let y=this.getDigitIgnoreLocators(t,v);y.length>0&&(u[this.locatorStrategies.digitIgnore]=y);let w=this.getContextLocators(t,v);w.length>0&&(u[this.locatorStrategies.context]=w)}console.groupCollapsed("Generating No Text locators for element:",t);let l=this.getUniqueLocators(t,this.getNoTextLocators.bind(this),n);if(l.length>0)u[this.locatorStrategies.no_text]=l;else{let v=[];v.push({css:this.generateUniqueCSSSelector(t,n),score:500,priority:3}),v.length>0&&(u[this.locatorStrategies.no_text]=v)}console.groupEnd();let h=this.getBestStrategy(u);if(!h)throw new Error("No locators found for element: "+t);u.strategy=h;let b={locators:u[u.strategy]??[],element_name:""};return Object.keys(u).length>1&&(b.allStrategyLocators=u),console.log("Generated locators:",b),b}catch(o){return console.error("Error in getElementLocators:",o),{locators:[],element_name:""}}}getBestStrategy(t){let n=[this.locatorStrategies.custom,this.locatorStrategies.context,this.locatorStrategies.text,this.locatorStrategies.text_with_index,this.locatorStrategies.digitIgnore,this.locatorStrategies.no_text];for(let r of n)if(t[r]&&t[r].length>0)return r;return null}},ga=Ts;var ks=class{constructor(t={}){let{inlineImages:n=!0,inlineStyles:r=!0,excludeSelectors:o=[]}=t;this.inlineImages=n,this.inlineStyles=r,this.excludeSelectors=o}imageToDataURL(t,n){try{let r=n.createElement("canvas");return r.width=t.naturalWidth||t.width,r.height=t.naturalHeight||t.height,r.getContext("2d").drawImage(t,0,0),r.toDataURL("image/png")}catch(r){return console.warn(`Failed to inline image: ${t.src}`,r),t.src}}processStyles(t){if(!this.inlineStyles)return;let n=Array.from(t.styleSheets);for(let r of n)try{if(!r.href)continue;let o=t.createElement("style"),u="",l=Array.from(r.cssRules||[]);for(let h of l)h.cssText&&(u+=h.cssText+`
|
|
18
|
+
`)}createStacklessError(e){if(this._browserName==="firefox"){let n=new Error("Error: "+e);return n.stack="",n}let t=new Error(e);return delete t.stack,t}createHighlight(){return new Or(this)}maskSelectors(e,t){this._highlight&&this.hideHighlight(),this._highlight=new Or(this),this._highlight.install();let n=[];for(let r of e)n.push(this.querySelectorAll(r,this.document.documentElement));this._highlight.maskElements(n.flat(),t)}highlight(e){this._highlight||(this._highlight=new Or(this),this._highlight.install()),this._highlight.runHighlightOnRaf(e)}hideHighlight(){this._highlight&&(this._highlight.uninstall(),delete this._highlight)}markTargetElements(e,t){var n,r;((n=this._markedElements)==null?void 0:n.callId)!==t&&(this._markedElements=void 0);let o=((r=this._markedElements)==null?void 0:r.elements)||new Set,u=new CustomEvent("__playwright_unmark_target__",{bubbles:!0,cancelable:!0,detail:t,composed:!0});for(let h of o)e.has(h)||h.dispatchEvent(u);let l=new CustomEvent("__playwright_mark_target__",{bubbles:!0,cancelable:!0,detail:t,composed:!0});for(let h of e)o.has(h)||h.dispatchEvent(l);this._markedElements={callId:t,elements:e}}_setupGlobalListenersRemovalDetection(){let e="__playwright_global_listeners_check__",t=!1,n=()=>t=!0;this.window.addEventListener(e,n),new MutationObserver(r=>{if(r.some(u=>Array.from(u.addedNodes).includes(this.document.documentElement))&&(t=!1,this.window.dispatchEvent(new CustomEvent(e)),!t)){this.window.addEventListener(e,n);for(let u of this.onGlobalListenersRemoved)u()}}).observe(this.document,{childList:!0})}_setupHitTargetInterceptors(){let e=n=>{var r;return(r=this._hitTargetInterceptor)==null?void 0:r.call(this,n)},t=()=>{for(let n of this._allHitTargetInterceptorEvents)this.window.addEventListener(n,e,{capture:!0,passive:!1})};t(),this.onGlobalListenersRemoved.add(t)}async expect(e,t,n){return t.expression==="to.have.count"||t.expression.endsWith(".array")?this.expectArray(n,t):e?await this.expectSingleElement(e,t):!t.isNot&&t.expression==="to.be.hidden"?{matches:!0}:t.isNot&&t.expression==="to.be.visible"?{matches:!1}:!t.isNot&&t.expression==="to.be.detached"?{matches:!0}:t.isNot&&t.expression==="to.be.attached"?{matches:!1}:t.isNot&&t.expression==="to.be.in.viewport"?{matches:!1}:{matches:t.isNot,missingReceived:!0}}async expectSingleElement(e,t){var n;let r=t.expression;{let o;if(r==="to.have.attribute"){let u=e.hasAttribute(t.expressionArg);o={matches:u,received:u?"attribute present":"attribute not present"}}else if(r==="to.be.checked"){let{checked:u,indeterminate:l}=t.expectedValue;if(l){if(u!==void 0)throw this.createStacklessError("Can't assert indeterminate and checked at the same time");o=this.elementState(e,"indeterminate")}else o=this.elementState(e,u===!1?"unchecked":"checked")}else if(r==="to.be.disabled")o=this.elementState(e,"disabled");else if(r==="to.be.editable")o=this.elementState(e,"editable");else if(r==="to.be.readonly")o=this.elementState(e,"editable"),o.matches=!o.matches;else if(r==="to.be.empty")if(e.nodeName==="INPUT"||e.nodeName==="TEXTAREA"){let u=e.value;o={matches:!u,received:u?"notEmpty":"empty"}}else{let u=(n=e.textContent)==null?void 0:n.trim();o={matches:!u,received:u?"notEmpty":"empty"}}else if(r==="to.be.enabled")o=this.elementState(e,"enabled");else if(r==="to.be.focused"){let u=this._activelyFocused(e).isFocused;o={matches:u,received:u?"focused":"inactive"}}else r==="to.be.hidden"?o=this.elementState(e,"hidden"):r==="to.be.visible"?o=this.elementState(e,"visible"):r==="to.be.attached"?o={matches:!0,received:"attached"}:r==="to.be.detached"&&(o={matches:!1,received:"attached"});if(o){if(o.received==="error:notconnected")throw this.createStacklessError("Element is not connected");return o}}if(r==="to.have.property"){let o=e,u=t.expressionArg.split(".");for(let p=0;p<u.length-1;p++){if(typeof o!="object"||!(u[p]in o))return{received:void 0,matches:!1};o=o[u[p]]}let l=o[u[u.length-1]],h=Hr(l,t.expectedValue);return{received:l,matches:h}}if(r==="to.be.in.viewport"){let o=await this.viewportRatio(e);return{received:`viewport ratio ${o}`,matches:o>0&&o>(t.expectedNumber??0)-1e-9}}if(r==="to.have.values"){if(e=this.retarget(e,"follow-label"),e.nodeName!=="SELECT"||!e.multiple)throw this.createStacklessError("Not a select element with a multiple attribute");let o=[...e.selectedOptions].map(u=>u.value);return o.length!==t.expectedText.length?{received:o,matches:!1}:{received:o,matches:o.map((u,l)=>new Dn(t.expectedText[l]).matches(u)).every(Boolean)}}if(r==="to.match.aria"){let o=al(e,t.expectedValue);return{received:o.received,matches:!!o.matches.length}}{let o;if(r==="to.have.attribute.value"){let u=e.getAttribute(t.expressionArg);if(u===null)return{received:null,matches:!1};o=u}else if(["to.have.class","to.contain.class"].includes(r)){if(!t.expectedText)throw this.createStacklessError("Expected text is not provided for "+r);return{received:e.classList.toString(),matches:new Dn(t.expectedText[0]).matchesClassList(this,e.classList,r==="to.contain.class")}}else if(r==="to.have.css")o=this.window.getComputedStyle(e).getPropertyValue(t.expressionArg);else if(r==="to.have.id")o=e.id;else if(r==="to.have.text")o=t.useInnerText?e.innerText:Ee(new Map,e).full;else if(r==="to.have.accessible.name")o=At(e,!1);else if(r==="to.have.accessible.description")o=Pr(e,!1);else if(r==="to.have.accessible.error.message")o=Co(e);else if(r==="to.have.role")o=ue(e)||"";else if(r==="to.have.title")o=this.document.title;else if(r==="to.have.url")o=this.document.location.href;else if(r==="to.have.value"){if(e=this.retarget(e,"follow-label"),e.nodeName!=="INPUT"&&e.nodeName!=="TEXTAREA"&&e.nodeName!=="SELECT")throw this.createStacklessError("Not an input element");o=e.value}if(o!==void 0&&t.expectedText){let u=new Dn(t.expectedText[0]);return{received:o,matches:u.matches(o)}}}throw this.createStacklessError("Unknown expect matcher: "+r)}expectArray(e,t){let n=t.expression;if(n==="to.have.count"){let h=e.length,p=h===t.expectedNumber;return{received:h,matches:p}}if(!t.expectedText)throw this.createStacklessError("Expected text is not provided for "+n);if(["to.have.class.array","to.contain.class.array"].includes(n)){let h=e.map(v=>v.classList),p=h.map(String);if(h.length!==t.expectedText.length)return{received:p,matches:!1};let b=this._matchSequentially(t.expectedText,h,(v,m)=>v.matchesClassList(this,m,n==="to.contain.class.array"));return{received:p,matches:b}}if(!["to.contain.text.array","to.have.text.array"].includes(n))throw this.createStacklessError("Unknown expect matcher: "+n);let r=e.map(h=>t.useInnerText?h.innerText:Ee(new Map,h).full),o=n!=="to.contain.text.array";if(!(r.length===t.expectedText.length||!o))return{received:r,matches:!1};let l=this._matchSequentially(t.expectedText,r,(h,p)=>h.matches(p));return{received:r,matches:l}}_matchSequentially(e,t,n){let r=e.map(l=>new Dn(l)),o=0,u=0;for(;o<r.length&&u<t.length;)n(r[o],t[u])&&++o,++u;return o===r.length}};function Pn(e){return e.replace(/\n/g,"\u21B5").replace(/\t/g,"\u21C6")}function ou(e){if(e=e.substring(1,e.length-1),!e.includes("\\"))return e;let t=[],n=0;for(;n<e.length;)e[n]==="\\"&&n+1<e.length&&n++,t.push(e[n++]);return t.join("")}function qn(e,t){if(e[0]==="/"&&e.lastIndexOf("/")>0){let o=e.lastIndexOf("/"),u=new RegExp(e.substring(1,o),e.substring(o+1));return{matcher:l=>u.test(l.full),kind:"regex"}}let n=t?JSON.parse.bind(JSON):ou,r=!1;return e.length>1&&e[0]==='"'&&e[e.length-1]==='"'?(e=n(e),r=!0):t&&e.length>1&&e[0]==='"'&&e[e.length-2]==='"'&&e[e.length-1]==="i"?(e=n(e.substring(0,e.length-1)),r=!1):t&&e.length>1&&e[0]==='"'&&e[e.length-2]==='"'&&e[e.length-1]==="s"?(e=n(e.substring(0,e.length-1)),r=!0):e.length>1&&e[0]==="'"&&e[e.length-1]==="'"&&(e=n(e),r=!0),e=ve(e),r?t?{kind:"strict",matcher:u=>u.normalized===e}:{matcher:u=>!e&&!u.immediate.length?!0:u.immediate.some(l=>ve(l)===e),kind:"strict"}:(e=e.toLowerCase(),{kind:"lax",matcher:o=>o.normalized.toLowerCase().includes(e)})}var Dn=class{_string;_substring;_regex;_normalizeWhiteSpace;_ignoreCase;constructor(e){if(this._normalizeWhiteSpace=e.normalizeWhiteSpace,this._ignoreCase=e.ignoreCase,this._string=e.matchSubstring?void 0:this.normalize(e.string),this._substring=e.matchSubstring?this.normalize(e.string):void 0,e.regexSource){let t=new Set((e.regexFlags||"").split(""));e.ignoreCase===!1&&t.delete("i"),e.ignoreCase===!0&&t.add("i"),this._regex=new RegExp(e.regexSource,[...t].join(""))}}matches(e){return this._regex||(e=this.normalize(e)),this._string!==void 0?e===this._string:this._substring!==void 0?e.includes(this._substring):this._regex?!!this._regex.test(e):!1}matchesClassList(e,t,n){if(n){if(this._regex)throw e.createStacklessError("Partial matching does not support regular expressions. Please provide a string value.");return this._string.split(/\s+/g).filter(Boolean).every(r=>t.contains(r))}return this.matches(t.toString())}normalize(e){return e&&(this._normalizeWhiteSpace&&(e=ve(e)),this._ignoreCase&&(e=e.toLocaleLowerCase()),e)}};function Hr(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!Hr(e[r],t[r]))return!1;return!0}if(e instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;++r)if(!t.hasOwnProperty(n[r]))return!1;for(let r of n)if(!Hr(e[r],t[r]))return!1;return!0}return typeof e=="number"&&typeof t=="number"?isNaN(e)&&isNaN(t):!1}var Me={selectorUtils:zi,roleUtils:to,domUtils:Eo,selectorGenerator:qo,stringUtils:Ji,InjectedScript:iu},pa=function(){if(!Me.InjectedScript)throw new Error("InjectedScript is not available yet.");let e=Me.InjectedScript,t=this.options||{sdkLanguage:"javascript",testIdAttributeName:"blinq-test-id",stableRafCount:0,browserName:"chromium",inputFileRoleTextbox:!1,customEngines:[],isUnderTest:!0};return new e(window,t)};var au=["slot","alt","name","placeholder","title","aria-label","aria-placeholder","role","data-testid","data-cy"];function cu(e){return`"${e.replace(/["\\]/g,t=>"\\"+t)}"`}function lu(e){return/^[a-zA-Z][a-zA-Z0-9\-\_]+$/.test(e)?"#"+e:`[id=${cu(e)}]`}function uu(e){let t="";for(let n=0;n<e.length;n++)t+=hu(e,n);return t}function hu(e,t){let n=e.charCodeAt(t);return n===0?"\uFFFD":n>=1&&n<=31||n>=48&&n<=57&&(t===0||t===1&&e.charCodeAt(0)===45)?"\\"+n.toString(16)+" ":t===0&&n===45&&e.length===1?"\\"+e.charAt(t):n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122?e.charAt(t):"\\"+e.charAt(t)}function fu(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,"$1$2\\$3").replace(/>>/g,"\\>\\>")}var Ts=class{constructor(t,n={}){this.locatorStrategies={text:"basic",no_text:"no_text",custom:"custom",context:"context",digitIgnore:"ignore_digit",text_with_index:"text_with_index"},this.options=n,this.dom_Parent=new Ai,this.PW=Me,this.injectedScript=t,this.cache=new Map}generateUniqueCSSSelector(t,n){var y;let r=(n==null?void 0:n.root)||window.document,o=(n==null?void 0:n.separator)||" > ",u=(n==null?void 0:n.isunique)||(w=>this.getMatchingElements(w,n).length===1),l=(n==null?void 0:n.noCSSId)||!1;if(!(t instanceof Element)||!r.contains(t))return"";let h="",p=t.getAttribute("id");if(p&&!/\d/.test(p)&&!l&&(h=lu(p),u(h))||t.tagName&&(h=t.tagName.toLowerCase()+h,u(h)))return h;let b=Array.from(t.classList).filter(w=>!/\d/.test(w));if(b.length&&(h+=b.map(w=>"."+uu(w)).join(""),u(h)))return h;for(let w of au)if(t.hasAttribute(w)){let A=t.getAttribute(w);if(A===""||/\d/.test(A))continue;A=A.replace(/[!"#$%&'()*+,./:;<=>?@[\]^`{|}~]/g,"\\$&"),h+=`[${w}=${this.PW.stringUtils.escapeForAttributeSelector(A)}]`}if(u(h)||t===r)return h;let v=t.parentElement;if(v){if(v!==r&&(t.assignedSlot&&(v=t.assignedSlot.parentElement??t.assignedSlot.parentNode.host),v&&v!==r&&(h=this.generateUniqueCSSSelector(v,n)+o+h,u(h))))return h}else if(t.parentNode instanceof ShadowRoot){let w=t.parentNode.host;if(w&&w!==r&&(h=this.generateUniqueCSSSelector(w,n)+" >>> "+h,u(h)))return h}let m=(y=t.parentElement)==null?void 0:y.children;if(m){for(let w=0;w<m.length;w++)if(m[w]===t)return h+`:nth-child(${w+1})`}return""}getMatchingElements(t,n={}){let{root:r=window.document,prefix:o,visible:u=!0}=n;return u&&(t=`${t} >> visible=true`),o&&(t=`${o} >> ${t}`),this.injectedScript.querySelectorAll(this.injectedScript.parseSelector(t),r)}getLocatorStrategies(){return this.locatorStrategies}getTextLocators(t,n){let r=this.injectedScript,o=this.PW.selectorGenerator.buildTextCandidates(r,t,n),u=[];for(let l of o){let h=0,p=[];for(let m of l){let{engine:y,selector:w}=m;y==="css"?p.push(w):p.push(`${y}=${w}`),h+=m.score}let b=p.join(" >> "),v=h/l.length;u.push({css:b,score:v})}return u}getNoTextLocators(t,n){let r=this.injectedScript,o=this.PW.selectorGenerator.buildNoTextCandidates(r,t,n);for(let u of o)u.engine==="css"?u.css=u.selector:u.css=`${u.engine}=${u.selector}`,delete u.engine,delete u.selector;return o}getCustomLocators(t,n){let{customAttributes:r=[]}=this.options;if(!r||!Array.isArray(r))return console.error("Custom attributes must be an array"),[];let o=[],u=[];for(let l of r){if(!l||typeof l!="string"){console.error("Custom attribute must be a string");continue}let h=t.getAttribute(l);h!==null&&(u.push(l),o.push({css:`[${l}=${this.PW.stringUtils.escapeForAttributeSelector(h)}]`,score:1,priority:1}))}return o}getContextLocators(t,n){if(!n||!Array.isArray(n))return console.error("Locators must be an array"),[];let r=[];try{let o=new Set;for(let u of n){let l=u.css;if(!l||typeof l!="string"){console.error("Locator must have a valid css selector");continue}let p=this.injectedScript.parseSelector(l).parts;if(!p||!Array.isArray(p)||p.length===0){console.error("Locator must have a valid css selector");continue}if(p.length<3)continue;let b=p[0];if(b.name!=="internal:text")continue;let v=b.body;if(!v||typeof v!="string"||v.length===0){console.error("Locator must have a valid text in the first part to be a context locator");continue}let m=p[1];if(m.name!=="xpath")continue;let y=m.body;if(!y||typeof y!="string"||y.length===0)continue;let w=m.body;if(!w||typeof w!="string"||w.length===0)continue;let A=/(\.\.)(\/\.\.)*/;try{if(A.test(w)){let $=w.split("..").length-1,U=l.indexOf(w),B=l.substring(U+w.length+3).trim();if(B.length===0)continue;let V=`internal:text=${v}`,te=this.getMatchingElements(V,{});if(te.length!==1){console.error("Context locator must have exactly one element matching the text part");continue}let ne=te[0],ee=this.injectedScript.utils.elementText(new Map,ne).full.trim(),ie=`${V} >> xpath=${y} >> ${B}`,ke=this.getMatchingElements(ie,{});if(ke.length!==1){console.error("Context locator must have exactly one element matching the full selector");continue}if(ke[0]!==t){console.error("Context locator must have the text element as the full element");continue}if(!o.has(ee)){o.add(ee);let se={css:B,climb:$,text:ee,priority:1};u.index!==void 0&&(se.index=u.index),r.push(se)}}}catch(I){console.error("Error parsing climb string:",I);continue}}}catch(o){console.error("Error generating context locators:",o)}return r.sort((o,u)=>o.text.length-u.text.length),r}getDigitIgnoreLocators(t,n){let r=[];try{if(!n||!Array.isArray(n))return console.error("Locators must be an array"),[];for(let o of n){let u=o.css;if(!u||typeof u!="string"){console.error("Locator must have a valid css selector");continue}let h=this.injectedScript.parseSelector(u).parts;if(!h||!Array.isArray(h)||h.length===0){console.error("Locator must have a valid css selector");continue}let p="",b=!1;for(let v of h){if(v.name!=="internal:text"){p+=`${v.name==="css"?"":v.name+"="}${v.source} >> `;continue}if(typeof v.body!="string"||v.body.length===0){p+=`${v.name==="css"?"":v.name+"="}${v.source} >> `;continue}let m=v.body,y=/\d+/g;b=y.test(m);let w=this.PW.stringUtils.escapeRegExp(m.substring(1,m.length-2)),A=new RegExp(w);p+=`internal:text=${fu(A).replace(y,"\\d+")} >> `}if(b&&(p.endsWith(" >> ")&&(p=p.slice(0,-4)),p)){let v=this.getMatchingElements(p,{});if(v.length!==1){console.error("Digit ignore locator must have exactly one element matching the final selector");continue}if(v[0]!==t){console.error("Digit ignore locator must match the original element");continue}r.push({css:p,priority:o.priority||1})}}}catch(o){console.error("Error generating digit ignore locators:",o)}return r}getTextwithIndexLocators(t){if(!t||!Array.isArray(t))return console.error("Locators must be an array"),[];let n=[];try{for(let r of t){if(!r||!r.css||typeof r.css!="string"){console.error("Locator must have a valid css selector");continue}let o=r.index;typeof o!="number"||o<0||n.push(r)}}catch(r){console.error("Error getting text with index locators:",r)}return n}getXPathSelector(t){if(typeof t!="number"||t<0)return console.error("Climb must be a non-negative integer"),"";if(t===0)return"";let n="xpath=..";if(t===1)return n;for(let r=1;r<t;r++)n+="/..";return n}categorizeLocators(t,n,r){let o=[],u=[];try{for(let l of n){let h=this.getMatchingElements(l.css,r);if(h.length===0){console.warn(`No elements found for locator: ${l.css}`);continue}else if(h.length===1){if(t===h[0])l.priority=1,o.push(l);else if(t.contains(h[0])){l.priority=1;let p=this.dom_Parent.getClimbCountToParent(h[0],t),b=this.getXPathSelector(p),v=`${l.css} >> ${b}`;l.css=v,o.push(l)}}else l.priority=2,l.elements=h,u.push(l)}}catch(l){console.error("Error categorizing locators:",l)}return{unique:o,nonUnique:u}}getUniqueLocators(t,n=this.getNoTextLocators,r={}){return this.getUniqueLocators2(t,n,r)}getUniqueLocators1(t,n=this.getNoTextLocators,r={}){try{let{maxLocators:o=5,root:u=window.document.body,next:l="LCA",minLocators:h=3}=r;if(!t)return[];if(t===u)return t===window.document.documentElement?[{css:"html",score:1,priority:1},{css:":root",score:1,priority:1}]:[{css:":root",score:1,priority:1}];console.log("Generating locators for element:",t);let p=n(t,r);if(console.log("Generated locators:",p),!p||!Array.isArray(p))return console.error("Locator generator did not return an array of locators"),[];console.log("Categorizing locators for element:",t);let b=this.categorizeLocators(t,p,r);console.log("Categorized locators:",b);let{unique:v,nonUnique:m}=b,y=[];if(v.length>0&&y.push(...v),y.length>=o)return y.slice(0,o);let w=null;for(let A of m){let I=A.css??A.selector,$=A.elements||this.getMatchingElements(I,r);if(l==="parent"?w=this.dom_Parent.getActualParent(t):w=this.dom_Parent.findBranchingParent($,t),w&&w!==t)if(u.contains(w)){let U=this.getUniqueLocators(w,n,{...r,root:u});for(let B of U){if(y.length>=o)return y.slice(0,o);let te=`${B.css??B.selector} >> ${I}`,ne=this.getMatchingElements(te,r),ee=(B.score+A.score)/2+100;if(ne.length===1&&ne[0]===t)B.css=te,B.score=ee,B.priority=1,y.push(B);else{let ie=ne.indexOf(t);ie!==-1&&ie<5&&(B.css=te,B.index=ie,B.priority=2,B.score=ee,y.push(B))}}}else{let U=$.indexOf(t);U!==-1&&U<5&&(A.index=U,A.priority=2,y.push(A))}else{let U=$.indexOf(t);U!==-1&&U<5&&(A.index=U,A.priority=2,y.push(A))}delete A.elements,delete A.strategy,delete A.engine,delete A.selector}if(y.length<h&&u&&u.contains(t)){let A=this.dom_Parent.getActualParent(t),I=this.getUniqueLocators(A,n,{...r,root:u});y.push(...I)}return y.sort((A,I)=>A.score-I.score),console.log("Final locators:",y,t),console.groupEnd(),y.slice(0,o)}catch(o){return console.error("Error in getUniqueLocators:",o),[]}}getUniqueLocators2(t,n=this.getNoTextLocators,r={}){try{let{maxLocators:o=5,root:u=window.document.body}=r;if(!t)return[];if(t===u)return t===window.document.documentElement?[{css:"html",score:1,priority:1},{css:":root",score:1,priority:1}]:[{css:":root",score:1,priority:1}];console.log("Generating locators for element:",t);let l=n(t,r);if(console.log("Generated locators:",l),!l||!Array.isArray(l))return console.error("Locator generator did not return an array of locators"),[];console.log("Categorizing locators for element:",t);let h=this.categorizeLocators(t,l,r);console.log("Categorized locators:",h);let{unique:p,nonUnique:b}=h,v=[];if(p.length>0&&v.push(...p),v.length>=o)return v.slice(0,o);let m=new Map,y=this.dom_Parent.getFullAncestorChainToRoot(t,u);y.shift();let w=[];for(let I of y){let $=n(I,r);if(!$||!Array.isArray($)||$.length===0)continue;let U=this.categorizeLocators(I,$,r);if(w.push({element:I,locators:U}),m.set(I,U),U.unique.length>0)break}let A=w[w.length-1];for(let I of b){let $=I.css??I.selector;if((I.elements||this.getMatchingElements($,r)).length===0){console.warn(`No elements found for locator: ${$}`);continue}for(let B of A.locators.unique){let V=`${B.css} >> ${$}`,te=this.getMatchingElements(V,r);if(te.length===1&&te[0]===t){let ne=(B.score+I.score)/2+100,ee={...B,css:V,score:ne,priority:1};v.push(ee)}else{let ne=te.indexOf(t);if(ne!==-1&&ne<5){let ee=(B.score+I.score)/2,ie={...B,css:V,index:ne,score:ee+200,priority:2};v.push(ie)}}}}return v.sort((I,$)=>I.score-$.score),console.log("Final locators:",v,t),console.groupEnd(),v.slice(0,o)}catch(o){return console.error("Error in getUniqueLocators:",o),[]}}getElementLocators(t,n={}){var r;try{let{excludeText:o=!1}=n,u={};if((r=this.options)!=null&&r.customAttributes){console.groupCollapsed("Generating Custom locators for element:",t);let v=this.getUniqueLocators(t,this.getCustomLocators.bind(this),n);v.length>0&&(u[this.locatorStrategies.custom]=v)}if(console.groupEnd(),!o){console.groupCollapsed("Generating Text locators for element:",t);let v=this.getUniqueLocators(t,this.getTextLocators.bind(this),n);console.groupEnd(),v.length>0&&(u[this.locatorStrategies.text]=v);let m=this.getTextwithIndexLocators(v);m.length>0&&(u[this.locatorStrategies.text_with_index]=m);let y=this.getDigitIgnoreLocators(t,v);y.length>0&&(u[this.locatorStrategies.digitIgnore]=y);let w=this.getContextLocators(t,v);w.length>0&&(u[this.locatorStrategies.context]=w)}console.groupCollapsed("Generating No Text locators for element:",t);let l=this.getUniqueLocators(t,this.getNoTextLocators.bind(this),n);if(l.length>0)u[this.locatorStrategies.no_text]=l;else{let v=[];v.push({css:this.generateUniqueCSSSelector(t,n),score:500,priority:3}),v.length>0&&(u[this.locatorStrategies.no_text]=v)}console.groupEnd();let h=this.getBestStrategy(u);if(!h)throw new Error("No locators found for element: "+t);u.strategy=h;let b={locators:u[u.strategy]??[],element_name:""};return Object.keys(u).length>1&&(b.allStrategyLocators=u),console.log("Generated locators:",b),b}catch(o){return console.error("Error in getElementLocators:",o),{locators:[],element_name:""}}}getBestStrategy(t){let n=[this.locatorStrategies.custom,this.locatorStrategies.context,this.locatorStrategies.text,this.locatorStrategies.text_with_index,this.locatorStrategies.digitIgnore,this.locatorStrategies.no_text];for(let r of n)if(t[r]&&t[r].length>0)return r;return null}},ga=Ts;var ks=class{constructor(t={}){let{inlineImages:n=!0,inlineStyles:r=!0,excludeSelectors:o=[]}=t;this.inlineImages=n,this.inlineStyles=r,this.excludeSelectors=o}imageToDataURL(t,n){try{let r=n.createElement("canvas");return r.width=t.naturalWidth||t.width,r.height=t.naturalHeight||t.height,r.getContext("2d").drawImage(t,0,0),r.toDataURL("image/png")}catch(r){return console.warn(`Failed to inline image: ${t.src}`,r),t.src}}processStyles(t){if(!this.inlineStyles)return;let n=Array.from(t.styleSheets);for(let r of n)try{if(!r.href)continue;let o=t.createElement("style"),u="",l=Array.from(r.cssRules||[]);for(let h of l)h.cssText&&(u+=h.cssText+`
|
|
19
19
|
`);o.textContent=u,r.ownerNode&&r.ownerNode.parentNode?r.ownerNode.parentNode.replaceChild(o,r.ownerNode):r.ownerNode&&t.head.appendChild(o)}catch(o){console.warn(`Error processing stylesheet: ${r.href}`,o)}}processImages(t){if(!this.inlineImages)return;t.querySelectorAll("img").forEach(r=>{if(!(r.src.startsWith("data:")||r.src.endsWith(".svg"))&&!this.excludeSelectors.some(o=>r.matches(o))&&r.complete&&r.naturalWidth!==0)try{r.setAttribute("src",this.imageToDataURL(r,t))}catch(o){console.warn(`Failed to process image: ${r.src}`,o)}})}removeExcludedElements(t){this.excludeSelectors.forEach(n=>{t.querySelectorAll(n).forEach(o=>{var u;(u=o.parentNode)==null||u.removeChild(o)})})}processComputedStyles(t){t.querySelectorAll("*").forEach(r=>{if(this.excludeSelectors.some(h=>r.matches(h)))return;let o=window.getComputedStyle(r),u=["display","position","width","height","margin","padding","color","background-color","font-family","font-size","text-align","line-height","border","box-shadow","opacity"],l=[];if(u.forEach(h=>{let p=o.getPropertyValue(h);p&&l.push(`${h}: ${p}`)}),l.length>0){let h=r.getAttribute("style")||"";r.setAttribute("style",h+l.join("; ")+";")}})}createSnapshot(){let t=window.document.cloneNode(!0),n=window.document,r=t;this.processStyles(r),this.processImages(r),this.removeExcludedElements(r),this.processComputedStyles(r);let o=n.doctype?new XMLSerializer().serializeToString(n.doctype):"<!DOCTYPE html>",u=r.documentElement.outerHTML;return`${o}${u}`}},ma=ks;var _s=class{isLeafNode(t){return t.kind==="text"?!0:!t.children||t.children.length===0}deepClone(t){if(t.kind==="text")return t.text;{let n={kind:"role",role:t.role};return"checked"in t&&(n.checked=t.checked),"disabled"in t&&(n.disabled=t.disabled),"expanded"in t&&(n.expanded=t.expanded),"level"in t&&(n.level=t.level),"pressed"in t&&(n.pressed=t.pressed),"selected"in t&&(n.selected=t.selected),t.name!==void 0&&(n.name=t.name),t.props&&(n.props=Object.assign({},t.props)),t.containerMode&&(n.containerMode=t.containerMode),t.children&&(n.children=t.children.map(r=>this.deepClone(r))),n}}yamlEscapeKeyIfNeeded(t){return this.yamlStringNeedsQuotes(t)?"'"+t.replace(/'/g,"''")+"'":t}yamlEscapeValueIfNeeded(t){return this.yamlStringNeedsQuotes(t)?'"'+t.replace(/[\\"\x00-\x1f\x7f-\x9f]/g,n=>{switch(n){case"\\":return"\\\\";case'"':return'\\"';case"\b":return"\\b";case"\f":return"\\f";case`
|
|
20
20
|
`:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return"\\x"+n.charCodeAt(0).toString(16).padStart(2,"0")}})+'"':t}yamlStringNeedsQuotes(t){return t?!!(t.length===0||/^\s|\s$/.test(t)||/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/.test(t)||/^-/.test(t)||/[\n:](\s|$)/.test(t)||/\s#/.test(t)||/[\n\r]/.test(t)||/^[&*\],?!>|@"'#%]/.test(t)||/[{}`]/.test(t)||/^\[/.test(t)||!isNaN(Number(t))||["y","n","yes","no","true","false","on","off","null"].includes(t.toLowerCase())):!1}filterParentToChildren(t,n){let r=n.some(o=>JSON.stringify(o)===JSON.stringify(t));if(r||this.isLeafNode(t))return r?this.deepClone(t):null;if(t.kind==="role"&&t.children&&t.children.length>0){let o=t.children.map(u=>this.filterParentToChildren(u,n)).filter(u=>u!==null);if(o.length>0){let u=this.deepClone(t);return u.children=o,u}}return null}serializeAriaSnapshot(t,n=0){let r=[],o=(l,h,p)=>{if(typeof l=="string"){let y=this.yamlEscapeValueIfNeeded(l);y&&r.push(p+"- text: "+y);return}let b=l.role;if(l.name&&l.name.length<=900){let y=l.name;if(y){let w=y.startsWith("/")&&y.endsWith("/")?y:JSON.stringify(y);b+=" "+w}}l.checked==="mixed"&&(b+=" [checked=mixed]"),l.checked===!0&&(b+=" [checked]"),l.disabled&&(b+=" [disabled]"),l.expanded&&(b+=" [expanded]"),l.level&&(b+=` [level=${l.level}]`),l.pressed==="mixed"&&(b+=" [pressed=mixed]"),l.pressed===!0&&(b+=" [pressed]"),l.selected===!0&&(b+=" [selected]");let v=p+"- "+this.yamlEscapeKeyIfNeeded(b);l.props===void 0&&(l.props={}),l.children===void 0&&(l.children=[]);let m=!!Object.keys(l.props).length;if(!l.children.length&&!m)r.push(v);else if(l.children.length===1&&typeof l.children[0]=="string"&&!m){let y=l.children[0];y?r.push(v+": "+this.yamlEscapeValueIfNeeded(y)):r.push(v)}else{r.push(v+":");for(let[y,w]of Object.entries(l.props)||[])r.push(p+" - /"+y+": "+this.yamlEscapeValueIfNeeded(w));for(let y of l.children||[])o(y,l,p+" ")}},u=t;if(u.role==="fragment")for(let l of u.children||[])o(l,u,"");else o(u,null,"");return r.join(`
|
|
21
21
|
`)}isSnapshotAvailable(t,n){if(n.has(t))return t}findMatchingElements(t,n){let r=new Map,o=t.trim().split(`
|
|
@@ -283,7 +283,7 @@ class LocatorGenerator {
|
|
|
283
283
|
}
|
|
284
284
|
const textElement = elements[0];
|
|
285
285
|
// const text = this.PW.selectorUtils.elementText(textElement);
|
|
286
|
-
const text = this.injectedScript.utils.elementText(new Map(), textElement).full;
|
|
286
|
+
const text = this.injectedScript.utils.elementText(new Map(), textElement).full.trim();
|
|
287
287
|
|
|
288
288
|
const fullSelector = `${textLocator} >> xpath=${xpath} >> ${restOfSelector}`;
|
|
289
289
|
const fullElements = this.getMatchingElements(fullSelector, {});
|
|
@@ -374,10 +374,13 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
374
374
|
}
|
|
375
375
|
case "verifyTextRelatedToText": {
|
|
376
376
|
step.type = Types.VERIFY_TEXT_RELATED_TO_TEXT;
|
|
377
|
-
const
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
|
|
377
|
+
const textAnchorParse = parseDataSource(call.arguments[0], stepParams);
|
|
378
|
+
const textAnchor = textAnchorParse.type === "literal" ? textAnchorParse.value : toVariableName(textAnchorParse.dataKey);
|
|
379
|
+
const climbParse = parseDataSource(call.arguments[1], stepParams);
|
|
380
|
+
const climb = climbParse.type === "literal" ? climbParse.value : toVariableName(climbParse.dataKey);
|
|
381
|
+
const textToVerifyParse = parseDataSource(call.arguments[2], stepParams);
|
|
382
|
+
const textToVerify = textToVerifyParse.type === "literal" ? textToVerifyParse.value : toVariableName(textToVerifyParse.dataKey);
|
|
383
|
+
step.parameters = [textAnchor, climb, textToVerify];
|
|
381
384
|
break;
|
|
382
385
|
}
|
|
383
386
|
case "setInputFiles": {
|