tomation 0.0.4 → 0.0.5

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.
@@ -12,8 +12,11 @@ declare enum EVENT_NAMES {
12
12
  TEST_FAILED = "tomation-test-failed",
13
13
  TEST_END = "tomation-test-end",
14
14
  TEST_STOP = "tomation-test-stop",
15
+ TEST_PAUSE = "tomation-test-pause",
16
+ TEST_PLAY = "tomation-test-play",
15
17
  USER_ACCEPT = "tomation-user-accept",
16
- USER_REJECT = "tomation-user-reject"
18
+ USER_REJECT = "tomation-user-reject",
19
+ SESSION_INIT = "tomation-session-init"
17
20
  }
18
21
  type AutomationEventHandlerType = ((action?: any) => void);
19
22
  declare class EventDispatcher {
package/dist/main.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ae=Object.defineProperty;var ce=(t,e,n)=>e in t?ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var i=(t,e,n)=>(ce(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class Q{constructor(e,n,s,o){i(this,"name");i(this,"selector");i(this,"parent");i(this,"postProcess");this.name=e,this.selector=n,this.parent=s||null,this.postProcess=o}getElementName(){let e="";return this.parent&&(e=" in "+this.parent.getElementName()),`${this.name}${e}`}}let F;const le=t=>{F=t},q=(t,e)=>(s=F,o)=>{s=s||F,console.log("Searching elem from Root = ",s);const r=[];s.querySelectorAll(t).forEach(c=>{c.style.display!=="none"&&r.push(c)});let a;return e?(console.log("Applying filter ",e),console.log(" -- to "+r.length+"elements: ",r),a=r.filter((c,y,x)=>{console.log("Apply filter to item "+y+": ",c);const p=e(c,y,x);return console.log(` -> Item ${y} ${p?"Match":"Discarded"}`),p})[0]):a=r[0],a&&o&&(console.log("Apply post process to = ",a),a=o(a)),console.log("Return elem = ",a),a},$=(t,e,n)=>({as:s=>new Q(s,t,e,n)}),ue=(t,e)=>({...$(t,e),postProcess:n=>({...$(t,e,n)})}),Z=t=>({...$(t,null),childOf:e=>({...ue(t,e)}),postProcess:e=>({...$(t,null,e)})}),D=t=>({where:e=>Z(q(t,e))}),he=D("div"),de=D("button"),pe=D("input"),me=D("textarea"),ge=t=>Z(q("#"+t)),ye=t=>D(t);let Y=!1;const Ee=t=>{Y=t},f=(...t)=>{Y&&console.log("[UIElement Filter]",...t)},we=t=>e=>{const n=e.className==t;return f(`classIs('${t}') on`,e,"=>",n),n},fe=t=>e=>{const n=e.className.split(" ").includes(t);return f(`classIncludes('${t}') on`,e,"=>",n),n},Ae=t=>e=>{var s;const n=((s=e.textContent)==null?void 0:s.trim())==t;return f(`innerTextIs('${t}') on`,e,"=>",n),n},xe=t=>e=>{const n=e.innerText.trim().includes(t);return f(`innerTextContains('${t}') on`,e,"=>",n),n},Ce=t=>e=>{const n=e.title==t;return f(`titleIs('${t}') on`,e,"=>",n),n},Te=t=>e=>{const n=e.placeholder===t;return f(`placeholderIs('${t}') on`,e,"=>",n),n},ke=()=>(t,e)=>{const n=e===0;return f("isFirstElement on",t,"index",e,"=>",n),n},Se=t=>(e,n)=>{const s=n===t;return f(`elementIndexIs(${t}) on`,e,"elemIndex",n,"=>",s),s},Ie=t=>e=>{const n=(e==null?void 0:e.firstChild).innerText.trim()===t;return f(`firstChildTextIs('${t}') on`,e,"=>",n),n},ve=t=>(e,n)=>{let s=!0,o=0;for(;s&&o<t.length;){const r=t[o](e,n);f(`and condition[${o}] on`,e,"elemIndex",n,"=>",r),s=s&&r,o++}return f("and final result on",e,"elemIndex",n,"=>",s),s},Ne={DIV:he,BUTTON:de,INPUT:pe,TEXTAREA:me,ELEMENT:ye,identifiedBy:ge};let P;const be=new Uint8Array(16);function De(){if(!P&&(P=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!P))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return P(be)}const d=[];for(let t=0;t<256;++t)d.push((t+256).toString(16).slice(1));function Oe(t,e=0){return(d[t[e+0]]+d[t[e+1]]+d[t[e+2]]+d[t[e+3]]+"-"+d[t[e+4]]+d[t[e+5]]+"-"+d[t[e+6]]+d[t[e+7]]+"-"+d[t[e+8]]+d[t[e+9]]+"-"+d[t[e+10]]+d[t[e+11]]+d[t[e+12]]+d[t[e+13]]+d[t[e+14]]+d[t[e+15]]).toLowerCase()}const Pe=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),X={randomUUID:Pe};function Le(t,e,n){if(X.randomUUID&&!e&&!t)return X.randomUUID();t=t||{};const s=t.random||(t.rng||De)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=s[o];return e}return Oe(s)}const E=(t=2e3)=>new Promise(e=>{setTimeout(()=>{e(null)},t)}),A=(t,e)=>{Object.entries(e).map(([s,o])=>({key:s,value:o})).forEach(s=>{const{key:o,value:r}=s;t.style[o]=r})};class Ue{constructor(e){i(this,"window");i(this,"document");i(this,"devToolsMessageContainer");i(this,"devToolsCheckElementContainer");i(this,"darkLayerLeft");i(this,"darkLayerTop");i(this,"darkLayerRight");i(this,"darkLayerBottom");i(this,"currentCheckElem");i(this,"contextViewerContainer");i(this,"devToolsAlertContainer");this.document=e.document,this.window=e,this.devToolsMessageContainer=this.createElement("DIV",{id:"dev-tools-message-container",styles:{width:"500px",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"white",position:"fixed",bottom:"10px",right:"10px",fontFamily:"monospace",zIndex:"9999"},parent:this.document.body}),this.devToolsAlertContainer=this.createElement("DIV",{id:"dev-tools-alert-container",styles:{width:"100%",height:"30px",backgroundColor:"#b00",color:"white",position:"absolute ",top:0,fontFamily:"monospace",zIndex:"9999",display:"none",alignItems:"center",justifyContent:"center",padding:"5px"},parent:this.document.body}),this.devToolsCheckElementContainer=this.createElement("DIV",{id:"dev-tools-check-element-container",styles:{width:"100%",height:this.document.body.clientHeight+"px",position:"absolute",top:"0px",left:"0px",zIndex:"9990",display:"none",opacity:"0",transition:"opacity .2s"},parent:this.document.body});const n={zIndex:"9991",backgroundColor:"rgba(0,0,0,0.3)",position:"absolute"};this.darkLayerLeft=this.createElement("DIV",{id:"dark-layer-left",styles:n,parent:this.devToolsCheckElementContainer}),this.darkLayerTop=this.createElement("DIV",{id:"dark-layer-top",styles:n,parent:this.devToolsCheckElementContainer}),this.darkLayerRight=this.createElement("DIV",{id:"dark-layer-right",styles:n,parent:this.devToolsCheckElementContainer}),this.darkLayerBottom=this.createElement("DIV",{id:"dark-layer-bottom",styles:n,parent:this.devToolsCheckElementContainer}),this.currentCheckElem=this.createElement("DIV",{id:"current-check-elem",parent:this.devToolsCheckElementContainer}),this.contextViewerContainer=this.createElement("DIV",{id:"context-viewer-container",styles:{width:"100%",height:this.document.body.clientHeight+"px",position:"absolute",top:"0px",left:"0px",zIndex:"10000",display:"none"},parent:this.document.body})}createElement(e,n){const s=this.document.createElement(e);return n&&(n.id&&(s.id=n==null?void 0:n.id),n.styles&&A(s,n.styles),n.parent&&n.parent.appendChild(s)),s}async logAction(e){const n=exports.AutomationInstance.document.createElement("DIV");n.innerText=e,A(n,{padding:"3px 10px",opacity:"1",transition:"opacity 1s"}),this.devToolsMessageContainer.appendChild(n),await E(4e3),n.style.opacity="0",await E(4e3),this.devToolsMessageContainer.removeChild(n),await E(1e3)}async checkElement(e,n){if(!e)return;const s=e.getBoundingClientRect(),o=this.document.body.getBoundingClientRect();this.darkLayerLeft.style.left="0px",this.darkLayerLeft.style.top=s.top+"px",this.darkLayerLeft.style.width=this.window.scrollX+s.left+"px",this.darkLayerLeft.style.height=s.height+"px",this.darkLayerTop.style.left=this.window.scrollX+"px",this.darkLayerTop.style.top="0px",this.darkLayerTop.style.width="100%",this.darkLayerTop.style.height=s.top+"px",this.darkLayerRight.style.left=this.window.scrollX+s.left+s.width+"px",this.darkLayerRight.style.top=s.top+"px",this.darkLayerRight.style.width=o.width-(s.left+s.width)+"px",this.darkLayerRight.style.height=s.height+"px",this.darkLayerBottom.style.left=this.window.scrollX+"px",this.darkLayerBottom.style.top=s.top+s.height+"px",this.darkLayerBottom.style.width="100%",this.darkLayerBottom.style.height=o.height-(s.top+s.height)+"px",this.currentCheckElem.id=`dev-tools-current-check-elem-${n}`,this.currentCheckElem.style.top=s.top+"px",this.currentCheckElem.style.left=this.window.scrollX+s.left+"px",this.currentCheckElem.style.height=s.height+"px",this.currentCheckElem.style.width=s.width+"px",this.currentCheckElem.style.boxShadow="0px 0px 5px 2px lightgreen",this.currentCheckElem.style.position="absolute",this.currentCheckElem.style.zIndex="9992",this.devToolsCheckElementContainer.style.display="block",this.devToolsCheckElementContainer.style.opacity="1",await E(200)}async showAlert(e){const n=exports.AutomationInstance.document.createElement("DIV"),s=exports.AutomationInstance.document.body;n.innerText=e,A(s,{paddingTop:"30px"}),A(this.devToolsAlertContainer,{display:"flex"}),this.devToolsAlertContainer.appendChild(n)}async hideAlert(){A(this.devToolsAlertContainer,{display:"none"});const e=exports.AutomationInstance.document.body;A(e,{paddingTop:"0"}),this.devToolsAlertContainer.firstChild&&this.devToolsAlertContainer.removeChild(this.devToolsAlertContainer.firstChild)}async hideCheckElementContainer(){this.devToolsCheckElementContainer.style.opacity="0",await E(200),this.devToolsCheckElementContainer.style.display="none"}displayContext(e){A(this.contextViewerContainer,{display:"flex","background-color":"white",position:"absolute",top:"0px",left:"0px","z-index":"9999"});const n=this.document.createElement("DIV");n.id="context-viewer-before",A(n,{flex:"50%",width:"100%",height:"auto",border:"2px solid orange"});const s=this.document.createElement("DIV");s.id="context-viewer-after",A(s,{flex:"50%",width:"100%",height:"auto",border:"2px solid green"});const o=this.document.createElement("DIV");o.innerHTML=e.beforeHTML,z(o,e.beforeInputValues);const r=this.document.createElement("DIV");r.innerHTML=e.afterHTML,z(r,e.afterInputValues),this.contextViewerContainer.appendChild(n),n.appendChild(o),setTimeout(()=>{this.contextViewerContainer.removeChild(n),this.contextViewerContainer.appendChild(s),s.appendChild(r),setTimeout(()=>{this.contextViewerContainer.removeChild(s),A(this.contextViewerContainer,{display:"none"})},2e3)},2e3)}}const z=(t,e)=>{t.querySelectorAll("input").forEach(n=>{const s=n.getAttribute("input-id")||"";n.value=e[s]})},W=null,L=async(t,e,n,s=1e3,o=0,r=10,a=!1)=>{if(console.log("Automation Status: ",exports.AutomationInstance.status),exports.AutomationInstance.isPaused)return new Promise((c,y)=>{exports.AutomationInstance.saveCurrentAction(async x=>{if(x.status=="skipped")return c(null);try{const p=await L(x,e,n,s,o,r,a);c(p)}catch(p){y(p)}},t)});if(exports.AutomationInstance.isStopped)throw new Error("Test stopped manually");if(console.groupCollapsed(`tries ${o}/${r}`),t&&(t.updateTries(o),await g.notifyActionUpdated(t)),o===r)throw console.groupEnd(),a?new Error(`UI Element ${e.getElementName()||"UNKNOWN"} still present after 10 tries`):new Error(`UI Element ${e.getElementName()||"UNKNOWN"} not found after 10 tries`);{const c=e.selector(n,e.postProcess);return console.groupEnd(),c?a?(await E(s),await L(t,e,n,s,++o,r,a)):(console.log("Element found = ",c),c):a?(console.log("Element removed."),W):(await E(s),await L(t,e,n,s,++o,r,a))}},J=async(t,e,n=1e3,s=10,o=!1)=>{const r=e==null?void 0:e.getElementName();console.group("Looking for Element: "+r);let a=null;if(e.parent)try{console.groupCollapsed("Look for Parent ",e.parent.getElementName()),a=await J(t,e.parent,n,s,o),console.groupEnd()}catch(c){if(console.groupEnd(),o&&c.message.includes("not found"))return console.log("Parent not found, so element was removed"),console.groupEnd(),W;throw console.groupEnd(),c}try{console.log("Using parent element: ",a);const c=await L(t,e,a,n,0,s,o);return console.groupEnd(),c}catch(c){if(o&&c.message.includes("not found"))return console.log("Parent not found, so element was removed"),console.groupEnd(),W;throw console.groupEnd(),c}};var H=(t=>(t.WAITING="waiting",t.RUNNING="running",t.STOPPED="stopped",t.PAUSED="paused",t.SUCCESS="success",t.ERROR="error",t.SKIPPED="skipped",t))(H||{});class g{constructor(){i(this,"status");i(this,"error");i(this,"id");i(this,"context");this.status="waiting",this.error="",this.id=Le(),this.context={beforeHTML:"",beforeInputValues:{},afterInputValues:{},afterHTML:"",url:"",startTimestamp:"",endTimestamp:""}}getJSON(){return{id:this.id,description:this.getDescription(),context:this.context,status:this.status,error:this.error}}reset(){this.status="waiting",this.error="",this.resetAction()}getInputValuesFromPage(){const e={};return exports.AutomationInstance.document.querySelectorAll("input").forEach((s,o)=>{const r=`value-id-${o}`;s.setAttribute("input-id",r),e[r]=s.value}),e}async execute(){try{this.status="running",this.context.beforeInputValues=this.getInputValuesFromPage(),this.context.beforeHTML=exports.AutomationInstance.document.body.innerHTML,await g.notifyActionUpdated(this),console.log("Action: ",this.getDescription()),await this.executeAction(),this.status="success",this.error="",exports.AutomationInstance.isStepByStepMode&&exports.AutomationInstance.pause()}catch(e){if(this.status="error",this.error=e.message,e.message=="Test stopped manually")throw Error("Error in Action "+this.getDescription()+". Message: "+e.message);this.status="paused",exports.AutomationInstance.pause()}finally{this.context.afterInputValues=this.getInputValuesFromPage(),this.context.afterHTML=exports.AutomationInstance.document.body.innerHTML,await g.notifyActionUpdated(this)}}static async notifyActionUpdated(e){m.dispatch(k.ACTION_UPDATE,{action:e.getJSON()})}}class _ extends g{constructor(n,s){super();i(this,"name");i(this,"stepsFn");i(this,"steps");i(this,"params");i(this,"index");this.name=n,this.stepsFn=s,this.steps=[],this.index=0}getDescription(){return this.name}compileSteps(){super.reset(),this.stepsFn(this.params)}stepsToJSON(){return this.steps.reduce((n,s)=>(n.push(s.getJSON()),n),[])}getJSON(){return{...super.getJSON(),type:"Action",params:this.params,steps:this.stepsToJSON()}}resetAction(){this.steps.length=0,this.index=0}async continue(){if(exports.AutomationInstance.isPaused)return new Promise((n,s)=>{exports.AutomationInstance.saveCurrentAction(async o=>{if(o.status=="skipped")return n();try{await o.continue(),n()}catch(r){s(r)}},this)});if(exports.AutomationInstance.isStopped)throw new Error("Test stopped manually");if(this.index<this.steps.length){const n=this.steps[this.index];try{if(await E(exports.AutomationInstance.speed),await n.execute(),!exports.AutomationInstance.isPaused)this.index++,await this.continue();else return new Promise((s,o)=>{exports.AutomationInstance.saveCurrentAction(async r=>{if(r.status=="skipped")return this.index++,await g.notifyActionUpdated(n),await this.continue(),s();try{await r.continue(),s()}catch(a){o(a)}},n)})}catch(s){throw s}}}async executeAction(){this.index=0,await this.continue()}setParams(n){this.params=n}addStep(n){this.steps.push(n)}}class h extends g{constructor(n){super();i(this,"uiElement");i(this,"element");i(this,"tries");this.uiElement=n,this.element=null,this.tries=0}getElementName(){var n;return(n=this.uiElement)==null?void 0:n.getElementName()}updateTries(n){this.tries=n}resetTries(){this.tries=0}getJSON(){return{id:this.id,element:this.getElementName(),description:this.getDescription(),status:this.status,error:this.error,context:this.context,tries:this.tries}}static waitForElement(n,s,o=1e3,r=10,a=!1){const c=s.getElementName();return new Promise(async(y,x)=>{var I;const p=async(C,O=1e3,v=0,N=!1)=>{if(console.groupCollapsed(`tries ${v}/${r}`),n.updateTries(v),await g.notifyActionUpdated(n),v===r)throw console.groupEnd(),N?new Error(`UI Element ${c||"UNKNOWN"} still present after 10 tries`):new Error(`UI Element ${c||"UNKNOWN"} not found after 10 tries`);{const M=s.selector(C,s.postProcess);return console.groupEnd(),M?N?(await E(O),await p(C,O,++v,N)):(console.log("Element found = ",M),M):N?(console.log("Element removed."),null):(await E(O),await p(C,O,++v,N))}};console.group("[Action On Element] Looking for Element: "+c);let T=null,K=!0;if(s.parent){console.groupCollapsed("Look for Parent ",s.parent.getElementName());try{T=await h.waitForElement(n,s.parent,o,r,a)}catch{K=!1}finally{console.groupEnd()}}if(K){console.log("using parent element: ",T);try{const C=await p(T,o,0,a);console.groupEnd(),y(C)}catch(C){console.groupEnd(),x(new Error(C.message))}}else console.groupEnd(),x(new Error(`Parent ${(I=s.parent)==null?void 0:I.getElementName()} of UI Element ${s.name||"UNKNOWN"} not found`))})}async executeAction(){var n;try{this.element=await J(this,this.uiElement),(n=this.element)==null||n.setAttribute("test-id",this.getElementName()),await exports.AutomationInstance.uiUtils.checkElement(this.element,this.getElementName()),this.executeActionOnElement(),await exports.AutomationInstance.uiUtils.hideCheckElementContainer()}catch(s){throw Error(s.message)}}resetAction(){this.element=null,this.resetTries()}}class $e extends h{constructor(e){super(e)}executeActionOnElement(){var e;return(e=this.element)==null?void 0:e.click()}getDescription(){return"Click in "+this.getElementName()}getJSON(){return{...super.getJSON(),type:"Click"}}}class Re extends h{constructor(n,s){super(n);i(this,"text");this.text=s}executeActionOnElement(){var s;if(!(((s=this.element)==null?void 0:s.innerText)===this.text))throw new Error(`Text in element ${this.getElementName()} is not '${this.text}'`)}getDescription(){return`Assert that text in ${this.getElementName()} is '${this.text}'`}getJSON(){return{...super.getJSON(),type:"AssertTextIsAction",value:this.text}}}class Je extends h{constructor(n,s){super(n);i(this,"text");this.text=s}executeActionOnElement(){var s;if(!((s=this.element)==null?void 0:s.innerText.includes(this.text)))throw new Error(`Text in element ${this.getElementName()} doesn't contain '${this.text}'`)}getDescription(){return`Assert that ${this.getElementName()} contains '${this.text}'`}getJSON(){return{...super.getJSON(),type:"AssertContainsText",value:this.text}}}class Ve extends h{constructor(n,s){super(n);i(this,"value");this.value=s}executeActionOnElement(){if(!(this.element.value===this.value))throw new Error(`Value in element ${this.getElementName()} is not '${this.value}'`)}getDescription(){return`Assert that value in ${this.getElementName()} is '${this.value}'`}getJSON(){return{...super.getJSON(),type:"AssertValueIsAction",value:this.value}}}class Ke extends h{constructor(e){super(e)}executeActionOnElement(){if(!!!this.element)throw new Error(`Element ${this.getElementName()} doesn't exist`)}getDescription(){return`Assert that ${this.getElementName()} exists`}getJSON(){return{...super.getJSON(),type:"AssertExistsAction"}}}class Me extends h{constructor(e){super(e)}async executeAction(){var e;try{this.element=await J(this,this.uiElement,1e3,5,!0),(e=this.element)==null||e.setAttribute("test-id",this.getElementName()),await exports.AutomationInstance.uiUtils.checkElement(this.element,this.getElementName()),this.executeActionOnElement(),await exports.AutomationInstance.uiUtils.hideCheckElementContainer()}catch(n){throw Error(n.message)}}executeActionOnElement(){if(!!this.element)throw new Error(`Element ${this.getElementName()} was not expected to exist`)}getDescription(){return`Assert that ${this.getElementName()} doesn't exist`}getJSON(){return{...super.getJSON(),type:"AssertNotExistsAction"}}}class Fe extends h{constructor(n,s){super(n);i(this,"value");this.value=s}executeActionOnElement(){var s,o,r,a;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((r=this.element)==null?void 0:r.tagName)!=="TEXTAREA"&&(n=(a=this.element)==null?void 0:a.querySelectorAll("input")[0],!n))throw new Error("Input element not found. Not able to type value in element "+this.getElementName());n.value=this.value,n.dispatchEvent(new Event("change"))}getDescription(){return`Select value '${this.value}' in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"Select",value:this.value}}}class ee extends h{constructor(n,s){super(n);i(this,"value");this.value=s}executeActionOnElement(){var s,o,r,a;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((r=this.element)==null?void 0:r.tagName)!=="TEXTAREA"&&(n=(a=this.element)==null?void 0:a.querySelectorAll("input")[0],!n))throw new Error("Input element not found. Not able to type value in element "+this.getElementName());n.value=this.value,n.dispatchEvent(new Event("change")),n.dispatchEvent(new Event("keyup",{bubbles:!0})),n.dispatchEvent(new Event("input",{bubbles:!0}))}getDescription(){return`Type value '${this.value}' in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"Type",value:this.value}}}class We extends h{constructor(n,s){super(n);i(this,"value");this.value=s}executeActionOnElement(){var s,o,r,a;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((r=this.element)==null?void 0:r.tagName)!=="TEXTAREA"&&(n=(a=this.element)==null?void 0:a.querySelectorAll("input")[0],!n))throw new Error("Input element not found. Not able to type value in element "+this.getElementName());n.value=this.value,n.dispatchEvent(new Event("change")),n.dispatchEvent(new Event("keyup",{bubbles:!0})),n.dispatchEvent(new Event("input",{bubbles:!0}))}getDescription(){return`Type a password in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"TypePassword",value:this.value}}}class Be extends h{constructor(e){super(e)}executeActionOnElement(){var e;(e=this.element)==null||e.dispatchEvent(new KeyboardEvent("keydown",{altKey:!1,code:"Escape",ctrlKey:!1,isComposing:!1,key:"Escape",location:0,metaKey:!1,repeat:!1,shiftKey:!1,which:27,charCode:0,keyCode:27}))}getDescription(){return`Press Esc key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressEscKey"}}}class qe extends h{constructor(e){super(e)}executeActionOnElement(){var e;(e=this.element)==null||e.dispatchEvent(new KeyboardEvent("keyup",{altKey:!1,code:"Down",ctrlKey:!1,isComposing:!1,key:"Down",location:0,metaKey:!1,repeat:!1,shiftKey:!1,which:40,charCode:0,keyCode:40}))}getDescription(){return`Press Down key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressDownKey"}}}class He extends h{constructor(e){super(e)}executeActionOnElement(){var e;(e=this.element)==null||e.dispatchEvent(new KeyboardEvent("keydown",{altKey:!1,code:"Tab",ctrlKey:!1,isComposing:!1,key:"Tab",location:0,metaKey:!1,repeat:!1,shiftKey:!1,which:9,charCode:0,keyCode:9}))}getDescription(){return`Press Tab key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressTabKey"}}}class je extends h{constructor(e){super(e)}executeActionOnElement(){var e;(e=this.element)==null||e.dispatchEvent(new KeyboardEvent("keydown",{altKey:!1,code:"Enter",ctrlKey:!1,isComposing:!1,key:"Enter",location:0,metaKey:!1,repeat:!1,shiftKey:!1,which:13,charCode:0,keyCode:13}))}getDescription(){return`Press Enter key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressEnterKey"}}}var te=(t=>(t.ESCAPE="Escape",t.ENTER="Enter",t.TAB="Tab",t.ARROW_DOWN="ArrowDown",t.ARROW_UP="ArrowUp",t.ARROW_LEFT="ArrowLeft",t.ARROW_RIGHT="ArrowRight",t.BACKSPACE="Backspace",t.DELETE="Delete",t.SHIFT="Shift",t.CONTROL="Control",t.ALT="Alt",t.META="Meta",t))(te||{});const G={Escape:27,Enter:13,Tab:9,ArrowDown:40,ArrowUp:38,ArrowLeft:37,ArrowRight:39,Backspace:8,Delete:46,Shift:16,Control:17,Alt:18,Meta:91};class Xe extends h{constructor(n,s){super(n);i(this,"key");this.key=s}executeActionOnElement(){var n;(n=this.element)==null||n.dispatchEvent(new KeyboardEvent("keydown",{key:this.key,code:this.key,keyCode:G[this.key],charCode:0,which:G[this.key],altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1,isComposing:!1,location:0,repeat:!1}))}getDescription(){return`Press ${this.key} key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressKey",key:this.key}}}class ze extends h{constructor(n,s){super(n);i(this,"file");this.file=s}executeActionOnElement(){const n=this.element,s=new DataTransfer;s.items.add(this.file);const o=s.files;n.files=o,n.dispatchEvent(new Event("change"));function r(c){var y;return c!=null&&c.parentElement?((y=c.parentElement)==null?void 0:y.tagName.toLowerCase())==="form"?c.parentElement:r(c.parentElement):null}const a=r(n);a&&a.dispatchEvent(new Event("change"))}getDescription(){return`Upload file in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"UploadFile"}}}class Ge extends h{constructor(n,s){super(n);i(this,"memorySlotName");this.memorySlotName=s}executeActionOnElement(){var s,o,r,a;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((r=this.element)==null?void 0:r.tagName)!=="TEXTAREA"&&(n=(a=this.element)==null?void 0:a.querySelectorAll("input")[0],!n))throw new Error("Input element not found. Not able to save value from element "+this.getElementName());m.dispatch(k.SAVE_VALUE,{memorySlotName:this.memorySlotName,value:n.value})}getDescription(){return`Save value of ${this.getElementName()} in ${this.memorySlotName}`}getJSON(){return{...super.getJSON(),type:"SaveValue",memorySlotName:this.memorySlotName}}}class Qe extends g{constructor(n){super();i(this,"miliseconds");this.miliseconds=n}getDescription(){return"Wait "+this.miliseconds+" miliseconds"}getJSON(){return{...super.getJSON(),type:"Wait"}}async executeAction(){await E(this.miliseconds)}resetAction(){}}class Ze extends g{constructor(n){super();i(this,"uiElement");i(this,"tries");this.uiElement=n,this.tries=0}updateTries(n){this.tries=n}resetAction(){this.tries=0}getElementName(){var n;return(n=this.uiElement)==null?void 0:n.getElementName()}async executeAction(){await J(this,this.uiElement,1e3,10,!0)}getDescription(){return"Wait until "+this.getElementName()+" is removed"}getJSON(){return{...super.getJSON(),type:"WaitUntilElementRemoved"}}}class Ye extends g{constructor(){super()}getDescription(){return"Paused"}getJSON(){return{...super.getJSON(),type:"Pause"}}async executeAction(){await exports.AutomationInstance.pause()}resetAction(){}}class _e extends g{constructor(n){super();i(this,"description");this.description=n}getDescription(){return"Manual Step: "+this.description}getJSON(){return{...super.getJSON(),type:"ManualStep"}}async executeAction(){return await exports.AutomationInstance.uiUtils.showAlert("Waiting manual step..."),new Promise((n,s)=>{m.on(k.USER_ACCEPT,async()=>(await exports.AutomationInstance.uiUtils.hideAlert(),n(!0))),m.on(k.USER_REJECT,async()=>(await exports.AutomationInstance.uiUtils.hideAlert(),s()))})}resetAction(){}}class et extends g{constructor(){super()}getDescription(){return"Reload page"}getJSON(){return{...super.getJSON(),type:"ReloadPage"}}async executeAction(){await location.reload()}resetAction(){}}const R=t=>t.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}),V=t=>{const e=new Date;return R(new Date(e.setDate(e.getDate()+t)))},ne=t=>{const e=new Date;return R(new Date(e.setMonth(e.getMonth()+t)))},tt=V(1),nt=V(-1),st=V(7),ot=V(-7),it=ne(1),rt=ne(-1),at={formatDate:R,today:R(new Date),tomorrow:tt,nextWeek:st,nextMonth:it,yesterday:nt,lastWeek:ot,lastMonth:rt};class ct{constructor(){i(this,"enabled",!1)}setEnabled(e){this.enabled=e}log(...e){this.enabled&&console.log("[tomation]",...e)}groupCollapsed(...e){this.enabled&&console.groupCollapsed("[tomation]",...e)}groupEnd(){this.enabled&&console.groupEnd()}error(...e){this.enabled&&console.error("[tomation]",...e)}}const l=new ct,se=t=>{l.setEnabled(t)},w=class w{static compileAction(e){const n=w.currentAction;w.currentAction=e,e.compileSteps(),w.currentAction=n}static addAction(e){l.log("Add action: ",e.getDescription()),w.currentAction.addStep(e)}static init(e){w.currentAction=e,w.isCompiling=!0,l.groupCollapsed("Compile: "+e.getDescription()),e.compileSteps(),w.isCompiling=!1,l.log("Compilation finished"),l.groupEnd()}};i(w,"currentAction"),i(w,"isCompiling");let u=w;var k=(t=>(t.ACTION_UPDATE="tomation-action-update",t.SAVE_VALUE="tomation-save-value",t.REGISTER_TEST="tomation-register-test",t.TEST_STARTED="tomation-test-started",t.TEST_PASSED="tomation-test-passed",t.TEST_FAILED="tomation-test-failed",t.TEST_END="tomation-test-end",t.TEST_STOP="tomation-test-stop",t.USER_ACCEPT="tomation-user-accept",t.USER_REJECT="tomation-user-reject",t))(k||{});class lt{constructor(){i(this,"events");this.events=new Map}on(e,n){var s;this.events.has(e)||this.events.set(e,[]),(s=this.events.get(e))==null||s.push(n)}off(e,n){var s;this.events.has(e)&&this.events.set(e,((s=this.events.get(e))==null?void 0:s.filter(o=>o!==n))||[])}dispatch(e,n){var s;this.events.has(e)&&((s=this.events.get(e))==null||s.forEach(o=>{console.log(`Dispatch Event ${e}:`,n),o(n)}))}}const m=new lt;var j=(t=>(t[t.SLOW=2e3]="SLOW",t[t.NORMAL=1e3]="NORMAL",t[t.FAST=200]="FAST",t))(j||{});const S=class S{static async start(e){if(S.running)throw l.error("Not able to run test while other test is running."),new Error("Not able to run test while other test is running.");S.running=!0,exports.AutomationInstance.status="Playing",exports.AutomationInstance.runMode="Normal",l.groupCollapsed("Start Action: ",e.getDescription()),m.dispatch("tomation-test-started",{action:e==null?void 0:e.getJSON()});try{await(e==null?void 0:e.execute()),m.dispatch("tomation-test-passed",{id:e.name})}catch(n){throw m.dispatch("tomation-test-failed",{id:e.name}),exports.AutomationInstance.uiUtils.hideCheckElementContainer(),l.error(`🤖 Error running task ${e.getDescription()}. Reason: ${n.message}`),n}finally{l.groupEnd(),S.running=!1,m.dispatch("tomation-test-end",{action:e==null?void 0:e.getJSON()})}}};i(S,"running",!1);let b=S;const U={},ut=(t,e)=>{console.log(`Registering Test: ${t}...`);const n=new _(t,e);u.init(n),console.log(`Compiled Test: ${t}`),m.dispatch("tomation-register-test",{id:t,action:n.getJSON()}),console.log(`Registered Test: ${t} in TestsMap`),U[t]=()=>{b.start(n)}},oe=t=>{if(U[t])U[t]();else throw console.log("Available Tests:",Object.keys(U)),new Error(`Test with id ${t} not found.`)},ht=(t,e)=>async n=>{const s=new _(t,e);if(s.setParams(n),!b.running&&!u.isCompiling)try{l.log(`Compilation of Task ${t} starts...`),u.init(s),l.log(`Compilation of Task ${t} Finished.`),l.log(`Start running Task ${t}...`),await b.start(s),l.log(`End of Task ${t}: SUCCESS`)}catch(o){l.error("Error running task "+t+". "+o.message)}else l.log(`Adding action ${t} to compilation stack`),u.addAction(s),u.compileAction(s)},dt=t=>{const e=new $e(t);u.addAction(e)},pt=t=>({textIs:e=>{u.addAction(new Re(t,e))},containsText:e=>{u.addAction(new Je(t,e))},valueIs:e=>{u.addAction(new Ve(t,e))},exists:()=>{u.addAction(new Ke(t))},notExists:()=>{u.addAction(new Me(t))}}),mt=t=>({in:e=>{const n=new Fe(e,t);u.addAction(n)}}),gt=t=>({in:e=>{const n=new ee(e,t);u.addAction(n)}}),yt=()=>({in:t=>{const e=new ee(t,"");u.addAction(e)}}),Et=()=>({in:t=>{u.addAction(new Be(t))}}),wt=()=>({in:t=>{u.addAction(new qe(t))}}),ft=()=>({in:t=>{u.addAction(new He(t))}}),At=()=>({in:t=>{u.addAction(new je(t))}}),xt=t=>({in:e=>{u.addAction(new Xe(e,t))}}),Ct=t=>({in:e=>{const n=new We(e,t);u.addAction(n)}}),Tt=t=>({in:e=>{const n=new ze(e,t);u.addAction(n)}}),kt=t=>({in:e=>{const n=new Ge(t,e);u.addAction(n)}}),ie=t=>{u.addAction(new Qe(t))};ie.untilElement=t=>({isRemoved:()=>{u.addAction(new Ze(t))}});const St=()=>{u.addAction(new Ye)},It=t=>{u.addAction(new _e(t))},vt=()=>{u.addAction(new et)};class Nt{constructor(e){i(this,"_document");i(this,"debug");i(this,"_uiUtils");i(this,"speed");i(this,"status");i(this,"runMode");i(this,"currentActionCallback");i(this,"currentAction");this._document=e.document,this.debug=!0,this._uiUtils=new Ue(e),this.speed=1e3,this.status="Stopped",this.runMode="Normal"}get document(){return this._document}get uiUtils(){return this._uiUtils}get isStepByStepMode(){return this.runMode=="Step By Step"}get isStopped(){return this.status=="Stopped"}get isPlaying(){return this.status=="Playing"}get isPaused(){return this.status=="Paused"}pause(){l.log("Pause Test"),this.status="Paused"}continue(){l.log("Continue Test"),this.status="Playing",this.runMode="Normal",this.currentActionCallback&&this.currentAction&&(l.log("Continue: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}next(){l.log("Continue Test to Next Step..."),this.status="Playing",this.runMode="Step By Step",this.currentActionCallback&&this.currentAction&&(l.log("Next: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}stop(){l.log("Stop Test"),this.status="Stopped",this.currentActionCallback&&this.currentAction&&(l.log("Stop: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0),m.dispatch("tomation-test-stop")}retryAction(){l.log("Retry current step"),this.status="Playing",this.currentActionCallback&&this.currentAction&&(this.currentAction.resetTries&&(l.log("Retry: Resetting tries for current action"),this.currentAction.resetTries()),l.log("Retry: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}skipAction(){l.log("Skip current step"),this.status="Playing",this.currentActionCallback&&this.currentAction&&(this.currentAction.status=H.SKIPPED,l.log("Skip: Marked current action as SKIPPED"),g.notifyActionUpdated(this.currentAction),l.log("Skip: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}saveCurrentAction(e,n){l.log("Save current action"),this.currentActionCallback=e,this.currentAction=n}setDebug(e){se(e)}}exports.AutomationInstance=void 0;const B=(t,e)=>(exports.AutomationInstance=new Nt(t),le(exports.AutomationInstance.document),e==null||e.forEach(n=>n()),exports.AutomationInstance);function re(t){const{matches:e,tests:n=[],speed:s="NORMAL",debug:o=!1}=t;if(!(typeof e=="string"?document.location.href.includes(e):!!document.location.href.match(e))){console.log(`[tomation] URL "${document.location.href}" does not match "${e}"`);return}try{console.log("[tomation] Setting up messaging bridge with extension..."),Object.values(k).forEach(a=>{console.log(`[tomation] Setting up listener for event "${a}"`),m.on(a,c=>{console.log(`[tomation] Dispatching event "${a}" to extension`,c),window.postMessage({message:"injectedScript-to-contentScript",sender:"tomation",payload:{cmd:a,params:c}})})}),window.addEventListener("message",a=>{try{console.log("[tomation] Received message from extension:",a.data);const{message:c,sender:y,payload:x}=a.data||{},{cmd:p,params:T}=x||{};if(y!=="web-extension")return;if(c==="contentScript-to-injectedScript"){const I={"run-test-request":()=>oe(T==null?void 0:T.testId),"reload-tests-request":()=>B(window,n||[]),"pause-test-request":()=>exports.AutomationInstance.pause(),"stop-test-request":()=>exports.AutomationInstance.stop(),"continue-test-request":()=>exports.AutomationInstance.continue(),"next-step-request":()=>exports.AutomationInstance.next(),"retry-action-request":()=>exports.AutomationInstance.retryAction(),"skip-action-request":()=>exports.AutomationInstance.skipAction(),"user-accept-request":()=>m.dispatch("tomation-user-accept"),"user-reject-request":()=>m.dispatch("tomation-user-reject")}[p];I?(console.log(`[tomation] Executing command "${p}" from extension`),I()):console.warn(`[tomation] Unknown command "${p}" from extension`);return}}catch(c){console.error("[tomation] Error handling message from extension:",c)}}),B(window,n),exports.AutomationInstance.setDebug(o),exports.AutomationInstance.speed=j[s],console.log("[tomation] Ready ✓")}catch(a){console.error("[tomation] Initialization failed:",a)}}exports.ACTION_STATUS=H;exports.Assert=pt;exports.AutomationEvents=m;exports.ClearValue=yt;exports.Click=dt;exports.DateUtils=at;exports.EVENT_NAMES=k;exports.KEY_MAP=te;exports.ManualTask=It;exports.Pause=St;exports.PressDownKey=wt;exports.PressEnterKey=At;exports.PressEscKey=Et;exports.PressKey=xt;exports.PressTabKey=ft;exports.ReloadPage=vt;exports.RunTest=oe;exports.SaveValue=kt;exports.Select=mt;exports.SelectorBuilder=q;exports.Setup=B;exports.Task=ht;exports.Test=ut;exports.TestSpeed=j;exports.Type=gt;exports.TypePassword=Ct;exports.UIElement=Q;exports.UploadFile=Tt;exports.Wait=ie;exports.and=ve;exports.classIncludes=fe;exports.classIs=we;exports.default=re;exports.elementIndexIs=Se;exports.firstChildTextIs=Ie;exports.innerTextContains=xe;exports.innerTextIs=Ae;exports.is=Ne;exports.isFirstElement=ke;exports.placeholderIs=Te;exports.setAutomationLogs=se;exports.setFilterLogs=Ee;exports.titleIs=Ce;exports.tomation=re;exports.wait=E;
1
+ "use strict";var ce=Object.defineProperty;var le=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var i=(t,e,n)=>(le(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class Q{constructor(e,n,s,o){i(this,"name");i(this,"selector");i(this,"parent");i(this,"postProcess");this.name=e,this.selector=n,this.parent=s||null,this.postProcess=o}getElementName(){let e="";return this.parent&&(e=" in "+this.parent.getElementName()),`${this.name}${e}`}}let M;const ue=t=>{M=t},q=(t,e)=>(s=M,o)=>{s=s||M,console.log("Searching elem from Root = ",s);const a=[];s.querySelectorAll(t).forEach(c=>{c.style.display!=="none"&&a.push(c)});let r;return e?(console.log("Applying filter ",e),console.log(" -- to "+a.length+"elements: ",a),r=a.filter((c,y,x)=>{console.log("Apply filter to item "+y+": ",c);const m=e(c,y,x);return console.log(` -> Item ${y} ${m?"Match":"Discarded"}`),m})[0]):r=a[0],r&&o&&(console.log("Apply post process to = ",r),r=o(r)),console.log("Return elem = ",r),r},$=(t,e,n)=>({as:s=>new Q(s,t,e,n)}),he=(t,e)=>({...$(t,e),postProcess:n=>({...$(t,e,n)})}),Z=t=>({...$(t,null),childOf:e=>({...he(t,e)}),postProcess:e=>({...$(t,null,e)})}),O=t=>({where:e=>Z(q(t,e))}),de=O("div"),pe=O("button"),me=O("input"),ge=O("textarea"),ye=t=>Z(q("#"+t)),Ee=t=>O(t);let Y=!1;const we=t=>{Y=t},f=(...t)=>{Y&&console.log("[UIElement Filter]",...t)},fe=t=>e=>{const n=e.className==t;return f(`classIs('${t}') on`,e,"=>",n),n},Ae=t=>e=>{const n=e.className.split(" ").includes(t);return f(`classIncludes('${t}') on`,e,"=>",n),n},xe=t=>e=>{var s;const n=((s=e.textContent)==null?void 0:s.trim())==t;return f(`innerTextIs('${t}') on`,e,"=>",n),n},Ce=t=>e=>{const n=e.innerText.trim().includes(t);return f(`innerTextContains('${t}') on`,e,"=>",n),n},Te=t=>e=>{const n=e.title==t;return f(`titleIs('${t}') on`,e,"=>",n),n},ke=t=>e=>{const n=e.placeholder===t;return f(`placeholderIs('${t}') on`,e,"=>",n),n},Se=()=>(t,e)=>{const n=e===0;return f("isFirstElement on",t,"index",e,"=>",n),n},Ie=t=>(e,n)=>{const s=n===t;return f(`elementIndexIs(${t}) on`,e,"elemIndex",n,"=>",s),s},ve=t=>e=>{const n=(e==null?void 0:e.firstChild).innerText.trim()===t;return f(`firstChildTextIs('${t}') on`,e,"=>",n),n},Ne=t=>(e,n)=>{const s=t.every((o,a)=>{const r=o(e,n);return f(`and condition[${a}] on`,e,"elemIndex",n,"=>",r),r});return f("and final result on",e,"elemIndex",n,"=>",s),s},be={DIV:de,BUTTON:pe,INPUT:me,TEXTAREA:ge,ELEMENT:Ee,identifiedBy:ye};let P;const Oe=new Uint8Array(16);function De(){if(!P&&(P=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!P))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return P(Oe)}const p=[];for(let t=0;t<256;++t)p.push((t+256).toString(16).slice(1));function Pe(t,e=0){return(p[t[e+0]]+p[t[e+1]]+p[t[e+2]]+p[t[e+3]]+"-"+p[t[e+4]]+p[t[e+5]]+"-"+p[t[e+6]]+p[t[e+7]]+"-"+p[t[e+8]]+p[t[e+9]]+"-"+p[t[e+10]]+p[t[e+11]]+p[t[e+12]]+p[t[e+13]]+p[t[e+14]]+p[t[e+15]]).toLowerCase()}const Le=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),X={randomUUID:Le};function _(t,e,n){if(X.randomUUID&&!e&&!t)return X.randomUUID();t=t||{};const s=t.random||(t.rng||De)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=s[o];return e}return Pe(s)}const E=(t=2e3)=>new Promise(e=>{setTimeout(()=>{e(null)},t)}),A=(t,e)=>{Object.entries(e).map(([s,o])=>({key:s,value:o})).forEach(s=>{const{key:o,value:a}=s;t.style[o]=a})};class Ue{constructor(e){i(this,"window");i(this,"document");i(this,"devToolsMessageContainer");i(this,"devToolsCheckElementContainer");i(this,"darkLayerLeft");i(this,"darkLayerTop");i(this,"darkLayerRight");i(this,"darkLayerBottom");i(this,"currentCheckElem");i(this,"contextViewerContainer");i(this,"devToolsAlertContainer");this.document=e.document,this.window=e,this.devToolsMessageContainer=this.createElement("DIV",{id:"dev-tools-message-container",styles:{width:"500px",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"white",position:"fixed",bottom:"10px",right:"10px",fontFamily:"monospace",zIndex:"9999"},parent:this.document.body}),this.devToolsAlertContainer=this.createElement("DIV",{id:"dev-tools-alert-container",styles:{width:"100%",height:"30px",backgroundColor:"#b00",color:"white",position:"absolute ",top:0,fontFamily:"monospace",zIndex:"9999",display:"none",alignItems:"center",justifyContent:"center",padding:"5px"},parent:this.document.body}),this.devToolsCheckElementContainer=this.createElement("DIV",{id:"dev-tools-check-element-container",styles:{width:"100%",height:this.document.body.clientHeight+"px",position:"absolute",top:"0px",left:"0px",zIndex:"9990",display:"none",opacity:"0",transition:"opacity .2s"},parent:this.document.body});const n={zIndex:"9991",backgroundColor:"rgba(0,0,0,0.3)",position:"absolute"};this.darkLayerLeft=this.createElement("DIV",{id:"dark-layer-left",styles:n,parent:this.devToolsCheckElementContainer}),this.darkLayerTop=this.createElement("DIV",{id:"dark-layer-top",styles:n,parent:this.devToolsCheckElementContainer}),this.darkLayerRight=this.createElement("DIV",{id:"dark-layer-right",styles:n,parent:this.devToolsCheckElementContainer}),this.darkLayerBottom=this.createElement("DIV",{id:"dark-layer-bottom",styles:n,parent:this.devToolsCheckElementContainer}),this.currentCheckElem=this.createElement("DIV",{id:"current-check-elem",parent:this.devToolsCheckElementContainer}),this.contextViewerContainer=this.createElement("DIV",{id:"context-viewer-container",styles:{width:"100%",height:this.document.body.clientHeight+"px",position:"absolute",top:"0px",left:"0px",zIndex:"10000",display:"none"},parent:this.document.body})}createElement(e,n){const s=this.document.createElement(e);return n&&(n.id&&(s.id=n==null?void 0:n.id),n.styles&&A(s,n.styles),n.parent&&n.parent.appendChild(s)),s}async logAction(e){const n=exports.AutomationInstance.document.createElement("DIV");n.innerText=e,A(n,{padding:"3px 10px",opacity:"1",transition:"opacity 1s"}),this.devToolsMessageContainer.appendChild(n),await E(4e3),n.style.opacity="0",await E(4e3),this.devToolsMessageContainer.removeChild(n),await E(1e3)}async checkElement(e,n){if(!e)return;const s=e.getBoundingClientRect(),o=this.document.body.getBoundingClientRect();this.darkLayerLeft.style.left="0px",this.darkLayerLeft.style.top=s.top+"px",this.darkLayerLeft.style.width=this.window.scrollX+s.left+"px",this.darkLayerLeft.style.height=s.height+"px",this.darkLayerTop.style.left=this.window.scrollX+"px",this.darkLayerTop.style.top="0px",this.darkLayerTop.style.width="100%",this.darkLayerTop.style.height=s.top+"px",this.darkLayerRight.style.left=this.window.scrollX+s.left+s.width+"px",this.darkLayerRight.style.top=s.top+"px",this.darkLayerRight.style.width=o.width-(s.left+s.width)+"px",this.darkLayerRight.style.height=s.height+"px",this.darkLayerBottom.style.left=this.window.scrollX+"px",this.darkLayerBottom.style.top=s.top+s.height+"px",this.darkLayerBottom.style.width="100%",this.darkLayerBottom.style.height=o.height-(s.top+s.height)+"px",this.currentCheckElem.id=`dev-tools-current-check-elem-${n}`,this.currentCheckElem.style.top=s.top+"px",this.currentCheckElem.style.left=this.window.scrollX+s.left+"px",this.currentCheckElem.style.height=s.height+"px",this.currentCheckElem.style.width=s.width+"px",this.currentCheckElem.style.boxShadow="0px 0px 5px 2px lightgreen",this.currentCheckElem.style.position="absolute",this.currentCheckElem.style.zIndex="9992",this.devToolsCheckElementContainer.style.display="block",this.devToolsCheckElementContainer.style.opacity="1",await E(200)}async showAlert(e){const n=exports.AutomationInstance.document.createElement("DIV"),s=exports.AutomationInstance.document.body;n.innerText=e,A(s,{paddingTop:"30px"}),A(this.devToolsAlertContainer,{display:"flex"}),this.devToolsAlertContainer.appendChild(n)}async hideAlert(){A(this.devToolsAlertContainer,{display:"none"});const e=exports.AutomationInstance.document.body;A(e,{paddingTop:"0"}),this.devToolsAlertContainer.firstChild&&this.devToolsAlertContainer.removeChild(this.devToolsAlertContainer.firstChild)}async hideCheckElementContainer(){this.devToolsCheckElementContainer.style.opacity="0",await E(200),this.devToolsCheckElementContainer.style.display="none"}displayContext(e){A(this.contextViewerContainer,{display:"flex","background-color":"white",position:"absolute",top:"0px",left:"0px","z-index":"9999"});const n=this.document.createElement("DIV");n.id="context-viewer-before",A(n,{flex:"50%",width:"100%",height:"auto",border:"2px solid orange"});const s=this.document.createElement("DIV");s.id="context-viewer-after",A(s,{flex:"50%",width:"100%",height:"auto",border:"2px solid green"});const o=this.document.createElement("DIV");o.innerHTML=e.beforeHTML,z(o,e.beforeInputValues);const a=this.document.createElement("DIV");a.innerHTML=e.afterHTML,z(a,e.afterInputValues),this.contextViewerContainer.appendChild(n),n.appendChild(o),setTimeout(()=>{this.contextViewerContainer.removeChild(n),this.contextViewerContainer.appendChild(s),s.appendChild(a),setTimeout(()=>{this.contextViewerContainer.removeChild(s),A(this.contextViewerContainer,{display:"none"})},2e3)},2e3)}}const z=(t,e)=>{t.querySelectorAll("input").forEach(n=>{const s=n.getAttribute("input-id")||"";n.value=e[s]})},W=null,L=async(t,e,n,s=1e3,o=0,a=10,r=!1)=>{if(console.log("Automation Status: ",exports.AutomationInstance.status),exports.AutomationInstance.isPaused)return new Promise((c,y)=>{exports.AutomationInstance.saveCurrentAction(async x=>{if(x.status=="skipped")return c(null);try{const m=await L(x,e,n,s,o,a,r);c(m)}catch(m){y(m)}},t)});if(exports.AutomationInstance.isStopped)throw new Error("Test stopped manually");if(console.groupCollapsed(`tries ${o}/${a}`),t&&(t.updateTries(o),await g.notifyActionUpdated(t)),o===a)throw console.groupEnd(),r?new Error(`UI Element ${e.getElementName()||"UNKNOWN"} still present after 10 tries`):new Error(`UI Element ${e.getElementName()||"UNKNOWN"} not found after 10 tries`);{const c=e.selector(n,e.postProcess);return console.groupEnd(),c?r?(await E(s),await L(t,e,n,s,++o,a,r)):(console.log("Element found = ",c),c):r?(console.log("Element removed."),W):(await E(s),await L(t,e,n,s,++o,a,r))}},J=async(t,e,n=1e3,s=10,o=!1)=>{const a=e==null?void 0:e.getElementName();console.group("Looking for Element: "+a);let r=null;if(e.parent)try{console.groupCollapsed("Look for Parent ",e.parent.getElementName()),r=await J(t,e.parent,n,s,o),console.groupEnd()}catch(c){if(console.groupEnd(),o&&c.message.includes("not found"))return console.log("Parent not found, so element was removed"),console.groupEnd(),W;throw console.groupEnd(),c}try{console.log("Using parent element: ",r);const c=await L(t,e,r,n,0,s,o);return console.groupEnd(),c}catch(c){if(o&&c.message.includes("not found"))return console.log("Parent not found, so element was removed"),console.groupEnd(),W;throw console.groupEnd(),c}};var H=(t=>(t.WAITING="waiting",t.RUNNING="running",t.STOPPED="stopped",t.PAUSED="paused",t.SUCCESS="success",t.ERROR="error",t.SKIPPED="skipped",t))(H||{});class g{constructor(){i(this,"status");i(this,"error");i(this,"id");i(this,"context");this.status="waiting",this.error="",this.id=_(),this.context={beforeHTML:"",beforeInputValues:{},afterInputValues:{},afterHTML:"",url:"",startTimestamp:"",endTimestamp:""}}getJSON(){return{id:this.id,description:this.getDescription(),context:this.context,status:this.status,error:this.error}}reset(){this.status="waiting",this.error="",this.resetAction()}getInputValuesFromPage(){const e={};return exports.AutomationInstance.document.querySelectorAll("input").forEach((s,o)=>{const a=`value-id-${o}`;s.setAttribute("input-id",a),e[a]=s.value}),e}async execute(){try{this.status="running",this.context.beforeInputValues=this.getInputValuesFromPage(),this.context.beforeHTML=exports.AutomationInstance.document.body.innerHTML,await g.notifyActionUpdated(this),console.log("Action: ",this.getDescription()),await this.executeAction(),this.status="success",this.error="",exports.AutomationInstance.isStepByStepMode&&exports.AutomationInstance.pause()}catch(e){if(this.status="error",this.error=e.message,e.message=="Test stopped manually")throw Error("Error in Action "+this.getDescription()+". Message: "+e.message);this.status="paused",exports.AutomationInstance.pause()}finally{this.context.afterInputValues=this.getInputValuesFromPage(),this.context.afterHTML=exports.AutomationInstance.document.body.innerHTML,await g.notifyActionUpdated(this)}}static async notifyActionUpdated(e){h.dispatch(k.ACTION_UPDATE,{action:e.getJSON()})}}class ee extends g{constructor(n,s){super();i(this,"name");i(this,"stepsFn");i(this,"steps");i(this,"params");i(this,"index");this.name=n,this.stepsFn=s,this.steps=[],this.index=0}getDescription(){return this.name}compileSteps(){super.reset(),this.stepsFn(this.params)}stepsToJSON(){return this.steps.reduce((n,s)=>(n.push(s.getJSON()),n),[])}getJSON(){return{...super.getJSON(),type:"Action",params:this.params,steps:this.stepsToJSON()}}resetAction(){this.steps.length=0,this.index=0}async continue(){if(exports.AutomationInstance.isPaused)return new Promise((n,s)=>{exports.AutomationInstance.saveCurrentAction(async o=>{if(o.status=="skipped")return n();try{await o.continue(),n()}catch(a){s(a)}},this)});if(exports.AutomationInstance.isStopped)throw new Error("Test stopped manually");if(this.index<this.steps.length){const n=this.steps[this.index];try{if(await E(exports.AutomationInstance.speed),await n.execute(),!exports.AutomationInstance.isPaused)this.index++,await this.continue();else return new Promise((s,o)=>{exports.AutomationInstance.saveCurrentAction(async a=>{if(a.status=="skipped")return this.index++,await g.notifyActionUpdated(n),await this.continue(),s();try{await a.continue(),s()}catch(r){o(r)}},n)})}catch(s){throw s}}}async executeAction(){this.index=0,await this.continue()}setParams(n){this.params=n}addStep(n){this.steps.push(n)}}class d extends g{constructor(n){super();i(this,"uiElement");i(this,"element");i(this,"tries");this.uiElement=n,this.element=null,this.tries=0}getElementName(){var n;return(n=this.uiElement)==null?void 0:n.getElementName()}updateTries(n){this.tries=n}resetTries(){this.tries=0}getJSON(){return{id:this.id,element:this.getElementName(),description:this.getDescription(),status:this.status,error:this.error,context:this.context,tries:this.tries}}static waitForElement(n,s,o=1e3,a=10,r=!1){const c=s.getElementName();return new Promise(async(y,x)=>{var I;const m=async(C,D=1e3,v=0,N=!1)=>{if(console.groupCollapsed(`tries ${v}/${a}`),n.updateTries(v),await g.notifyActionUpdated(n),v===a)throw console.groupEnd(),N?new Error(`UI Element ${c||"UNKNOWN"} still present after 10 tries`):new Error(`UI Element ${c||"UNKNOWN"} not found after 10 tries`);{const F=s.selector(C,s.postProcess);return console.groupEnd(),F?N?(await E(D),await m(C,D,++v,N)):(console.log("Element found = ",F),F):N?(console.log("Element removed."),null):(await E(D),await m(C,D,++v,N))}};console.group("[Action On Element] Looking for Element: "+c);let T=null,V=!0;if(s.parent){console.groupCollapsed("Look for Parent ",s.parent.getElementName());try{T=await d.waitForElement(n,s.parent,o,a,r)}catch{V=!1}finally{console.groupEnd()}}if(V){console.log("using parent element: ",T);try{const C=await m(T,o,0,r);console.groupEnd(),y(C)}catch(C){console.groupEnd(),x(new Error(C.message))}}else console.groupEnd(),x(new Error(`Parent ${(I=s.parent)==null?void 0:I.getElementName()} of UI Element ${s.name||"UNKNOWN"} not found`))})}async executeAction(){var n;try{this.element=await J(this,this.uiElement),(n=this.element)==null||n.setAttribute("test-id",this.getElementName()),await exports.AutomationInstance.uiUtils.checkElement(this.element,this.getElementName()),this.executeActionOnElement(),await exports.AutomationInstance.uiUtils.hideCheckElementContainer()}catch(s){throw Error(s.message)}}resetAction(){this.element=null,this.resetTries()}}class $e extends d{constructor(e){super(e)}executeActionOnElement(){var e;return(e=this.element)==null?void 0:e.click()}getDescription(){return"Click in "+this.getElementName()}getJSON(){return{...super.getJSON(),type:"Click"}}}class Re extends d{constructor(n,s){super(n);i(this,"text");this.text=s}executeActionOnElement(){var s;if(!(((s=this.element)==null?void 0:s.innerText)===this.text))throw new Error(`Text in element ${this.getElementName()} is not '${this.text}'`)}getDescription(){return`Assert that text in ${this.getElementName()} is '${this.text}'`}getJSON(){return{...super.getJSON(),type:"AssertTextIsAction",value:this.text}}}class Je extends d{constructor(n,s){super(n);i(this,"text");this.text=s}executeActionOnElement(){var s;if(!((s=this.element)==null?void 0:s.innerText.includes(this.text)))throw new Error(`Text in element ${this.getElementName()} doesn't contain '${this.text}'`)}getDescription(){return`Assert that ${this.getElementName()} contains '${this.text}'`}getJSON(){return{...super.getJSON(),type:"AssertContainsText",value:this.text}}}class Ke extends d{constructor(n,s){super(n);i(this,"value");this.value=s}executeActionOnElement(){if(!(this.element.value===this.value))throw new Error(`Value in element ${this.getElementName()} is not '${this.value}'`)}getDescription(){return`Assert that value in ${this.getElementName()} is '${this.value}'`}getJSON(){return{...super.getJSON(),type:"AssertValueIsAction",value:this.value}}}class Ve extends d{constructor(e){super(e)}executeActionOnElement(){if(!!!this.element)throw new Error(`Element ${this.getElementName()} doesn't exist`)}getDescription(){return`Assert that ${this.getElementName()} exists`}getJSON(){return{...super.getJSON(),type:"AssertExistsAction"}}}class Fe extends d{constructor(e){super(e)}async executeAction(){var e;try{this.element=await J(this,this.uiElement,1e3,5,!0),(e=this.element)==null||e.setAttribute("test-id",this.getElementName()),await exports.AutomationInstance.uiUtils.checkElement(this.element,this.getElementName()),this.executeActionOnElement(),await exports.AutomationInstance.uiUtils.hideCheckElementContainer()}catch(n){throw Error(n.message)}}executeActionOnElement(){if(!!this.element)throw new Error(`Element ${this.getElementName()} was not expected to exist`)}getDescription(){return`Assert that ${this.getElementName()} doesn't exist`}getJSON(){return{...super.getJSON(),type:"AssertNotExistsAction"}}}class Me extends d{constructor(n,s){super(n);i(this,"value");this.value=s}executeActionOnElement(){var s,o,a,r;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((a=this.element)==null?void 0:a.tagName)!=="TEXTAREA"&&(n=(r=this.element)==null?void 0:r.querySelectorAll("input")[0],!n))throw new Error("Input element not found. Not able to type value in element "+this.getElementName());n.value=this.value,n.dispatchEvent(new Event("change"))}getDescription(){return`Select value '${this.value}' in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"Select",value:this.value}}}class te extends d{constructor(n,s){super(n);i(this,"value");this.value=s}executeActionOnElement(){var s,o,a,r;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((a=this.element)==null?void 0:a.tagName)!=="TEXTAREA"&&(n=(r=this.element)==null?void 0:r.querySelectorAll("input")[0],!n))throw new Error("Input element not found. Not able to type value in element "+this.getElementName());n.value=this.value,n.dispatchEvent(new Event("change")),n.dispatchEvent(new Event("keyup",{bubbles:!0})),n.dispatchEvent(new Event("input",{bubbles:!0}))}getDescription(){return`Type value '${this.value}' in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"Type",value:this.value}}}class We extends d{constructor(n,s){super(n);i(this,"value");this.value=s}executeActionOnElement(){var s,o,a,r;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((a=this.element)==null?void 0:a.tagName)!=="TEXTAREA"&&(n=(r=this.element)==null?void 0:r.querySelectorAll("input")[0],!n))throw new Error("Input element not found. Not able to type value in element "+this.getElementName());n.value=this.value,n.dispatchEvent(new Event("change")),n.dispatchEvent(new Event("keyup",{bubbles:!0})),n.dispatchEvent(new Event("input",{bubbles:!0}))}getDescription(){return`Type a password in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"TypePassword",value:this.value}}}class Be extends d{constructor(e){super(e)}executeActionOnElement(){var e;(e=this.element)==null||e.dispatchEvent(new KeyboardEvent("keydown",{altKey:!1,code:"Escape",ctrlKey:!1,isComposing:!1,key:"Escape",location:0,metaKey:!1,repeat:!1,shiftKey:!1,which:27,charCode:0,keyCode:27}))}getDescription(){return`Press Esc key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressEscKey"}}}class qe extends d{constructor(e){super(e)}executeActionOnElement(){var e;(e=this.element)==null||e.dispatchEvent(new KeyboardEvent("keyup",{altKey:!1,code:"Down",ctrlKey:!1,isComposing:!1,key:"Down",location:0,metaKey:!1,repeat:!1,shiftKey:!1,which:40,charCode:0,keyCode:40}))}getDescription(){return`Press Down key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressDownKey"}}}class He extends d{constructor(e){super(e)}executeActionOnElement(){var e;(e=this.element)==null||e.dispatchEvent(new KeyboardEvent("keydown",{altKey:!1,code:"Tab",ctrlKey:!1,isComposing:!1,key:"Tab",location:0,metaKey:!1,repeat:!1,shiftKey:!1,which:9,charCode:0,keyCode:9}))}getDescription(){return`Press Tab key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressTabKey"}}}class je extends d{constructor(e){super(e)}executeActionOnElement(){var e;(e=this.element)==null||e.dispatchEvent(new KeyboardEvent("keydown",{altKey:!1,code:"Enter",ctrlKey:!1,isComposing:!1,key:"Enter",location:0,metaKey:!1,repeat:!1,shiftKey:!1,which:13,charCode:0,keyCode:13}))}getDescription(){return`Press Enter key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressEnterKey"}}}var ne=(t=>(t.ESCAPE="Escape",t.ENTER="Enter",t.TAB="Tab",t.ARROW_DOWN="ArrowDown",t.ARROW_UP="ArrowUp",t.ARROW_LEFT="ArrowLeft",t.ARROW_RIGHT="ArrowRight",t.BACKSPACE="Backspace",t.DELETE="Delete",t.SHIFT="Shift",t.CONTROL="Control",t.ALT="Alt",t.META="Meta",t))(ne||{});const G={Escape:27,Enter:13,Tab:9,ArrowDown:40,ArrowUp:38,ArrowLeft:37,ArrowRight:39,Backspace:8,Delete:46,Shift:16,Control:17,Alt:18,Meta:91};class Xe extends d{constructor(n,s){super(n);i(this,"key");this.key=s}executeActionOnElement(){var n;(n=this.element)==null||n.dispatchEvent(new KeyboardEvent("keydown",{key:this.key,code:this.key,keyCode:G[this.key],charCode:0,which:G[this.key],altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1,isComposing:!1,location:0,repeat:!1}))}getDescription(){return`Press ${this.key} key in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"PressKey",key:this.key}}}class ze extends d{constructor(n,s){super(n);i(this,"file");this.file=s}executeActionOnElement(){const n=this.element,s=new DataTransfer;s.items.add(this.file);const o=s.files;n.files=o,n.dispatchEvent(new Event("change"));function a(c){var y;return c!=null&&c.parentElement?((y=c.parentElement)==null?void 0:y.tagName.toLowerCase())==="form"?c.parentElement:a(c.parentElement):null}const r=a(n);r&&r.dispatchEvent(new Event("change"))}getDescription(){return`Upload file in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"UploadFile"}}}class Ge extends d{constructor(n,s){super(n);i(this,"memorySlotName");this.memorySlotName=s}executeActionOnElement(){var s,o,a,r;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((a=this.element)==null?void 0:a.tagName)!=="TEXTAREA"&&(n=(r=this.element)==null?void 0:r.querySelectorAll("input")[0],!n))throw new Error("Input element not found. Not able to save value from element "+this.getElementName());h.dispatch(k.SAVE_VALUE,{memorySlotName:this.memorySlotName,value:n.value})}getDescription(){return`Save value of ${this.getElementName()} in ${this.memorySlotName}`}getJSON(){return{...super.getJSON(),type:"SaveValue",memorySlotName:this.memorySlotName}}}class Qe extends g{constructor(n){super();i(this,"miliseconds");this.miliseconds=n}getDescription(){return"Wait "+this.miliseconds+" miliseconds"}getJSON(){return{...super.getJSON(),type:"Wait"}}async executeAction(){await E(this.miliseconds)}resetAction(){}}class Ze extends g{constructor(n){super();i(this,"uiElement");i(this,"tries");this.uiElement=n,this.tries=0}updateTries(n){this.tries=n}resetAction(){this.tries=0}getElementName(){var n;return(n=this.uiElement)==null?void 0:n.getElementName()}async executeAction(){await J(this,this.uiElement,1e3,10,!0)}getDescription(){return"Wait until "+this.getElementName()+" is removed"}getJSON(){return{...super.getJSON(),type:"WaitUntilElementRemoved"}}}class Ye extends g{constructor(){super()}getDescription(){return"Paused"}getJSON(){return{...super.getJSON(),type:"Pause"}}async executeAction(){await exports.AutomationInstance.pause()}resetAction(){}}class _e extends g{constructor(n){super();i(this,"description");this.description=n}getDescription(){return"Manual Step: "+this.description}getJSON(){return{...super.getJSON(),type:"ManualStep"}}async executeAction(){return await exports.AutomationInstance.uiUtils.showAlert("Waiting manual step..."),new Promise((n,s)=>{h.on(k.USER_ACCEPT,async()=>(await exports.AutomationInstance.uiUtils.hideAlert(),n(!0))),h.on(k.USER_REJECT,async()=>(await exports.AutomationInstance.uiUtils.hideAlert(),s()))})}resetAction(){}}class et extends g{constructor(){super()}getDescription(){return"Reload page"}getJSON(){return{...super.getJSON(),type:"ReloadPage"}}async executeAction(){await location.reload()}resetAction(){}}const R=t=>t.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}),K=t=>{const e=new Date;return R(new Date(e.setDate(e.getDate()+t)))},se=t=>{const e=new Date;return R(new Date(e.setMonth(e.getMonth()+t)))},tt=K(1),nt=K(-1),st=K(7),ot=K(-7),it=se(1),rt=se(-1),at={formatDate:R,today:R(new Date),tomorrow:tt,nextWeek:st,nextMonth:it,yesterday:nt,lastWeek:ot,lastMonth:rt};class ct{constructor(){i(this,"enabled",!1)}setEnabled(e){this.enabled=e}log(...e){this.enabled&&console.log("[tomation]",...e)}groupCollapsed(...e){this.enabled&&console.groupCollapsed("[tomation]",...e)}groupEnd(){this.enabled&&console.groupEnd()}error(...e){this.enabled&&console.error("[tomation]",...e)}}const l=new ct,oe=t=>{l.setEnabled(t)},w=class w{static compileAction(e){const n=w.currentAction;w.currentAction=e,e.compileSteps(),w.currentAction=n}static addAction(e){l.log("Add action: ",e.getDescription()),w.currentAction.addStep(e)}static init(e){w.currentAction=e,w.isCompiling=!0,l.groupCollapsed("Compile: "+e.getDescription()),e.compileSteps(),w.isCompiling=!1,l.log("Compilation finished"),l.groupEnd()}};i(w,"currentAction"),i(w,"isCompiling");let u=w;var k=(t=>(t.ACTION_UPDATE="tomation-action-update",t.SAVE_VALUE="tomation-save-value",t.REGISTER_TEST="tomation-register-test",t.TEST_STARTED="tomation-test-started",t.TEST_PASSED="tomation-test-passed",t.TEST_FAILED="tomation-test-failed",t.TEST_END="tomation-test-end",t.TEST_STOP="tomation-test-stop",t.TEST_PAUSE="tomation-test-pause",t.TEST_PLAY="tomation-test-play",t.USER_ACCEPT="tomation-user-accept",t.USER_REJECT="tomation-user-reject",t.SESSION_INIT="tomation-session-init",t))(k||{});class lt{constructor(){i(this,"events");this.events=new Map}on(e,n){var s;this.events.has(e)||this.events.set(e,[]),(s=this.events.get(e))==null||s.push(n)}off(e,n){var s;this.events.has(e)&&this.events.set(e,((s=this.events.get(e))==null?void 0:s.filter(o=>o!==n))||[])}dispatch(e,n){var s;this.events.has(e)&&((s=this.events.get(e))==null||s.forEach(o=>{console.log(`Dispatch Event ${e}:`,n),o(n)}))}}const h=new lt;var j=(t=>(t[t.SLOW=2e3]="SLOW",t[t.NORMAL=1e3]="NORMAL",t[t.FAST=200]="FAST",t))(j||{});const S=class S{static async start(e){if(S.running)throw l.error("Not able to run test while other test is running."),new Error("Not able to run test while other test is running.");S.running=!0,exports.AutomationInstance.status="Playing",exports.AutomationInstance.runMode="Normal",l.groupCollapsed("Start Action: ",e.getDescription()),h.dispatch("tomation-test-started",{action:e==null?void 0:e.getJSON()});try{await(e==null?void 0:e.execute()),h.dispatch("tomation-test-passed",{id:e.name})}catch(n){throw h.dispatch("tomation-test-failed",{id:e.name}),exports.AutomationInstance.uiUtils.hideCheckElementContainer(),l.error(`🤖 Error running task ${e.getDescription()}. Reason: ${n.message}`),n}finally{l.groupEnd(),S.running=!1,h.dispatch("tomation-test-end",{action:e==null?void 0:e.getJSON()})}}};i(S,"running",!1);let b=S;const U={},ut=(t,e)=>{console.log(`Registering Test: ${t}...`);const n=new ee(t,e);u.init(n),console.log(`Compiled Test: ${t}`),h.dispatch("tomation-register-test",{id:t,action:n.getJSON()}),console.log(`Registered Test: ${t} in TestsMap`),U[t]=()=>{b.start(n)}},ie=t=>{if(U[t])U[t]();else throw console.log("Available Tests:",Object.keys(U)),new Error(`Test with id ${t} not found.`)},ht=(t,e)=>async n=>{const s=new ee(t,e);if(s.setParams(n),!b.running&&!u.isCompiling)try{l.log(`Compilation of Task ${t} starts...`),u.init(s),l.log(`Compilation of Task ${t} Finished.`),l.log(`Start running Task ${t}...`),await b.start(s),l.log(`End of Task ${t}: SUCCESS`)}catch(o){l.error("Error running task "+t+". "+o.message)}else l.log(`Adding action ${t} to compilation stack`),u.addAction(s),u.compileAction(s)},dt=t=>{const e=new $e(t);u.addAction(e)},pt=t=>({textIs:e=>{u.addAction(new Re(t,e))},containsText:e=>{u.addAction(new Je(t,e))},valueIs:e=>{u.addAction(new Ke(t,e))},exists:()=>{u.addAction(new Ve(t))},notExists:()=>{u.addAction(new Fe(t))}}),mt=t=>({in:e=>{const n=new Me(e,t);u.addAction(n)}}),gt=t=>({in:e=>{const n=new te(e,t);u.addAction(n)}}),yt=()=>({in:t=>{const e=new te(t,"");u.addAction(e)}}),Et=()=>({in:t=>{u.addAction(new Be(t))}}),wt=()=>({in:t=>{u.addAction(new qe(t))}}),ft=()=>({in:t=>{u.addAction(new He(t))}}),At=()=>({in:t=>{u.addAction(new je(t))}}),xt=t=>({in:e=>{u.addAction(new Xe(e,t))}}),Ct=t=>({in:e=>{const n=new We(e,t);u.addAction(n)}}),Tt=t=>({in:e=>{const n=new ze(e,t);u.addAction(n)}}),kt=t=>({in:e=>{const n=new Ge(t,e);u.addAction(n)}}),re=t=>{u.addAction(new Qe(t))};re.untilElement=t=>({isRemoved:()=>{u.addAction(new Ze(t))}});const St=()=>{u.addAction(new Ye)},It=t=>{u.addAction(new _e(t))},vt=()=>{u.addAction(new et)};class Nt{constructor(e){i(this,"_document");i(this,"debug");i(this,"_uiUtils");i(this,"speed");i(this,"status");i(this,"runMode");i(this,"currentActionCallback");i(this,"currentAction");this._document=e.document,this.debug=!0,this._uiUtils=new Ue(e),this.speed=1e3,this.status="Stopped",this.runMode="Normal"}get document(){return this._document}get uiUtils(){return this._uiUtils}get isStepByStepMode(){return this.runMode=="Step By Step"}get isStopped(){return this.status=="Stopped"}get isPlaying(){return this.status=="Playing"}get isPaused(){return this.status=="Paused"}pause(){l.log("Pause Test"),this.status="Paused",h.dispatch("tomation-test-pause")}continue(){l.log("Continue Test"),this.status="Playing",this.runMode="Normal",h.dispatch("tomation-test-play"),this.currentActionCallback&&this.currentAction&&(l.log("Continue: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}next(){l.log("Continue Test to Next Step..."),this.status="Playing",this.runMode="Step By Step",h.dispatch("tomation-test-play"),this.currentActionCallback&&this.currentAction&&(l.log("Next: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}stop(){l.log("Stop Test"),this.status="Stopped",this.currentActionCallback&&this.currentAction&&(l.log("Stop: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0),h.dispatch("tomation-test-stop")}retryAction(){l.log("Retry current step"),this.status="Playing",h.dispatch("tomation-test-play"),this.currentActionCallback&&this.currentAction&&(this.currentAction.resetTries&&(l.log("Retry: Resetting tries for current action"),this.currentAction.resetTries()),l.log("Retry: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}skipAction(){l.log("Skip current step"),this.status="Playing",this.currentActionCallback&&this.currentAction&&(this.currentAction.status=H.SKIPPED,l.log("Skip: Marked current action as SKIPPED"),g.notifyActionUpdated(this.currentAction),l.log("Skip: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}saveCurrentAction(e,n){l.log("Save current action"),this.currentActionCallback=e,this.currentAction=n}setDebug(e){oe(e)}}exports.AutomationInstance=void 0;const B=(t,e)=>(exports.AutomationInstance=new Nt(t),ue(exports.AutomationInstance.document),e==null||e.forEach(n=>n()),exports.AutomationInstance);function ae(t){const{matches:e,tests:n=[],speed:s="NORMAL",debug:o=!1}=t;if(!(typeof e=="string"?document.location.href.includes(e):!!document.location.href.match(e))){console.log(`[tomation] URL "${document.location.href}" does not match "${e}"`);return}try{console.log("[tomation] Setting up messaging bridge with extension..."),Object.values(k).forEach(r=>{console.log(`[tomation] Setting up listener for event "${r}"`),h.on(r,c=>{console.log(`[tomation] Dispatching event "${r}" to extension`,c),window.postMessage({message:"injectedScript-to-contentScript",sender:"tomation",payload:{cmd:r,params:c}})})}),window.addEventListener("message",r=>{try{console.log("[tomation] Received message from extension:",r.data);const{message:c,sender:y,payload:x}=r.data||{},{cmd:m,params:T}=x||{};if(y!=="web-extension")return;if(c==="contentScript-to-injectedScript"){const I={"run-test-request":()=>ie(T==null?void 0:T.testId),"reload-tests-request":()=>B(window,n||[]),"pause-test-request":()=>exports.AutomationInstance.pause(),"stop-test-request":()=>exports.AutomationInstance.stop(),"continue-test-request":()=>exports.AutomationInstance.continue(),"next-step-request":()=>exports.AutomationInstance.next(),"retry-action-request":()=>exports.AutomationInstance.retryAction(),"skip-action-request":()=>exports.AutomationInstance.skipAction(),"user-accept-request":()=>h.dispatch("tomation-user-accept"),"user-reject-request":()=>h.dispatch("tomation-user-reject")}[m];I?(console.log(`[tomation] Executing command "${m}" from extension`),I()):console.warn(`[tomation] Unknown command "${m}" from extension`);return}}catch(c){console.error("[tomation] Error handling message from extension:",c)}}),B(window,n),exports.AutomationInstance.setDebug(o),exports.AutomationInstance.speed=j[s],window.postMessage({message:"injectedScript-to-contentScript",sender:"tomation",payload:{cmd:"tomation-session-init",params:{speed:exports.AutomationInstance.speed,sessionId:_()}}}),console.log("[tomation] Ready ✓")}catch(r){console.error("[tomation] Initialization failed:",r)}}exports.ACTION_STATUS=H;exports.Assert=pt;exports.AutomationEvents=h;exports.ClearValue=yt;exports.Click=dt;exports.DateUtils=at;exports.EVENT_NAMES=k;exports.KEY_MAP=ne;exports.ManualTask=It;exports.Pause=St;exports.PressDownKey=wt;exports.PressEnterKey=At;exports.PressEscKey=Et;exports.PressKey=xt;exports.PressTabKey=ft;exports.ReloadPage=vt;exports.RunTest=ie;exports.SaveValue=kt;exports.Select=mt;exports.SelectorBuilder=q;exports.Setup=B;exports.Task=ht;exports.Test=ut;exports.TestSpeed=j;exports.Type=gt;exports.TypePassword=Ct;exports.UIElement=Q;exports.UploadFile=Tt;exports.Wait=re;exports.and=Ne;exports.classIncludes=Ae;exports.classIs=fe;exports.default=ae;exports.elementIndexIs=Ie;exports.firstChildTextIs=ve;exports.innerTextContains=Ce;exports.innerTextIs=xe;exports.is=be;exports.isFirstElement=Se;exports.placeholderIs=ke;exports.setAutomationLogs=oe;exports.setFilterLogs=we;exports.titleIs=Te;exports.tomation=ae;exports.wait=E;
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
- var ne = Object.defineProperty;
2
- var se = (t, e, n) => e in t ? ne(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var i = (t, e, n) => (se(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- class oe {
1
+ var se = Object.defineProperty;
2
+ var oe = (t, e, n) => e in t ? se(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var i = (t, e, n) => (oe(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ class ie {
5
5
  constructor(e, n, s, o) {
6
6
  i(this, "name");
7
7
  i(this, "selector");
@@ -15,28 +15,28 @@ class oe {
15
15
  }
16
16
  }
17
17
  let W;
18
- const ie = (t) => {
18
+ const re = (t) => {
19
19
  W = t;
20
20
  }, z = (t, e) => (s = W, o) => {
21
21
  s = s || W, console.log("Searching elem from Root = ", s);
22
- const r = [];
22
+ const a = [];
23
23
  s.querySelectorAll(t).forEach((l) => {
24
- l.style.display !== "none" && r.push(l);
24
+ l.style.display !== "none" && a.push(l);
25
25
  });
26
- let a;
27
- return e ? (console.log("Applying filter ", e), console.log(" -- to " + r.length + "elements: ", r), a = r.filter((l, E, C) => {
26
+ let r;
27
+ return e ? (console.log("Applying filter ", e), console.log(" -- to " + a.length + "elements: ", a), r = a.filter((l, E, C) => {
28
28
  console.log("Apply filter to item " + E + ": ", l);
29
- const m = e(l, E, C);
30
- return console.log(` -> Item ${E} ${m ? "Match" : "Discarded"}`), m;
31
- })[0]) : a = r[0], a && o && (console.log("Apply post process to = ", a), a = o(a)), console.log("Return elem = ", a), a;
29
+ const g = e(l, E, C);
30
+ return console.log(` -> Item ${E} ${g ? "Match" : "Discarded"}`), g;
31
+ })[0]) : r = a[0], r && o && (console.log("Apply post process to = ", r), r = o(r)), console.log("Return elem = ", r), r;
32
32
  }, R = (t, e, n) => ({
33
33
  /**
34
34
  * Sets the UI element identifier
35
35
  * @param uiElementId
36
36
  * @returns
37
37
  */
38
- as: (s) => new oe(s, t, e, n)
39
- }), re = (t, e) => ({
38
+ as: (s) => new ie(s, t, e, n)
39
+ }), ae = (t, e) => ({
40
40
  ...R(t, e),
41
41
  /**
42
42
  * Tansform the UI element that will be returned
@@ -49,7 +49,7 @@ const ie = (t) => {
49
49
  }), G = (t) => ({
50
50
  ...R(t, null),
51
51
  childOf: (e) => ({
52
- ...re(t, e)
52
+ ...ae(t, e)
53
53
  }),
54
54
  /**
55
55
  * Tansform the UI element that will be returned
@@ -59,9 +59,9 @@ const ie = (t) => {
59
59
  postProcess: (e) => ({
60
60
  ...R(t, null, e)
61
61
  })
62
- }), I = (t) => ({
62
+ }), D = (t) => ({
63
63
  where: (e) => G(z(t, e))
64
- }), ae = I("div"), ce = I("button"), le = I("input"), ue = I("textarea"), he = (t) => G(z("#" + t)), de = (t) => I(t);
64
+ }), ce = D("div"), le = D("button"), ue = D("input"), he = D("textarea"), de = (t) => G(z("#" + t)), pe = (t) => D(t);
65
65
  let Q = !1;
66
66
  const _e = (t) => {
67
67
  Q = t;
@@ -96,48 +96,47 @@ const _e = (t) => {
96
96
  const n = (e == null ? void 0 : e.firstChild).innerText.trim() === t;
97
97
  return x(`firstChildTextIs('${t}') on`, e, "=>", n), n;
98
98
  }, lt = (t) => (e, n) => {
99
- let s = !0, o = 0;
100
- for (; s && o < t.length; ) {
101
- const r = t[o](e, n);
102
- x(`and condition[${o}] on`, e, "elemIndex", n, "=>", r), s = s && r, o++;
103
- }
99
+ const s = t.every((o, a) => {
100
+ const r = o(e, n);
101
+ return x(`and condition[${a}] on`, e, "elemIndex", n, "=>", r), r;
102
+ });
104
103
  return x("and final result on", e, "elemIndex", n, "=>", s), s;
105
104
  }, ut = {
106
- DIV: ae,
107
- BUTTON: ce,
108
- INPUT: le,
109
- TEXTAREA: ue,
110
- ELEMENT: de,
111
- identifiedBy: he
105
+ DIV: ce,
106
+ BUTTON: le,
107
+ INPUT: ue,
108
+ TEXTAREA: he,
109
+ ELEMENT: pe,
110
+ identifiedBy: de
112
111
  };
113
112
  let P;
114
- const pe = new Uint8Array(16);
115
- function me() {
113
+ const me = new Uint8Array(16);
114
+ function ge() {
116
115
  if (!P && (P = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !P))
117
116
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
118
- return P(pe);
117
+ return P(me);
119
118
  }
120
119
  const p = [];
121
120
  for (let t = 0; t < 256; ++t)
122
121
  p.push((t + 256).toString(16).slice(1));
123
- function ge(t, e = 0) {
122
+ function ye(t, e = 0) {
124
123
  return (p[t[e + 0]] + p[t[e + 1]] + p[t[e + 2]] + p[t[e + 3]] + "-" + p[t[e + 4]] + p[t[e + 5]] + "-" + p[t[e + 6]] + p[t[e + 7]] + "-" + p[t[e + 8]] + p[t[e + 9]] + "-" + p[t[e + 10]] + p[t[e + 11]] + p[t[e + 12]] + p[t[e + 13]] + p[t[e + 14]] + p[t[e + 15]]).toLowerCase();
125
124
  }
126
- const ye = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), B = {
127
- randomUUID: ye
125
+ const Ee = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), B = {
126
+ randomUUID: Ee
128
127
  };
129
- function Ee(t, e, n) {
128
+ function Z(t, e, n) {
130
129
  if (B.randomUUID && !e && !t)
131
130
  return B.randomUUID();
132
131
  t = t || {};
133
- const s = t.random || (t.rng || me)();
132
+ const s = t.random || (t.rng || ge)();
134
133
  if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, e) {
135
134
  n = n || 0;
136
135
  for (let o = 0; o < 16; ++o)
137
136
  e[n + o] = s[o];
138
137
  return e;
139
138
  }
140
- return ge(s);
139
+ return ye(s);
141
140
  }
142
141
  const f = (t = 2e3) => new Promise((e) => {
143
142
  setTimeout(() => {
@@ -148,8 +147,8 @@ const f = (t = 2e3) => new Promise((e) => {
148
147
  key: s,
149
148
  value: o
150
149
  })).forEach((s) => {
151
- const { key: o, value: r } = s;
152
- t.style[o] = r;
150
+ const { key: o, value: a } = s;
151
+ t.style[o] = a;
153
152
  });
154
153
  };
155
154
  class we {
@@ -315,9 +314,9 @@ class we {
315
314
  });
316
315
  const o = this.document.createElement("DIV");
317
316
  o.innerHTML = e.beforeHTML, H(o, e.beforeInputValues);
318
- const r = this.document.createElement("DIV");
319
- r.innerHTML = e.afterHTML, H(r, e.afterInputValues), this.contextViewerContainer.appendChild(n), n.appendChild(o), setTimeout(() => {
320
- this.contextViewerContainer.removeChild(n), this.contextViewerContainer.appendChild(s), s.appendChild(r), setTimeout(() => {
317
+ const a = this.document.createElement("DIV");
318
+ a.innerHTML = e.afterHTML, H(a, e.afterInputValues), this.contextViewerContainer.appendChild(n), n.appendChild(o), setTimeout(() => {
319
+ this.contextViewerContainer.removeChild(n), this.contextViewerContainer.appendChild(s), s.appendChild(a), setTimeout(() => {
321
320
  this.contextViewerContainer.removeChild(s), A(this.contextViewerContainer, { display: "none" });
322
321
  }, 2e3);
323
322
  }, 2e3);
@@ -328,43 +327,43 @@ const H = (t, e) => {
328
327
  const s = n.getAttribute("input-id") || "";
329
328
  n.value = e[s];
330
329
  });
331
- }, q = null, $ = async (t, e, n, s = 1e3, o = 0, r = 10, a = !1) => {
330
+ }, q = null, $ = async (t, e, n, s = 1e3, o = 0, a = 10, r = !1) => {
332
331
  if (console.log("Automation Status: ", c.status), c.isPaused)
333
332
  return new Promise((l, E) => {
334
333
  c.saveCurrentAction(async (C) => {
335
334
  if (C.status == "skipped")
336
335
  return l(null);
337
336
  try {
338
- const m = await $(C, e, n, s, o, r, a);
339
- l(m);
340
- } catch (m) {
341
- E(m);
337
+ const g = await $(C, e, n, s, o, a, r);
338
+ l(g);
339
+ } catch (g) {
340
+ E(g);
342
341
  }
343
342
  }, t);
344
343
  });
345
344
  if (c.isStopped)
346
345
  throw new Error("Test stopped manually");
347
- if (console.groupCollapsed(`tries ${o}/${r}`), t && (t.updateTries(o), await g.notifyActionUpdated(t)), o === r)
348
- throw console.groupEnd(), a ? new Error(`UI Element ${e.getElementName() || "UNKNOWN"} still present after 10 tries`) : new Error(`UI Element ${e.getElementName() || "UNKNOWN"} not found after 10 tries`);
346
+ if (console.groupCollapsed(`tries ${o}/${a}`), t && (t.updateTries(o), await y.notifyActionUpdated(t)), o === a)
347
+ throw console.groupEnd(), r ? new Error(`UI Element ${e.getElementName() || "UNKNOWN"} still present after 10 tries`) : new Error(`UI Element ${e.getElementName() || "UNKNOWN"} not found after 10 tries`);
349
348
  {
350
349
  const l = e.selector(n, e.postProcess);
351
- return console.groupEnd(), l ? a ? (await f(s), await $(t, e, n, s, ++o, r, a)) : (console.log("Element found = ", l), l) : a ? (console.log("Element removed."), q) : (await f(s), await $(t, e, n, s, ++o, r, a));
350
+ return console.groupEnd(), l ? r ? (await f(s), await $(t, e, n, s, ++o, a, r)) : (console.log("Element found = ", l), l) : r ? (console.log("Element removed."), q) : (await f(s), await $(t, e, n, s, ++o, a, r));
352
351
  }
353
352
  }, V = async (t, e, n = 1e3, s = 10, o = !1) => {
354
- const r = e == null ? void 0 : e.getElementName();
355
- console.group("Looking for Element: " + r);
356
- let a = null;
353
+ const a = e == null ? void 0 : e.getElementName();
354
+ console.group("Looking for Element: " + a);
355
+ let r = null;
357
356
  if (e.parent)
358
357
  try {
359
- console.groupCollapsed("Look for Parent ", e.parent.getElementName()), a = await V(t, e.parent, n, s, o), console.groupEnd();
358
+ console.groupCollapsed("Look for Parent ", e.parent.getElementName()), r = await V(t, e.parent, n, s, o), console.groupEnd();
360
359
  } catch (l) {
361
360
  if (console.groupEnd(), o && l.message.includes("not found"))
362
361
  return console.log("Parent not found, so element was removed"), console.groupEnd(), q;
363
362
  throw console.groupEnd(), l;
364
363
  }
365
364
  try {
366
- console.log("Using parent element: ", a);
367
- const l = await $(t, e, a, n, 0, s, o);
365
+ console.log("Using parent element: ", r);
366
+ const l = await $(t, e, r, n, 0, s, o);
368
367
  return console.groupEnd(), l;
369
368
  } catch (l) {
370
369
  if (o && l.message.includes("not found"))
@@ -372,14 +371,14 @@ const H = (t, e) => {
372
371
  throw console.groupEnd(), l;
373
372
  }
374
373
  };
375
- var Z = /* @__PURE__ */ ((t) => (t.WAITING = "waiting", t.RUNNING = "running", t.STOPPED = "stopped", t.PAUSED = "paused", t.SUCCESS = "success", t.ERROR = "error", t.SKIPPED = "skipped", t))(Z || {});
376
- class g {
374
+ var Y = /* @__PURE__ */ ((t) => (t.WAITING = "waiting", t.RUNNING = "running", t.STOPPED = "stopped", t.PAUSED = "paused", t.SUCCESS = "success", t.ERROR = "error", t.SKIPPED = "skipped", t))(Y || {});
375
+ class y {
377
376
  constructor() {
378
377
  i(this, "status");
379
378
  i(this, "error");
380
379
  i(this, "id");
381
380
  i(this, "context");
382
- this.status = "waiting", this.error = "", this.id = Ee(), this.context = {
381
+ this.status = "waiting", this.error = "", this.id = Z(), this.context = {
383
382
  beforeHTML: "",
384
383
  beforeInputValues: {},
385
384
  afterInputValues: {},
@@ -404,28 +403,28 @@ class g {
404
403
  getInputValuesFromPage() {
405
404
  const e = {};
406
405
  return c.document.querySelectorAll("input").forEach((s, o) => {
407
- const r = `value-id-${o}`;
408
- s.setAttribute("input-id", r), e[r] = s.value;
406
+ const a = `value-id-${o}`;
407
+ s.setAttribute("input-id", a), e[a] = s.value;
409
408
  }), e;
410
409
  }
411
410
  async execute() {
412
411
  try {
413
- this.status = "running", this.context.beforeInputValues = this.getInputValuesFromPage(), this.context.beforeHTML = c.document.body.innerHTML, await g.notifyActionUpdated(this), console.log("Action: ", this.getDescription()), await this.executeAction(), this.status = "success", this.error = "", c.isStepByStepMode && c.pause();
412
+ this.status = "running", this.context.beforeInputValues = this.getInputValuesFromPage(), this.context.beforeHTML = c.document.body.innerHTML, await y.notifyActionUpdated(this), console.log("Action: ", this.getDescription()), await this.executeAction(), this.status = "success", this.error = "", c.isStepByStepMode && c.pause();
414
413
  } catch (e) {
415
414
  if (this.status = "error", this.error = e.message, e.message == "Test stopped manually")
416
415
  throw Error("Error in Action " + this.getDescription() + ". Message: " + e.message);
417
416
  this.status = "paused", c.pause();
418
417
  } finally {
419
- this.context.afterInputValues = this.getInputValuesFromPage(), this.context.afterHTML = c.document.body.innerHTML, await g.notifyActionUpdated(this);
418
+ this.context.afterInputValues = this.getInputValuesFromPage(), this.context.afterHTML = c.document.body.innerHTML, await y.notifyActionUpdated(this);
420
419
  }
421
420
  }
422
421
  static async notifyActionUpdated(e) {
423
- y.dispatch(N.ACTION_UPDATE, {
422
+ m.dispatch(v.ACTION_UPDATE, {
424
423
  action: e.getJSON()
425
424
  });
426
425
  }
427
426
  }
428
- class Y extends g {
427
+ class _ extends y {
429
428
  constructor(n, s) {
430
429
  super();
431
430
  i(this, "name");
@@ -463,8 +462,8 @@ class Y extends g {
463
462
  return n();
464
463
  try {
465
464
  await o.continue(), n();
466
- } catch (r) {
467
- s(r);
465
+ } catch (a) {
466
+ s(a);
468
467
  }
469
468
  }, this);
470
469
  });
@@ -477,13 +476,13 @@ class Y extends g {
477
476
  this.index++, await this.continue();
478
477
  else
479
478
  return new Promise((s, o) => {
480
- c.saveCurrentAction(async (r) => {
481
- if (r.status == "skipped")
482
- return this.index++, await g.notifyActionUpdated(n), await this.continue(), s();
479
+ c.saveCurrentAction(async (a) => {
480
+ if (a.status == "skipped")
481
+ return this.index++, await y.notifyActionUpdated(n), await this.continue(), s();
483
482
  try {
484
- await r.continue(), s();
485
- } catch (a) {
486
- o(a);
483
+ await a.continue(), s();
484
+ } catch (r) {
485
+ o(r);
487
486
  }
488
487
  }, n);
489
488
  });
@@ -502,7 +501,7 @@ class Y extends g {
502
501
  this.steps.push(n);
503
502
  }
504
503
  }
505
- class d extends g {
504
+ class d extends y {
506
505
  constructor(n) {
507
506
  super();
508
507
  i(this, "uiElement");
@@ -536,16 +535,16 @@ class d extends g {
536
535
  * @param uiElement
537
536
  * @param delay of each try. Defaults to 1 second
538
537
  */
539
- static waitForElement(n, s, o = 1e3, r = 10, a = !1) {
538
+ static waitForElement(n, s, o = 1e3, a = 10, r = !1) {
540
539
  const l = s.getElementName();
541
540
  return new Promise(async (E, C) => {
542
- var v;
543
- const m = async (k, L = 1e3, b = 0, D = !1) => {
544
- if (console.groupCollapsed(`tries ${b}/${r}`), n.updateTries(b), await g.notifyActionUpdated(n), b === r)
545
- throw console.groupEnd(), D ? new Error(`UI Element ${l || "UNKNOWN"} still present after 10 tries`) : new Error(`UI Element ${l || "UNKNOWN"} not found after 10 tries`);
541
+ var N;
542
+ const g = async (k, L = 1e3, b = 0, I = !1) => {
543
+ if (console.groupCollapsed(`tries ${b}/${a}`), n.updateTries(b), await y.notifyActionUpdated(n), b === a)
544
+ throw console.groupEnd(), I ? new Error(`UI Element ${l || "UNKNOWN"} still present after 10 tries`) : new Error(`UI Element ${l || "UNKNOWN"} not found after 10 tries`);
546
545
  {
547
546
  const M = s.selector(k, s.postProcess);
548
- return console.groupEnd(), M ? D ? (await f(L), await m(k, L, ++b, D)) : (console.log("Element found = ", M), M) : D ? (console.log("Element removed."), null) : (await f(L), await m(k, L, ++b, D));
547
+ return console.groupEnd(), M ? I ? (await f(L), await g(k, L, ++b, I)) : (console.log("Element found = ", M), M) : I ? (console.log("Element removed."), null) : (await f(L), await g(k, L, ++b, I));
549
548
  }
550
549
  };
551
550
  console.group("[Action On Element] Looking for Element: " + l);
@@ -553,7 +552,7 @@ class d extends g {
553
552
  if (s.parent) {
554
553
  console.groupCollapsed("Look for Parent ", s.parent.getElementName());
555
554
  try {
556
- T = await d.waitForElement(n, s.parent, o, r, a);
555
+ T = await d.waitForElement(n, s.parent, o, a, r);
557
556
  } catch {
558
557
  F = !1;
559
558
  } finally {
@@ -563,13 +562,13 @@ class d extends g {
563
562
  if (F) {
564
563
  console.log("using parent element: ", T);
565
564
  try {
566
- const k = await m(T, o, 0, a);
565
+ const k = await g(T, o, 0, r);
567
566
  console.groupEnd(), E(k);
568
567
  } catch (k) {
569
568
  console.groupEnd(), C(new Error(k.message));
570
569
  }
571
570
  } else
572
- console.groupEnd(), C(new Error(`Parent ${(v = s.parent) == null ? void 0 : v.getElementName()} of UI Element ${s.name || "UNKNOWN"} not found`));
571
+ console.groupEnd(), C(new Error(`Parent ${(N = s.parent) == null ? void 0 : N.getElementName()} of UI Element ${s.name || "UNKNOWN"} not found`));
573
572
  });
574
573
  }
575
574
  async executeAction() {
@@ -718,9 +717,9 @@ class Se extends d {
718
717
  this.value = s;
719
718
  }
720
719
  executeActionOnElement() {
721
- var s, o, r, a;
720
+ var s, o, a, r;
722
721
  let n = this.element;
723
- if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((o = this.element) == null ? void 0 : o.tagName) !== "SELECT" && ((r = this.element) == null ? void 0 : r.tagName) !== "TEXTAREA" && (n = (a = this.element) == null ? void 0 : a.querySelectorAll("input")[0], !n))
722
+ if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((o = this.element) == null ? void 0 : o.tagName) !== "SELECT" && ((a = this.element) == null ? void 0 : a.tagName) !== "TEXTAREA" && (n = (r = this.element) == null ? void 0 : r.querySelectorAll("input")[0], !n))
724
723
  throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
725
724
  n.value = this.value, n.dispatchEvent(new Event("change"));
726
725
  }
@@ -735,16 +734,16 @@ class Se extends d {
735
734
  };
736
735
  }
737
736
  }
738
- class _ extends d {
737
+ class ee extends d {
739
738
  constructor(n, s) {
740
739
  super(n);
741
740
  i(this, "value");
742
741
  this.value = s;
743
742
  }
744
743
  executeActionOnElement() {
745
- var s, o, r, a;
744
+ var s, o, a, r;
746
745
  let n = this.element;
747
- if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((o = this.element) == null ? void 0 : o.tagName) !== "SELECT" && ((r = this.element) == null ? void 0 : r.tagName) !== "TEXTAREA" && (n = (a = this.element) == null ? void 0 : a.querySelectorAll("input")[0], !n))
746
+ if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((o = this.element) == null ? void 0 : o.tagName) !== "SELECT" && ((a = this.element) == null ? void 0 : a.tagName) !== "TEXTAREA" && (n = (r = this.element) == null ? void 0 : r.querySelectorAll("input")[0], !n))
748
747
  throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
749
748
  n.value = this.value, n.dispatchEvent(new Event("change")), n.dispatchEvent(new Event("keyup", { bubbles: !0 })), n.dispatchEvent(new Event("input", { bubbles: !0 }));
750
749
  }
@@ -759,16 +758,16 @@ class _ extends d {
759
758
  };
760
759
  }
761
760
  }
762
- class Ne extends d {
761
+ class ve extends d {
763
762
  constructor(n, s) {
764
763
  super(n);
765
764
  i(this, "value");
766
765
  this.value = s;
767
766
  }
768
767
  executeActionOnElement() {
769
- var s, o, r, a;
768
+ var s, o, a, r;
770
769
  let n = this.element;
771
- if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((o = this.element) == null ? void 0 : o.tagName) !== "SELECT" && ((r = this.element) == null ? void 0 : r.tagName) !== "TEXTAREA" && (n = (a = this.element) == null ? void 0 : a.querySelectorAll("input")[0], !n))
770
+ if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((o = this.element) == null ? void 0 : o.tagName) !== "SELECT" && ((a = this.element) == null ? void 0 : a.tagName) !== "TEXTAREA" && (n = (r = this.element) == null ? void 0 : r.querySelectorAll("input")[0], !n))
772
771
  throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
773
772
  n.value = this.value, n.dispatchEvent(new Event("change")), n.dispatchEvent(new Event("keyup", { bubbles: !0 })), n.dispatchEvent(new Event("input", { bubbles: !0 }));
774
773
  }
@@ -783,7 +782,7 @@ class Ne extends d {
783
782
  };
784
783
  }
785
784
  }
786
- class ve extends d {
785
+ class Ne extends d {
787
786
  constructor(e) {
788
787
  super(e);
789
788
  }
@@ -849,7 +848,7 @@ class be extends d {
849
848
  };
850
849
  }
851
850
  }
852
- class De extends d {
851
+ class Ie extends d {
853
852
  constructor(e) {
854
853
  super(e);
855
854
  }
@@ -915,8 +914,8 @@ class Oe extends d {
915
914
  };
916
915
  }
917
916
  }
918
- var Ie = /* @__PURE__ */ ((t) => (t.ESCAPE = "Escape", t.ENTER = "Enter", t.TAB = "Tab", t.ARROW_DOWN = "ArrowDown", t.ARROW_UP = "ArrowUp", t.ARROW_LEFT = "ArrowLeft", t.ARROW_RIGHT = "ArrowRight", t.BACKSPACE = "Backspace", t.DELETE = "Delete", t.SHIFT = "Shift", t.CONTROL = "Control", t.ALT = "Alt", t.META = "Meta", t))(Ie || {});
919
- const X = {
917
+ var De = /* @__PURE__ */ ((t) => (t.ESCAPE = "Escape", t.ENTER = "Enter", t.TAB = "Tab", t.ARROW_DOWN = "ArrowDown", t.ARROW_UP = "ArrowUp", t.ARROW_LEFT = "ArrowLeft", t.ARROW_RIGHT = "ArrowRight", t.BACKSPACE = "Backspace", t.DELETE = "Delete", t.SHIFT = "Shift", t.CONTROL = "Control", t.ALT = "Alt", t.META = "Meta", t))(De || {});
918
+ const j = {
920
919
  Escape: 27,
921
920
  Enter: 13,
922
921
  Tab: 9,
@@ -943,9 +942,9 @@ class Le extends d {
943
942
  new KeyboardEvent("keydown", {
944
943
  key: this.key,
945
944
  code: this.key,
946
- keyCode: X[this.key],
945
+ keyCode: j[this.key],
947
946
  charCode: 0,
948
- which: X[this.key],
947
+ which: j[this.key],
949
948
  altKey: !1,
950
949
  ctrlKey: !1,
951
950
  metaKey: !1,
@@ -978,12 +977,12 @@ class Pe extends d {
978
977
  s.items.add(this.file);
979
978
  const o = s.files;
980
979
  n.files = o, n.dispatchEvent(new Event("change"));
981
- function r(l) {
980
+ function a(l) {
982
981
  var E;
983
- return l != null && l.parentElement ? ((E = l.parentElement) == null ? void 0 : E.tagName.toLowerCase()) === "form" ? l.parentElement : r(l.parentElement) : null;
982
+ return l != null && l.parentElement ? ((E = l.parentElement) == null ? void 0 : E.tagName.toLowerCase()) === "form" ? l.parentElement : a(l.parentElement) : null;
984
983
  }
985
- const a = r(n);
986
- a && a.dispatchEvent(new Event("change"));
984
+ const r = a(n);
985
+ r && r.dispatchEvent(new Event("change"));
987
986
  }
988
987
  getDescription() {
989
988
  return `Upload file in ${this.getElementName()}`;
@@ -1002,11 +1001,11 @@ class $e extends d {
1002
1001
  this.memorySlotName = s;
1003
1002
  }
1004
1003
  executeActionOnElement() {
1005
- var s, o, r, a;
1004
+ var s, o, a, r;
1006
1005
  let n = this.element;
1007
- if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((o = this.element) == null ? void 0 : o.tagName) !== "SELECT" && ((r = this.element) == null ? void 0 : r.tagName) !== "TEXTAREA" && (n = (a = this.element) == null ? void 0 : a.querySelectorAll("input")[0], !n))
1006
+ if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((o = this.element) == null ? void 0 : o.tagName) !== "SELECT" && ((a = this.element) == null ? void 0 : a.tagName) !== "TEXTAREA" && (n = (r = this.element) == null ? void 0 : r.querySelectorAll("input")[0], !n))
1008
1007
  throw new Error("Input element not found. Not able to save value from element " + this.getElementName());
1009
- y.dispatch(N.SAVE_VALUE, {
1008
+ m.dispatch(v.SAVE_VALUE, {
1010
1009
  memorySlotName: this.memorySlotName,
1011
1010
  value: n.value
1012
1011
  });
@@ -1022,7 +1021,7 @@ class $e extends d {
1022
1021
  };
1023
1022
  }
1024
1023
  }
1025
- class Ue extends g {
1024
+ class Ue extends y {
1026
1025
  constructor(n) {
1027
1026
  super();
1028
1027
  i(this, "miliseconds");
@@ -1043,7 +1042,7 @@ class Ue extends g {
1043
1042
  resetAction() {
1044
1043
  }
1045
1044
  }
1046
- class Re extends g {
1045
+ class Re extends y {
1047
1046
  constructor(n) {
1048
1047
  super();
1049
1048
  i(this, "uiElement");
@@ -1073,7 +1072,7 @@ class Re extends g {
1073
1072
  };
1074
1073
  }
1075
1074
  }
1076
- class Je extends g {
1075
+ class Je extends y {
1077
1076
  constructor() {
1078
1077
  super();
1079
1078
  }
@@ -1092,7 +1091,7 @@ class Je extends g {
1092
1091
  resetAction() {
1093
1092
  }
1094
1093
  }
1095
- class Ve extends g {
1094
+ class Ve extends y {
1096
1095
  constructor(n) {
1097
1096
  super();
1098
1097
  i(this, "description");
@@ -1109,13 +1108,13 @@ class Ve extends g {
1109
1108
  }
1110
1109
  async executeAction() {
1111
1110
  return await c.uiUtils.showAlert("Waiting manual step..."), new Promise((n, s) => {
1112
- y.on(N.USER_ACCEPT, async () => (await c.uiUtils.hideAlert(), n(!0))), y.on(N.USER_REJECT, async () => (await c.uiUtils.hideAlert(), s()));
1111
+ m.on(v.USER_ACCEPT, async () => (await c.uiUtils.hideAlert(), n(!0))), m.on(v.USER_REJECT, async () => (await c.uiUtils.hideAlert(), s()));
1113
1112
  });
1114
1113
  }
1115
1114
  resetAction() {
1116
1115
  }
1117
1116
  }
1118
- class Ke extends g {
1117
+ class Ke extends y {
1119
1118
  constructor() {
1120
1119
  super();
1121
1120
  }
@@ -1137,10 +1136,10 @@ class Ke extends g {
1137
1136
  const J = (t) => t.toLocaleDateString("en-US", { year: "numeric", month: "2-digit", day: "2-digit" }), K = (t) => {
1138
1137
  const e = /* @__PURE__ */ new Date();
1139
1138
  return J(new Date(e.setDate(e.getDate() + t)));
1140
- }, ee = (t) => {
1139
+ }, te = (t) => {
1141
1140
  const e = /* @__PURE__ */ new Date();
1142
1141
  return J(new Date(e.setMonth(e.getMonth() + t)));
1143
- }, Fe = K(1), Me = K(-1), We = K(7), qe = K(-7), Be = ee(1), He = ee(-1), ht = {
1142
+ }, Fe = K(1), Me = K(-1), We = K(7), qe = K(-7), Be = te(1), He = te(-1), ht = {
1144
1143
  formatDate: J,
1145
1144
  today: J(/* @__PURE__ */ new Date()),
1146
1145
  tomorrow: Fe,
@@ -1150,7 +1149,7 @@ const J = (t) => t.toLocaleDateString("en-US", { year: "numeric", month: "2-digi
1150
1149
  lastWeek: qe,
1151
1150
  lastMonth: He
1152
1151
  };
1153
- class Xe {
1152
+ class je {
1154
1153
  constructor() {
1155
1154
  i(this, "enabled", !1);
1156
1155
  }
@@ -1170,7 +1169,7 @@ class Xe {
1170
1169
  this.enabled && console.error("[tomation]", ...e);
1171
1170
  }
1172
1171
  }
1173
- const u = new Xe(), je = (t) => {
1172
+ const u = new je(), Xe = (t) => {
1174
1173
  u.setEnabled(t);
1175
1174
  }, w = class w {
1176
1175
  static compileAction(e) {
@@ -1186,7 +1185,7 @@ const u = new Xe(), je = (t) => {
1186
1185
  };
1187
1186
  i(w, "currentAction"), i(w, "isCompiling");
1188
1187
  let h = w;
1189
- var N = /* @__PURE__ */ ((t) => (t.ACTION_UPDATE = "tomation-action-update", t.SAVE_VALUE = "tomation-save-value", t.REGISTER_TEST = "tomation-register-test", t.TEST_STARTED = "tomation-test-started", t.TEST_PASSED = "tomation-test-passed", t.TEST_FAILED = "tomation-test-failed", t.TEST_END = "tomation-test-end", t.TEST_STOP = "tomation-test-stop", t.USER_ACCEPT = "tomation-user-accept", t.USER_REJECT = "tomation-user-reject", t))(N || {});
1188
+ var v = /* @__PURE__ */ ((t) => (t.ACTION_UPDATE = "tomation-action-update", t.SAVE_VALUE = "tomation-save-value", t.REGISTER_TEST = "tomation-register-test", t.TEST_STARTED = "tomation-test-started", t.TEST_PASSED = "tomation-test-passed", t.TEST_FAILED = "tomation-test-failed", t.TEST_END = "tomation-test-end", t.TEST_STOP = "tomation-test-stop", t.TEST_PAUSE = "tomation-test-pause", t.TEST_PLAY = "tomation-test-play", t.USER_ACCEPT = "tomation-user-accept", t.USER_REJECT = "tomation-user-reject", t.SESSION_INIT = "tomation-session-init", t))(v || {});
1190
1189
  class ze {
1191
1190
  constructor() {
1192
1191
  i(this, "events");
@@ -1207,21 +1206,21 @@ class ze {
1207
1206
  }));
1208
1207
  }
1209
1208
  }
1210
- const y = new ze();
1211
- var te = /* @__PURE__ */ ((t) => (t[t.SLOW = 2e3] = "SLOW", t[t.NORMAL = 1e3] = "NORMAL", t[t.FAST = 200] = "FAST", t))(te || {});
1209
+ const m = new ze();
1210
+ var ne = /* @__PURE__ */ ((t) => (t[t.SLOW = 2e3] = "SLOW", t[t.NORMAL = 1e3] = "NORMAL", t[t.FAST = 200] = "FAST", t))(ne || {});
1212
1211
  const S = class S {
1213
1212
  static async start(e) {
1214
1213
  if (S.running)
1215
1214
  throw u.error("Not able to run test while other test is running."), new Error("Not able to run test while other test is running.");
1216
- S.running = !0, c.status = "Playing", c.runMode = "Normal", u.groupCollapsed("Start Action: ", e.getDescription()), y.dispatch("tomation-test-started", {
1215
+ S.running = !0, c.status = "Playing", c.runMode = "Normal", u.groupCollapsed("Start Action: ", e.getDescription()), m.dispatch("tomation-test-started", {
1217
1216
  action: e == null ? void 0 : e.getJSON()
1218
1217
  });
1219
1218
  try {
1220
- await (e == null ? void 0 : e.execute()), y.dispatch("tomation-test-passed", { id: e.name });
1219
+ await (e == null ? void 0 : e.execute()), m.dispatch("tomation-test-passed", { id: e.name });
1221
1220
  } catch (n) {
1222
- throw y.dispatch("tomation-test-failed", { id: e.name }), c.uiUtils.hideCheckElementContainer(), u.error(`🤖 Error running task ${e.getDescription()}. Reason: ${n.message}`), n;
1221
+ throw m.dispatch("tomation-test-failed", { id: e.name }), c.uiUtils.hideCheckElementContainer(), u.error(`🤖 Error running task ${e.getDescription()}. Reason: ${n.message}`), n;
1223
1222
  } finally {
1224
- u.groupEnd(), S.running = !1, y.dispatch("tomation-test-end", {
1223
+ u.groupEnd(), S.running = !1, m.dispatch("tomation-test-end", {
1225
1224
  action: e == null ? void 0 : e.getJSON()
1226
1225
  });
1227
1226
  }
@@ -1231,8 +1230,8 @@ i(S, "running", !1);
1231
1230
  let O = S;
1232
1231
  const U = {}, dt = (t, e) => {
1233
1232
  console.log(`Registering Test: ${t}...`);
1234
- const n = new Y(t, e);
1235
- h.init(n), console.log(`Compiled Test: ${t}`), y.dispatch("tomation-register-test", { id: t, action: n.getJSON() }), console.log(`Registered Test: ${t} in TestsMap`), U[t] = () => {
1233
+ const n = new _(t, e);
1234
+ h.init(n), console.log(`Compiled Test: ${t}`), m.dispatch("tomation-register-test", { id: t, action: n.getJSON() }), console.log(`Registered Test: ${t} in TestsMap`), U[t] = () => {
1236
1235
  O.start(n);
1237
1236
  };
1238
1237
  }, Ge = (t) => {
@@ -1241,7 +1240,7 @@ const U = {}, dt = (t, e) => {
1241
1240
  else
1242
1241
  throw console.log("Available Tests:", Object.keys(U)), new Error(`Test with id ${t} not found.`);
1243
1242
  }, pt = (t, e) => async (n) => {
1244
- const s = new Y(t, e);
1243
+ const s = new _(t, e);
1245
1244
  if (s.setParams(n), !O.running && !h.isCompiling)
1246
1245
  try {
1247
1246
  u.log(`Compilation of Task ${t} starts...`), h.init(s), u.log(`Compilation of Task ${t} Finished.`), u.log(`Start running Task ${t}...`), await O.start(s), u.log(`End of Task ${t}: SUCCESS`);
@@ -1276,17 +1275,17 @@ const U = {}, dt = (t, e) => {
1276
1275
  }
1277
1276
  }), Et = (t) => ({
1278
1277
  in: (e) => {
1279
- const n = new _(e, t);
1278
+ const n = new ee(e, t);
1280
1279
  h.addAction(n);
1281
1280
  }
1282
1281
  }), wt = () => ({
1283
1282
  in: (t) => {
1284
- const e = new _(t, "");
1283
+ const e = new ee(t, "");
1285
1284
  h.addAction(e);
1286
1285
  }
1287
1286
  }), ft = () => ({
1288
1287
  in: (t) => {
1289
- h.addAction(new ve(t));
1288
+ h.addAction(new Ne(t));
1290
1289
  }
1291
1290
  }), xt = () => ({
1292
1291
  in: (t) => {
@@ -1294,7 +1293,7 @@ const U = {}, dt = (t, e) => {
1294
1293
  }
1295
1294
  }), At = () => ({
1296
1295
  in: (t) => {
1297
- h.addAction(new De(t));
1296
+ h.addAction(new Ie(t));
1298
1297
  }
1299
1298
  }), Ct = () => ({
1300
1299
  in: (t) => {
@@ -1306,7 +1305,7 @@ const U = {}, dt = (t, e) => {
1306
1305
  }
1307
1306
  }), Tt = (t) => ({
1308
1307
  in: (e) => {
1309
- const n = new Ne(e, t);
1308
+ const n = new ve(e, t);
1310
1309
  h.addAction(n);
1311
1310
  }
1312
1311
  }), St = (t) => ({
@@ -1314,7 +1313,7 @@ const U = {}, dt = (t, e) => {
1314
1313
  const n = new Pe(e, t);
1315
1314
  h.addAction(n);
1316
1315
  }
1317
- }), Nt = (t) => ({
1316
+ }), vt = (t) => ({
1318
1317
  in: (e) => {
1319
1318
  const n = new $e(t, e);
1320
1319
  h.addAction(n);
@@ -1327,11 +1326,11 @@ Qe.untilElement = (t) => ({
1327
1326
  h.addAction(new Re(t));
1328
1327
  }
1329
1328
  });
1330
- const vt = () => {
1329
+ const Nt = () => {
1331
1330
  h.addAction(new Je());
1332
1331
  }, bt = (t) => {
1333
1332
  h.addAction(new Ve(t));
1334
- }, Dt = () => {
1333
+ }, It = () => {
1335
1334
  h.addAction(new Ke());
1336
1335
  };
1337
1336
  class Ze {
@@ -1365,35 +1364,47 @@ class Ze {
1365
1364
  return this.status == "Paused";
1366
1365
  }
1367
1366
  pause() {
1368
- u.log("Pause Test"), this.status = "Paused";
1367
+ u.log("Pause Test"), this.status = "Paused", m.dispatch(
1368
+ "tomation-test-pause"
1369
+ /* TEST_PAUSE */
1370
+ );
1369
1371
  }
1370
1372
  continue() {
1371
- u.log("Continue Test"), this.status = "Playing", this.runMode = "Normal", this.currentActionCallback && this.currentAction && (u.log("Continue: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1373
+ u.log("Continue Test"), this.status = "Playing", this.runMode = "Normal", m.dispatch(
1374
+ "tomation-test-play"
1375
+ /* TEST_PLAY */
1376
+ ), this.currentActionCallback && this.currentAction && (u.log("Continue: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1372
1377
  }
1373
1378
  next() {
1374
- u.log("Continue Test to Next Step..."), this.status = "Playing", this.runMode = "Step By Step", this.currentActionCallback && this.currentAction && (u.log("Next: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1379
+ u.log("Continue Test to Next Step..."), this.status = "Playing", this.runMode = "Step By Step", m.dispatch(
1380
+ "tomation-test-play"
1381
+ /* TEST_PLAY */
1382
+ ), this.currentActionCallback && this.currentAction && (u.log("Next: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1375
1383
  }
1376
1384
  stop() {
1377
- u.log("Stop Test"), this.status = "Stopped", this.currentActionCallback && this.currentAction && (u.log("Stop: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0), y.dispatch(
1385
+ u.log("Stop Test"), this.status = "Stopped", this.currentActionCallback && this.currentAction && (u.log("Stop: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0), m.dispatch(
1378
1386
  "tomation-test-stop"
1379
1387
  /* TEST_STOP */
1380
1388
  );
1381
1389
  }
1382
1390
  retryAction() {
1383
- u.log("Retry current step"), this.status = "Playing", this.currentActionCallback && this.currentAction && (this.currentAction.resetTries && (u.log("Retry: Resetting tries for current action"), this.currentAction.resetTries()), u.log("Retry: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1391
+ u.log("Retry current step"), this.status = "Playing", m.dispatch(
1392
+ "tomation-test-play"
1393
+ /* TEST_PLAY */
1394
+ ), this.currentActionCallback && this.currentAction && (this.currentAction.resetTries && (u.log("Retry: Resetting tries for current action"), this.currentAction.resetTries()), u.log("Retry: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1384
1395
  }
1385
1396
  skipAction() {
1386
- u.log("Skip current step"), this.status = "Playing", this.currentActionCallback && this.currentAction && (this.currentAction.status = Z.SKIPPED, u.log("Skip: Marked current action as SKIPPED"), g.notifyActionUpdated(this.currentAction), u.log("Skip: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1397
+ u.log("Skip current step"), this.status = "Playing", this.currentActionCallback && this.currentAction && (this.currentAction.status = Y.SKIPPED, u.log("Skip: Marked current action as SKIPPED"), y.notifyActionUpdated(this.currentAction), u.log("Skip: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1387
1398
  }
1388
1399
  saveCurrentAction(e, n) {
1389
1400
  u.log("Save current action"), this.currentActionCallback = e, this.currentAction = n;
1390
1401
  }
1391
1402
  setDebug(e) {
1392
- je(e);
1403
+ Xe(e);
1393
1404
  }
1394
1405
  }
1395
1406
  let c;
1396
- const j = (t, e) => (c = new Ze(t), ie(c.document), e == null || e.forEach((n) => n()), c);
1407
+ const X = (t, e) => (c = new Ze(t), re(c.document), e == null || e.forEach((n) => n()), c);
1397
1408
  function Ot(t) {
1398
1409
  const {
1399
1410
  matches: e,
@@ -1406,82 +1417,92 @@ function Ot(t) {
1406
1417
  return;
1407
1418
  }
1408
1419
  try {
1409
- console.log("[tomation] Setting up messaging bridge with extension..."), Object.values(N).forEach((a) => {
1410
- console.log(`[tomation] Setting up listener for event "${a}"`), y.on(a, (l) => {
1411
- console.log(`[tomation] Dispatching event "${a}" to extension`, l), window.postMessage({
1420
+ console.log("[tomation] Setting up messaging bridge with extension..."), Object.values(v).forEach((r) => {
1421
+ console.log(`[tomation] Setting up listener for event "${r}"`), m.on(r, (l) => {
1422
+ console.log(`[tomation] Dispatching event "${r}" to extension`, l), window.postMessage({
1412
1423
  message: "injectedScript-to-contentScript",
1413
1424
  sender: "tomation",
1414
1425
  payload: {
1415
- cmd: a,
1426
+ cmd: r,
1416
1427
  params: l
1417
1428
  }
1418
1429
  });
1419
1430
  });
1420
- }), window.addEventListener("message", (a) => {
1431
+ }), window.addEventListener("message", (r) => {
1421
1432
  try {
1422
- console.log("[tomation] Received message from extension:", a.data);
1423
- const { message: l, sender: E, payload: C } = a.data || {}, { cmd: m, params: T } = C || {};
1433
+ console.log("[tomation] Received message from extension:", r.data);
1434
+ const { message: l, sender: E, payload: C } = r.data || {}, { cmd: g, params: T } = C || {};
1424
1435
  if (E !== "web-extension")
1425
1436
  return;
1426
1437
  if (l === "contentScript-to-injectedScript") {
1427
- const v = {
1438
+ const N = {
1428
1439
  "run-test-request": () => Ge(T == null ? void 0 : T.testId),
1429
- "reload-tests-request": () => j(window, n || []),
1440
+ "reload-tests-request": () => X(window, n || []),
1430
1441
  "pause-test-request": () => c.pause(),
1431
1442
  "stop-test-request": () => c.stop(),
1432
1443
  "continue-test-request": () => c.continue(),
1433
1444
  "next-step-request": () => c.next(),
1434
1445
  "retry-action-request": () => c.retryAction(),
1435
1446
  "skip-action-request": () => c.skipAction(),
1436
- "user-accept-request": () => y.dispatch(
1447
+ "user-accept-request": () => m.dispatch(
1437
1448
  "tomation-user-accept"
1438
1449
  /* USER_ACCEPT */
1439
1450
  ),
1440
- "user-reject-request": () => y.dispatch(
1451
+ "user-reject-request": () => m.dispatch(
1441
1452
  "tomation-user-reject"
1442
1453
  /* USER_REJECT */
1443
1454
  )
1444
- }[m];
1445
- v ? (console.log(`[tomation] Executing command "${m}" from extension`), v()) : console.warn(`[tomation] Unknown command "${m}" from extension`);
1455
+ }[g];
1456
+ N ? (console.log(`[tomation] Executing command "${g}" from extension`), N()) : console.warn(`[tomation] Unknown command "${g}" from extension`);
1446
1457
  return;
1447
1458
  }
1448
1459
  } catch (l) {
1449
1460
  console.error("[tomation] Error handling message from extension:", l);
1450
1461
  }
1451
- }), j(window, n), c.setDebug(o), c.speed = te[s], console.log("[tomation] Ready ✓");
1452
- } catch (a) {
1453
- console.error("[tomation] Initialization failed:", a);
1462
+ }), X(window, n), c.setDebug(o), c.speed = ne[s], window.postMessage({
1463
+ message: "injectedScript-to-contentScript",
1464
+ sender: "tomation",
1465
+ payload: {
1466
+ cmd: "tomation-session-init",
1467
+ params: {
1468
+ speed: c.speed,
1469
+ sessionId: Z()
1470
+ }
1471
+ }
1472
+ }), console.log("[tomation] Ready ✓");
1473
+ } catch (r) {
1474
+ console.error("[tomation] Initialization failed:", r);
1454
1475
  }
1455
1476
  }
1456
1477
  export {
1457
- Z as ACTION_STATUS,
1478
+ Y as ACTION_STATUS,
1458
1479
  gt as Assert,
1459
- y as AutomationEvents,
1480
+ m as AutomationEvents,
1460
1481
  c as AutomationInstance,
1461
1482
  wt as ClearValue,
1462
1483
  mt as Click,
1463
1484
  ht as DateUtils,
1464
- N as EVENT_NAMES,
1465
- Ie as KEY_MAP,
1485
+ v as EVENT_NAMES,
1486
+ De as KEY_MAP,
1466
1487
  bt as ManualTask,
1467
- vt as Pause,
1488
+ Nt as Pause,
1468
1489
  xt as PressDownKey,
1469
1490
  Ct as PressEnterKey,
1470
1491
  ft as PressEscKey,
1471
1492
  kt as PressKey,
1472
1493
  At as PressTabKey,
1473
- Dt as ReloadPage,
1494
+ It as ReloadPage,
1474
1495
  Ge as RunTest,
1475
- Nt as SaveValue,
1496
+ vt as SaveValue,
1476
1497
  yt as Select,
1477
1498
  z as SelectorBuilder,
1478
- j as Setup,
1499
+ X as Setup,
1479
1500
  pt as Task,
1480
1501
  dt as Test,
1481
- te as TestSpeed,
1502
+ ne as TestSpeed,
1482
1503
  Et as Type,
1483
1504
  Tt as TypePassword,
1484
- oe as UIElement,
1505
+ ie as UIElement,
1485
1506
  St as UploadFile,
1486
1507
  Qe as Wait,
1487
1508
  lt as and,
@@ -1495,7 +1516,7 @@ export {
1495
1516
  ut as is,
1496
1517
  rt as isFirstElement,
1497
1518
  it as placeholderIs,
1498
- je as setAutomationLogs,
1519
+ Xe as setAutomationLogs,
1499
1520
  _e as setFilterLogs,
1500
1521
  ot as titleIs,
1501
1522
  Ot as tomation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tomation",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -28,7 +28,7 @@
28
28
  "uuid": "^9.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^17.0.35",
31
+ "@types/node": "^20.19.30",
32
32
  "@types/uuid": "^9.0.2",
33
33
  "@vitest/coverage-v8": "^1.5.0",
34
34
  "@vitest/ui": "^1.5.0",