tomation 0.0.9 → 0.0.11

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.js CHANGED
@@ -1,170 +1,144 @@
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 {
5
- constructor(e, n, s, o) {
6
- i(this, "name");
7
- i(this, "selector");
8
- i(this, "parent");
9
- i(this, "postProcess");
10
- this.name = e, this.selector = n, this.parent = s || null, this.postProcess = o;
1
+ var se = Object.defineProperty;
2
+ var oe = (e, t, n) => t in e ? se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var r = (e, t, n) => (oe(e, typeof t != "symbol" ? t + "" : t, n), n);
4
+ const st = (e) => (t) => t.className == e, ot = (e) => (t) => t.className.split(" ").includes(e), it = (e) => (t) => {
5
+ var s;
6
+ return ((s = t.textContent) == null ? void 0 : s.trim()) == e;
7
+ }, rt = (e) => (t) => t.innerText.trim().includes(e), at = (e) => (t) => t.title == e, ct = (e) => (t) => t.placeholder === e, lt = () => (e, t) => t === 0, ut = (e) => (t, n) => n === e, ht = (e) => (t) => (t == null ? void 0 : t.firstChild).innerText.trim() === e, dt = (e) => (t, n) => e.every((o, i) => o(t, n));
8
+ class ie {
9
+ constructor(t, n, s, o) {
10
+ r(this, "name");
11
+ r(this, "selector");
12
+ r(this, "parent");
13
+ r(this, "postProcess");
14
+ this.name = t, this.selector = n, this.parent = s || null, this.postProcess = o;
11
15
  }
12
16
  getElementName() {
13
- let e = "";
14
- return this.parent && (e = " in " + this.parent.getElementName()), `${this.name}${e}`;
17
+ let t = "";
18
+ return this.parent && (t = " in " + this.parent.getElementName()), `${this.name}${t}`;
15
19
  }
16
20
  }
17
21
  let F;
18
- const ie = (t) => {
19
- F = t;
20
- }, j = (t, e) => (s = F, o) => {
22
+ const re = (e) => {
23
+ F = e;
24
+ }, z = (e, t) => (s = F, o) => {
21
25
  s = s || F, console.log("Searching elem from Root = ", s);
22
- const a = [];
23
- s.querySelectorAll(t).forEach((l) => {
24
- l.style.display !== "none" && a.push(l);
26
+ const i = [];
27
+ s.querySelectorAll(e).forEach((l) => {
28
+ l.style.display !== "none" && i.push(l);
25
29
  });
26
- let r;
27
- return e ? (console.log("Applying filter ", e), console.log(" -- to " + a.length + "elements: ", a), r = a.filter((l, w, C) => {
28
- console.log("Apply filter to item " + w + ": ", l);
29
- const g = e(l, w, C);
30
- return console.log(` -> Item ${w} ${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
- }, $ = (t, e, n) => ({
30
+ let c;
31
+ return t ? (console.log("Applying filter ", t), console.log(" -- to " + i.length + "elements: ", i), c = i.filter((l, y, w) => {
32
+ console.log("Apply filter to item " + y + ": ", l);
33
+ const f = t(l, y, w);
34
+ return console.log(` -> Item ${y} ${f ? "Match" : "Discarded"}`), f;
35
+ })[0]) : c = i[0], c && o && (console.log("Apply post process to = ", c), c = o(c)), console.log("Return elem = ", c), c;
36
+ }, R = (e, t, n) => ({
33
37
  /**
34
38
  * Sets the UI element identifier
35
39
  * @param uiElementId
36
40
  * @returns
37
41
  */
38
- as: (s) => new oe(s, t, e, n)
39
- }), re = (t, e) => ({
40
- ...$(t, e),
42
+ as: (s) => new ie(s, e, t, n)
43
+ }), ae = (e, t) => ({
44
+ ...R(e, t),
41
45
  /**
42
46
  * Tansform the UI element that will be returned
43
47
  * @param postProcessFn
44
48
  * @returns
45
49
  */
46
50
  postProcess: (n) => ({
47
- ...$(t, e, n)
51
+ ...R(e, t, n)
48
52
  })
49
- }), X = (t) => ({
50
- ...$(t, null),
51
- childOf: (e) => ({
52
- ...re(t, e)
53
+ }), G = (e) => ({
54
+ ...R(e, null),
55
+ childOf: (t) => ({
56
+ ...ae(e, t)
53
57
  }),
54
58
  /**
55
59
  * Tansform the UI element that will be returned
56
60
  * @param postProcessFn
57
61
  * @returns
58
62
  */
59
- postProcess: (e) => ({
60
- ...$(t, null, e)
63
+ postProcess: (t) => ({
64
+ ...R(e, null, t)
61
65
  })
62
- }), O = (t) => ({
63
- where: (e) => X(j(t, e))
64
- }), ae = O("div"), ce = O("button"), le = O("input"), ue = O("textarea"), he = (t) => X(j("#" + t)), de = (t) => O(t);
65
- let z = !1;
66
- const _e = (t) => {
67
- z = t;
68
- }, A = (...t) => {
69
- z && console.log("[UIElement Filter]", ...t);
70
- }, et = (t) => (e) => {
71
- const n = e.className == t;
72
- return A(`classIs('${t}') on`, e, "=>", n), n;
73
- }, tt = (t) => (e) => {
74
- const n = e.className.split(" ").includes(t);
75
- return A(`classIncludes('${t}') on`, e, "=>", n), n;
76
- }, nt = (t) => (e) => {
77
- var s;
78
- const n = ((s = e.textContent) == null ? void 0 : s.trim()) == t;
79
- return A(`innerTextIs('${t}') on`, e, "=>", n), n;
80
- }, st = (t) => (e) => {
81
- const n = e.innerText.trim().includes(t);
82
- return A(`innerTextContains('${t}') on`, e, "=>", n), n;
83
- }, ot = (t) => (e) => {
84
- const n = e.title == t;
85
- return A(`titleIs('${t}') on`, e, "=>", n), n;
86
- }, it = (t) => (e) => {
87
- const n = e.placeholder === t;
88
- return A(`placeholderIs('${t}') on`, e, "=>", n), n;
89
- }, rt = () => (t, e) => {
90
- const n = e === 0;
91
- return A("isFirstElement on", t, "index", e, "=>", n), n;
92
- }, at = (t) => (e, n) => {
93
- const s = n === t;
94
- return A(`elementIndexIs(${t}) on`, e, "elemIndex", n, "=>", s), s;
95
- }, ct = (t) => (e) => {
96
- const n = (e == null ? void 0 : e.firstChild).innerText.trim() === t;
97
- return A(`firstChildTextIs('${t}') on`, e, "=>", n), n;
98
- }, lt = (t) => (e, n) => {
99
- const s = t.every((o, a) => {
100
- const r = o(e, n);
101
- return A(`and condition[${a}] on`, e, "elemIndex", n, "=>", r), r;
102
- });
103
- return A("and final result on", e, "elemIndex", n, "=>", s), s;
104
- }, ut = {
105
- DIV: ae,
106
- BUTTON: ce,
107
- INPUT: le,
108
- TEXTAREA: ue,
109
- ELEMENT: de,
110
- identifiedBy: he
111
- };
112
- let I;
113
- const pe = new Uint8Array(16);
114
- function me() {
115
- if (!I && (I = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !I))
116
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
117
- return I(pe);
118
- }
119
- const p = [];
120
- for (let t = 0; t < 256; ++t)
121
- p.push((t + 256).toString(16).slice(1));
122
- function ge(t, e = 0) {
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();
124
- }
125
- const ye = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), W = {
126
- randomUUID: ye
66
+ }), D = (e) => ({
67
+ where: (t) => G(z(e, t))
68
+ }), ce = D("div"), le = D("button"), ue = D("input"), he = D("textarea"), de = (e) => G(z("#" + e)), pe = (e) => D(e), pt = {
69
+ DIV: ce,
70
+ BUTTON: le,
71
+ INPUT: ue,
72
+ TEXTAREA: he,
73
+ ELEMENT: pe,
74
+ identifiedBy: de
127
75
  };
128
- function G(t, e, n) {
129
- if (W.randomUUID && !e && !t)
130
- return W.randomUUID();
131
- t = t || {};
132
- const s = t.random || (t.rng || me)();
133
- if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, e) {
134
- n = n || 0;
135
- for (let o = 0; o < 16; ++o)
136
- e[n + o] = s[o];
137
- return e;
76
+ var d = /* @__PURE__ */ ((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))(d || {});
77
+ class me {
78
+ constructor() {
79
+ r(this, "events");
80
+ this.events = /* @__PURE__ */ new Map();
81
+ }
82
+ on(t, n) {
83
+ var s;
84
+ this.events.has(t) || this.events.set(t, []), (s = this.events.get(t)) == null || s.push(n);
85
+ }
86
+ off(t, n) {
87
+ var s;
88
+ this.events.has(t) && this.events.set(t, ((s = this.events.get(t)) == null ? void 0 : s.filter((o) => o !== n)) || []);
89
+ }
90
+ dispatch(t, n) {
91
+ var s;
92
+ this.events.has(t) && ((s = this.events.get(t)) == null || s.forEach((o) => {
93
+ console.log(`Dispatch Event ${t}:`, n), o(n);
94
+ }));
138
95
  }
139
- return ge(s);
140
96
  }
141
- const f = (t = 2e3) => new Promise((e) => {
97
+ const g = new me();
98
+ let b = !1;
99
+ const u = {
100
+ setEnabled(e) {
101
+ b = e;
102
+ },
103
+ log(...e) {
104
+ b && console.log("[tomation]", ...e);
105
+ },
106
+ groupCollapsed(...e) {
107
+ b && console.groupCollapsed("[tomation]", ...e);
108
+ },
109
+ groupEnd() {
110
+ b && console.groupEnd();
111
+ },
112
+ error(...e) {
113
+ b && console.error("[tomation]", ...e);
114
+ }
115
+ }, A = (e = 2e3) => new Promise((t) => {
142
116
  setTimeout(() => {
143
- e(null);
144
- }, t);
145
- }), x = (t, e) => {
146
- Object.entries(e).map(([s, o]) => ({
117
+ t(null);
118
+ }, e);
119
+ }), C = (e, t) => {
120
+ Object.entries(t).map(([s, o]) => ({
147
121
  key: s,
148
122
  value: o
149
123
  })).forEach((s) => {
150
- const { key: o, value: a } = s;
151
- t.style[o] = a;
124
+ const { key: o, value: i } = s;
125
+ e.style[o] = i;
152
126
  });
153
127
  };
154
- class Ee {
155
- constructor(e) {
156
- i(this, "window");
157
- i(this, "document");
158
- i(this, "devToolsMessageContainer");
159
- i(this, "devToolsCheckElementContainer");
160
- i(this, "darkLayerLeft");
161
- i(this, "darkLayerTop");
162
- i(this, "darkLayerRight");
163
- i(this, "darkLayerBottom");
164
- i(this, "currentCheckElem");
165
- i(this, "contextViewerContainer");
166
- i(this, "devToolsAlertContainer");
167
- this.document = e.document, this.window = e, this.devToolsMessageContainer = this.createElement("DIV", {
128
+ class ge {
129
+ constructor(t) {
130
+ r(this, "window");
131
+ r(this, "document");
132
+ r(this, "devToolsMessageContainer");
133
+ r(this, "devToolsCheckElementContainer");
134
+ r(this, "darkLayerLeft");
135
+ r(this, "darkLayerTop");
136
+ r(this, "darkLayerRight");
137
+ r(this, "darkLayerBottom");
138
+ r(this, "currentCheckElem");
139
+ r(this, "contextViewerContainer");
140
+ r(this, "devToolsAlertContainer");
141
+ this.document = t.document, this.window = t, this.devToolsMessageContainer = this.createElement("DIV", {
168
142
  id: "dev-tools-message-container",
169
143
  styles: {
170
144
  width: "500px",
@@ -247,50 +221,50 @@ class Ee {
247
221
  parent: this.document.body
248
222
  });
249
223
  }
250
- createElement(e, n) {
251
- const s = this.document.createElement(e);
252
- 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;
224
+ createElement(t, n) {
225
+ const s = this.document.createElement(t);
226
+ return n && (n.id && (s.id = n == null ? void 0 : n.id), n.styles && C(s, n.styles), n.parent && n.parent.appendChild(s)), s;
253
227
  }
254
228
  /**
255
229
  *
256
230
  * @param message @deprecated
257
231
  */
258
- async logAction(e) {
259
- const n = c.document.createElement("DIV");
260
- n.innerText = e, x(n, {
232
+ async logAction(t) {
233
+ const n = a.document.createElement("DIV");
234
+ n.innerText = t, C(n, {
261
235
  padding: "3px 10px",
262
236
  opacity: "1",
263
237
  transition: "opacity 1s"
264
- }), this.devToolsMessageContainer.appendChild(n), await f(4e3), n.style.opacity = "0", await f(4e3), this.devToolsMessageContainer.removeChild(n), await f(1e3);
238
+ }), this.devToolsMessageContainer.appendChild(n), await A(4e3), n.style.opacity = "0", await A(4e3), this.devToolsMessageContainer.removeChild(n), await A(1e3);
265
239
  }
266
- async checkElement(e, n) {
267
- if (!e)
240
+ async checkElement(t, n) {
241
+ if (!t)
268
242
  return;
269
- const s = e.getBoundingClientRect(), o = this.document.body.getBoundingClientRect();
270
- 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 f(200);
243
+ const s = t.getBoundingClientRect(), o = this.document.body.getBoundingClientRect();
244
+ 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);
271
245
  }
272
- async showAlert(e) {
273
- const n = c.document.createElement("DIV"), s = c.document.body;
274
- n.innerText = e, x(s, {
246
+ async showAlert(t) {
247
+ const n = a.document.createElement("DIV"), s = a.document.body;
248
+ n.innerText = t, C(s, {
275
249
  paddingTop: "30px"
276
- }), x(this.devToolsAlertContainer, {
250
+ }), C(this.devToolsAlertContainer, {
277
251
  display: "flex"
278
252
  }), this.devToolsAlertContainer.appendChild(n);
279
253
  }
280
254
  async hideAlert() {
281
- x(this.devToolsAlertContainer, {
255
+ C(this.devToolsAlertContainer, {
282
256
  display: "none"
283
257
  });
284
- const e = c.document.body;
285
- x(e, {
258
+ const t = a.document.body;
259
+ C(t, {
286
260
  paddingTop: "0"
287
261
  }), this.devToolsAlertContainer.firstChild && this.devToolsAlertContainer.removeChild(this.devToolsAlertContainer.firstChild);
288
262
  }
289
263
  async hideCheckElementContainer() {
290
- this.devToolsCheckElementContainer.style.opacity = "0", await f(200), this.devToolsCheckElementContainer.style.display = "none";
264
+ this.devToolsCheckElementContainer.style.opacity = "0", await A(200), this.devToolsCheckElementContainer.style.display = "none";
291
265
  }
292
- displayContext(e) {
293
- x(this.contextViewerContainer, {
266
+ displayContext(t) {
267
+ C(this.contextViewerContainer, {
294
268
  display: "flex",
295
269
  "background-color": "white",
296
270
  position: "absolute",
@@ -299,86 +273,197 @@ class Ee {
299
273
  "z-index": "9999"
300
274
  });
301
275
  const n = this.document.createElement("DIV");
302
- n.id = "context-viewer-before", x(n, {
276
+ n.id = "context-viewer-before", C(n, {
303
277
  flex: "50%",
304
278
  width: "100%",
305
279
  height: "auto",
306
280
  border: "2px solid orange"
307
281
  });
308
282
  const s = this.document.createElement("DIV");
309
- s.id = "context-viewer-after", x(s, {
283
+ s.id = "context-viewer-after", C(s, {
310
284
  flex: "50%",
311
285
  width: "100%",
312
286
  height: "auto",
313
287
  border: "2px solid green"
314
288
  });
315
289
  const o = this.document.createElement("DIV");
316
- o.innerHTML = e.beforeHTML, q(o, e.beforeInputValues);
317
- const a = this.document.createElement("DIV");
318
- a.innerHTML = e.afterHTML, q(a, e.afterInputValues), this.contextViewerContainer.appendChild(n), n.appendChild(o), setTimeout(() => {
319
- this.contextViewerContainer.removeChild(n), this.contextViewerContainer.appendChild(s), s.appendChild(a), setTimeout(() => {
320
- this.contextViewerContainer.removeChild(s), x(this.contextViewerContainer, { display: "none" });
290
+ o.innerHTML = t.beforeHTML, H(o, t.beforeInputValues);
291
+ const i = this.document.createElement("DIV");
292
+ i.innerHTML = t.afterHTML, H(i, t.afterInputValues), this.contextViewerContainer.appendChild(n), n.appendChild(o), setTimeout(() => {
293
+ this.contextViewerContainer.removeChild(n), this.contextViewerContainer.appendChild(s), s.appendChild(i), setTimeout(() => {
294
+ this.contextViewerContainer.removeChild(s), C(this.contextViewerContainer, { display: "none" });
321
295
  }, 2e3);
322
296
  }, 2e3);
323
297
  }
324
298
  }
325
- const q = (t, e) => {
326
- t.querySelectorAll("input").forEach((n) => {
299
+ const H = (e, t) => {
300
+ e.querySelectorAll("input").forEach((n) => {
327
301
  const s = n.getAttribute("input-id") || "";
328
- n.value = e[s];
302
+ n.value = t[s];
303
+ });
304
+ };
305
+ var Q = /* @__PURE__ */ ((e) => (e[e.SLOW = 2e3] = "SLOW", e[e.NORMAL = 1e3] = "NORMAL", e[e.FAST = 200] = "FAST", e))(Q || {});
306
+ class ye {
307
+ constructor(t) {
308
+ r(this, "_document");
309
+ r(this, "debug");
310
+ r(this, "_uiUtils");
311
+ r(this, "speed");
312
+ r(this, "status");
313
+ r(this, "runMode");
314
+ r(this, "currentActionCallback");
315
+ r(this, "currentAction");
316
+ this._document = t.document, this.debug = !0, this._uiUtils = new ge(t), this.speed = 1e3, this.status = "Stopped", this.runMode = "Normal";
317
+ }
318
+ get document() {
319
+ return this._document;
320
+ }
321
+ get uiUtils() {
322
+ return this._uiUtils;
323
+ }
324
+ get isStepByStepMode() {
325
+ return this.runMode == "Step By Step";
326
+ }
327
+ get isStopped() {
328
+ return this.status == "Stopped";
329
+ }
330
+ get isPlaying() {
331
+ return this.status == "Playing";
332
+ }
333
+ get isPaused() {
334
+ return this.status == "Paused";
335
+ }
336
+ pause() {
337
+ u.log("Pause Test"), this.status = "Paused", g.dispatch(d.TEST_PAUSE);
338
+ }
339
+ continue() {
340
+ u.log("Continue Test"), this.status = "Playing", this.runMode = "Normal", g.dispatch(d.TEST_PLAY), this.currentActionCallback && this.currentAction && (u.log("Continue: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
341
+ }
342
+ next() {
343
+ u.log("Continue Test to Next Step..."), this.status = "Playing", this.runMode = "Step By Step", g.dispatch(d.TEST_PLAY), this.currentActionCallback && this.currentAction && (u.log("Next: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
344
+ }
345
+ stop() {
346
+ 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), g.dispatch(d.TEST_STOP);
347
+ }
348
+ retryAction() {
349
+ u.log("Retry current step"), this.status = "Playing", g.dispatch(d.TEST_PLAY), 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);
350
+ }
351
+ skipAction() {
352
+ 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"), E.notifyActionUpdated(this.currentAction), u.log("Skip: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
353
+ }
354
+ saveCurrentAction(t, n) {
355
+ u.log("Save current action"), this.currentActionCallback = t, this.currentAction = n;
356
+ }
357
+ setDebug(t) {
358
+ u.setEnabled(t);
359
+ }
360
+ }
361
+ let a;
362
+ const _ = (e, t) => (a = new ye(e), re(a.document), t == null || t.forEach((n) => n()), a);
363
+ let P = !1;
364
+ async function Ee(e) {
365
+ if (P)
366
+ 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.");
367
+ P = !0, a.status = "Playing", a.runMode = "Normal", u.groupCollapsed("Start Action: ", e.getDescription()), g.dispatch(d.TEST_STARTED, {
368
+ action: e == null ? void 0 : e.getJSON()
329
369
  });
330
- }, M = null, L = async (t, e, n, s = 1e3, o = 0, a = 10, r = !1) => {
331
- if (console.log("Automation Status: ", c.status), c.isPaused)
332
- return new Promise((l, w) => {
333
- c.saveCurrentAction(async (C) => {
334
- if (C.status == "skipped")
370
+ try {
371
+ await (e == null ? void 0 : e.execute()), g.dispatch(d.TEST_PASSED, { id: e.name });
372
+ } catch (t) {
373
+ throw g.dispatch(d.TEST_FAILED, { id: e.name }), a.uiUtils.hideCheckElementContainer(), u.error(`🤖 Error running task ${e.getDescription()}. Reason: ${t.message}`), t;
374
+ } finally {
375
+ u.groupEnd(), P = !1, g.dispatch(d.TEST_END, {
376
+ action: e == null ? void 0 : e.getJSON()
377
+ });
378
+ }
379
+ }
380
+ const W = {
381
+ start: Ee,
382
+ get running() {
383
+ return P;
384
+ }
385
+ };
386
+ let I;
387
+ const we = new Uint8Array(16);
388
+ function fe() {
389
+ if (!I && (I = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !I))
390
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
391
+ return I(we);
392
+ }
393
+ const m = [];
394
+ for (let e = 0; e < 256; ++e)
395
+ m.push((e + 256).toString(16).slice(1));
396
+ function xe(e, t = 0) {
397
+ 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();
398
+ }
399
+ const Ae = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), j = {
400
+ randomUUID: Ae
401
+ };
402
+ function Z(e, t, n) {
403
+ if (j.randomUUID && !t && !e)
404
+ return j.randomUUID();
405
+ e = e || {};
406
+ const s = e.random || (e.rng || fe)();
407
+ if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, t) {
408
+ n = n || 0;
409
+ for (let o = 0; o < 16; ++o)
410
+ t[n + o] = s[o];
411
+ return t;
412
+ }
413
+ return xe(s);
414
+ }
415
+ const q = null, L = async (e, t, n, s = 1e3, o = 0, i = 10, c = !1) => {
416
+ if (console.log("Automation Status: ", a.status), a.isPaused)
417
+ return new Promise((l, y) => {
418
+ a.saveCurrentAction(async (w) => {
419
+ if (w.status == "skipped")
335
420
  return l(null);
336
421
  try {
337
- const g = await L(C, e, n, s, o, a, r);
338
- l(g);
339
- } catch (g) {
340
- w(g);
422
+ const f = await L(w, t, n, s, o, i, c);
423
+ l(f);
424
+ } catch (f) {
425
+ y(f);
341
426
  }
342
- }, t);
427
+ }, e);
343
428
  });
344
- if (c.isStopped)
429
+ if (a.isStopped)
345
430
  throw new Error("Test stopped manually");
346
- if (console.groupCollapsed(`tries ${o}/${a}`), t && (t.updateTries(o), await E.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`);
431
+ if (console.groupCollapsed(`tries ${o}/${i}`), e && (e.updateTries(o), await E.notifyActionUpdated(e)), o === i)
432
+ throw console.groupEnd(), c ? new Error(`UI Element ${t.getElementName() || "UNKNOWN"} still present after 10 tries`) : new Error(`UI Element ${t.getElementName() || "UNKNOWN"} not found after 10 tries`);
348
433
  {
349
- const l = e.selector(n, e.postProcess);
350
- return console.groupEnd(), l ? r ? (await f(s), await L(t, e, n, s, ++o, a, r)) : (console.log("Element found = ", l), l) : r ? (console.log("Element removed."), M) : (await f(s), await L(t, e, n, s, ++o, a, r));
351
- }
352
- }, R = async (t, e, n = 1e3, s = 10, o = !1) => {
353
- const a = e == null ? void 0 : e.getElementName();
354
- console.group("Looking for Element: " + a);
355
- let r = null;
356
- if (e.parent)
434
+ const l = t.selector(n, t.postProcess);
435
+ return console.groupEnd(), l ? c ? (await A(s), await L(e, t, n, s, ++o, i, c)) : (console.log("Element found = ", l), l) : c ? (console.log("Element removed."), q) : (await A(s), await L(e, t, n, s, ++o, i, c));
436
+ }
437
+ }, J = async (e, t, n = 1e3, s = 10, o = !1) => {
438
+ const i = t == null ? void 0 : t.getElementName();
439
+ console.group("Looking for Element: " + i);
440
+ let c = null;
441
+ if (t.parent)
357
442
  try {
358
- console.groupCollapsed("Look for Parent ", e.parent.getElementName()), r = await R(t, e.parent, n, s, o), console.groupEnd();
443
+ console.groupCollapsed("Look for Parent ", t.parent.getElementName()), c = await J(e, t.parent, n, s, o), console.groupEnd();
359
444
  } catch (l) {
360
445
  if (console.groupEnd(), o && l.message.includes("not found"))
361
- return console.log("Parent not found, so element was removed"), console.groupEnd(), M;
446
+ return console.log("Parent not found, so element was removed"), console.groupEnd(), q;
362
447
  throw console.groupEnd(), l;
363
448
  }
364
449
  try {
365
- console.log("Using parent element: ", r);
366
- const l = await L(t, e, r, n, 0, s, o);
450
+ console.log("Using parent element: ", c);
451
+ const l = await L(e, t, c, n, 0, s, o);
367
452
  return console.groupEnd(), l;
368
453
  } catch (l) {
369
454
  if (o && l.message.includes("not found"))
370
- return console.log("Parent not found, so element was removed"), console.groupEnd(), M;
455
+ return console.log("Parent not found, so element was removed"), console.groupEnd(), q;
371
456
  throw console.groupEnd(), l;
372
457
  }
373
458
  };
374
- var Q = /* @__PURE__ */ ((t) => (t.WAITING = "waiting", t.RUNNING = "running", t.STOPPED = "stopped", t.PAUSED = "paused", t.SUCCESS = "success", t.ERROR = "error", t.SKIPPED = "skipped", t))(Q || {});
459
+ var Y = /* @__PURE__ */ ((e) => (e.WAITING = "waiting", e.RUNNING = "running", e.STOPPED = "stopped", e.PAUSED = "paused", e.SUCCESS = "success", e.ERROR = "error", e.SKIPPED = "skipped", e))(Y || {});
375
460
  class E {
376
461
  constructor() {
377
- i(this, "status");
378
- i(this, "error");
379
- i(this, "id");
380
- i(this, "context");
381
- this.status = "waiting", this.error = "", this.id = G(), this.context = {
462
+ r(this, "status");
463
+ r(this, "error");
464
+ r(this, "id");
465
+ r(this, "context");
466
+ this.status = "waiting", this.error = "", this.id = Z(), this.context = {
382
467
  beforeHTML: "",
383
468
  beforeInputValues: {},
384
469
  afterInputValues: {},
@@ -401,37 +486,37 @@ class E {
401
486
  this.status = "waiting", this.error = "", this.resetAction();
402
487
  }
403
488
  getInputValuesFromPage() {
404
- const e = {};
405
- return c.document.querySelectorAll("input").forEach((s, o) => {
406
- const a = `value-id-${o}`;
407
- s.setAttribute("input-id", a), e[a] = s.value;
408
- }), e;
489
+ const t = {};
490
+ return a.document.querySelectorAll("input").forEach((s, o) => {
491
+ const i = `value-id-${o}`;
492
+ s.setAttribute("input-id", i), t[i] = s.value;
493
+ }), t;
409
494
  }
410
495
  async execute() {
411
496
  try {
412
- this.status = "running", this.context.beforeInputValues = this.getInputValuesFromPage(), this.context.beforeHTML = c.document.body.innerHTML, await E.notifyActionUpdated(this), console.log("Action: ", this.getDescription()), await this.executeAction(), this.status = "success", this.error = "", c.isStepByStepMode && c.pause();
413
- } catch (e) {
414
- if (this.status = "error", this.error = e.message, e.message == "Test stopped manually")
415
- throw Error("Error in Action " + this.getDescription() + ". Message: " + e.message);
416
- this.status = "paused", c.pause();
497
+ this.status = "running", this.context.beforeInputValues = this.getInputValuesFromPage(), this.context.beforeHTML = a.document.body.innerHTML, await E.notifyActionUpdated(this), console.log("Action: ", this.getDescription()), await this.executeAction(), this.status = "success", this.error = "", a.isStepByStepMode && a.pause();
498
+ } catch (t) {
499
+ if (this.status = "error", this.error = t.message, t.message == "Test stopped manually")
500
+ throw Error("Error in Action " + this.getDescription() + ". Message: " + t.message);
501
+ this.status = "paused", a.pause();
417
502
  } finally {
418
- this.context.afterInputValues = this.getInputValuesFromPage(), this.context.afterHTML = c.document.body.innerHTML, await E.notifyActionUpdated(this);
503
+ this.context.afterInputValues = this.getInputValuesFromPage(), this.context.afterHTML = a.document.body.innerHTML, await E.notifyActionUpdated(this);
419
504
  }
420
505
  }
421
- static async notifyActionUpdated(e) {
422
- m.dispatch(T.ACTION_UPDATE, {
423
- action: e.getJSON()
506
+ static async notifyActionUpdated(t) {
507
+ g.dispatch(d.ACTION_UPDATE, {
508
+ action: t.getJSON()
424
509
  });
425
510
  }
426
511
  }
427
- class Z extends E {
512
+ class ee extends E {
428
513
  constructor(n, s) {
429
514
  super();
430
- i(this, "name");
431
- i(this, "stepsFn");
432
- i(this, "steps");
433
- i(this, "params");
434
- i(this, "index");
515
+ r(this, "name");
516
+ r(this, "stepsFn");
517
+ r(this, "steps");
518
+ r(this, "params");
519
+ r(this, "index");
435
520
  this.name = n, this.stepsFn = s, this.steps = [], this.index = 0;
436
521
  }
437
522
  getDescription() {
@@ -454,41 +539,40 @@ class Z extends E {
454
539
  resetAction() {
455
540
  this.steps.length = 0, this.index = 0;
456
541
  }
457
- async handlePause() {
458
- return new Promise((n, s) => {
459
- c.saveCurrentAction(async (o) => {
460
- if (o.status === "skipped") {
461
- n();
462
- return;
463
- }
464
- try {
465
- await this.continue(), n();
466
- } catch (a) {
467
- s(a);
468
- }
469
- }, this);
470
- });
471
- }
472
542
  async continue() {
473
- for (; this.index < this.steps.length; ) {
474
- if (c.isStopped)
475
- throw new Error("Test stopped manually");
543
+ if (a.isPaused)
544
+ return new Promise((n, s) => {
545
+ a.saveCurrentAction(async (o) => {
546
+ if (o.status == "skipped")
547
+ return n();
548
+ try {
549
+ await o.continue(), n();
550
+ } catch (i) {
551
+ s(i);
552
+ }
553
+ }, this);
554
+ });
555
+ if (a.isStopped)
556
+ throw new Error("Test stopped manually");
557
+ if (this.index < this.steps.length) {
476
558
  const n = this.steps[this.index];
477
559
  try {
478
- if (await f(c.speed), await n.execute(), c.isPaused) {
479
- if (await this.handlePause(), n.status === "skipped") {
480
- this.index++;
481
- continue;
482
- }
483
- } else
484
- this.index++;
560
+ if (await A(a.speed), await n.execute(), !a.isPaused)
561
+ this.index++, await this.continue();
562
+ else
563
+ return new Promise((s, o) => {
564
+ a.saveCurrentAction(async (i) => {
565
+ if (i.status == "skipped")
566
+ return this.index++, await E.notifyActionUpdated(n), await this.continue(), s();
567
+ try {
568
+ await i.continue(), s();
569
+ } catch (c) {
570
+ o(c);
571
+ }
572
+ }, n);
573
+ });
485
574
  } catch (s) {
486
- throw m.dispatch(T.ACTION_ERROR, {
487
- action: this.getJSON(),
488
- step: n,
489
- error: s.message,
490
- index: this.index
491
- }), s;
575
+ throw s;
492
576
  }
493
577
  }
494
578
  }
@@ -502,12 +586,12 @@ class Z extends E {
502
586
  this.steps.push(n);
503
587
  }
504
588
  }
505
- class d extends E {
589
+ class p extends E {
506
590
  constructor(n) {
507
591
  super();
508
- i(this, "uiElement");
509
- i(this, "element");
510
- i(this, "tries");
592
+ r(this, "uiElement");
593
+ r(this, "element");
594
+ r(this, "tries");
511
595
  this.uiElement = n, this.element = null, this.tries = 0;
512
596
  }
513
597
  getElementName() {
@@ -536,46 +620,46 @@ class d extends E {
536
620
  * @param uiElement
537
621
  * @param delay of each try. Defaults to 1 second
538
622
  */
539
- static waitForElement(n, s, o = 1e3, a = 10, r = !1) {
623
+ static waitForElement(n, s, o = 1e3, i = 10, c = !1) {
540
624
  const l = s.getElementName();
541
- return new Promise(async (w, C) => {
542
- var v;
543
- const g = async (S, D = 1e3, N = 0, b = !1) => {
544
- if (console.groupCollapsed(`tries ${N}/${a}`), n.updateTries(N), await E.notifyActionUpdated(n), N === a)
545
- throw console.groupEnd(), b ? new Error(`UI Element ${l || "UNKNOWN"} still present after 10 tries`) : new Error(`UI Element ${l || "UNKNOWN"} not found after 10 tries`);
625
+ return new Promise(async (y, w) => {
626
+ var V;
627
+ const f = async (x, O = 1e3, N = 0, v = !1) => {
628
+ if (console.groupCollapsed(`tries ${N}/${i}`), n.updateTries(N), await E.notifyActionUpdated(n), N === i)
629
+ throw console.groupEnd(), v ? new Error(`UI Element ${l || "UNKNOWN"} still present after 10 tries`) : new Error(`UI Element ${l || "UNKNOWN"} not found after 10 tries`);
546
630
  {
547
- const K = s.selector(S, s.postProcess);
548
- return console.groupEnd(), K ? b ? (await f(D), await g(S, D, ++N, b)) : (console.log("Element found = ", K), K) : b ? (console.log("Element removed."), null) : (await f(D), await g(S, D, ++N, b));
631
+ const M = s.selector(x, s.postProcess);
632
+ return console.groupEnd(), M ? v ? (await A(O), await f(x, O, ++N, v)) : (console.log("Element found = ", M), M) : v ? (console.log("Element removed."), null) : (await A(O), await f(x, O, ++N, v));
549
633
  }
550
634
  };
551
635
  console.group("[Action On Element] Looking for Element: " + l);
552
- let k = null, V = !0;
636
+ let S = null, T = !0;
553
637
  if (s.parent) {
554
638
  console.groupCollapsed("Look for Parent ", s.parent.getElementName());
555
639
  try {
556
- k = await d.waitForElement(n, s.parent, o, a, r);
640
+ S = await p.waitForElement(n, s.parent, o, i, c);
557
641
  } catch {
558
- V = !1;
642
+ T = !1;
559
643
  } finally {
560
644
  console.groupEnd();
561
645
  }
562
646
  }
563
- if (V) {
564
- console.log("using parent element: ", k);
647
+ if (T) {
648
+ console.log("using parent element: ", S);
565
649
  try {
566
- const S = await g(k, o, 0, r);
567
- console.groupEnd(), w(S);
568
- } catch (S) {
569
- console.groupEnd(), C(new Error(S.message));
650
+ const x = await f(S, o, 0, c);
651
+ console.groupEnd(), y(x);
652
+ } catch (x) {
653
+ console.groupEnd(), w(new Error(x.message));
570
654
  }
571
655
  } else
572
- console.groupEnd(), C(new Error(`Parent ${(v = s.parent) == null ? void 0 : v.getElementName()} of UI Element ${s.name || "UNKNOWN"} not found`));
656
+ console.groupEnd(), w(new Error(`Parent ${(V = s.parent) == null ? void 0 : V.getElementName()} of UI Element ${s.name || "UNKNOWN"} not found`));
573
657
  });
574
658
  }
575
659
  async executeAction() {
576
660
  var n;
577
661
  try {
578
- this.element = await R(this, this.uiElement), (n = this.element) == null || n.setAttribute("test-id", this.getElementName()), await c.uiUtils.checkElement(this.element, this.getElementName()), this.executeActionOnElement(), await c.uiUtils.hideCheckElementContainer();
662
+ this.element = await J(this, this.uiElement), (n = this.element) == null || n.setAttribute("test-id", this.getElementName()), await a.uiUtils.checkElement(this.element, this.getElementName()), this.executeActionOnElement(), await a.uiUtils.hideCheckElementContainer();
579
663
  } catch (s) {
580
664
  throw Error(s.message);
581
665
  }
@@ -584,13 +668,13 @@ class d extends E {
584
668
  this.element = null, this.resetTries();
585
669
  }
586
670
  }
587
- class we extends d {
588
- constructor(e) {
589
- super(e);
671
+ class Ce extends p {
672
+ constructor(t) {
673
+ super(t);
590
674
  }
591
675
  executeActionOnElement() {
592
- var e;
593
- return (e = this.element) == null ? void 0 : e.click();
676
+ var t;
677
+ return (t = this.element) == null ? void 0 : t.click();
594
678
  }
595
679
  getDescription() {
596
680
  return "Click in " + this.getElementName();
@@ -602,10 +686,10 @@ class we extends d {
602
686
  };
603
687
  }
604
688
  }
605
- class fe extends d {
689
+ class Se extends p {
606
690
  constructor(n, s) {
607
691
  super(n);
608
- i(this, "text");
692
+ r(this, "text");
609
693
  this.text = s;
610
694
  }
611
695
  executeActionOnElement() {
@@ -624,10 +708,10 @@ class fe extends d {
624
708
  };
625
709
  }
626
710
  }
627
- class Ae extends d {
711
+ class Te extends p {
628
712
  constructor(n, s) {
629
713
  super(n);
630
- i(this, "text");
714
+ r(this, "text");
631
715
  this.text = s;
632
716
  }
633
717
  executeActionOnElement() {
@@ -646,10 +730,10 @@ class Ae extends d {
646
730
  };
647
731
  }
648
732
  }
649
- class xe extends d {
733
+ class ke extends p {
650
734
  constructor(n, s) {
651
735
  super(n);
652
- i(this, "value");
736
+ r(this, "value");
653
737
  this.value = s;
654
738
  }
655
739
  executeActionOnElement() {
@@ -667,9 +751,9 @@ class xe extends d {
667
751
  };
668
752
  }
669
753
  }
670
- class Ce extends d {
671
- constructor(e) {
672
- super(e);
754
+ class Ne extends p {
755
+ constructor(t) {
756
+ super(t);
673
757
  }
674
758
  executeActionOnElement() {
675
759
  if (!!!this.element)
@@ -685,14 +769,14 @@ class Ce extends d {
685
769
  };
686
770
  }
687
771
  }
688
- class Se extends d {
689
- constructor(e) {
690
- super(e);
772
+ class ve extends p {
773
+ constructor(t) {
774
+ super(t);
691
775
  }
692
776
  async executeAction() {
693
- var e;
777
+ var t;
694
778
  try {
695
- this.element = await R(this, this.uiElement, 1e3, 5, !0), (e = this.element) == null || e.setAttribute("test-id", this.getElementName()), await c.uiUtils.checkElement(this.element, this.getElementName()), this.executeActionOnElement(), await c.uiUtils.hideCheckElementContainer();
779
+ this.element = await J(this, this.uiElement, 1e3, 5, !0), (t = this.element) == null || t.setAttribute("test-id", this.getElementName()), await a.uiUtils.checkElement(this.element, this.getElementName()), this.executeActionOnElement(), await a.uiUtils.hideCheckElementContainer();
696
780
  } catch (n) {
697
781
  throw Error(n.message);
698
782
  }
@@ -711,16 +795,16 @@ class Se extends d {
711
795
  };
712
796
  }
713
797
  }
714
- class ke extends d {
798
+ class be extends p {
715
799
  constructor(n, s) {
716
800
  super(n);
717
- i(this, "value");
801
+ r(this, "value");
718
802
  this.value = s;
719
803
  }
720
804
  executeActionOnElement() {
721
- var s, o, a, r;
805
+ var s, o, i, c;
722
806
  let n = this.element;
723
- 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))
807
+ 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 = (c = this.element) == null ? void 0 : c.querySelectorAll("input")[0], !n))
724
808
  throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
725
809
  n.value = this.value, n.dispatchEvent(new Event("change"));
726
810
  }
@@ -735,16 +819,16 @@ class ke extends d {
735
819
  };
736
820
  }
737
821
  }
738
- class Y extends d {
822
+ class te extends p {
739
823
  constructor(n, s) {
740
824
  super(n);
741
- i(this, "value");
825
+ r(this, "value");
742
826
  this.value = s;
743
827
  }
744
828
  executeActionOnElement() {
745
- var s, o, a, r;
829
+ var s, o, i, c;
746
830
  let n = this.element;
747
- 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))
831
+ 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 = (c = this.element) == null ? void 0 : c.querySelectorAll("input")[0], !n))
748
832
  throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
749
833
  n.value = this.value, n.dispatchEvent(new Event("change")), n.dispatchEvent(new Event("keyup", { bubbles: !0 })), n.dispatchEvent(new Event("input", { bubbles: !0 }));
750
834
  }
@@ -759,16 +843,16 @@ class Y extends d {
759
843
  };
760
844
  }
761
845
  }
762
- class Te extends d {
846
+ class De extends p {
763
847
  constructor(n, s) {
764
848
  super(n);
765
- i(this, "value");
849
+ r(this, "value");
766
850
  this.value = s;
767
851
  }
768
852
  executeActionOnElement() {
769
- var s, o, a, r;
853
+ var s, o, i, c;
770
854
  let n = this.element;
771
- 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))
855
+ 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 = (c = this.element) == null ? void 0 : c.querySelectorAll("input")[0], !n))
772
856
  throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
773
857
  n.value = this.value, n.dispatchEvent(new Event("change")), n.dispatchEvent(new Event("keyup", { bubbles: !0 })), n.dispatchEvent(new Event("input", { bubbles: !0 }));
774
858
  }
@@ -783,13 +867,13 @@ class Te extends d {
783
867
  };
784
868
  }
785
869
  }
786
- class ve extends d {
787
- constructor(e) {
788
- super(e);
870
+ class Oe extends p {
871
+ constructor(t) {
872
+ super(t);
789
873
  }
790
874
  executeActionOnElement() {
791
- var e;
792
- (e = this.element) == null || e.dispatchEvent(
875
+ var t;
876
+ (t = this.element) == null || t.dispatchEvent(
793
877
  new KeyboardEvent("keydown", {
794
878
  altKey: !1,
795
879
  code: "Escape",
@@ -816,13 +900,13 @@ class ve extends d {
816
900
  };
817
901
  }
818
902
  }
819
- class Ne extends d {
820
- constructor(e) {
821
- super(e);
903
+ class Ie extends p {
904
+ constructor(t) {
905
+ super(t);
822
906
  }
823
907
  executeActionOnElement() {
824
- var e;
825
- (e = this.element) == null || e.dispatchEvent(
908
+ var t;
909
+ (t = this.element) == null || t.dispatchEvent(
826
910
  new KeyboardEvent("keyup", {
827
911
  altKey: !1,
828
912
  code: "Down",
@@ -849,13 +933,13 @@ class Ne extends d {
849
933
  };
850
934
  }
851
935
  }
852
- class be extends d {
853
- constructor(e) {
854
- super(e);
936
+ class Pe extends p {
937
+ constructor(t) {
938
+ super(t);
855
939
  }
856
940
  executeActionOnElement() {
857
- var e;
858
- (e = this.element) == null || e.dispatchEvent(
941
+ var t;
942
+ (t = this.element) == null || t.dispatchEvent(
859
943
  new KeyboardEvent("keydown", {
860
944
  altKey: !1,
861
945
  code: "Tab",
@@ -882,13 +966,13 @@ class be extends d {
882
966
  };
883
967
  }
884
968
  }
885
- class Oe extends d {
886
- constructor(e) {
887
- super(e);
969
+ class Le extends p {
970
+ constructor(t) {
971
+ super(t);
888
972
  }
889
973
  executeActionOnElement() {
890
- var e;
891
- (e = this.element) == null || e.dispatchEvent(
974
+ var t;
975
+ (t = this.element) == null || t.dispatchEvent(
892
976
  new KeyboardEvent("keydown", {
893
977
  altKey: !1,
894
978
  code: "Enter",
@@ -915,8 +999,8 @@ class Oe extends d {
915
999
  };
916
1000
  }
917
1001
  }
918
- 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 || {});
919
- const B = {
1002
+ var Ue = /* @__PURE__ */ ((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))(Ue || {});
1003
+ const X = {
920
1004
  Escape: 27,
921
1005
  Enter: 13,
922
1006
  Tab: 9,
@@ -931,10 +1015,10 @@ const B = {
931
1015
  Alt: 18,
932
1016
  Meta: 91
933
1017
  };
934
- class Ie extends d {
1018
+ class Re extends p {
935
1019
  constructor(n, s) {
936
1020
  super(n);
937
- i(this, "key");
1021
+ r(this, "key");
938
1022
  this.key = s;
939
1023
  }
940
1024
  executeActionOnElement() {
@@ -943,9 +1027,9 @@ class Ie extends d {
943
1027
  new KeyboardEvent("keydown", {
944
1028
  key: this.key,
945
1029
  code: this.key,
946
- keyCode: B[this.key],
1030
+ keyCode: X[this.key],
947
1031
  charCode: 0,
948
- which: B[this.key],
1032
+ which: X[this.key],
949
1033
  altKey: !1,
950
1034
  ctrlKey: !1,
951
1035
  metaKey: !1,
@@ -967,10 +1051,10 @@ class Ie extends d {
967
1051
  };
968
1052
  }
969
1053
  }
970
- class Le extends d {
1054
+ class $e extends p {
971
1055
  constructor(n, s) {
972
1056
  super(n);
973
- i(this, "file");
1057
+ r(this, "file");
974
1058
  this.file = s;
975
1059
  }
976
1060
  executeActionOnElement() {
@@ -978,12 +1062,12 @@ class Le extends d {
978
1062
  s.items.add(this.file);
979
1063
  const o = s.files;
980
1064
  n.files = o, n.dispatchEvent(new Event("change"));
981
- function a(l) {
982
- var w;
983
- return l != null && l.parentElement ? ((w = l.parentElement) == null ? void 0 : w.tagName.toLowerCase()) === "form" ? l.parentElement : a(l.parentElement) : null;
1065
+ function i(l) {
1066
+ var y;
1067
+ return l != null && l.parentElement ? ((y = l.parentElement) == null ? void 0 : y.tagName.toLowerCase()) === "form" ? l.parentElement : i(l.parentElement) : null;
984
1068
  }
985
- const r = a(n);
986
- r && r.dispatchEvent(new Event("change"));
1069
+ const c = i(n);
1070
+ c && c.dispatchEvent(new Event("change"));
987
1071
  }
988
1072
  getDescription() {
989
1073
  return `Upload file in ${this.getElementName()}`;
@@ -995,18 +1079,18 @@ class Le extends d {
995
1079
  };
996
1080
  }
997
1081
  }
998
- class Pe extends d {
1082
+ class Je extends p {
999
1083
  constructor(n, s) {
1000
1084
  super(n);
1001
- i(this, "memorySlotName");
1085
+ r(this, "memorySlotName");
1002
1086
  this.memorySlotName = s;
1003
1087
  }
1004
1088
  executeActionOnElement() {
1005
- var s, o, a, r;
1089
+ var s, o, i, c;
1006
1090
  let n = this.element;
1007
- 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))
1091
+ 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 = (c = this.element) == null ? void 0 : c.querySelectorAll("input")[0], !n))
1008
1092
  throw new Error("Input element not found. Not able to save value from element " + this.getElementName());
1009
- m.dispatch(T.SAVE_VALUE, {
1093
+ g.dispatch(d.SAVE_VALUE, {
1010
1094
  memorySlotName: this.memorySlotName,
1011
1095
  value: n.value
1012
1096
  });
@@ -1022,10 +1106,10 @@ class Pe extends d {
1022
1106
  };
1023
1107
  }
1024
1108
  }
1025
- class $e extends E {
1109
+ class Ke extends E {
1026
1110
  constructor(n) {
1027
1111
  super();
1028
- i(this, "miliseconds");
1112
+ r(this, "miliseconds");
1029
1113
  this.miliseconds = n;
1030
1114
  }
1031
1115
  getDescription() {
@@ -1038,16 +1122,16 @@ class $e extends E {
1038
1122
  };
1039
1123
  }
1040
1124
  async executeAction() {
1041
- await f(this.miliseconds);
1125
+ await A(this.miliseconds);
1042
1126
  }
1043
1127
  resetAction() {
1044
1128
  }
1045
1129
  }
1046
- class Ue extends E {
1130
+ class Ve extends E {
1047
1131
  constructor(n) {
1048
1132
  super();
1049
- i(this, "uiElement");
1050
- i(this, "tries");
1133
+ r(this, "uiElement");
1134
+ r(this, "tries");
1051
1135
  this.uiElement = n, this.tries = 0;
1052
1136
  }
1053
1137
  updateTries(n) {
@@ -1061,7 +1145,7 @@ class Ue extends E {
1061
1145
  return (n = this.uiElement) == null ? void 0 : n.getElementName();
1062
1146
  }
1063
1147
  async executeAction() {
1064
- await R(this, this.uiElement, 1e3, 10, !0);
1148
+ await J(this, this.uiElement, 1e3, 10, !0);
1065
1149
  }
1066
1150
  getDescription() {
1067
1151
  return "Wait until " + this.getElementName() + " is removed";
@@ -1073,7 +1157,7 @@ class Ue extends E {
1073
1157
  };
1074
1158
  }
1075
1159
  }
1076
- class Re extends E {
1160
+ class Me extends E {
1077
1161
  constructor() {
1078
1162
  super();
1079
1163
  }
@@ -1087,15 +1171,15 @@ class Re extends E {
1087
1171
  };
1088
1172
  }
1089
1173
  async executeAction() {
1090
- await c.pause();
1174
+ await a.pause();
1091
1175
  }
1092
1176
  resetAction() {
1093
1177
  }
1094
1178
  }
1095
- class Je extends E {
1179
+ class Fe extends E {
1096
1180
  constructor(n) {
1097
1181
  super();
1098
- i(this, "description");
1182
+ r(this, "description");
1099
1183
  this.description = n;
1100
1184
  }
1101
1185
  getDescription() {
@@ -1108,14 +1192,14 @@ class Je extends E {
1108
1192
  };
1109
1193
  }
1110
1194
  async executeAction() {
1111
- return await c.uiUtils.showAlert("Waiting manual step..."), new Promise((n, s) => {
1112
- m.on(T.USER_ACCEPT, async () => (await c.uiUtils.hideAlert(), n(!0))), m.on(T.USER_REJECT, async () => (await c.uiUtils.hideAlert(), s()));
1195
+ return await a.uiUtils.showAlert("Waiting manual step..."), new Promise((n, s) => {
1196
+ g.on(d.USER_ACCEPT, async () => (await a.uiUtils.hideAlert(), n(!0))), g.on(d.USER_REJECT, async () => (await a.uiUtils.hideAlert(), s()));
1113
1197
  });
1114
1198
  }
1115
1199
  resetAction() {
1116
1200
  }
1117
1201
  }
1118
- class Ve extends E {
1202
+ class We extends E {
1119
1203
  constructor() {
1120
1204
  super();
1121
1205
  }
@@ -1134,437 +1218,269 @@ class Ve extends E {
1134
1218
  resetAction() {
1135
1219
  }
1136
1220
  }
1137
- class Ke extends E {
1138
- constructor(n, s, o, a = "condition") {
1139
- super();
1140
- i(this, "condition");
1141
- i(this, "ifAction");
1142
- i(this, "elseAction");
1143
- i(this, "conditionDescription");
1144
- this.condition = n, this.ifAction = s, this.elseAction = o, this.conditionDescription = a;
1145
- }
1146
- getDescription() {
1147
- const n = this.elseAction ? `, else ${this.elseAction.getDescription()}` : "";
1148
- return `If ${this.conditionDescription}, then ${this.ifAction.getDescription()}${n}`;
1149
- }
1150
- getJSON() {
1151
- var n;
1152
- return {
1153
- ...super.getJSON(),
1154
- type: "If",
1155
- conditionDescription: this.conditionDescription,
1156
- ifAction: this.ifAction.getJSON(),
1157
- elseAction: (n = this.elseAction) == null ? void 0 : n.getJSON()
1158
- };
1159
- }
1160
- async executeAction() {
1161
- try {
1162
- await this.condition(), await this.ifAction.execute();
1163
- } catch {
1164
- this.elseAction && await this.elseAction.execute();
1165
- }
1166
- }
1167
- resetAction() {
1168
- var n;
1169
- this.ifAction.reset(), (n = this.elseAction) == null || n.reset();
1170
- }
1171
- compileSteps() {
1172
- var n;
1173
- this.ifAction.compileSteps(), (n = this.elseAction) == null || n.compileSteps();
1174
- }
1175
- }
1176
- const U = (t) => t.toLocaleDateString("en-US", { year: "numeric", month: "2-digit", day: "2-digit" }), J = (t) => {
1177
- const e = /* @__PURE__ */ new Date();
1178
- return U(new Date(e.setDate(e.getDate() + t)));
1179
- }, _ = (t) => {
1180
- const e = /* @__PURE__ */ new Date();
1181
- return U(new Date(e.setMonth(e.getMonth() + t)));
1182
- }, Fe = J(1), Me = J(-1), We = J(7), qe = J(-7), Be = _(1), He = _(-1), ht = {
1183
- formatDate: U,
1184
- today: U(/* @__PURE__ */ new Date()),
1185
- tomorrow: Fe,
1186
- nextWeek: We,
1187
- nextMonth: Be,
1188
- yesterday: Me,
1189
- lastWeek: qe,
1190
- lastMonth: He
1191
- };
1192
- class je {
1193
- constructor() {
1194
- i(this, "enabled", !1);
1195
- }
1196
- setEnabled(e) {
1197
- this.enabled = e;
1198
- }
1199
- log(...e) {
1200
- this.enabled && console.log("[tomation]", ...e);
1201
- }
1202
- groupCollapsed(...e) {
1203
- this.enabled && console.groupCollapsed("[tomation]", ...e);
1204
- }
1205
- groupEnd() {
1206
- this.enabled && console.groupEnd();
1207
- }
1208
- error(...e) {
1209
- this.enabled && console.error("[tomation]", ...e);
1210
- }
1211
- }
1212
- const u = new je(), Xe = (t) => {
1213
- u.setEnabled(t);
1214
- }, y = class y {
1215
- static compileAction(e) {
1216
- const n = y.currentAction;
1217
- y.currentAction = e, e.compileSteps(), y.currentAction = n;
1218
- }
1219
- static compileConditionalAction(e) {
1220
- const n = y.currentAction;
1221
- y.currentAction = e, e.compileSteps(), y.currentAction = n;
1222
- }
1223
- static addAction(e) {
1224
- u.log("Add action: ", e.getDescription()), y.currentAction.addStep(e);
1225
- }
1226
- static init(e) {
1227
- y.currentAction = e, y.isCompiling = !0, u.groupCollapsed("Compile: " + e.getDescription()), e.compileSteps(), y.isCompiling = !1, u.log("Compilation finished"), u.groupEnd();
1228
- }
1221
+ let k, B;
1222
+ const qe = (e) => {
1223
+ const t = k;
1224
+ k = e, e.compileSteps(), k = t;
1225
+ }, Be = (e) => {
1226
+ u.log("Add action: ", e.getDescription()), k.addStep(e);
1227
+ }, He = (e) => {
1228
+ k = e, B = !0, u.groupCollapsed("Compile: " + e.getDescription()), e.compileSteps(), B = !1, u.log("Compilation finished"), u.groupEnd();
1229
+ }, _e = () => k, je = () => B, h = {
1230
+ init: He,
1231
+ addAction: Be,
1232
+ compileAction: qe,
1233
+ getCurrentAction: _e,
1234
+ getIsCompiling: je
1235
+ }, U = {}, Xe = (e) => {
1236
+ if (U[e])
1237
+ U[e]();
1238
+ else
1239
+ throw console.log("Available Tests:", Object.keys(U)), new Error(`Test with id ${e} not found.`);
1240
+ }, mt = (e, t) => {
1241
+ console.log(`Registering Test: ${e}...`);
1242
+ const n = new ee(e, t);
1243
+ h.init(n), console.log(`Compiled Test: ${e}`), g.dispatch(d.REGISTER_TEST, { id: e, action: n.getJSON() }), console.log(`Registered Test: ${e} in TestsMap`), U[e] = () => {
1244
+ W.start(n);
1245
+ };
1229
1246
  };
1230
- i(y, "currentAction"), i(y, "isCompiling");
1231
- let h = y;
1232
- var T = /* @__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.ACTION_ERROR = "tomation-action-error", t))(T || {});
1233
- class ze {
1234
- constructor() {
1235
- i(this, "events");
1236
- this.events = /* @__PURE__ */ new Map();
1237
- }
1238
- on(e, n) {
1239
- var s;
1240
- this.events.has(e) || this.events.set(e, []), (s = this.events.get(e)) == null || s.push(n);
1241
- }
1242
- off(e, n) {
1243
- var s;
1244
- this.events.has(e) && this.events.set(e, ((s = this.events.get(e)) == null ? void 0 : s.filter((o) => o !== n)) || []);
1245
- }
1246
- dispatch(e, n) {
1247
- var s;
1248
- this.events.has(e) && ((s = this.events.get(e)) == null || s.forEach((o) => {
1249
- console.log(`Dispatch Event ${e}:`, n), o(n);
1250
- }));
1251
- }
1252
- }
1253
- const m = new ze();
1254
- var ee = /* @__PURE__ */ ((t) => (t[t.SLOW = 2e3] = "SLOW", t[t.NORMAL = 1e3] = "NORMAL", t[t.FAST = 200] = "FAST", t))(ee || {});
1255
- class te {
1256
- static async start(e) {
1257
- if (c.status !== "Stopped")
1258
- 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.");
1259
- c.status = "Playing", c.runMode = "Normal", u.groupCollapsed("Start Action: ", e.getDescription()), m.dispatch("tomation-test-started", {
1260
- action: e == null ? void 0 : e.getJSON()
1247
+ function gt(e) {
1248
+ const {
1249
+ matches: t,
1250
+ tests: n = [],
1251
+ speed: s = "NORMAL",
1252
+ debug: o = !1
1253
+ } = e, i = Z();
1254
+ if (console.log(`[tomation] Initializing on URL: ${document.location.href} with session ID: ${i}`), window.postMessage({
1255
+ message: "injectedScript-to-contentScript",
1256
+ sender: "tomation",
1257
+ payload: {
1258
+ cmd: d.SESSION_INIT,
1259
+ params: {
1260
+ sessionId: i
1261
+ }
1262
+ }
1263
+ }), !(typeof t == "string" ? document.location.href.includes(t) : !!document.location.href.match(t))) {
1264
+ console.log(`[tomation] URL "${document.location.href}" does not match "${t}"`), window.postMessage({
1265
+ message: "injectedScript-to-contentScript",
1266
+ sender: "tomation",
1267
+ payload: {
1268
+ cmd: d.URL_MISMATCH,
1269
+ params: {
1270
+ sessionId: i,
1271
+ matches: t,
1272
+ url: document.location.href
1273
+ }
1274
+ }
1261
1275
  });
1262
- try {
1263
- await (e == null ? void 0 : e.execute()), m.dispatch("tomation-test-passed", { id: e.name }), c.status = "Stopped";
1264
- } catch (n) {
1265
- throw m.dispatch("tomation-test-failed", { id: e.name }), c.uiUtils.hideCheckElementContainer(), u.error(`🤖 Error running task ${e.getDescription()}. Reason: ${n.message}`), c.status = "Paused", n;
1266
- } finally {
1267
- u.groupEnd(), m.dispatch("tomation-test-end", {
1268
- action: e == null ? void 0 : e.getJSON()
1276
+ return;
1277
+ }
1278
+ try {
1279
+ console.log("[tomation] Setting up messaging bridge with extension..."), Object.values(d).forEach((l) => {
1280
+ console.log(`[tomation] Setting up listener for event "${l}"`), g.on(l, (y) => {
1281
+ const w = {
1282
+ cmd: l,
1283
+ params: {
1284
+ ...y,
1285
+ sessionId: i
1286
+ }
1287
+ };
1288
+ console.log(`[tomation] Dispatching event "${l}" to extension: `, w), window.postMessage({
1289
+ message: "injectedScript-to-contentScript",
1290
+ sender: "tomation",
1291
+ payload: w
1292
+ });
1269
1293
  });
1270
- }
1294
+ }), window.addEventListener("message", (l) => {
1295
+ try {
1296
+ console.log("[tomation] Received message from extension:", l.data);
1297
+ const { message: y, sender: w, payload: f } = l.data || {}, { cmd: S, params: T } = f || {};
1298
+ if (w !== "web-extension")
1299
+ return;
1300
+ if (y === "contentScript-to-injectedScript") {
1301
+ const x = {
1302
+ "run-test-request": () => Xe(T == null ? void 0 : T.testId),
1303
+ "reload-tests-request": () => _(window, n || []),
1304
+ "pause-test-request": () => a.pause(),
1305
+ "stop-test-request": () => a.stop(),
1306
+ "continue-test-request": () => a.continue(),
1307
+ "next-step-request": () => a.next(),
1308
+ "retry-action-request": () => a.retryAction(),
1309
+ "skip-action-request": () => a.skipAction(),
1310
+ "user-accept-request": () => g.dispatch(d.USER_ACCEPT),
1311
+ "user-reject-request": () => g.dispatch(d.USER_REJECT)
1312
+ }[S];
1313
+ x ? (console.log(`[tomation] Executing command "${S}" from extension`), x()) : console.warn(`[tomation] Unknown command "${S}" from extension`);
1314
+ return;
1315
+ }
1316
+ } catch (y) {
1317
+ console.error("[tomation] Error handling message from extension:", y);
1318
+ }
1319
+ }), _(window, n), a.setDebug(o), a.speed = Q[s], window.postMessage({
1320
+ message: "injectedScript-to-contentScript",
1321
+ sender: "tomation",
1322
+ payload: {
1323
+ cmd: d.SESSION_CONNECTED,
1324
+ params: {
1325
+ speed: a.speed,
1326
+ sessionId: i
1327
+ }
1328
+ }
1329
+ }), console.log("[tomation] Ready ✓");
1330
+ } catch (l) {
1331
+ console.error("[tomation] Initialization failed:", l);
1271
1332
  }
1272
1333
  }
1273
- const P = {}, dt = (t, e) => {
1274
- console.log(`Registering Test: ${t}...`);
1275
- const n = new Z(t, e);
1276
- m.dispatch("tomation-register-test", { id: t }), console.log(`Registered Test: ${t} in TestsMap`), P[t] = () => {
1277
- u.log(`Compilation of Test ${t} starts...`), h.init(n), u.log(`Compilation of Test ${t} Finished.`), u.log(`Start running Test ${t}...`), te.start(n);
1278
- };
1279
- }, Ge = (t) => {
1280
- if (P[t])
1281
- P[t]();
1282
- else
1283
- throw console.log("Available Tests:", Object.keys(P)), new Error(`Test with id ${t} not found.`);
1284
- }, pt = (t, e) => async (n) => {
1285
- const s = new Z(t, e);
1286
- if (s.setParams(n), c.status == "Stopped" && !h.isCompiling)
1334
+ const yt = (e, t) => async (n) => {
1335
+ const s = new ee(e, t);
1336
+ if (s.setParams(n), !W.running && !h.getIsCompiling())
1287
1337
  try {
1288
- u.log(`Compilation of Task ${t} starts...`), h.init(s), u.log(`Compilation of Task ${t} Finished.`), u.log(`Start running Task ${t}...`), await te.start(s), u.log(`End of Task ${t}: SUCCESS`);
1338
+ u.log(`Compilation of Task ${e} starts...`), h.init(s), u.log(`Compilation of Task ${e} Finished.`), u.log(`Start running Task ${e}...`), await W.start(s), u.log(`End of Task ${e}: SUCCESS`);
1289
1339
  } catch (o) {
1290
- u.error("Error running task " + t + ". " + o.message);
1340
+ u.error("Error running task " + e + ". " + o.message);
1291
1341
  }
1292
1342
  else
1293
- u.log(`Adding action ${t} to compilation stack`), h.addAction(s), h.compileAction(s);
1294
- }, mt = (t) => {
1295
- const e = new we(t);
1296
- h.addAction(e);
1297
- }, gt = (t) => ({
1298
- textIs: (e) => {
1299
- h.addAction(new fe(t, e));
1343
+ u.log(`Adding action ${e} to compilation stack`), h.addAction(s), h.compileAction(s);
1344
+ }, Et = (e) => {
1345
+ const t = new Ce(e);
1346
+ h.addAction(t);
1347
+ }, wt = (e) => ({
1348
+ textIs: (t) => {
1349
+ h.addAction(new Se(e, t));
1300
1350
  },
1301
- containsText: (e) => {
1302
- h.addAction(new Ae(t, e));
1351
+ containsText: (t) => {
1352
+ h.addAction(new Te(e, t));
1303
1353
  },
1304
- valueIs: (e) => {
1305
- h.addAction(new xe(t, e));
1354
+ valueIs: (t) => {
1355
+ h.addAction(new ke(e, t));
1306
1356
  },
1307
1357
  exists: () => {
1308
- h.addAction(new Ce(t));
1358
+ h.addAction(new Ne(e));
1309
1359
  },
1310
1360
  notExists: () => {
1311
- h.addAction(new Se(t));
1312
- }
1313
- }), yt = (t) => ({
1314
- in: (e) => {
1315
- const n = new ke(e, t);
1316
- h.addAction(n);
1317
- }
1318
- }), Et = (t) => ({
1319
- in: (e) => {
1320
- const n = new Y(e, t);
1321
- h.addAction(n);
1361
+ h.addAction(new ve(e));
1322
1362
  }
1323
- }), wt = () => ({
1363
+ }), ft = (e) => ({
1324
1364
  in: (t) => {
1325
- const e = new Y(t, "");
1326
- h.addAction(e);
1365
+ const n = new be(t, e);
1366
+ h.addAction(n);
1327
1367
  }
1328
- }), ft = () => ({
1368
+ }), xt = (e) => ({
1329
1369
  in: (t) => {
1330
- h.addAction(new ve(t));
1370
+ const n = new te(t, e);
1371
+ h.addAction(n);
1331
1372
  }
1332
1373
  }), At = () => ({
1333
- in: (t) => {
1334
- h.addAction(new Ne(t));
1335
- }
1336
- }), xt = () => ({
1337
- in: (t) => {
1338
- h.addAction(new be(t));
1374
+ in: (e) => {
1375
+ const t = new te(e, "");
1376
+ h.addAction(t);
1339
1377
  }
1340
1378
  }), Ct = () => ({
1341
- in: (t) => {
1342
- h.addAction(new Oe(t));
1379
+ in: (e) => {
1380
+ h.addAction(new Oe(e));
1343
1381
  }
1344
- }), St = (t) => ({
1382
+ }), St = () => ({
1345
1383
  in: (e) => {
1346
- h.addAction(new Ie(e, t));
1384
+ h.addAction(new Ie(e));
1347
1385
  }
1348
- }), kt = (t) => ({
1386
+ }), Tt = () => ({
1349
1387
  in: (e) => {
1350
- const n = new Te(e, t);
1351
- h.addAction(n);
1388
+ h.addAction(new Pe(e));
1352
1389
  }
1353
- }), Tt = (t) => ({
1390
+ }), kt = () => ({
1354
1391
  in: (e) => {
1355
- const n = new Le(e, t);
1392
+ h.addAction(new Le(e));
1393
+ }
1394
+ }), Nt = (e) => ({
1395
+ in: (t) => {
1396
+ h.addAction(new Re(t, e));
1397
+ }
1398
+ }), vt = (e) => ({
1399
+ in: (t) => {
1400
+ const n = new De(t, e);
1356
1401
  h.addAction(n);
1357
1402
  }
1358
- }), vt = (t) => ({
1359
- in: (e) => {
1360
- const n = new Pe(t, e);
1403
+ }), bt = (e) => ({
1404
+ in: (t) => {
1405
+ const n = new $e(t, e);
1361
1406
  h.addAction(n);
1362
1407
  }
1363
- }), Qe = (t) => {
1364
- h.addAction(new $e(t));
1408
+ }), Dt = (e) => ({
1409
+ in: (t) => {
1410
+ const n = new Je(e, t);
1411
+ h.addAction(n);
1412
+ }
1413
+ }), ze = (e) => {
1414
+ h.addAction(new Ke(e));
1365
1415
  };
1366
- Qe.untilElement = (t) => ({
1416
+ ze.untilElement = (e) => ({
1367
1417
  isRemoved: () => {
1368
- h.addAction(new Ue(t));
1418
+ h.addAction(new Ve(e));
1369
1419
  }
1370
1420
  });
1371
- const Nt = () => {
1372
- h.addAction(new Re());
1373
- }, bt = (t) => {
1374
- h.addAction(new Je(t));
1375
- }, Ot = () => {
1376
- h.addAction(new Ve());
1377
- }, Dt = (t, e) => ({
1378
- then: (n) => ({
1379
- else: (s) => {
1380
- const o = new Ke(e, n, s, t);
1381
- h.addAction(o);
1382
- }
1383
- })
1384
- });
1385
- class Ze {
1386
- constructor(e) {
1387
- i(this, "_document");
1388
- i(this, "debug");
1389
- i(this, "_uiUtils");
1390
- i(this, "speed");
1391
- i(this, "status");
1392
- i(this, "runMode");
1393
- i(this, "currentActionCallback");
1394
- i(this, "currentAction");
1395
- this._document = e.document, this.debug = !0, this._uiUtils = new Ee(e), this.speed = 1e3, this.status = "Stopped", this.runMode = "Normal";
1396
- }
1397
- get document() {
1398
- return this._document;
1399
- }
1400
- get uiUtils() {
1401
- return this._uiUtils;
1402
- }
1403
- get isStepByStepMode() {
1404
- return this.runMode == "Step By Step";
1405
- }
1406
- get isStopped() {
1407
- return this.status == "Stopped";
1408
- }
1409
- get isPlaying() {
1410
- return this.status == "Playing";
1411
- }
1412
- get isPaused() {
1413
- return this.status == "Paused";
1414
- }
1415
- pause() {
1416
- u.log("Pause Test"), this.status = "Paused", m.dispatch(
1417
- "tomation-test-pause"
1418
- /* TEST_PAUSE */
1419
- );
1420
- }
1421
- continue() {
1422
- u.log("Continue Test"), this.status = "Playing", this.runMode = "Normal", m.dispatch(
1423
- "tomation-test-play"
1424
- /* TEST_PLAY */
1425
- ), this.currentActionCallback && this.currentAction && (u.log("Continue: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1426
- }
1427
- next() {
1428
- u.log("Continue Test to Next Step..."), this.status = "Paused", this.runMode = "Step By Step", this.currentActionCallback && this.currentAction && (u.log("Next: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1429
- }
1430
- stop() {
1431
- 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(
1432
- "tomation-test-stop"
1433
- /* TEST_STOP */
1434
- );
1435
- }
1436
- retryAction() {
1437
- u.log("Retry current step"), this.status = "Playing", m.dispatch(
1438
- "tomation-test-play"
1439
- /* TEST_PLAY */
1440
- ), 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);
1441
- }
1442
- skipAction() {
1443
- u.log("Skip current step"), this.status = "Playing", this.currentActionCallback && this.currentAction && (this.currentAction.status = Q.SKIPPED, u.log("Skip: Marked current action as SKIPPED"), E.notifyActionUpdated(this.currentAction), u.log("Skip: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1444
- }
1445
- saveCurrentAction(e, n) {
1446
- u.log("Save current action"), this.currentActionCallback = e, this.currentAction = n;
1447
- }
1448
- setDebug(e) {
1449
- Xe(e);
1450
- }
1451
- }
1452
- let c;
1453
- const H = (t, e) => (c = new Ze(t), ie(c.document), e == null || e.forEach((n) => n()), c);
1454
- function It(t) {
1455
- const {
1456
- matches: e,
1457
- tests: n = [],
1458
- speed: s = "NORMAL",
1459
- debug: o = !1
1460
- } = t;
1461
- if (!(typeof e == "string" ? document.location.href.includes(e) : !!document.location.href.match(e))) {
1462
- console.log(`[tomation] URL "${document.location.href}" does not match "${e}"`);
1463
- return;
1464
- }
1465
- try {
1466
- console.log("[tomation] Setting up messaging bridge with extension..."), Object.values(T).forEach((r) => {
1467
- console.log(`[tomation] Setting up listener for event "${r}"`), m.on(r, (l) => {
1468
- console.log(`[tomation] Dispatching event "${r}" to extension`, l), window.postMessage({
1469
- message: "injectedScript-to-contentScript",
1470
- sender: "tomation",
1471
- payload: {
1472
- cmd: r,
1473
- params: l
1474
- }
1475
- });
1476
- });
1477
- }), window.addEventListener("message", (r) => {
1478
- try {
1479
- console.log("[tomation] Received message from extension:", r.data);
1480
- const { message: l, sender: w, payload: C } = r.data || {}, { cmd: g, params: k } = C || {};
1481
- if (w !== "web-extension")
1482
- return;
1483
- if (l === "contentScript-to-injectedScript") {
1484
- const v = {
1485
- "run-test-request": () => Ge(k == null ? void 0 : k.testId),
1486
- "reload-tests-request": () => H(window, n || []),
1487
- "pause-test-request": () => c.pause(),
1488
- "stop-test-request": () => c.stop(),
1489
- "continue-test-request": () => c.continue(),
1490
- "next-step-request": () => c.next(),
1491
- "retry-action-request": () => c.retryAction(),
1492
- "skip-action-request": () => c.skipAction(),
1493
- "user-accept-request": () => m.dispatch(
1494
- "tomation-user-accept"
1495
- /* USER_ACCEPT */
1496
- ),
1497
- "user-reject-request": () => m.dispatch(
1498
- "tomation-user-reject"
1499
- /* USER_REJECT */
1500
- )
1501
- }[g];
1502
- v ? (console.log(`[tomation] Executing command "${g}" from extension`), v()) : console.warn(`[tomation] Unknown command "${g}" from extension`);
1503
- return;
1504
- }
1505
- } catch (l) {
1506
- console.error("[tomation] Error handling message from extension:", l);
1507
- }
1508
- }), window.postMessage({
1509
- message: "injectedScript-to-contentScript",
1510
- sender: "tomation",
1511
- payload: {
1512
- cmd: "tomation-session-init",
1513
- params: {
1514
- sessionId: G()
1515
- }
1516
- }
1517
- }), H(window, n), c.setDebug(o), c.speed = ee[s], console.log("[tomation] Ready ✓");
1518
- } catch (r) {
1519
- console.error("[tomation] Initialization failed:", r);
1520
- }
1521
- }
1421
+ const Ot = () => {
1422
+ h.addAction(new Me());
1423
+ }, It = (e) => {
1424
+ h.addAction(new Fe(e));
1425
+ }, Pt = () => {
1426
+ h.addAction(new We());
1427
+ }, $ = (e) => e.toLocaleDateString("en-US", { year: "numeric", month: "2-digit", day: "2-digit" }), K = (e) => {
1428
+ const t = /* @__PURE__ */ new Date();
1429
+ return $(new Date(t.setDate(t.getDate() + e)));
1430
+ }, ne = (e) => {
1431
+ const t = /* @__PURE__ */ new Date();
1432
+ return $(new Date(t.setMonth(t.getMonth() + e)));
1433
+ }, Ge = K(1), Qe = K(-1), Ze = K(7), Ye = K(-7), et = ne(1), tt = ne(-1), Lt = {
1434
+ formatDate: $,
1435
+ today: $(/* @__PURE__ */ new Date()),
1436
+ tomorrow: Ge,
1437
+ nextWeek: Ze,
1438
+ nextMonth: et,
1439
+ yesterday: Qe,
1440
+ lastWeek: Ye,
1441
+ lastMonth: tt
1442
+ };
1522
1443
  export {
1523
- Q as ACTION_STATUS,
1524
- gt as Assert,
1525
- m as AutomationEvents,
1526
- c as AutomationInstance,
1527
- wt as ClearValue,
1528
- mt as Click,
1529
- ht as DateUtils,
1530
- T as EVENT_NAMES,
1531
- Dt as If,
1532
- De as KEY_MAP,
1533
- bt as ManualTask,
1534
- Nt as Pause,
1535
- At as PressDownKey,
1536
- Ct as PressEnterKey,
1537
- ft as PressEscKey,
1538
- St as PressKey,
1539
- xt as PressTabKey,
1540
- Ot as ReloadPage,
1541
- Ge as RunTest,
1542
- vt as SaveValue,
1543
- yt as Select,
1544
- j as SelectorBuilder,
1545
- H as Setup,
1546
- pt as Task,
1547
- dt as Test,
1548
- ee as TestSpeed,
1549
- Et as Type,
1550
- kt as TypePassword,
1551
- oe as UIElement,
1552
- Tt as UploadFile,
1553
- Qe as Wait,
1554
- lt as and,
1555
- tt as classIncludes,
1556
- et as classIs,
1557
- It as default,
1558
- at as elementIndexIs,
1559
- ct as firstChildTextIs,
1560
- st as innerTextContains,
1561
- nt as innerTextIs,
1562
- ut as is,
1563
- rt as isFirstElement,
1564
- it as placeholderIs,
1565
- Xe as setAutomationLogs,
1566
- _e as setFilterLogs,
1567
- ot as titleIs,
1568
- It as tomation,
1569
- f as wait
1444
+ Y as ACTION_STATUS,
1445
+ wt as Assert,
1446
+ g as AutomationEvents,
1447
+ a as AutomationInstance,
1448
+ At as ClearValue,
1449
+ Et as Click,
1450
+ Lt as DateUtils,
1451
+ d as EVENT_NAMES,
1452
+ Ue as KEY_MAP,
1453
+ It as ManualTask,
1454
+ Ot as Pause,
1455
+ St as PressDownKey,
1456
+ kt as PressEnterKey,
1457
+ Ct as PressEscKey,
1458
+ Nt as PressKey,
1459
+ Tt as PressTabKey,
1460
+ Pt as ReloadPage,
1461
+ Dt as SaveValue,
1462
+ ft as Select,
1463
+ _ as Setup,
1464
+ yt as Task,
1465
+ mt as Test,
1466
+ Q as TestSpeed,
1467
+ xt as Type,
1468
+ vt as TypePassword,
1469
+ ie as UIElement,
1470
+ bt as UploadFile,
1471
+ ze as Wait,
1472
+ dt as and,
1473
+ ot as classIncludes,
1474
+ st as classIs,
1475
+ gt as default,
1476
+ ut as elementIndexIs,
1477
+ ht as firstChildTextIs,
1478
+ rt as innerTextContains,
1479
+ it as innerTextIs,
1480
+ pt as is,
1481
+ lt as isFirstElement,
1482
+ ct as placeholderIs,
1483
+ at as titleIs,
1484
+ gt as tomation,
1485
+ A as wait
1570
1486
  };