tomation 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.cjs +1 -1
- package/dist/main.d.ts +1 -14
- package/dist/main.js +1279 -1477
- package/dist/{dom → src/dom}/actions.d.ts +1 -1
- package/dist/{dsl → src/dsl}/actions.d.ts +1 -1
- package/dist/{dsl → src/dsl}/task.d.ts +1 -1
- package/dist/{dsl → src/dsl}/ui-element-filters.d.ts +1 -1
- package/dist/{dsl → src/dsl}/ui-element.d.ts +5 -5
- package/dist/{engine → src/engine}/compiler.d.ts +1 -1
- package/dist/{engine → src/engine}/runner.d.ts +2 -2
- package/dist/src/main.d.ts +13 -0
- package/package.json +13 -17
- /package/dist/{dsl → src/dsl}/test.d.ts +0 -0
- /package/dist/{engine → src/engine}/events.d.ts +0 -0
- /package/dist/{feedback → src/feedback}/logger.d.ts +0 -0
- /package/dist/{feedback → src/feedback}/ui-utils.d.ts +0 -0
- /package/dist/{tomation.d.ts → src/tomation.d.ts} +0 -0
- /package/dist/{utils → src/utils}/date-utils.d.ts +0 -0
package/dist/main.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var re=Object.defineProperty;var ae=(e,t,n)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var r=(e,t,n)=>(ae(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ce=e=>t=>t.className==e,le=e=>t=>t.className.split(" ").includes(e),ue=e=>t=>{var s;return((s=t.textContent)==null?void 0:s.trim())==e},he=e=>t=>t.innerText.trim().includes(e),de=e=>t=>t.title==e,pe=e=>t=>t.placeholder===e,me=()=>(e,t)=>t===0,ge=e=>(t,n)=>n===e,ye=e=>t=>(t==null?void 0:t.firstChild).innerText.trim()===e,Ee=e=>(t,n)=>e.every((o,i)=>o(t,n));class G{constructor(t,n,s,o){r(this,"name");r(this,"selector");r(this,"parent");r(this,"postProcess");this.name=t,this.selector=n,this.parent=s||null,this.postProcess=o}getElementName(){let t="";return this.parent&&(t=" in "+this.parent.getElementName()),`${this.name}${t}`}}let M;const we=e=>{M=e},Q=(e,t)=>(s=M,o)=>{s=s||M,console.log("Searching elem from Root = ",s);const i=[];s.querySelectorAll(e).forEach(c=>{c.style.display!=="none"&&i.push(c)});let a;return t?(console.log("Applying filter ",t),console.log(" -- to "+i.length+"elements: ",i),a=i.filter((c,g,E)=>{console.log("Apply filter to item "+g+": ",c);const w=t(c,g,E);return console.log(` -> Item ${g} ${w?"Match":"Discarded"}`),w})[0]):a=i[0],a&&o&&(console.log("Apply post process to = ",a),a=o(a)),console.log("Return elem = ",a),a},U=(e,t,n)=>({as:s=>new G(s,e,t,n)}),Ae=(e,t)=>({...U(e,t),postProcess:n=>({...U(e,t,n)})}),Z=e=>({...U(e,null),childOf:t=>({...Ae(e,t)}),postProcess:t=>({...U(e,null,t)})}),v=e=>({where:t=>Z(Q(e,t))}),fe=v("div"),xe=v("button"),Te=v("input"),Se=v("textarea"),Ce=e=>Z(Q("#"+e)),ke=e=>v(e),Ie={DIV:fe,BUTTON:xe,INPUT:Te,TEXTAREA:Se,ELEMENT:ke,identifiedBy:Ce};var h=(e=>(e.ACTION_UPDATE="tomation-action-update",e.SAVE_VALUE="tomation-save-value",e.REGISTER_TEST="tomation-register-test",e.TEST_STARTED="tomation-test-started",e.TEST_PASSED="tomation-test-passed",e.TEST_FAILED="tomation-test-failed",e.TEST_END="tomation-test-end",e.TEST_STOP="tomation-test-stop",e.TEST_PAUSE="tomation-test-pause",e.TEST_PLAY="tomation-test-play",e.USER_ACCEPT="tomation-user-accept",e.USER_REJECT="tomation-user-reject",e.SESSION_INIT="tomation-session-init",e.URL_MISMATCH="tomation-url-mismatch",e.SESSION_CONNECTED="tomation-session-connected",e))(h||{});class Ne{constructor(){r(this,"events");this.events=new Map}on(t,n){var s;this.events.has(t)||this.events.set(t,[]),(s=this.events.get(t))==null||s.push(n)}off(t,n){var s;this.events.has(t)&&this.events.set(t,((s=this.events.get(t))==null?void 0:s.filter(o=>o!==n))||[])}dispatch(t,n){var s;this.events.has(t)&&((s=this.events.get(t))==null||s.forEach(o=>{console.log(`Dispatch Event ${t}:`,n),o(n)}))}}const d=new Ne;let N=!1;const l={setEnabled(e){N=e},log(...e){N&&console.log("[tomation]",...e)},groupCollapsed(...e){N&&console.groupCollapsed("[tomation]",...e)},groupEnd(){N&&console.groupEnd()},error(...e){N&&console.error("[tomation]",...e)}},A=(e=2e3)=>new Promise(t=>{setTimeout(()=>{t(null)},e)}),x=(e,t)=>{Object.entries(t).map(([s,o])=>({key:s,value:o})).forEach(s=>{const{key:o,value:i}=s;e.style[o]=i})};class ve{constructor(t){r(this,"window");r(this,"document");r(this,"devToolsMessageContainer");r(this,"devToolsCheckElementContainer");r(this,"darkLayerLeft");r(this,"darkLayerTop");r(this,"darkLayerRight");r(this,"darkLayerBottom");r(this,"currentCheckElem");r(this,"contextViewerContainer");r(this,"devToolsAlertContainer");this.document=t.document,this.window=t,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(t,n){const s=this.document.createElement(t);return n&&(n.id&&(s.id=n==null?void 0:n.id),n.styles&&x(s,n.styles),n.parent&&n.parent.appendChild(s)),s}async logAction(t){const n=exports.AutomationInstance.document.createElement("DIV");n.innerText=t,x(n,{padding:"3px 10px",opacity:"1",transition:"opacity 1s"}),this.devToolsMessageContainer.appendChild(n),await A(4e3),n.style.opacity="0",await A(4e3),this.devToolsMessageContainer.removeChild(n),await A(1e3)}async checkElement(t,n){if(!t)return;const s=t.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 A(200)}async showAlert(t){const n=exports.AutomationInstance.document.createElement("DIV"),s=exports.AutomationInstance.document.body;n.innerText=t,x(s,{paddingTop:"30px"}),x(this.devToolsAlertContainer,{display:"flex"}),this.devToolsAlertContainer.appendChild(n)}async hideAlert(){x(this.devToolsAlertContainer,{display:"none"});const t=exports.AutomationInstance.document.body;x(t,{paddingTop:"0"}),this.devToolsAlertContainer.firstChild&&this.devToolsAlertContainer.removeChild(this.devToolsAlertContainer.firstChild)}async hideCheckElementContainer(){this.devToolsCheckElementContainer.style.opacity="0",await A(200),this.devToolsCheckElementContainer.style.display="none"}displayContext(t){x(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",x(n,{flex:"50%",width:"100%",height:"auto",border:"2px solid orange"});const s=this.document.createElement("DIV");s.id="context-viewer-after",x(s,{flex:"50%",width:"100%",height:"auto",border:"2px solid green"});const o=this.document.createElement("DIV");o.innerHTML=t.beforeHTML,j(o,t.beforeInputValues);const i=this.document.createElement("DIV");i.innerHTML=t.afterHTML,j(i,t.afterInputValues),this.contextViewerContainer.appendChild(n),n.appendChild(o),setTimeout(()=>{this.contextViewerContainer.removeChild(n),this.contextViewerContainer.appendChild(s),s.appendChild(i),setTimeout(()=>{this.contextViewerContainer.removeChild(s),x(this.contextViewerContainer,{display:"none"})},2e3)},2e3)}}const j=(e,t)=>{e.querySelectorAll("input").forEach(n=>{const s=n.getAttribute("input-id")||"";n.value=t[s]})};var H=(e=>(e[e.SLOW=2e3]="SLOW",e[e.NORMAL=1e3]="NORMAL",e[e.FAST=200]="FAST",e))(H||{});class be{constructor(t){r(this,"_document");r(this,"debug");r(this,"_uiUtils");r(this,"speed");r(this,"status");r(this,"runMode");r(this,"currentActionCallback");r(this,"currentAction");this._document=t.document,this.debug=!0,this._uiUtils=new ve(t),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",d.dispatch(h.TEST_PAUSE)}continue(){l.log("Continue Test"),this.status="Playing",this.runMode="Normal",d.dispatch(h.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",d.dispatch(h.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),d.dispatch(h.TEST_STOP)}retryAction(){l.log("Retry current step"),this.status="Playing",d.dispatch(h.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=_.SKIPPED,l.log("Skip: Marked current action as SKIPPED"),y.notifyActionUpdated(this.currentAction),l.log("Skip: Executing current action callback"),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}saveCurrentAction(t,n){l.log("Save current action"),this.currentActionCallback=t,this.currentAction=n}setDebug(t){l.setEnabled(t)}}exports.AutomationInstance=void 0;const F=(e,t)=>(exports.AutomationInstance=new be(e),we(exports.AutomationInstance.document),t==null||t.forEach(n=>n()),exports.AutomationInstance);let O=!1;async function De(e){if(O)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.");O=!0,exports.AutomationInstance.status="Playing",exports.AutomationInstance.runMode="Normal",l.groupCollapsed("Start Action: ",e.getDescription()),d.dispatch(h.TEST_STARTED,{action:e==null?void 0:e.getJSON()});try{await(e==null?void 0:e.execute()),d.dispatch(h.TEST_PASSED,{id:e.name})}catch(t){throw d.dispatch(h.TEST_FAILED,{id:e.name}),exports.AutomationInstance.uiUtils.hideCheckElementContainer(),l.error(`🤖 Error running task ${e.getDescription()}. Reason: ${t.message}`),t}finally{l.groupEnd(),O=!1,d.dispatch(h.TEST_END,{action:e==null?void 0:e.getJSON()})}}const W={start:De,get running(){return O}};let D;const Oe=new Uint8Array(16);function Pe(){if(!D&&(D=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!D))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return D(Oe)}const m=[];for(let e=0;e<256;++e)m.push((e+256).toString(16).slice(1));function Le(e,t=0){return(m[e[t+0]]+m[e[t+1]]+m[e[t+2]]+m[e[t+3]]+"-"+m[e[t+4]]+m[e[t+5]]+"-"+m[e[t+6]]+m[e[t+7]]+"-"+m[e[t+8]]+m[e[t+9]]+"-"+m[e[t+10]]+m[e[t+11]]+m[e[t+12]]+m[e[t+13]]+m[e[t+14]]+m[e[t+15]]).toLowerCase()}const Ue=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),X={randomUUID:Ue};function Y(e,t,n){if(X.randomUUID&&!t&&!e)return X.randomUUID();e=e||{};const s=e.random||(e.rng||Pe)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,t){n=n||0;for(let o=0;o<16;++o)t[n+o]=s[o];return t}return Le(s)}const q=null,P=async(e,t,n,s=1e3,o=0,i=10,a=!1)=>{if(console.log("Automation Status: ",exports.AutomationInstance.status),exports.AutomationInstance.isPaused)return new Promise((c,g)=>{exports.AutomationInstance.saveCurrentAction(async E=>{if(E.status=="skipped")return c(null);try{const w=await P(E,t,n,s,o,i,a);c(w)}catch(w){g(w)}},e)});if(exports.AutomationInstance.isStopped)throw new Error("Test stopped manually");if(console.groupCollapsed(`tries ${o}/${i}`),e&&(e.updateTries(o),await y.notifyActionUpdated(e)),o===i)throw console.groupEnd(),a?new Error(`UI Element ${t.getElementName()||"UNKNOWN"} still present after 10 tries`):new Error(`UI Element ${t.getElementName()||"UNKNOWN"} not found after 10 tries`);{const c=t.selector(n,t.postProcess);return console.groupEnd(),c?a?(await A(s),await P(e,t,n,s,++o,i,a)):(console.log("Element found = ",c),c):a?(console.log("Element removed."),q):(await A(s),await P(e,t,n,s,++o,i,a))}},$=async(e,t,n=1e3,s=10,o=!1)=>{const i=t==null?void 0:t.getElementName();console.group("Looking for Element: "+i);let a=null;if(t.parent)try{console.groupCollapsed("Look for Parent ",t.parent.getElementName()),a=await $(e,t.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(),q;throw console.groupEnd(),c}try{console.log("Using parent element: ",a);const c=await P(e,t,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(),q;throw console.groupEnd(),c}};var _=(e=>(e.WAITING="waiting",e.RUNNING="running",e.STOPPED="stopped",e.PAUSED="paused",e.SUCCESS="success",e.ERROR="error",e.SKIPPED="skipped",e))(_||{});class y{constructor(){r(this,"status");r(this,"error");r(this,"id");r(this,"context");this.status="waiting",this.error="",this.id=Y(),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 t={};return exports.AutomationInstance.document.querySelectorAll("input").forEach((s,o)=>{const i=`value-id-${o}`;s.setAttribute("input-id",i),t[i]=s.value}),t}async execute(){try{this.status="running",this.context.beforeInputValues=this.getInputValuesFromPage(),this.context.beforeHTML=exports.AutomationInstance.document.body.innerHTML,await y.notifyActionUpdated(this),console.log("Action: ",this.getDescription()),await this.executeAction(),this.status="success",this.error="",exports.AutomationInstance.isStepByStepMode&&exports.AutomationInstance.pause()}catch(t){if(this.status="error",this.error=t.message,t.message=="Test stopped manually")throw Error("Error in Action "+this.getDescription()+". Message: "+t.message);this.status="paused",exports.AutomationInstance.pause()}finally{this.context.afterInputValues=this.getInputValuesFromPage(),this.context.afterHTML=exports.AutomationInstance.document.body.innerHTML,await y.notifyActionUpdated(this)}}static async notifyActionUpdated(t){d.dispatch(h.ACTION_UPDATE,{action:t.getJSON()})}}class ee extends y{constructor(n,s){super();r(this,"name");r(this,"stepsFn");r(this,"steps");r(this,"params");r(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(i){s(i)}},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 A(exports.AutomationInstance.speed),await n.execute(),!exports.AutomationInstance.isPaused)this.index++,await this.continue();else return new Promise((s,o)=>{exports.AutomationInstance.saveCurrentAction(async i=>{if(i.status=="skipped")return this.index++,await y.notifyActionUpdated(n),await this.continue(),s();try{await i.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 p extends y{constructor(n){super();r(this,"uiElement");r(this,"element");r(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,i=10,a=!1){const c=s.getElementName();return new Promise(async(g,E)=>{var K;const w=async(f,b=1e3,k=0,I=!1)=>{if(console.groupCollapsed(`tries ${k}/${i}`),n.updateTries(k),await y.notifyActionUpdated(n),k===i)throw console.groupEnd(),I?new Error(`UI Element ${c||"UNKNOWN"} still present after 10 tries`):new Error(`UI Element ${c||"UNKNOWN"} not found after 10 tries`);{const V=s.selector(f,s.postProcess);return console.groupEnd(),V?I?(await A(b),await w(f,b,++k,I)):(console.log("Element found = ",V),V):I?(console.log("Element removed."),null):(await A(b),await w(f,b,++k,I))}};console.group("[Action On Element] Looking for Element: "+c);let T=null,S=!0;if(s.parent){console.groupCollapsed("Look for Parent ",s.parent.getElementName());try{T=await p.waitForElement(n,s.parent,o,i,a)}catch{S=!1}finally{console.groupEnd()}}if(S){console.log("using parent element: ",T);try{const f=await w(T,o,0,a);console.groupEnd(),g(f)}catch(f){console.groupEnd(),E(new Error(f.message))}}else console.groupEnd(),E(new Error(`Parent ${(K=s.parent)==null?void 0:K.getElementName()} of UI Element ${s.name||"UNKNOWN"} not found`))})}async executeAction(){var n;try{this.element=await $(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 Re extends p{constructor(t){super(t)}executeActionOnElement(){var t;return(t=this.element)==null?void 0:t.click()}getDescription(){return"Click in "+this.getElementName()}getJSON(){return{...super.getJSON(),type:"Click"}}}class $e extends p{constructor(n,s){super(n);r(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 p{constructor(n,s){super(n);r(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 p{constructor(n,s){super(n);r(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 p{constructor(t){super(t)}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 p{constructor(t){super(t)}async executeAction(){var t;try{this.element=await $(this,this.uiElement,1e3,5,!0),(t=this.element)==null||t.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 p{constructor(n,s){super(n);r(this,"value");this.value=s}executeActionOnElement(){var s,o,i,a;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((i=this.element)==null?void 0:i.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 te extends p{constructor(n,s){super(n);r(this,"value");this.value=s}executeActionOnElement(){var s,o,i,a;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((i=this.element)==null?void 0:i.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 p{constructor(n,s){super(n);r(this,"value");this.value=s}executeActionOnElement(){var s,o,i,a;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((i=this.element)==null?void 0:i.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 qe extends p{constructor(t){super(t)}executeActionOnElement(){var t;(t=this.element)==null||t.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 Be extends p{constructor(t){super(t)}executeActionOnElement(){var t;(t=this.element)==null||t.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 p{constructor(t){super(t)}executeActionOnElement(){var t;(t=this.element)==null||t.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 _e extends p{constructor(t){super(t)}executeActionOnElement(){var t;(t=this.element)==null||t.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=(e=>(e.ESCAPE="Escape",e.ENTER="Enter",e.TAB="Tab",e.ARROW_DOWN="ArrowDown",e.ARROW_UP="ArrowUp",e.ARROW_LEFT="ArrowLeft",e.ARROW_RIGHT="ArrowRight",e.BACKSPACE="Backspace",e.DELETE="Delete",e.SHIFT="Shift",e.CONTROL="Control",e.ALT="Alt",e.META="Meta",e))(ne||{});const z={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 je extends p{constructor(n,s){super(n);r(this,"key");this.key=s}executeActionOnElement(){var n;(n=this.element)==null||n.dispatchEvent(new KeyboardEvent("keydown",{key:this.key,code:this.key,keyCode:z[this.key],charCode:0,which:z[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 Xe extends p{constructor(n,s){super(n);r(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 i(c){var g;return c!=null&&c.parentElement?((g=c.parentElement)==null?void 0:g.tagName.toLowerCase())==="form"?c.parentElement:i(c.parentElement):null}const a=i(n);a&&a.dispatchEvent(new Event("change"))}getDescription(){return`Upload file in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:"UploadFile"}}}class ze extends p{constructor(n,s){super(n);r(this,"memorySlotName");this.memorySlotName=s}executeActionOnElement(){var s,o,i,a;let n=this.element;if(((s=this.element)==null?void 0:s.tagName)!=="INPUT"&&((o=this.element)==null?void 0:o.tagName)!=="SELECT"&&((i=this.element)==null?void 0:i.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());d.dispatch(h.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 Ge extends y{constructor(n){super();r(this,"miliseconds");this.miliseconds=n}getDescription(){return"Wait "+this.miliseconds+" miliseconds"}getJSON(){return{...super.getJSON(),type:"Wait"}}async executeAction(){await A(this.miliseconds)}resetAction(){}}class Qe extends y{constructor(n){super();r(this,"uiElement");r(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 $(this,this.uiElement,1e3,10,!0)}getDescription(){return"Wait until "+this.getElementName()+" is removed"}getJSON(){return{...super.getJSON(),type:"WaitUntilElementRemoved"}}}class Ze extends y{constructor(){super()}getDescription(){return"Paused"}getJSON(){return{...super.getJSON(),type:"Pause"}}async executeAction(){await exports.AutomationInstance.pause()}resetAction(){}}class Ye extends y{constructor(n){super();r(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)=>{d.on(h.USER_ACCEPT,async()=>(await exports.AutomationInstance.uiUtils.hideAlert(),n(!0))),d.on(h.USER_REJECT,async()=>(await exports.AutomationInstance.uiUtils.hideAlert(),s()))})}resetAction(){}}class et extends y{constructor(){super()}getDescription(){return"Reload page"}getJSON(){return{...super.getJSON(),type:"ReloadPage"}}async executeAction(){await location.reload()}resetAction(){}}let C,B;const tt=e=>{const t=C;C=e,e.compileSteps(),C=t},nt=e=>{l.log("Add action: ",e.getDescription()),C.addStep(e)},st=e=>{C=e,B=!0,l.groupCollapsed("Compile: "+e.getDescription()),e.compileSteps(),B=!1,l.log("Compilation finished"),l.groupEnd()},ot=()=>C,it=()=>B,u={init:st,addAction:nt,compileAction:tt,getCurrentAction:ot,getIsCompiling:it},L={},rt=e=>{if(L[e])L[e]();else throw console.log("Available Tests:",Object.keys(L)),new Error(`Test with id ${e} not found.`)},at=(e,t)=>{console.log(`Registering Test: ${e}...`);const n=new ee(e,t);u.init(n),console.log(`Compiled Test: ${e}`),d.dispatch(h.REGISTER_TEST,{id:e,action:n.getJSON()}),console.log(`Registered Test: ${e} in TestsMap`),L[e]=()=>{W.start(n)}};function se(e){const{matches:t,tests:n=[],speed:s="NORMAL",debug:o=!1}=e,i=Y();if(console.log(`[tomation] Initializing on URL: ${document.location.href} with session ID: ${i}`),window.postMessage({message:"injectedScript-to-contentScript",sender:"tomation",payload:{cmd:h.SESSION_INIT,params:{sessionId:i}}}),!(typeof t=="string"?document.location.href.includes(t):!!document.location.href.match(t))){console.log(`[tomation] URL "${document.location.href}" does not match "${t}"`),window.postMessage({message:"injectedScript-to-contentScript",sender:"tomation",payload:{cmd:h.URL_MISMATCH,params:{sessionId:i,matches:t,url:document.location.href}}});return}try{console.log("[tomation] Setting up messaging bridge with extension..."),Object.values(h).forEach(c=>{console.log(`[tomation] Setting up listener for event "${c}"`),d.on(c,g=>{const E={cmd:c,params:{...g,sessionId:i}};console.log(`[tomation] Dispatching event "${c}" to extension: `,E),window.postMessage({message:"injectedScript-to-contentScript",sender:"tomation",payload:E})})}),window.addEventListener("message",c=>{try{console.log("[tomation] Received message from extension:",c.data);const{message:g,sender:E,payload:w}=c.data||{},{cmd:T,params:S}=w||{};if(E!=="web-extension")return;if(g==="contentScript-to-injectedScript"){const f={"run-test-request":()=>rt(S==null?void 0:S.testId),"reload-tests-request":()=>F(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":()=>d.dispatch(h.USER_ACCEPT),"user-reject-request":()=>d.dispatch(h.USER_REJECT)}[T];f?(console.log(`[tomation] Executing command "${T}" from extension`),f()):console.warn(`[tomation] Unknown command "${T}" from extension`);return}}catch(g){console.error("[tomation] Error handling message from extension:",g)}}),F(window,n),exports.AutomationInstance.setDebug(o),exports.AutomationInstance.speed=H[s],window.postMessage({message:"injectedScript-to-contentScript",sender:"tomation",payload:{cmd:h.SESSION_CONNECTED,params:{speed:exports.AutomationInstance.speed,sessionId:i}}}),console.log("[tomation] Ready ✓")}catch(c){console.error("[tomation] Initialization failed:",c)}}const ct=(e,t)=>async n=>{const s=new ee(e,t);if(s.setParams(n),!W.running&&!u.getIsCompiling())try{l.log(`Compilation of Task ${e} starts...`),u.init(s),l.log(`Compilation of Task ${e} Finished.`),l.log(`Start running Task ${e}...`),await W.start(s),l.log(`End of Task ${e}: SUCCESS`)}catch(o){l.error("Error running task "+e+". "+o.message)}else l.log(`Adding action ${e} to compilation stack`),u.addAction(s),u.compileAction(s)},lt=e=>{const t=new Re(e);u.addAction(t)},ut=e=>({textIs:t=>{u.addAction(new $e(e,t))},containsText:t=>{u.addAction(new Je(e,t))},valueIs:t=>{u.addAction(new Ke(e,t))},exists:()=>{u.addAction(new Ve(e))},notExists:()=>{u.addAction(new Me(e))}}),ht=e=>({in:t=>{const n=new Fe(t,e);u.addAction(n)}}),dt=e=>({in:t=>{const n=new te(t,e);u.addAction(n)}}),pt=()=>({in:e=>{const t=new te(e,"");u.addAction(t)}}),mt=()=>({in:e=>{u.addAction(new qe(e))}}),gt=()=>({in:e=>{u.addAction(new Be(e))}}),yt=()=>({in:e=>{u.addAction(new He(e))}}),Et=()=>({in:e=>{u.addAction(new _e(e))}}),wt=e=>({in:t=>{u.addAction(new je(t,e))}}),At=e=>({in:t=>{const n=new We(t,e);u.addAction(n)}}),ft=e=>({in:t=>{const n=new Xe(t,e);u.addAction(n)}}),xt=e=>({in:t=>{const n=new ze(e,t);u.addAction(n)}}),oe=e=>{u.addAction(new Ge(e))};oe.untilElement=e=>({isRemoved:()=>{u.addAction(new Qe(e))}});const Tt=()=>{u.addAction(new Ze)},St=e=>{u.addAction(new Ye(e))},Ct=()=>{u.addAction(new et)},R=e=>e.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}),J=e=>{const t=new Date;return R(new Date(t.setDate(t.getDate()+e)))},ie=e=>{const t=new Date;return R(new Date(t.setMonth(t.getMonth()+e)))},kt=J(1),It=J(-1),Nt=J(7),vt=J(-7),bt=ie(1),Dt=ie(-1),Ot={formatDate:R,today:R(new Date),tomorrow:kt,nextWeek:Nt,nextMonth:bt,yesterday:It,lastWeek:vt,lastMonth:Dt};exports.ACTION_STATUS=_;exports.Assert=ut;exports.AutomationEvents=d;exports.ClearValue=pt;exports.Click=lt;exports.DateUtils=Ot;exports.EVENT_NAMES=h;exports.KEY_MAP=ne;exports.ManualTask=St;exports.Pause=Tt;exports.PressDownKey=gt;exports.PressEnterKey=Et;exports.PressEscKey=mt;exports.PressKey=wt;exports.PressTabKey=yt;exports.ReloadPage=Ct;exports.SaveValue=xt;exports.Select=ht;exports.Setup=F;exports.Task=ct;exports.Test=at;exports.TestSpeed=H;exports.Type=dt;exports.TypePassword=At;exports.UIElement=G;exports.UploadFile=ft;exports.Wait=oe;exports.and=Ee;exports.classIncludes=le;exports.classIs=ce;exports.default=se;exports.elementIndexIs=ge;exports.firstChildTextIs=ye;exports.innerTextContains=he;exports.innerTextIs=ue;exports.is=Ie;exports.isFirstElement=me;exports.placeholderIs=pe;exports.titleIs=de;exports.tomation=se;exports.wait=A;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=!1,t=(...t)=>{e&&console.log(`[UIElement Filter]`,...t)},n=e=>n=>{let r=n.className==e;return t(`classIs('${e}') on`,n,`=>`,r),r},r=e=>n=>{let r=n.className.split(` `).includes(e);return t(`classIncludes('${e}') on`,n,`=>`,r),r},i=e=>n=>{let r=n.textContent?.trim()==e;return t(`innerTextIs('${e}') on`,n,`=>`,r),r},a=e=>n=>{let r=n.innerText.trim().includes(e);return t(`innerTextContains('${e}') on`,n,`=>`,r),r},o=e=>n=>{let r=n.title==e;return t(`titleIs('${e}') on`,n,`=>`,r),r},s=e=>n=>{let r=n.placeholder===e;return t(`placeholderIs('${e}') on`,n,`=>`,r),r},c=()=>(e,n)=>{let r=n===0;return t(`isFirstElement on`,e,`index`,n,`=>`,r),r},l=e=>(n,r)=>{let i=r===e;return t(`elementIndexIs(${e}) on`,n,`elemIndex`,r,`=>`,i),i},u=e=>n=>{let r=(n?.firstChild).innerText.trim()===e;return t(`firstChildTextIs('${e}') on`,n,`=>`,r),r},d=e=>(n,r)=>{let i=e.every((e,i)=>{let a=e(n,r);return t(`and condition[${i}] on`,n,`elemIndex`,r,`=>`,a),a});return t(`and final result on`,n,`elemIndex`,r,`=>`,i),i},f=class{name;selector;parent;postProcess;constructor(e,t,n,r){this.name=e,this.selector=t,this.parent=n||null,this.postProcess=r}getElementName(){let e=``;return this.parent&&(e=` in `+this.parent.getElementName()),`${this.name}${e}`}},p,ee=e=>{p=e},m=(e,t)=>(n=p,r)=>{n||=p,console.log(`Searching elem from Root = `,n);let i=[];n.querySelectorAll(e).forEach(e=>{e.style.display!==`none`&&i.push(e)});let a;return t?(console.log(`Applying filter `,t),console.log(` -- to `+i.length+`elements: `,i),a=i.filter((e,n,r)=>{console.log(`Apply filter to item `+n+`: `,e);let i=t(e,n,r);return console.log(` -> Item ${n} ${i?`Match`:`Discarded`}`),i})[0]):a=i[0],a&&r&&(console.log(`Apply post process to = `,a),a=r(a)),console.log(`Return elem = `,a),a},h=(e,t,n)=>({as:r=>new f(r,e,t,n)}),te=(e,t)=>({...h(e,t),postProcess:n=>({...h(e,t,n)})}),g=e=>({...h(e,null),childOf:t=>({...te(e,t)}),postProcess:t=>({...h(e,null,t)})}),_=e=>({where:t=>g(m(e,t))}),ne={DIV:_(`div`),BUTTON:_(`button`),INPUT:_(`input`),TEXTAREA:_(`textarea`),ELEMENT:e=>_(e),identifiedBy:e=>g(m(`#`+e))},v=function(e){return e.ACTION_UPDATE=`tomation-action-update`,e.SAVE_VALUE=`tomation-save-value`,e.REGISTER_TEST=`tomation-register-test`,e.TEST_STARTED=`tomation-test-started`,e.TEST_PASSED=`tomation-test-passed`,e.TEST_FAILED=`tomation-test-failed`,e.TEST_END=`tomation-test-end`,e.TEST_STOP=`tomation-test-stop`,e.TEST_PAUSE=`tomation-test-pause`,e.TEST_PLAY=`tomation-test-play`,e.USER_ACCEPT=`tomation-user-accept`,e.USER_REJECT=`tomation-user-reject`,e.SESSION_INIT=`tomation-session-init`,e.URL_MISMATCH=`tomation-url-mismatch`,e.SESSION_CONNECTED=`tomation-session-connected`,e}(v||{}),y=new class{events;constructor(){this.events=new Map}on(e,t){this.events.has(e)||this.events.set(e,[]),this.events.get(e)?.push(t)}off(e,t){this.events.has(e)&&this.events.set(e,this.events.get(e)?.filter(e=>e!==t)||[])}dispatch(e,t){this.events.has(e)&&this.events.get(e)?.forEach(n=>{console.log(`Dispatch Event ${e}:`,t),n(t)})}},b=!1,x={setEnabled(e){b=e},log(...e){b&&console.log(`[tomation]`,...e)},groupCollapsed(...e){b&&console.groupCollapsed(`[tomation]`,...e)},groupEnd(){b&&console.groupEnd()},error(...e){b&&console.error(`[tomation]`,...e)}},S=(e=2e3)=>new Promise(t=>{setTimeout(()=>{t(null)},e)}),C=(e,t)=>{Object.entries(t).map(([e,t])=>({key:e,value:t})).forEach(t=>{let{key:n,value:r}=t;e.style[n]=r})},re=class{window;document;devToolsMessageContainer;devToolsCheckElementContainer;darkLayerLeft;darkLayerTop;darkLayerRight;darkLayerBottom;currentCheckElem;contextViewerContainer;devToolsAlertContainer;constructor(e){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});let t={zIndex:`9991`,backgroundColor:`rgba(0,0,0,0.3)`,position:`absolute`};this.darkLayerLeft=this.createElement(`DIV`,{id:`dark-layer-left`,styles:t,parent:this.devToolsCheckElementContainer}),this.darkLayerTop=this.createElement(`DIV`,{id:`dark-layer-top`,styles:t,parent:this.devToolsCheckElementContainer}),this.darkLayerRight=this.createElement(`DIV`,{id:`dark-layer-right`,styles:t,parent:this.devToolsCheckElementContainer}),this.darkLayerBottom=this.createElement(`DIV`,{id:`dark-layer-bottom`,styles:t,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,t){let n=this.document.createElement(e);return t&&(t.id&&(n.id=t?.id),t.styles&&C(n,t.styles),t.parent&&t.parent.appendChild(n)),n}async logAction(e){let t=O.document.createElement(`DIV`);t.innerText=e,C(t,{padding:`3px 10px`,opacity:`1`,transition:`opacity 1s`}),this.devToolsMessageContainer.appendChild(t),await S(4e3),t.style.opacity=`0`,await S(4e3),this.devToolsMessageContainer.removeChild(t),await S(1e3)}async checkElement(e,t){if(!e)return;let n=e.getBoundingClientRect(),r=this.document.body.getBoundingClientRect();this.darkLayerLeft.style.left=`0px`,this.darkLayerLeft.style.top=n.top+`px`,this.darkLayerLeft.style.width=this.window.scrollX+n.left+`px`,this.darkLayerLeft.style.height=n.height+`px`,this.darkLayerTop.style.left=this.window.scrollX+`px`,this.darkLayerTop.style.top=`0px`,this.darkLayerTop.style.width=`100%`,this.darkLayerTop.style.height=n.top+`px`,this.darkLayerRight.style.left=this.window.scrollX+n.left+n.width+`px`,this.darkLayerRight.style.top=n.top+`px`,this.darkLayerRight.style.width=r.width-(n.left+n.width)+`px`,this.darkLayerRight.style.height=n.height+`px`,this.darkLayerBottom.style.left=this.window.scrollX+`px`,this.darkLayerBottom.style.top=n.top+n.height+`px`,this.darkLayerBottom.style.width=`100%`,this.darkLayerBottom.style.height=r.height-(n.top+n.height)+`px`,this.currentCheckElem.id=`dev-tools-current-check-elem-${t}`,this.currentCheckElem.style.top=n.top+`px`,this.currentCheckElem.style.left=this.window.scrollX+n.left+`px`,this.currentCheckElem.style.height=n.height+`px`,this.currentCheckElem.style.width=n.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 S(200)}async showAlert(e){let t=O.document.createElement(`DIV`),n=O.document.body;t.innerText=e,C(n,{paddingTop:`30px`}),C(this.devToolsAlertContainer,{display:`flex`}),this.devToolsAlertContainer.appendChild(t)}async hideAlert(){C(this.devToolsAlertContainer,{display:`none`});let e=O.document.body;C(e,{paddingTop:`0`}),this.devToolsAlertContainer.firstChild&&this.devToolsAlertContainer.removeChild(this.devToolsAlertContainer.firstChild)}async hideCheckElementContainer(){this.devToolsCheckElementContainer.style.opacity=`0`,await S(200),this.devToolsCheckElementContainer.style.display=`none`}displayContext(e){C(this.contextViewerContainer,{display:`flex`,"background-color":`white`,position:`absolute`,top:`0px`,left:`0px`,"z-index":`9999`});let t=this.document.createElement(`DIV`);t.id=`context-viewer-before`,C(t,{flex:`50%`,width:`100%`,height:`auto`,border:`2px solid orange`});let n=this.document.createElement(`DIV`);n.id=`context-viewer-after`,C(n,{flex:`50%`,width:`100%`,height:`auto`,border:`2px solid green`});let r=this.document.createElement(`DIV`);r.innerHTML=e.beforeHTML,w(r,e.beforeInputValues);let i=this.document.createElement(`DIV`);i.innerHTML=e.afterHTML,w(i,e.afterInputValues),this.contextViewerContainer.appendChild(t),t.appendChild(r),setTimeout(()=>{this.contextViewerContainer.removeChild(t),this.contextViewerContainer.appendChild(n),n.appendChild(i),setTimeout(()=>{this.contextViewerContainer.removeChild(n),C(this.contextViewerContainer,{display:`none`})},2e3)},2e3)}},w=(e,t)=>{e.querySelectorAll(`input`).forEach(e=>{e.value=t[e.getAttribute(`input-id`)||``]})},T=function(e){return e[e.SLOW=2e3]=`SLOW`,e[e.NORMAL=1e3]=`NORMAL`,e[e.FAST=200]=`FAST`,e}(T||{}),E=function(e){return e.PLAYING=`Playing`,e.STOPPED=`Stopped`,e.PAUSED=`Paused`,e}(E||{}),D=function(e){return e.NORMAL=`Normal`,e.STEPBYSTEP=`Step By Step`,e}(D||{}),ie=class{_document;debug;_uiUtils;speed;status;runMode;currentActionCallback;currentAction;constructor(e){this._document=e.document,this.debug=!0,this._uiUtils=new re(e),this.speed=T.NORMAL,this.status=E.STOPPED,this.runMode=D.NORMAL}get document(){return this._document}get uiUtils(){return this._uiUtils}get isStepByStepMode(){return this.runMode==D.STEPBYSTEP}get isStopped(){return this.status==E.STOPPED}get isPlaying(){return this.status==E.PLAYING}get isPaused(){return this.status==E.PAUSED}pause(){x.log(`Pause Test`),this.status=E.PAUSED,y.dispatch(v.TEST_PAUSE)}continue(){x.log(`Continue Test`),this.status=E.PLAYING,this.runMode=D.NORMAL,y.dispatch(v.TEST_PLAY),this.currentActionCallback&&this.currentAction&&(x.log(`Continue: Executing current action callback`),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}next(){x.log(`Continue Test to Next Step...`),this.status=E.PLAYING,this.runMode=D.STEPBYSTEP,y.dispatch(v.TEST_PLAY),this.currentActionCallback&&this.currentAction&&(x.log(`Next: Executing current action callback`),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}stop(){x.log(`Stop Test`),this.status=E.STOPPED,this.currentActionCallback&&this.currentAction&&(x.log(`Stop: Executing current action callback`),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0),y.dispatch(v.TEST_STOP)}retryAction(){x.log(`Retry current step`),this.status=E.PLAYING,y.dispatch(v.TEST_PLAY),this.currentActionCallback&&this.currentAction&&(this.currentAction.resetTries&&(x.log(`Retry: Resetting tries for current action`),this.currentAction.resetTries()),x.log(`Retry: Executing current action callback`),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}skipAction(){x.log(`Skip current step`),this.status=E.PLAYING,this.currentActionCallback&&this.currentAction&&(this.currentAction.status=L.SKIPPED,x.log(`Skip: Marked current action as SKIPPED`),R.notifyActionUpdated(this.currentAction),x.log(`Skip: Executing current action callback`),this.currentActionCallback(this.currentAction),this.currentActionCallback=void 0)}saveCurrentAction(e,t){x.log(`Save current action`),this.currentActionCallback=e,this.currentAction=t}setDebug(e){x.setEnabled(e)}},O,k=(e,t)=>(O=new ie(e),ee(O.document),t?.forEach(e=>e()),O),A=!1;async function ae(e){if(A)throw x.error(`Not able to run test while other test is running.`),Error(`Not able to run test while other test is running.`);A=!0,O.status=E.PLAYING,O.runMode=D.NORMAL,x.groupCollapsed(`Start Action: `,e.getDescription()),y.dispatch(v.TEST_STARTED,{action:e?.getJSON()});try{await e?.execute(),y.dispatch(v.TEST_PASSED,{id:e.name})}catch(t){throw y.dispatch(v.TEST_FAILED,{id:e.name}),O.uiUtils.hideCheckElementContainer(),x.error(`🤖 Error running task ${e.getDescription()}. Reason: ${t.message}`),t}finally{x.groupEnd(),A=!1,y.dispatch(v.TEST_END,{action:e?.getJSON()})}}var j={start:ae,get running(){return A}},M=[];for(let e=0;e<256;++e)M.push((e+256).toString(16).slice(1));function oe(e,t=0){return(M[e[t+0]]+M[e[t+1]]+M[e[t+2]]+M[e[t+3]]+`-`+M[e[t+4]]+M[e[t+5]]+`-`+M[e[t+6]]+M[e[t+7]]+`-`+M[e[t+8]]+M[e[t+9]]+`-`+M[e[t+10]]+M[e[t+11]]+M[e[t+12]]+M[e[t+13]]+M[e[t+14]]+M[e[t+15]]).toLowerCase()}var se=new Uint8Array(16);function ce(){return crypto.getRandomValues(se)}function N(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():le(e,t,n)}function le(e,t,n){e||={};let r=e.random??e.rng?.()??ce();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return oe(r)}var P=null,F=async(e,t,n,r=1e3,i=0,a=10,o=!1)=>{if(console.log(`Automation Status: `,O.status),O.isPaused)return new Promise((s,c)=>{O.saveCurrentAction(async e=>{if(e.status==L.SKIPPED)return s(null);try{s(await F(e,t,n,r,i,a,o))}catch(e){c(e)}},e)});if(O.isStopped)throw Error(`Test stopped manually`);if(console.groupCollapsed(`tries ${i}/${a}`),e&&(e.updateTries(i),await R.notifyActionUpdated(e)),i===a)throw console.groupEnd(),Error(o?`UI Element ${t.getElementName()||`UNKNOWN`} still present after 10 tries`:`UI Element ${t.getElementName()||`UNKNOWN`} not found after 10 tries`);{let s=t.selector(n,t.postProcess);return console.groupEnd(),s?o?(await S(r),await F(e,t,n,r,++i,a,o)):(console.log(`Element found = `,s),s):o?(console.log(`Element removed.`),P):(await S(r),await F(e,t,n,r,++i,a,o))}},I=async(e,t,n=1e3,r=10,i=!1)=>{let a=t?.getElementName();console.group(`Looking for Element: `+a);let o=null;if(t.parent)try{console.groupCollapsed(`Look for Parent `,t.parent.getElementName()),o=await I(e,t.parent,n,r,i),console.groupEnd()}catch(e){if(console.groupEnd(),i&&e.message.includes(`not found`))return console.log(`Parent not found, so element was removed`),console.groupEnd(),P;throw console.groupEnd(),e}try{console.log(`Using parent element: `,o);let a=await F(e,t,o,n,0,r,i);return console.groupEnd(),a}catch(e){if(i&&e.message.includes(`not found`))return console.log(`Parent not found, so element was removed`),console.groupEnd(),P;throw console.groupEnd(),e}},L=function(e){return e.WAITING=`waiting`,e.RUNNING=`running`,e.STOPPED=`stopped`,e.PAUSED=`paused`,e.SUCCESS=`success`,e.ERROR=`error`,e.SKIPPED=`skipped`,e}(L||{}),R=class e{status;error;id;context;constructor(){this.status=L.WAITING,this.error=``,this.id=N(),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=L.WAITING,this.error=``,this.resetAction()}getInputValuesFromPage(){let e={};return O.document.querySelectorAll(`input`).forEach((t,n)=>{let r=`value-id-${n}`;t.setAttribute(`input-id`,r),e[r]=t.value}),e}async execute(){try{this.status=L.RUNNING,this.context.beforeInputValues=this.getInputValuesFromPage(),this.context.beforeHTML=O.document.body.innerHTML,await e.notifyActionUpdated(this),console.log(`Action: `,this.getDescription()),await this.executeAction(),this.status=L.SUCCESS,this.error=``,O.isStepByStepMode&&O.pause()}catch(e){if(this.status=L.ERROR,this.error=e.message,e.message==`Test stopped manually`)throw Error(`Error in Action `+this.getDescription()+`. Message: `+e.message);this.status=L.PAUSED,O.pause()}finally{this.context.afterInputValues=this.getInputValuesFromPage(),this.context.afterHTML=O.document.body.innerHTML,await e.notifyActionUpdated(this)}}static async notifyActionUpdated(e){y.dispatch(v.ACTION_UPDATE,{action:e.getJSON()})}},z=class extends R{name;stepsFn;steps;params;index;constructor(e,t){super(),this.name=e,this.stepsFn=t,this.steps=[],this.index=0}getDescription(){return this.name}compileSteps(){super.reset(),this.stepsFn(this.params)}stepsToJSON(){return this.steps.reduce((e,t)=>(e.push(t.getJSON()),e),[])}getJSON(){return{...super.getJSON(),type:`Action`,params:this.params,steps:this.stepsToJSON()}}resetAction(){this.steps.length=0,this.index=0}async continue(){if(O.isPaused)return new Promise((e,t)=>{O.saveCurrentAction(async n=>{if(n.status==L.SKIPPED)return e();try{await n.continue(),e()}catch(e){t(e)}},this)});if(O.isStopped)throw Error(`Test stopped manually`);if(this.index<this.steps.length){let e=this.steps[this.index];try{if(await S(O.speed),await e.execute(),!O.isPaused)this.index++,await this.continue();else return new Promise((t,n)=>{O.saveCurrentAction(async r=>{if(r.status==L.SKIPPED)return this.index++,await R.notifyActionUpdated(e),await this.continue(),t();try{await r.continue(),t()}catch(e){n(e)}},e)})}catch(e){throw e}}}async executeAction(){this.index=0,await this.continue()}setParams(e){this.params=e}addStep(e){this.steps.push(e)}},B=class e extends R{uiElement;element;tries;constructor(e){super(),this.uiElement=e,this.element=null,this.tries=0}getElementName(){return this.uiElement?.getElementName()}updateTries(e){this.tries=e}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(t,n,r=1e3,i=10,a=!1){let o=n.getElementName();return new Promise(async(s,c)=>{let l=async(e,r=1e3,a=0,s=!1)=>{if(console.groupCollapsed(`tries ${a}/${i}`),t.updateTries(a),await R.notifyActionUpdated(t),a===i)throw console.groupEnd(),Error(s?`UI Element ${o||`UNKNOWN`} still present after 10 tries`:`UI Element ${o||`UNKNOWN`} not found after 10 tries`);{let t=n.selector(e,n.postProcess);return console.groupEnd(),t?s?(await S(r),await l(e,r,++a,s)):(console.log(`Element found = `,t),t):s?(console.log(`Element removed.`),null):(await S(r),await l(e,r,++a,s))}};console.group(`[Action On Element] Looking for Element: `+o);let u=null,d=!0;if(n.parent){console.groupCollapsed(`Look for Parent `,n.parent.getElementName());try{u=await e.waitForElement(t,n.parent,r,i,a)}catch{d=!1}finally{console.groupEnd()}}if(d){console.log(`using parent element: `,u);try{let e=await l(u,r,0,a);console.groupEnd(),s(e)}catch(e){console.groupEnd(),c(Error(e.message))}}else console.groupEnd(),c(Error(`Parent ${n.parent?.getElementName()} of UI Element ${n.name||`UNKNOWN`} not found`))})}async executeAction(){try{this.element=await I(this,this.uiElement),this.element?.setAttribute(`test-id`,this.getElementName()),await O.uiUtils.checkElement(this.element,this.getElementName()),this.executeActionOnElement(),await O.uiUtils.hideCheckElementContainer()}catch(e){throw Error(e.message)}}resetAction(){this.element=null,this.resetTries()}},ue=class extends B{constructor(e){super(e)}executeActionOnElement(){return this.element?.click()}getDescription(){return`Click in `+this.getElementName()}getJSON(){return{...super.getJSON(),type:`Click`}}},de=class extends B{text;constructor(e,t){super(e),this.text=t}executeActionOnElement(){if(this.element?.innerText!==this.text)throw 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}}},fe=class extends B{text;constructor(e,t){super(e),this.text=t}executeActionOnElement(){if(!this.element?.innerText.includes(this.text))throw 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}}},pe=class extends B{value;constructor(e,t){super(e),this.value=t}executeActionOnElement(){if(this.element.value!==this.value)throw 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}}},me=class extends B{constructor(e){super(e)}executeActionOnElement(){if(!this.element)throw Error(`Element ${this.getElementName()} doesn't exist`)}getDescription(){return`Assert that ${this.getElementName()} exists`}getJSON(){return{...super.getJSON(),type:`AssertExistsAction`}}},he=class extends B{constructor(e){super(e)}async executeAction(){try{this.element=await I(this,this.uiElement,1e3,5,!0),this.element?.setAttribute(`test-id`,this.getElementName()),await O.uiUtils.checkElement(this.element,this.getElementName()),this.executeActionOnElement(),await O.uiUtils.hideCheckElementContainer()}catch(e){throw Error(e.message)}}executeActionOnElement(){if(this.element)throw Error(`Element ${this.getElementName()} was not expected to exist`)}getDescription(){return`Assert that ${this.getElementName()} doesn't exist`}getJSON(){return{...super.getJSON(),type:`AssertNotExistsAction`}}},ge=class extends B{value;constructor(e,t){super(e),this.value=t}executeActionOnElement(){let e=this.element;if(this.element?.tagName!==`INPUT`&&this.element?.tagName!==`SELECT`&&this.element?.tagName!==`TEXTAREA`&&(e=this.element?.querySelectorAll(`input`)[0],!e))throw Error(`Input element not found. Not able to type value in element `+this.getElementName());e.value=this.value,e.dispatchEvent(new Event(`change`))}getDescription(){return`Select value '${this.value}' in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:`Select`,value:this.value}}},V=class extends B{value;constructor(e,t){super(e),this.value=t}executeActionOnElement(){let e=this.element;if(this.element?.tagName!==`INPUT`&&this.element?.tagName!==`SELECT`&&this.element?.tagName!==`TEXTAREA`&&(e=this.element?.querySelectorAll(`input`)[0],!e))throw Error(`Input element not found. Not able to type value in element `+this.getElementName());e.value=this.value,e.dispatchEvent(new Event(`change`)),e.dispatchEvent(new Event(`keyup`,{bubbles:!0})),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}getDescription(){return`Type value '${this.value}' in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:`Type`,value:this.value}}},_e=class extends B{value;constructor(e,t){super(e),this.value=t}executeActionOnElement(){let e=this.element;if(this.element?.tagName!==`INPUT`&&this.element?.tagName!==`SELECT`&&this.element?.tagName!==`TEXTAREA`&&(e=this.element?.querySelectorAll(`input`)[0],!e))throw Error(`Input element not found. Not able to type value in element `+this.getElementName());e.value=this.value,e.dispatchEvent(new Event(`change`)),e.dispatchEvent(new Event(`keyup`,{bubbles:!0})),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}getDescription(){return`Type a password in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:`TypePassword`,value:this.value}}},ve=class extends B{constructor(e){super(e)}executeActionOnElement(){this.element?.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`}}},ye=class extends B{constructor(e){super(e)}executeActionOnElement(){this.element?.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`}}},be=class extends B{constructor(e){super(e)}executeActionOnElement(){this.element?.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`}}},xe=class extends B{constructor(e){super(e)}executeActionOnElement(){this.element?.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`}}},H=function(e){return e.ESCAPE=`Escape`,e.ENTER=`Enter`,e.TAB=`Tab`,e.ARROW_DOWN=`ArrowDown`,e.ARROW_UP=`ArrowUp`,e.ARROW_LEFT=`ArrowLeft`,e.ARROW_RIGHT=`ArrowRight`,e.BACKSPACE=`Backspace`,e.DELETE=`Delete`,e.SHIFT=`Shift`,e.CONTROL=`Control`,e.ALT=`Alt`,e.META=`Meta`,e}(H||{}),U={[H.ESCAPE]:27,[H.ENTER]:13,[H.TAB]:9,[H.ARROW_DOWN]:40,[H.ARROW_UP]:38,[H.ARROW_LEFT]:37,[H.ARROW_RIGHT]:39,[H.BACKSPACE]:8,[H.DELETE]:46,[H.SHIFT]:16,[H.CONTROL]:17,[H.ALT]:18,[H.META]:91},Se=class extends B{key;constructor(e,t){super(e),this.key=t}executeActionOnElement(){this.element?.dispatchEvent(new KeyboardEvent(`keydown`,{key:this.key,code:this.key,keyCode:U[this.key],charCode:0,which:U[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}}},Ce=class extends B{file;constructor(e,t){super(e),this.file=t}executeActionOnElement(){let e=this.element,t=new DataTransfer;t.items.add(this.file),e.files=t.files,e.dispatchEvent(new Event(`change`));function n(e){return e?.parentElement?e.parentElement?.tagName.toLowerCase()===`form`?e.parentElement:n(e.parentElement):null}let r=n(e);r&&r.dispatchEvent(new Event(`change`))}getDescription(){return`Upload file in ${this.getElementName()}`}getJSON(){return{...super.getJSON(),type:`UploadFile`}}},we=class extends B{memorySlotName;constructor(e,t){super(e),this.memorySlotName=t}executeActionOnElement(){let e=this.element;if(this.element?.tagName!==`INPUT`&&this.element?.tagName!==`SELECT`&&this.element?.tagName!==`TEXTAREA`&&(e=this.element?.querySelectorAll(`input`)[0],!e))throw Error(`Input element not found. Not able to save value from element `+this.getElementName());y.dispatch(v.SAVE_VALUE,{memorySlotName:this.memorySlotName,value:e.value})}getDescription(){return`Save value of ${this.getElementName()} in ${this.memorySlotName}`}getJSON(){return{...super.getJSON(),type:`SaveValue`,memorySlotName:this.memorySlotName}}},Te=class extends R{miliseconds;constructor(e){super(),this.miliseconds=e}getDescription(){return`Wait `+this.miliseconds+` miliseconds`}getJSON(){return{...super.getJSON(),type:`Wait`}}async executeAction(){await S(this.miliseconds)}resetAction(){}},Ee=class extends R{uiElement;tries;constructor(e){super(),this.uiElement=e,this.tries=0}updateTries(e){this.tries=e}resetAction(){this.tries=0}getElementName(){return this.uiElement?.getElementName()}async executeAction(){await I(this,this.uiElement,1e3,10,!0)}getDescription(){return`Wait until `+this.getElementName()+` is removed`}getJSON(){return{...super.getJSON(),type:`WaitUntilElementRemoved`}}},De=class extends R{constructor(){super()}getDescription(){return`Paused`}getJSON(){return{...super.getJSON(),type:`Pause`}}async executeAction(){await O.pause()}resetAction(){}},Oe=class extends R{description;constructor(e){super(),this.description=e}getDescription(){return`Manual Step: `+this.description}getJSON(){return{...super.getJSON(),type:`ManualStep`}}async executeAction(){return await O.uiUtils.showAlert(`Waiting manual step...`),new Promise((e,t)=>{y.on(v.USER_ACCEPT,async()=>(await O.uiUtils.hideAlert(),e(!0))),y.on(v.USER_REJECT,async()=>(await O.uiUtils.hideAlert(),t()))})}resetAction(){}},ke=class extends R{constructor(){super()}getDescription(){return`Reload page`}getJSON(){return{...super.getJSON(),type:`ReloadPage`}}async executeAction(){await location.reload()}resetAction(){}},W,G,K={init:e=>{W=e,G=!0,x.groupCollapsed(`Compile: `+e.getDescription()),e.compileSteps(),G=!1,x.log(`Compilation finished`),x.groupEnd()},addAction:e=>{x.log(`Add action: `,e.getDescription()),W.addStep(e)},compileAction:e=>{let t=W;W=e,e.compileSteps(),W=t},getCurrentAction:()=>W,getIsCompiling:()=>G},q={},Ae=e=>{if(q[e])q[e]();else throw console.log(`Available Tests:`,Object.keys(q)),Error(`Test with id ${e} not found.`)},je=(e,t)=>{console.log(`Registering Test: ${e}...`);let n=new z(e,t);K.init(n),console.log(`Compiled Test: ${e}`),y.dispatch(v.REGISTER_TEST,{id:e,action:n.getJSON()}),console.log(`Registered Test: ${e} in TestsMap`),q[e]=()=>{j.start(n)}};function J(e){let{matches:t,tests:n=[],speed:r=`NORMAL`,debug:i=!1}=e,a=N();if(console.log(`[tomation] Initializing on URL: ${document.location.href} with session ID: ${a}`),window.postMessage({message:`injectedScript-to-contentScript`,sender:`tomation`,payload:{cmd:v.SESSION_INIT,params:{sessionId:a}}}),!(typeof t==`string`?document.location.href.includes(t):document.location.href.match(t))){console.log(`[tomation] URL "${document.location.href}" does not match "${t}"`),window.postMessage({message:`injectedScript-to-contentScript`,sender:`tomation`,payload:{cmd:v.URL_MISMATCH,params:{sessionId:a,matches:t,url:document.location.href}}});return}try{console.log(`[tomation] Setting up messaging bridge with extension...`),Object.values(v).forEach(e=>{console.log(`[tomation] Setting up listener for event "${e}"`),y.on(e,t=>{let n={cmd:e,params:{...t,sessionId:a}};console.log(`[tomation] Dispatching event "${e}" to extension: `,n),window.postMessage({message:`injectedScript-to-contentScript`,sender:`tomation`,payload:n})})}),window.addEventListener(`message`,e=>{try{console.log(`[tomation] Received message from extension:`,e.data);let{message:t,sender:r,payload:i}=e.data||{},{cmd:a,params:o}=i||{};if(r!==`web-extension`)return;if(t===`contentScript-to-injectedScript`){let e={"run-test-request":()=>Ae(o?.testId),"reload-tests-request":()=>k(window,n||[]),"pause-test-request":()=>O.pause(),"stop-test-request":()=>O.stop(),"continue-test-request":()=>O.continue(),"next-step-request":()=>O.next(),"retry-action-request":()=>O.retryAction(),"skip-action-request":()=>O.skipAction(),"user-accept-request":()=>y.dispatch(v.USER_ACCEPT),"user-reject-request":()=>y.dispatch(v.USER_REJECT)}[a];e?(console.log(`[tomation] Executing command "${a}" from extension`),e()):console.warn(`[tomation] Unknown command "${a}" from extension`);return}}catch(e){console.error(`[tomation] Error handling message from extension:`,e)}}),k(window,n),O.setDebug(i),O.speed=T[r],window.postMessage({message:`injectedScript-to-contentScript`,sender:`tomation`,payload:{cmd:v.SESSION_CONNECTED,params:{speed:O.speed,sessionId:a}}}),console.log(`[tomation] Ready ✓`)}catch(e){console.error(`[tomation] Initialization failed:`,e)}}var Me=(e,t)=>async n=>{let r=new z(e,t);if(r.setParams(n),!j.running&&!K.getIsCompiling())try{x.log(`Compilation of Task ${e} starts...`),K.init(r),x.log(`Compilation of Task ${e} Finished.`),x.log(`Start running Task ${e}...`),await j.start(r),x.log(`End of Task ${e}: SUCCESS`)}catch(t){x.error(`Error running task `+e+`. `+t.message)}else x.log(`Adding action ${e} to compilation stack`),K.addAction(r),K.compileAction(r)},Ne=e=>{let t=new ue(e);K.addAction(t)},Pe=e=>({textIs:t=>{K.addAction(new de(e,t))},containsText:t=>{K.addAction(new fe(e,t))},valueIs:t=>{K.addAction(new pe(e,t))},exists:()=>{K.addAction(new me(e))},notExists:()=>{K.addAction(new he(e))}}),Fe=e=>({in:t=>{let n=new ge(t,e);K.addAction(n)}}),Ie=e=>({in:t=>{let n=new V(t,e);K.addAction(n)}}),Le=()=>({in:e=>{let t=new V(e,``);K.addAction(t)}}),Re=()=>({in:e=>{K.addAction(new ve(e))}}),ze=()=>({in:e=>{K.addAction(new ye(e))}}),Be=()=>({in:e=>{K.addAction(new be(e))}}),Ve=()=>({in:e=>{K.addAction(new xe(e))}}),He=e=>({in:t=>{K.addAction(new Se(t,e))}}),Ue=e=>({in:t=>{let n=new _e(t,e);K.addAction(n)}}),We=e=>({in:t=>{let n=new Ce(t,e);K.addAction(n)}}),Ge=e=>({in:t=>{let n=new we(e,t);K.addAction(n)}}),Y=e=>{K.addAction(new Te(e))};Y.untilElement=e=>({isRemoved:()=>{K.addAction(new Ee(e))}});var Ke=()=>{K.addAction(new De)},qe=e=>{K.addAction(new Oe(e))},X=()=>{K.addAction(new ke)},Z=e=>e.toLocaleDateString(`en-US`,{year:`numeric`,month:`2-digit`,day:`2-digit`}),Q=e=>{let t=new Date;return Z(new Date(t.setDate(t.getDate()+e)))},$=e=>{let t=new Date;return Z(new Date(t.setMonth(t.getMonth()+e)))},Je=Q(1),Ye=Q(-1),Xe=Q(7),Ze=Q(-7),Qe=$(1),$e=$(-1),et={formatDate:Z,today:Z(new Date),tomorrow:Je,nextWeek:Xe,nextMonth:Qe,yesterday:Ye,lastWeek:Ze,lastMonth:$e},tt=J;exports.ACTION_STATUS=L,exports.Assert=Pe,exports.AutomationEvents=y,Object.defineProperty(exports,`AutomationInstance`,{enumerable:!0,get:function(){return O}}),exports.ClearValue=Le,exports.Click=Ne,exports.DateUtils=et,exports.EVENT_NAMES=v,exports.KEY_MAP=H,exports.ManualTask=qe,exports.Pause=Ke,exports.PressDownKey=ze,exports.PressEnterKey=Ve,exports.PressEscKey=Re,exports.PressKey=He,exports.PressTabKey=Be,exports.ReloadPage=X,exports.SaveValue=Ge,exports.Select=Fe,exports.Setup=k,exports.Task=Me,exports.Test=je,exports.TestSpeed=T,exports.Type=Ie,exports.TypePassword=Ue,exports.UIElement=f,exports.UploadFile=We,exports.Wait=Y,exports.and=d,exports.classIncludes=r,exports.classIs=n,exports.default=tt,exports.elementIndexIs=l,exports.firstChildTextIs=u,exports.innerTextContains=a,exports.innerTextIs=i,exports.is=ne,exports.isFirstElement=c,exports.placeholderIs=s,exports.titleIs=o,exports.tomation=J,exports.wait=S;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { is, UIElement } from './dsl/ui-element';
|
|
3
|
-
import { Test } from './dsl/test';
|
|
4
|
-
import { tomation } from './tomation';
|
|
5
|
-
import { wait } from './feedback/ui-utils';
|
|
6
|
-
import { Task } from './dsl/task';
|
|
7
|
-
import { Select, Click, Type, TypePassword, ClearValue, Assert, PressEscKey, PressDownKey, PressTabKey, PressKey, PressEnterKey, UploadFile, SaveValue, Wait, Pause, ManualTask, ReloadPage } from './dsl/actions';
|
|
8
|
-
import DateUtils from './utils/date-utils';
|
|
9
|
-
import { AutomationEvents, EVENT_NAMES } from './engine/events';
|
|
10
|
-
import { AutomationInstance, Setup } from './engine/runner';
|
|
11
|
-
import { TestSpeed } from './engine/runner';
|
|
12
|
-
import { ACTION_STATUS, KEY_MAP } from './dom/actions';
|
|
13
|
-
export default tomation;
|
|
14
|
-
export { tomation, UIElement, is, classIs, classIncludes, innerTextIs, innerTextContains, titleIs, placeholderIs, isFirstElement, elementIndexIs, firstChildTextIs, and, Test, Task, Click, Assert, Select, Type, TypePassword, ClearValue, PressEscKey, PressDownKey, PressTabKey, PressKey, PressEnterKey, KEY_MAP, UploadFile, SaveValue, Wait, Pause, ManualTask, ReloadPage, DateUtils, AutomationEvents, AutomationInstance, Setup, EVENT_NAMES, TestSpeed, wait, ACTION_STATUS, };
|
|
1
|
+
export {}
|