pw-automation-framework 2.0.1

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.
Files changed (111) hide show
  1. package/README.md +93 -0
  2. package/bin/lexxit-automation-framework.js +427 -0
  3. package/dist/app.d.ts +2 -0
  4. package/dist/app.js +26 -0
  5. package/dist/app.js.map +1 -0
  6. package/dist/controllers/controller.d.ts +57 -0
  7. package/dist/controllers/controller.js +263 -0
  8. package/dist/controllers/controller.js.map +1 -0
  9. package/dist/core/BrowserManager.d.ts +46 -0
  10. package/dist/core/BrowserManager.js +377 -0
  11. package/dist/core/BrowserManager.js.map +1 -0
  12. package/dist/core/PlaywrightEngine.d.ts +16 -0
  13. package/dist/core/PlaywrightEngine.js +246 -0
  14. package/dist/core/PlaywrightEngine.js.map +1 -0
  15. package/dist/core/ScreenshotManager.d.ts +10 -0
  16. package/dist/core/ScreenshotManager.js +28 -0
  17. package/dist/core/ScreenshotManager.js.map +1 -0
  18. package/dist/core/TestData.d.ts +12 -0
  19. package/dist/core/TestData.js +29 -0
  20. package/dist/core/TestData.js.map +1 -0
  21. package/dist/core/TestExecutor.d.ts +16 -0
  22. package/dist/core/TestExecutor.js +355 -0
  23. package/dist/core/TestExecutor.js.map +1 -0
  24. package/dist/core/handlers/AllHandlers.d.ts +116 -0
  25. package/dist/core/handlers/AllHandlers.js +648 -0
  26. package/dist/core/handlers/AllHandlers.js.map +1 -0
  27. package/dist/core/handlers/BaseHandler.d.ts +16 -0
  28. package/dist/core/handlers/BaseHandler.js +27 -0
  29. package/dist/core/handlers/BaseHandler.js.map +1 -0
  30. package/dist/core/handlers/ClickHandler.d.ts +34 -0
  31. package/dist/core/handlers/ClickHandler.js +359 -0
  32. package/dist/core/handlers/ClickHandler.js.map +1 -0
  33. package/dist/core/handlers/CustomCodeHandler.d.ts +35 -0
  34. package/dist/core/handlers/CustomCodeHandler.js +102 -0
  35. package/dist/core/handlers/CustomCodeHandler.js.map +1 -0
  36. package/dist/core/handlers/DropdownHandler.d.ts +43 -0
  37. package/dist/core/handlers/DropdownHandler.js +304 -0
  38. package/dist/core/handlers/DropdownHandler.js.map +1 -0
  39. package/dist/core/handlers/InputHandler.d.ts +24 -0
  40. package/dist/core/handlers/InputHandler.js +197 -0
  41. package/dist/core/handlers/InputHandler.js.map +1 -0
  42. package/dist/core/registry/ActionRegistry.d.ts +8 -0
  43. package/dist/core/registry/ActionRegistry.js +35 -0
  44. package/dist/core/registry/ActionRegistry.js.map +1 -0
  45. package/dist/installer/frameworkLauncher.d.ts +31 -0
  46. package/dist/installer/frameworkLauncher.js +198 -0
  47. package/dist/installer/frameworkLauncher.js.map +1 -0
  48. package/dist/queue/ExecutionQueue.d.ts +52 -0
  49. package/dist/queue/ExecutionQueue.js +175 -0
  50. package/dist/queue/ExecutionQueue.js.map +1 -0
  51. package/dist/routes/api.routes.d.ts +2 -0
  52. package/dist/routes/api.routes.js +16 -0
  53. package/dist/routes/api.routes.js.map +1 -0
  54. package/dist/server.d.ts +1 -0
  55. package/dist/server.js +30 -0
  56. package/dist/server.js.map +1 -0
  57. package/dist/types/types.d.ts +135 -0
  58. package/dist/types/types.js +4 -0
  59. package/dist/types/types.js.map +1 -0
  60. package/dist/utils/elementHighlight.d.ts +35 -0
  61. package/dist/utils/elementHighlight.js +136 -0
  62. package/dist/utils/elementHighlight.js.map +1 -0
  63. package/dist/utils/locatorHelper.d.ts +7 -0
  64. package/dist/utils/locatorHelper.js +53 -0
  65. package/dist/utils/locatorHelper.js.map +1 -0
  66. package/dist/utils/logger.d.ts +12 -0
  67. package/dist/utils/logger.js +35 -0
  68. package/dist/utils/logger.js.map +1 -0
  69. package/dist/utils/response.d.ts +4 -0
  70. package/dist/utils/response.js +25 -0
  71. package/dist/utils/response.js.map +1 -0
  72. package/dist/utils/responseFormatter.d.ts +78 -0
  73. package/dist/utils/responseFormatter.js +123 -0
  74. package/dist/utils/responseFormatter.js.map +1 -0
  75. package/dist/utils/sseManager.d.ts +32 -0
  76. package/dist/utils/sseManager.js +122 -0
  77. package/dist/utils/sseManager.js.map +1 -0
  78. package/lexxit-automation-framework-2.0.0.tgz +0 -0
  79. package/npmignore +5 -0
  80. package/package.json +36 -0
  81. package/scripts/postinstall.js +52 -0
  82. package/src/app.ts +27 -0
  83. package/src/controllers/controller.ts +282 -0
  84. package/src/core/BrowserManager.ts +398 -0
  85. package/src/core/PlaywrightEngine.ts +371 -0
  86. package/src/core/ScreenshotManager.ts +25 -0
  87. package/src/core/TestData.ts +25 -0
  88. package/src/core/TestExecutor.ts +436 -0
  89. package/src/core/handlers/AllHandlers.ts +626 -0
  90. package/src/core/handlers/BaseHandler.ts +41 -0
  91. package/src/core/handlers/ClickHandler.ts +482 -0
  92. package/src/core/handlers/CustomCodeHandler.ts +123 -0
  93. package/src/core/handlers/DropdownHandler.ts +438 -0
  94. package/src/core/handlers/InputHandler.ts +192 -0
  95. package/src/core/registry/ActionRegistry.ts +31 -0
  96. package/src/installer/frameworkLauncher.ts +242 -0
  97. package/src/installer/install.sh +107 -0
  98. package/src/public/dashboard.html +540 -0
  99. package/src/public/queue-monitor.html +190 -0
  100. package/src/queue/ExecutionQueue.ts +200 -0
  101. package/src/routes/api.routes.ts +16 -0
  102. package/src/server.ts +29 -0
  103. package/src/types/types.ts +169 -0
  104. package/src/utils/elementHighlight.ts +174 -0
  105. package/src/utils/locatorHelper.ts +49 -0
  106. package/src/utils/logger.ts +40 -0
  107. package/src/utils/response.ts +27 -0
  108. package/src/utils/responseFormatter.ts +167 -0
  109. package/src/utils/sseManager.ts +127 -0
  110. package/tsconfig.json +18 -0
  111. package/videos/fb1b94b6-6639-4c9a-82bb-63572606f403/page@5bd5c6c8b62baa700e9810cdd64f5c49.webm +0 -0
@@ -0,0 +1,648 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableHandler = exports.CheckboxHandler = exports.KeyboardHandler = exports.WaitHandler = exports.AssertionHandler = void 0;
4
+ const response_1 = require("../../utils/response");
5
+ const locatorHelper_1 = require("../../utils/locatorHelper");
6
+ const BaseHandler_1 = require("./BaseHandler");
7
+ // ─── AssertionHandler ─────────────────────────────────────────────────────────
8
+ class AssertionHandler extends BaseHandler_1.BaseHandler {
9
+ constructor(tConfig, page) { super(tConfig, page); }
10
+ getActions() {
11
+ return {
12
+ verifytext: this.verifyText.bind(this),
13
+ verifytextcontains: this.verifyTextContains.bind(this),
14
+ verifytextnotequal: this.verifyTextNotEqual.bind(this),
15
+ verifyvalue: this.verifyValue.bind(this),
16
+ verifyvisible: this.verifyVisible.bind(this),
17
+ verifyhidden: this.verifyHidden.bind(this),
18
+ verifyenabled: this.verifyEnabled.bind(this),
19
+ verifydisabled: this.verifyDisabled.bind(this),
20
+ verifyurl: this.verifyURL.bind(this),
21
+ verifypartialurl: this.verifyPartialURL.bind(this),
22
+ verifyelementcount: this.verifyElementCount.bind(this),
23
+ verifyattribute: this.verifyAttribute.bind(this),
24
+ verifychecked: this.verifyChecked.bind(this),
25
+ verifyunchecked: this.verifyUnchecked.bind(this),
26
+ gettext: this.getText.bind(this),
27
+ getattribute: this.getAttribute.bind(this),
28
+ assertequal: this.assertEqual.bind(this),
29
+ assertnotequal: this.assertNotEqual.bind(this),
30
+ };
31
+ }
32
+ async verifyText(args) {
33
+ const [strategy, locator, expected] = args;
34
+ if (!strategy || !locator || expected === undefined)
35
+ return (0, response_1.fail)("verifyText needs: strategy, locator, expectedText");
36
+ try {
37
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
38
+ await el.waitFor({ state: "visible", timeout: this.timeout });
39
+ const actual = (await el.innerText()).trim();
40
+ const ok = actual === expected.trim();
41
+ const msg = ok ? `Text matches: "${expected}"` : `Text mismatch. Expected: "${expected}", Got: "${actual}"`;
42
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
43
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
44
+ }
45
+ catch (error) {
46
+ return (0, response_1.fail)(`Failed verifyText [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
47
+ }
48
+ }
49
+ async verifyTextContains(args) {
50
+ const [strategy, locator, partial] = args;
51
+ if (!strategy || !locator || partial === undefined)
52
+ return (0, response_1.fail)("verifyTextContains needs: strategy, locator, partialText");
53
+ try {
54
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
55
+ await el.waitFor({ state: "visible", timeout: this.timeout });
56
+ const actual = (await el.innerText()).trim();
57
+ const ok = actual.toLowerCase().includes(partial.toLowerCase());
58
+ const msg = ok ? `Text contains: "${partial}"` : `Text "${actual}" does not contain "${partial}"`;
59
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
60
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
61
+ }
62
+ catch (error) {
63
+ return (0, response_1.fail)(`Failed verifyTextContains [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
64
+ }
65
+ }
66
+ async verifyTextNotEqual(args) {
67
+ const [strategy, locator, notExpected] = args;
68
+ if (!strategy || !locator || notExpected === undefined)
69
+ return (0, response_1.fail)("verifyTextNotEqual needs: strategy, locator, text");
70
+ try {
71
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
72
+ await el.waitFor({ state: "visible", timeout: this.timeout });
73
+ const actual = (await el.innerText()).trim();
74
+ const ok = actual !== notExpected.trim();
75
+ const msg = ok ? `Text is not "${notExpected}" ✓` : `Text should not equal "${notExpected}"`;
76
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
77
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
78
+ }
79
+ catch (error) {
80
+ return (0, response_1.fail)(`Failed verifyTextNotEqual [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
81
+ }
82
+ }
83
+ async verifyValue(args) {
84
+ const [strategy, locator, expected] = args;
85
+ if (!strategy || !locator || expected === undefined)
86
+ return (0, response_1.fail)("verifyValue needs: strategy, locator, expected");
87
+ try {
88
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
89
+ await el.waitFor({ state: "attached", timeout: this.timeout });
90
+ const actual = await el.inputValue();
91
+ const ok = actual === expected;
92
+ const msg = ok ? `Value matches: "${expected}"` : `Value mismatch. Expected: "${expected}", Got: "${actual}"`;
93
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
94
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
95
+ }
96
+ catch (error) {
97
+ return (0, response_1.fail)(`Failed verifyValue [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
98
+ }
99
+ }
100
+ async verifyVisible(args) {
101
+ const [strategy, locator] = args;
102
+ if (!strategy || !locator)
103
+ return (0, response_1.fail)("verifyVisible needs: strategy, locator");
104
+ try {
105
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
106
+ const visible = await el.isVisible();
107
+ const msg = visible ? "Element is visible ✓" : "Element is NOT visible";
108
+ const sc = visible ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
109
+ return visible ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
110
+ }
111
+ catch (error) {
112
+ return (0, response_1.fail)(`Failed verifyVisible [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
113
+ }
114
+ }
115
+ async verifyHidden(args) {
116
+ const [strategy, locator] = args;
117
+ if (!strategy || !locator)
118
+ return (0, response_1.fail)("verifyHidden needs: strategy, locator");
119
+ try {
120
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
121
+ const hidden = await el.isHidden();
122
+ const msg = hidden ? "Element is hidden ✓" : "Element is visible (expected hidden)";
123
+ const sc = hidden ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
124
+ return hidden ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
125
+ }
126
+ catch (error) {
127
+ return (0, response_1.fail)(`Failed verifyHidden [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
128
+ }
129
+ }
130
+ async verifyEnabled(args) {
131
+ const [strategy, locator] = args;
132
+ if (!strategy || !locator)
133
+ return (0, response_1.fail)("verifyEnabled needs: strategy, locator");
134
+ try {
135
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
136
+ const enabled = await el.isEnabled();
137
+ const sc = enabled ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
138
+ return enabled ? (0, response_1.pass)("Element is enabled ✓", sc) : (0, response_1.fail)("Element is NOT enabled", undefined, sc);
139
+ }
140
+ catch (error) {
141
+ return (0, response_1.fail)(`Failed verifyEnabled [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
142
+ }
143
+ }
144
+ async verifyDisabled(args) {
145
+ const [strategy, locator] = args;
146
+ if (!strategy || !locator)
147
+ return (0, response_1.fail)("verifyDisabled needs: strategy, locator");
148
+ try {
149
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
150
+ const disabled = await el.isDisabled();
151
+ const sc = disabled ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
152
+ return disabled ? (0, response_1.pass)("Element is disabled ✓", sc) : (0, response_1.fail)("Element is NOT disabled", undefined, sc);
153
+ }
154
+ catch (error) {
155
+ return (0, response_1.fail)(`Failed verifyDisabled [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
156
+ }
157
+ }
158
+ async verifyURL(args) {
159
+ const [expected] = args;
160
+ const actual = this.page.url();
161
+ const ok = actual === expected;
162
+ const msg = ok ? `URL matches ✓` : `URL mismatch. Expected: "${expected}", Got: "${actual}"`;
163
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
164
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
165
+ }
166
+ async verifyPartialURL(args) {
167
+ const [partial] = args;
168
+ const actual = this.page.url();
169
+ const ok = actual.includes(partial);
170
+ const msg = ok ? `URL contains: "${partial}" ✓` : `URL "${actual}" does not contain "${partial}"`;
171
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
172
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
173
+ }
174
+ async verifyElementCount(args) {
175
+ const [strategy, locator, expectedStr] = args;
176
+ const expected = parseInt(expectedStr, 10);
177
+ if (!strategy || !locator || isNaN(expected))
178
+ return (0, response_1.fail)("verifyElementCount needs: strategy, locator, expectedCount");
179
+ try {
180
+ const actual = await this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator)).count();
181
+ const ok = actual === expected;
182
+ const msg = ok ? `Count: ${actual} ✓` : `Count mismatch. Expected: ${expected}, Got: ${actual}`;
183
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
184
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
185
+ }
186
+ catch (error) {
187
+ return (0, response_1.fail)(`Failed verifyElementCount [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
188
+ }
189
+ }
190
+ async verifyAttribute(args) {
191
+ const [strategy, locator, attribute, expected] = args;
192
+ if (!strategy || !locator || !attribute || expected === undefined)
193
+ return (0, response_1.fail)("verifyAttribute needs: strategy, locator, attribute, expectedValue");
194
+ try {
195
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
196
+ await el.waitFor({ state: "attached", timeout: this.timeout });
197
+ const actual = await el.getAttribute(attribute);
198
+ const ok = actual === expected;
199
+ const msg = ok ? `Attribute "${attribute}" = "${expected}" ✓` : `Attr "${attribute}" mismatch. Expected: "${expected}", Got: "${actual}"`;
200
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
201
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
202
+ }
203
+ catch (error) {
204
+ return (0, response_1.fail)(`Failed verifyAttribute [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
205
+ }
206
+ }
207
+ async verifyChecked(args) {
208
+ const [strategy, locator] = args;
209
+ if (!strategy || !locator)
210
+ return (0, response_1.fail)("verifyChecked needs: strategy, locator");
211
+ try {
212
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
213
+ const checked = await el.isChecked();
214
+ const sc = checked ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
215
+ return checked ? (0, response_1.pass)("Checkbox is checked ✓", sc) : (0, response_1.fail)("Checkbox is NOT checked", undefined, sc);
216
+ }
217
+ catch (error) {
218
+ return (0, response_1.fail)(`Failed verifyChecked [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
219
+ }
220
+ }
221
+ async verifyUnchecked(args) {
222
+ const [strategy, locator] = args;
223
+ if (!strategy || !locator)
224
+ return (0, response_1.fail)("verifyUnchecked needs: strategy, locator");
225
+ try {
226
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
227
+ const unchecked = !(await el.isChecked());
228
+ const sc = unchecked ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
229
+ return unchecked ? (0, response_1.pass)("Checkbox is unchecked ✓", sc) : (0, response_1.fail)("Checkbox IS checked (expected unchecked)", undefined, sc);
230
+ }
231
+ catch (error) {
232
+ return (0, response_1.fail)(`Failed verifyUnchecked [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
233
+ }
234
+ }
235
+ async getText(args) {
236
+ const [strategy, locator, storeKey] = args;
237
+ if (!strategy || !locator)
238
+ return (0, response_1.fail)("getText needs: strategy, locator, [storeKey]");
239
+ try {
240
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
241
+ await el.waitFor({ state: "visible", timeout: this.timeout });
242
+ const text = (await el.innerText()).trim();
243
+ if (storeKey)
244
+ this.testData.set(storeKey, text);
245
+ return (0, response_1.pass)(`Text: "${text}"`, await this.shots.onPass(this.page), { text });
246
+ }
247
+ catch (error) {
248
+ return (0, response_1.fail)(`Failed getText [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
249
+ }
250
+ }
251
+ async getAttribute(args) {
252
+ const [strategy, locator, attribute, storeKey] = args;
253
+ if (!strategy || !locator || !attribute)
254
+ return (0, response_1.fail)("getAttribute needs: strategy, locator, attribute, [storeKey]");
255
+ try {
256
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
257
+ await el.waitFor({ state: "attached", timeout: this.timeout });
258
+ const value = await el.getAttribute(attribute);
259
+ if (storeKey)
260
+ this.testData.set(storeKey, value);
261
+ return (0, response_1.pass)(`Attribute "${attribute}": "${value}"`, await this.shots.onPass(this.page), { value });
262
+ }
263
+ catch (error) {
264
+ return (0, response_1.fail)(`Failed getAttribute [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
265
+ }
266
+ }
267
+ async assertEqual(args) {
268
+ const [actual, expected, label] = args;
269
+ const ok = actual === expected;
270
+ const tag = label || "Value";
271
+ const msg = ok ? `${tag} matches: "${expected}" ✓` : `${tag} mismatch. Expected: "${expected}", Got: "${actual}"`;
272
+ return ok ? (0, response_1.pass)(msg) : (0, response_1.fail)(msg);
273
+ }
274
+ async assertNotEqual(args) {
275
+ const [actual, notExpected, label] = args;
276
+ const ok = actual !== notExpected;
277
+ const tag = label || "Value";
278
+ const msg = ok ? `${tag} is not "${notExpected}" ✓` : `${tag} should not equal "${notExpected}"`;
279
+ return ok ? (0, response_1.pass)(msg) : (0, response_1.fail)(msg);
280
+ }
281
+ }
282
+ exports.AssertionHandler = AssertionHandler;
283
+ // ─── WaitHandler ─────────────────────────────────────────────────────────────
284
+ class WaitHandler extends BaseHandler_1.BaseHandler {
285
+ constructor(tConfig, page) { super(tConfig, page); }
286
+ getActions() {
287
+ return {
288
+ waitforelement: this.waitForElement.bind(this),
289
+ waitforelementhidden: this.waitForElementHidden.bind(this),
290
+ waitforurl: this.waitForURL.bind(this),
291
+ waitfortitle: this.waitForTitle.bind(this),
292
+ waitforpageload: this.waitForPageLoad.bind(this),
293
+ waitfornetworkidle: this.waitForNetworkIdle.bind(this),
294
+ waitfortextpresent: this.waitForTextPresent.bind(this),
295
+ sleep: this.sleep.bind(this),
296
+ };
297
+ }
298
+ async waitForElement(args) {
299
+ const [strategy, locator, timeoutStr] = args;
300
+ const timeout = parseInt(timeoutStr || String(this.timeout), 10);
301
+ if (!strategy || !locator)
302
+ return (0, response_1.fail)("waitForElement needs: strategy, locator, [timeoutMs]");
303
+ try {
304
+ await this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator)).waitFor({ state: "visible", timeout });
305
+ return (0, response_1.pass)(`Element visible: [${strategy}=${locator}]`, await this.shots.onPass(this.page));
306
+ }
307
+ catch (error) {
308
+ return (0, response_1.fail)(`Element not visible in ${timeout}ms [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
309
+ }
310
+ }
311
+ async waitForElementHidden(args) {
312
+ const [strategy, locator, timeoutStr] = args;
313
+ const timeout = parseInt(timeoutStr || String(this.timeout), 10);
314
+ if (!strategy || !locator)
315
+ return (0, response_1.fail)("waitForElementHidden needs: strategy, locator, [timeoutMs]");
316
+ try {
317
+ await this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator)).waitFor({ state: "hidden", timeout });
318
+ return (0, response_1.pass)(`Element hidden: [${strategy}=${locator}]`, await this.shots.onPass(this.page));
319
+ }
320
+ catch (error) {
321
+ return (0, response_1.fail)(`Element still visible after ${timeout}ms [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
322
+ }
323
+ }
324
+ async waitForURL(args) {
325
+ const [urlPattern, timeoutStr] = args;
326
+ const timeout = parseInt(timeoutStr || String(this.timeout), 10);
327
+ if (!urlPattern)
328
+ return (0, response_1.fail)("waitForURL needs: urlPattern, [timeoutMs]");
329
+ try {
330
+ await this.page.waitForURL(new RegExp(urlPattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")), { timeout });
331
+ return (0, response_1.pass)(`URL matches: "${urlPattern}"`, await this.shots.onPass(this.page));
332
+ }
333
+ catch (error) {
334
+ return (0, response_1.fail)(`URL not reached in ${timeout}ms: "${urlPattern}"`, error.message, await this.shots.onFail(this.page));
335
+ }
336
+ }
337
+ async waitForTitle(args) {
338
+ const [titlePart, timeoutStr] = args;
339
+ const timeout = parseInt(timeoutStr || String(this.timeout), 10);
340
+ if (!titlePart)
341
+ return (0, response_1.fail)("waitForTitle needs: titlePart, [timeoutMs]");
342
+ try {
343
+ await this.page.waitForFunction((t) => document.title.includes(t), titlePart, { timeout });
344
+ return (0, response_1.pass)(`Title contains: "${titlePart}"`, await this.shots.onPass(this.page));
345
+ }
346
+ catch (error) {
347
+ return (0, response_1.fail)(`Title not found in ${timeout}ms: "${titlePart}"`, error.message, await this.shots.onFail(this.page));
348
+ }
349
+ }
350
+ async waitForPageLoad(args) {
351
+ const timeout = parseInt(args[0] || String(this.timeout), 10);
352
+ try {
353
+ await this.page.waitForLoadState("domcontentloaded", { timeout });
354
+ return (0, response_1.pass)("Page loaded", await this.shots.onPass(this.page));
355
+ }
356
+ catch (error) {
357
+ return (0, response_1.fail)(`Page did not load in ${timeout}ms`, error.message, await this.shots.onFail(this.page));
358
+ }
359
+ }
360
+ async waitForNetworkIdle(args) {
361
+ const timeout = parseInt(args[0] || String(this.timeout), 10);
362
+ try {
363
+ await this.page.waitForLoadState("networkidle", { timeout });
364
+ return (0, response_1.pass)("Network is idle", await this.shots.onPass(this.page));
365
+ }
366
+ catch (error) {
367
+ return (0, response_1.fail)(`Network not idle in ${timeout}ms`, error.message, await this.shots.onFail(this.page));
368
+ }
369
+ }
370
+ async waitForTextPresent(args) {
371
+ const [strategy, locator, text, timeoutStr] = args;
372
+ const timeout = parseInt(timeoutStr || String(this.timeout), 10);
373
+ if (!strategy || !locator || !text)
374
+ return (0, response_1.fail)("waitForTextPresent needs: strategy, locator, text, [timeoutMs]");
375
+ try {
376
+ await this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator)).filter({ hasText: text }).waitFor({ state: "visible", timeout });
377
+ return (0, response_1.pass)(`Text "${text}" is present`, await this.shots.onPass(this.page));
378
+ }
379
+ catch (error) {
380
+ return (0, response_1.fail)(`Text "${text}" not found in ${timeout}ms`, error.message, await this.shots.onFail(this.page));
381
+ }
382
+ }
383
+ async sleep(args) {
384
+ const ms = parseInt(args[0] || "1000", 10);
385
+ await this.page.waitForTimeout(ms);
386
+ return (0, response_1.pass)(`Waited ${ms}ms`);
387
+ }
388
+ }
389
+ exports.WaitHandler = WaitHandler;
390
+ // ─── KeyboardHandler ──────────────────────────────────────────────────────────
391
+ class KeyboardHandler extends BaseHandler_1.BaseHandler {
392
+ constructor(tConfig, page) { super(tConfig, page); }
393
+ getActions() {
394
+ return {
395
+ presskey: this.pressKey.bind(this),
396
+ presskeyon: this.pressKeyOn.bind(this),
397
+ keysendenter: this.sendEnter.bind(this),
398
+ keysendtab: this.sendTab.bind(this),
399
+ keysendesc: this.sendEsc.bind(this),
400
+ keycombo: this.keyCombo.bind(this),
401
+ selectall: this.selectAll.bind(this),
402
+ copytext: this.copyText.bind(this),
403
+ pastetext: this.pasteText.bind(this),
404
+ };
405
+ }
406
+ async pressKey(args) {
407
+ const [key] = args;
408
+ if (!key)
409
+ return (0, response_1.fail)("pressKey needs: keyName (e.g. Enter, Tab, F5, ArrowDown)");
410
+ try {
411
+ await this.page.keyboard.press(key);
412
+ return (0, response_1.pass)(`Pressed: ${key}`);
413
+ }
414
+ catch (error) {
415
+ return (0, response_1.fail)(`Failed pressKey: ${key}`, error.message);
416
+ }
417
+ }
418
+ async pressKeyOn(args) {
419
+ const [strategy, locator, key] = args;
420
+ if (!strategy || !locator || !key)
421
+ return (0, response_1.fail)("pressKeyOn needs: strategy, locator, keyName");
422
+ try {
423
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
424
+ await el.waitFor({ state: "visible", timeout: this.timeout });
425
+ await el.press(key, { timeout: this.timeout });
426
+ return (0, response_1.pass)(`Pressed ${key} on [${strategy}=${locator}]`, await this.shots.onPass(this.page));
427
+ }
428
+ catch (error) {
429
+ return (0, response_1.fail)(`Failed pressKeyOn [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
430
+ }
431
+ }
432
+ async sendEnter(args) { return this.pressKeyOn([args[0], args[1], "Enter"]); }
433
+ async sendTab(args) { return this.pressKeyOn([args[0], args[1], "Tab"]); }
434
+ async sendEsc(args) { return this.pressKeyOn([args[0], args[1], "Escape"]); }
435
+ // tSetup.keyCombo('Control+A')
436
+ async keyCombo(args) {
437
+ const [combo] = args;
438
+ if (!combo)
439
+ return (0, response_1.fail)("keyCombo needs: combo (e.g. Control+A, Control+Shift+T)");
440
+ try {
441
+ await this.page.keyboard.press(combo);
442
+ return (0, response_1.pass)(`Key combo: ${combo}`);
443
+ }
444
+ catch (error) {
445
+ return (0, response_1.fail)(`Failed keyCombo: ${combo}`, error.message);
446
+ }
447
+ }
448
+ async selectAll(args) {
449
+ const [strategy, locator] = args;
450
+ try {
451
+ if (strategy && locator) {
452
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
453
+ await el.focus();
454
+ }
455
+ await this.page.keyboard.press("Control+A");
456
+ return (0, response_1.pass)("Select All (Ctrl+A)");
457
+ }
458
+ catch (error) {
459
+ return (0, response_1.fail)("Failed selectAll", error.message);
460
+ }
461
+ }
462
+ async copyText(args) {
463
+ try {
464
+ await this.page.keyboard.press("Control+C");
465
+ return (0, response_1.pass)("Copied selection");
466
+ }
467
+ catch (error) {
468
+ return (0, response_1.fail)("Failed copyText", error.message);
469
+ }
470
+ }
471
+ async pasteText(args) {
472
+ try {
473
+ await this.page.keyboard.press("Control+V");
474
+ return (0, response_1.pass)("Pasted");
475
+ }
476
+ catch (error) {
477
+ return (0, response_1.fail)("Failed pasteText", error.message);
478
+ }
479
+ }
480
+ }
481
+ exports.KeyboardHandler = KeyboardHandler;
482
+ // ─── CheckboxHandler ──────────────────────────────────────────────────────────
483
+ class CheckboxHandler extends BaseHandler_1.BaseHandler {
484
+ constructor(tConfig, page) { super(tConfig, page); }
485
+ getActions() {
486
+ return {
487
+ checkcheckbox: this.check.bind(this),
488
+ uncheckcheckbox: this.uncheck.bind(this),
489
+ togglecheckbox: this.toggle.bind(this),
490
+ selectradio: this.selectRadio.bind(this),
491
+ };
492
+ }
493
+ async check(args) {
494
+ const [strategy, locator] = args;
495
+ if (!strategy || !locator)
496
+ return (0, response_1.fail)("checkCheckbox needs: strategy, locator");
497
+ try {
498
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
499
+ await el.waitFor({ state: "visible", timeout: this.timeout });
500
+ await el.check({ timeout: this.timeout });
501
+ return (0, response_1.pass)(`Checked [${strategy}=${locator}]`, await this.shots.onPass(this.page));
502
+ }
503
+ catch (error) {
504
+ return (0, response_1.fail)(`Failed check [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
505
+ }
506
+ }
507
+ async uncheck(args) {
508
+ const [strategy, locator] = args;
509
+ if (!strategy || !locator)
510
+ return (0, response_1.fail)("uncheckCheckbox needs: strategy, locator");
511
+ try {
512
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
513
+ await el.waitFor({ state: "visible", timeout: this.timeout });
514
+ await el.uncheck({ timeout: this.timeout });
515
+ return (0, response_1.pass)(`Unchecked [${strategy}=${locator}]`, await this.shots.onPass(this.page));
516
+ }
517
+ catch (error) {
518
+ return (0, response_1.fail)(`Failed uncheck [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
519
+ }
520
+ }
521
+ async toggle(args) {
522
+ const [strategy, locator] = args;
523
+ if (!strategy || !locator)
524
+ return (0, response_1.fail)("toggleCheckbox needs: strategy, locator");
525
+ try {
526
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
527
+ await el.waitFor({ state: "visible", timeout: this.timeout });
528
+ const checked = await el.isChecked();
529
+ checked ? await el.uncheck() : await el.check();
530
+ return (0, response_1.pass)(`Toggled (now ${!checked}) [${strategy}=${locator}]`, await this.shots.onPass(this.page));
531
+ }
532
+ catch (error) {
533
+ return (0, response_1.fail)(`Failed toggle [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
534
+ }
535
+ }
536
+ async selectRadio(args) {
537
+ const [strategy, locator] = args;
538
+ if (!strategy || !locator)
539
+ return (0, response_1.fail)("selectRadio needs: strategy, locator");
540
+ try {
541
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
542
+ await el.waitFor({ state: "visible", timeout: this.timeout });
543
+ await el.click({ timeout: this.timeout });
544
+ return (0, response_1.pass)(`Radio selected [${strategy}=${locator}]`, await this.shots.onPass(this.page));
545
+ }
546
+ catch (error) {
547
+ return (0, response_1.fail)(`Failed selectRadio [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
548
+ }
549
+ }
550
+ }
551
+ exports.CheckboxHandler = CheckboxHandler;
552
+ // ─── TableHandler ─────────────────────────────────────────────────────────────
553
+ class TableHandler extends BaseHandler_1.BaseHandler {
554
+ constructor(tConfig, page) { super(tConfig, page); }
555
+ getActions() {
556
+ return {
557
+ gettablerowcount: this.getTableRowCount.bind(this),
558
+ gettablecellvalue: this.getTableCellValue.bind(this),
559
+ verifytablecell: this.verifyTableCell.bind(this),
560
+ clicktablerow: this.clickTableRow.bind(this),
561
+ gettablecolumnvalues: this.getTableColumnValues.bind(this),
562
+ };
563
+ }
564
+ // tSetup.getTableRowCount('xpath', '//table/tbody/tr', 'storeKey')
565
+ async getTableRowCount(args) {
566
+ const [strategy, locator, storeKey] = args;
567
+ if (!strategy || !locator)
568
+ return (0, response_1.fail)("getTableRowCount needs: strategy, locator, [storeKey]");
569
+ try {
570
+ const count = await this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator)).count();
571
+ if (storeKey)
572
+ this.testData.set(storeKey, count);
573
+ return (0, response_1.pass)(`Row count: ${count}`, await this.shots.onPass(this.page), { count });
574
+ }
575
+ catch (error) {
576
+ return (0, response_1.fail)(`Failed getTableRowCount [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
577
+ }
578
+ }
579
+ // tSetup.getTableCellValue('xpath', '//table/tbody/tr[2]/td[3]', 'storeKey')
580
+ async getTableCellValue(args) {
581
+ const [strategy, locator, storeKey] = args;
582
+ if (!strategy || !locator)
583
+ return (0, response_1.fail)("getTableCellValue needs: strategy, locator, [storeKey]");
584
+ try {
585
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
586
+ await el.waitFor({ state: "visible", timeout: this.timeout });
587
+ const text = (await el.innerText()).trim();
588
+ if (storeKey)
589
+ this.testData.set(storeKey, text);
590
+ return (0, response_1.pass)(`Cell value: "${text}"`, await this.shots.onPass(this.page), { text });
591
+ }
592
+ catch (error) {
593
+ return (0, response_1.fail)(`Failed getTableCellValue [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
594
+ }
595
+ }
596
+ // tSetup.verifyTableCell('xpath', '//table/tbody/tr[1]/td[2]', 'Expected Value')
597
+ async verifyTableCell(args) {
598
+ const [strategy, locator, expected] = args;
599
+ if (!strategy || !locator || !expected)
600
+ return (0, response_1.fail)("verifyTableCell needs: strategy, locator, expectedValue");
601
+ try {
602
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator));
603
+ await el.waitFor({ state: "visible", timeout: this.timeout });
604
+ const actual = (await el.innerText()).trim();
605
+ const ok = actual === expected.trim();
606
+ const msg = ok ? `Cell matches: "${expected}" ✓` : `Cell mismatch. Expected: "${expected}", Got: "${actual}"`;
607
+ const sc = ok ? await this.shots.onPass(this.page) : await this.shots.onFail(this.page);
608
+ return ok ? (0, response_1.pass)(msg, sc) : (0, response_1.fail)(msg, undefined, sc);
609
+ }
610
+ catch (error) {
611
+ return (0, response_1.fail)(`Failed verifyTableCell [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
612
+ }
613
+ }
614
+ // tSetup.clickTableRow('xpath', '//table/tbody/tr', '3')
615
+ async clickTableRow(args) {
616
+ const [strategy, locator, rowStr] = args;
617
+ const row = parseInt(rowStr || "1", 10) - 1;
618
+ if (!strategy || !locator)
619
+ return (0, response_1.fail)("clickTableRow needs: strategy, locator, rowNumber");
620
+ try {
621
+ const el = this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator)).nth(row);
622
+ await el.waitFor({ state: "visible", timeout: this.timeout });
623
+ await el.click({ timeout: this.timeout });
624
+ return (0, response_1.pass)(`Clicked row ${row + 1}`, await this.shots.onPass(this.page));
625
+ }
626
+ catch (error) {
627
+ return (0, response_1.fail)(`Failed clickTableRow row=${row + 1}`, error.message, await this.shots.onFail(this.page));
628
+ }
629
+ }
630
+ // tSetup.getTableColumnValues('xpath', '//table/tbody/tr/td[2]', 'storeKey')
631
+ async getTableColumnValues(args) {
632
+ const [strategy, locator, storeKey] = args;
633
+ if (!strategy || !locator)
634
+ return (0, response_1.fail)("getTableColumnValues needs: strategy, locator, [storeKey]");
635
+ try {
636
+ const values = await this.page.locator((0, locatorHelper_1.buildLocatorString)(strategy, locator)).allInnerTexts();
637
+ const trimmed = values.map(v => v.trim());
638
+ if (storeKey)
639
+ this.testData.set(storeKey, trimmed);
640
+ return (0, response_1.pass)(`Column values: [${trimmed.join(", ")}]`, await this.shots.onPass(this.page), { values: trimmed });
641
+ }
642
+ catch (error) {
643
+ return (0, response_1.fail)(`Failed getTableColumnValues [${strategy}=${locator}]`, error.message, await this.shots.onFail(this.page));
644
+ }
645
+ }
646
+ }
647
+ exports.TableHandler = TableHandler;
648
+ //# sourceMappingURL=AllHandlers.js.map