automation_model 1.0.449-dev → 1.0.449

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 (74) hide show
  1. package/README.md +133 -0
  2. package/lib/analyze_helper.js.map +1 -1
  3. package/lib/api.d.ts +43 -2
  4. package/lib/api.js +239 -49
  5. package/lib/api.js.map +1 -1
  6. package/lib/auto_page.d.ts +7 -2
  7. package/lib/auto_page.js +270 -49
  8. package/lib/auto_page.js.map +1 -1
  9. package/lib/browser_manager.d.ts +7 -3
  10. package/lib/browser_manager.js +172 -48
  11. package/lib/browser_manager.js.map +1 -1
  12. package/lib/bruno.d.ts +2 -0
  13. package/lib/bruno.js +381 -0
  14. package/lib/bruno.js.map +1 -0
  15. package/lib/command_common.d.ts +6 -0
  16. package/lib/command_common.js +202 -0
  17. package/lib/command_common.js.map +1 -0
  18. package/lib/date_time.js.map +1 -1
  19. package/lib/drawRect.js.map +1 -1
  20. package/lib/environment.d.ts +1 -0
  21. package/lib/environment.js +6 -3
  22. package/lib/environment.js.map +1 -1
  23. package/lib/error-messages.d.ts +6 -0
  24. package/lib/error-messages.js +206 -0
  25. package/lib/error-messages.js.map +1 -0
  26. package/lib/file_checker.d.ts +1 -0
  27. package/lib/file_checker.js +61 -0
  28. package/lib/file_checker.js.map +1 -0
  29. package/lib/find_function.js.map +1 -1
  30. package/lib/generation_scripts.d.ts +4 -0
  31. package/lib/generation_scripts.js +2 -0
  32. package/lib/generation_scripts.js.map +1 -0
  33. package/lib/index.d.ts +3 -0
  34. package/lib/index.js +3 -0
  35. package/lib/index.js.map +1 -1
  36. package/lib/init_browser.d.ts +4 -2
  37. package/lib/init_browser.js +117 -11
  38. package/lib/init_browser.js.map +1 -1
  39. package/lib/locate_element.d.ts +7 -0
  40. package/lib/locate_element.js +215 -0
  41. package/lib/locate_element.js.map +1 -0
  42. package/lib/locator.d.ts +37 -0
  43. package/lib/locator.js +172 -0
  44. package/lib/locator.js.map +1 -1
  45. package/lib/locator_log.d.ts +26 -0
  46. package/lib/locator_log.js +69 -0
  47. package/lib/locator_log.js.map +1 -0
  48. package/lib/network.d.ts +3 -0
  49. package/lib/network.js +183 -0
  50. package/lib/network.js.map +1 -0
  51. package/lib/route.d.ts +33 -0
  52. package/lib/route.js +325 -0
  53. package/lib/route.js.map +1 -0
  54. package/lib/scripts/axe.mini.js +12 -0
  55. package/lib/snapshot_validation.d.ts +37 -0
  56. package/lib/snapshot_validation.js +357 -0
  57. package/lib/snapshot_validation.js.map +1 -0
  58. package/lib/stable_browser.d.ts +150 -55
  59. package/lib/stable_browser.js +2541 -1306
  60. package/lib/stable_browser.js.map +1 -1
  61. package/lib/table.d.ts +15 -0
  62. package/lib/table.js +257 -0
  63. package/lib/table.js.map +1 -0
  64. package/lib/table_analyze.js.map +1 -1
  65. package/lib/table_helper.d.ts +19 -0
  66. package/lib/table_helper.js +116 -0
  67. package/lib/table_helper.js.map +1 -0
  68. package/lib/test_context.d.ts +7 -0
  69. package/lib/test_context.js +15 -10
  70. package/lib/test_context.js.map +1 -1
  71. package/lib/utils.d.ts +35 -2
  72. package/lib/utils.js +683 -11
  73. package/lib/utils.js.map +1 -1
  74. package/package.json +21 -11
package/lib/utils.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import CryptoJS from "crypto-js";
2
2
  import path from "path";
3
3
  import { TOTP } from "totp-generator";
4
+ import fs from "fs";
5
+ import axios from "axios";
6
+ import objectPath from "object-path";
4
7
  // Function to encrypt a string
5
8
  function encrypt(text, key = null) {
6
9
  if (!key) {
@@ -8,8 +11,29 @@ function encrypt(text, key = null) {
8
11
  }
9
12
  return CryptoJS.AES.encrypt(text, key).toString();
10
13
  }
14
+ function getTestDataValue(key, environment = "*") {
15
+ const blinqEnvPath = "data/data.json";
16
+ const envPath = path.resolve(process.cwd(), blinqEnvPath);
17
+ const envJson = JSON.parse(fs.readFileSync(envPath, "utf-8"));
18
+ const dataArray = envJson[environment];
19
+ const item = dataArray.find((item) => item.key === key);
20
+ // if the item is not found in the specific env, check if it exists in the default environment
21
+ if (!item && environment !== "*") {
22
+ return getTestDataValue(key, "*");
23
+ }
24
+ if (!item) {
25
+ throw new Error(`Key ${key} not found in data.json`);
26
+ }
27
+ if (item.DataType === "string") {
28
+ return item.value;
29
+ }
30
+ else if (item.DataType === "secret" || item.DataType === "totp") {
31
+ return decrypt(item.value, null, false);
32
+ }
33
+ throw new Error(`Unsupported data type for key ${key}`);
34
+ }
11
35
  // Function to decrypt a string
12
- async function decrypt(encryptedText, key = null, totpWait = true) {
36
+ function decrypt(encryptedText, key = null, totpWait = true) {
13
37
  if (!key) {
14
38
  key = _findKey();
15
39
  }
@@ -21,19 +45,105 @@ async function decrypt(encryptedText, key = null, totpWait = true) {
21
45
  const bytes = CryptoJS.AES.decrypt(encryptedText, key);
22
46
  encryptedText = bytes.toString(CryptoJS.enc.Utf8);
23
47
  let { otp, expires } = TOTP.generate(encryptedText);
24
- if (totpWait) {
25
- // expires is in unix time, check if we have at least 10 seconds left, if it's less than wait for the expires time
26
- if (expires - Date.now() < 10000) {
27
- await new Promise((resolve) => setTimeout(resolve, (expires - Date.now() + 1000) % 30000));
28
- ({ otp, expires } = TOTP.generate(encryptedText));
29
- }
30
- }
48
+ // if (totpWait) {
49
+ // // expires is in unix time, check if we have at least 10 seconds left, if it's less than wait for the expires time
50
+ // if (expires - Date.now() < 10000) {
51
+ // await new Promise((resolve) => setTimeout(resolve, (expires - Date.now() + 1000) % 30000));
52
+ // ({ otp, expires } = TOTP.generate(encryptedText));
53
+ // }
54
+ // }
31
55
  return otp;
32
56
  }
57
+ if (encryptedText.startsWith("mask:")) {
58
+ return encryptedText.substring(5);
59
+ }
33
60
  const bytes = CryptoJS.AES.decrypt(encryptedText, key);
34
61
  return bytes.toString(CryptoJS.enc.Utf8);
35
62
  }
63
+ export function testForRegex(text) {
64
+ const regexEndPattern = /\/([gimuy]*)$/;
65
+ if (text.startsWith("/")) {
66
+ const match = regexEndPattern.test(text);
67
+ if (match) {
68
+ try {
69
+ const regex = new RegExp(text.substring(1, text.lastIndexOf("/")), text.match(regexEndPattern)[1]);
70
+ return true;
71
+ }
72
+ catch {
73
+ // not regex
74
+ }
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+ function _convertToRegexQuery(text, isRegex, fullMatch, ignoreCase) {
80
+ let query = "internal:text=/";
81
+ let queryEnd = "/";
82
+ let pattern = "";
83
+ const regexEndPattern = /\/([gimuy]*)$/;
84
+ if (text.startsWith("/")) {
85
+ const match = regexEndPattern.test(text);
86
+ if (match) {
87
+ try {
88
+ const regex = new RegExp(text.substring(1, text.lastIndexOf("/")), text.match(regexEndPattern)[1]);
89
+ text = text.replace(/"/g, '\\"');
90
+ return "internal:text=" + text;
91
+ }
92
+ catch {
93
+ // not regex
94
+ }
95
+ }
96
+ }
97
+ if (isRegex) {
98
+ pattern = text;
99
+ }
100
+ else {
101
+ // first remove \n then split the text by any white space,
102
+ let parts = text.replace(/\\n/g, "").split(/\s+/);
103
+ // escape regex split part
104
+ parts = parts.map((part) => escapeRegex(part));
105
+ pattern = parts.join("\\s*");
106
+ }
107
+ if (fullMatch) {
108
+ pattern = "^\\s*" + pattern + "\\s*$";
109
+ }
110
+ if (ignoreCase) {
111
+ queryEnd += "i";
112
+ }
113
+ return query + pattern + queryEnd + " >> visible=true";
114
+ }
115
+ function escapeRegex(str) {
116
+ // Special regex characters that need to be escaped
117
+ const specialChars = [
118
+ "/",
119
+ ".",
120
+ "*",
121
+ "+",
122
+ "?",
123
+ "^",
124
+ "$",
125
+ "(",
126
+ ")",
127
+ "[",
128
+ "]",
129
+ "{",
130
+ "}",
131
+ "|",
132
+ "\\",
133
+ "-",
134
+ "'",
135
+ '"',
136
+ ">", // added to avoid confusion with pw selectorsxw
137
+ ];
138
+ // Create a regex that will match all special characters
139
+ const escapedRegex = new RegExp(specialChars.map((char) => `\\${char}`).join("|"), "g");
140
+ // Escape special characters by prefixing them with a backslash
141
+ return str.replace(escapedRegex, "\\$&");
142
+ }
36
143
  function _findKey() {
144
+ if (process.env.PROJECT_KEY) {
145
+ return process.env.PROJECT_KEY;
146
+ }
37
147
  if (process.env.PROJECT_ID) {
38
148
  return process.env.PROJECT_ID;
39
149
  }
@@ -45,7 +155,569 @@ function _findKey() {
45
155
  // extract the base folder name
46
156
  return path.basename(folder);
47
157
  }
48
- // console.log(encrypt("Hello, World!", null));
49
- // console.log(decrypt("U2FsdGVkX1+6mavadgkMgJPIhR3IO1pDkx36TjTyoyE=", null));
50
- export { encrypt, decrypt };
158
+ function _getDataFile(world = null, context = null, web = null) {
159
+ let dataFile = null;
160
+ if (world && world.reportFolder) {
161
+ dataFile = path.join(world.reportFolder, "data.json");
162
+ }
163
+ else if (web && web.reportFolder) {
164
+ dataFile = path.join(web.reportFolder, "data.json");
165
+ }
166
+ else if (context && context.reportFolder) {
167
+ dataFile = path.join(context.reportFolder, "data.json");
168
+ }
169
+ else if (web && web.project_path) {
170
+ dataFile = path.join(web.project_path, "data", "data.json");
171
+ }
172
+ else {
173
+ dataFile = "data.json";
174
+ }
175
+ return dataFile;
176
+ }
177
+ function _getTestDataFile(world = null, context = null, web = null) {
178
+ let dataFile = null;
179
+ if (world && world.reportFolder) {
180
+ dataFile = path.join(world.reportFolder, "data.json");
181
+ }
182
+ else if (web && web.reportFolder) {
183
+ dataFile = path.join(web.reportFolder, "data.json");
184
+ }
185
+ else if (context && context.reportFolder) {
186
+ dataFile = path.join(context.reportFolder, "data.json");
187
+ }
188
+ else if (fs.existsSync(path.join("data", "data.json"))) {
189
+ dataFile = path.join("data", "data.json");
190
+ }
191
+ else {
192
+ dataFile = "data.json";
193
+ }
194
+ return dataFile;
195
+ }
196
+ function _getTestData(world = null, context = null, web = null) {
197
+ const dataFile = _getDataFile(world, context, web);
198
+ let data = {};
199
+ if (fs.existsSync(dataFile)) {
200
+ // convert \r\n to \n
201
+ const fileContent = fs.readFileSync(dataFile, "utf8").replace(/\r\n/g, "\n");
202
+ data = JSON.parse(fileContent);
203
+ }
204
+ return data;
205
+ }
206
+ async function replaceWithLocalTestData(value, world, _decrypt = true, totpWait = true, context = null, web = null, throwError = true) {
207
+ if (!value) {
208
+ return value;
209
+ }
210
+ let env = context?.environment?.name || "";
211
+ // used for unit tests
212
+ let testData = context?._data_ ? context._data_ : _getTestData(world, context, web);
213
+ const resolveDatePlaceholder = async (key) => {
214
+ const dateQuery = key.substring(5);
215
+ const parts = dateQuery.split(">>");
216
+ const returnTemplate = parts[1] || null;
217
+ const serviceUrl = _getServerUrl();
218
+ const config = {
219
+ method: "post",
220
+ url: `${serviceUrl}/api/runs/find-date/find`,
221
+ headers: {
222
+ "x-source": "true",
223
+ "Content-Type": "application/json",
224
+ Authorization: `Bearer ${process.env.TOKEN}`,
225
+ },
226
+ data: JSON.stringify({ value: parts[0] }),
227
+ };
228
+ const result = await axios.request(config);
229
+ if (result.status !== 200 || !result.data?.status || !result.data.result) {
230
+ console.error("Failed to find date");
231
+ throw new Error("Failed to find date");
232
+ }
233
+ return formatDate(result.data.result, returnTemplate);
234
+ };
235
+ const resolvePlaceholder = async (key) => {
236
+ if (key.startsWith("date:")) {
237
+ return await resolveDatePlaceholder(key);
238
+ }
239
+ let resolved = replaceTestDataValue(env, key, testData, _decrypt);
240
+ if (resolved !== null)
241
+ return resolved;
242
+ resolved = replaceTestDataValue("*", key, testData, _decrypt);
243
+ if (resolved !== null)
244
+ return resolved;
245
+ if (throwError) {
246
+ throw new Error(`Parameter "{{${key}}}" is undefined in the test data`);
247
+ }
248
+ else {
249
+ console.warn(`Parameter "{{${key}}}" is undefined in the test data`);
250
+ return null;
251
+ }
252
+ };
253
+ const recursiveReplace = async (input) => {
254
+ const regex = /{{([^{}]+)}}/g;
255
+ let result = input;
256
+ let match;
257
+ let anyChange = false;
258
+ while ((match = regex.exec(result)) !== null) {
259
+ const fullMatch = match[0];
260
+ const key = match[1].trim();
261
+ const replacement = await resolvePlaceholder(key);
262
+ if (replacement !== null) {
263
+ result = result.replace(fullMatch, replacement);
264
+ anyChange = true;
265
+ regex.lastIndex = 0; // reset index due to string mutation
266
+ }
267
+ }
268
+ // If replacements were made, repeat to resolve nested placeholders
269
+ return anyChange ? await recursiveReplace(result) : result;
270
+ };
271
+ value = await recursiveReplace(value);
272
+ // Only evaluate if value contains a JS expression
273
+ if ((value.startsWith("secret:") || value.startsWith("totp:") || value.startsWith("mask:")) && _decrypt) {
274
+ return decrypt(value, null, totpWait);
275
+ }
276
+ if (value.startsWith("${") && value.endsWith("}")) {
277
+ value = evaluateString(value, context?.examplesRow);
278
+ }
279
+ return value;
280
+ }
281
+ function replaceTestDataValue(env, key, testData, decryptValue = true) {
282
+ const path = key.split(".");
283
+ const value = objectPath.get(testData, path);
284
+ if (value && !Array.isArray(value)) {
285
+ return value;
286
+ }
287
+ const dataArray = testData[env];
288
+ if (!dataArray) {
289
+ return null;
290
+ }
291
+ for (const obj of dataArray) {
292
+ if (obj.key !== key) {
293
+ continue;
294
+ }
295
+ if (obj.DataType === "secret") {
296
+ if (decryptValue === true) {
297
+ return decrypt(`secret:${obj.value}`, null);
298
+ }
299
+ else {
300
+ return `secret:${obj.value}`;
301
+ }
302
+ }
303
+ if (obj.DataType === "totp") {
304
+ return `totp:${obj.value}`;
305
+ }
306
+ return obj.value;
307
+ }
308
+ return null;
309
+ }
310
+ function evaluateString(template, parameters) {
311
+ if (!parameters) {
312
+ parameters = {};
313
+ }
314
+ try {
315
+ return new Function(...Object.keys(parameters), `return \`${template}\`;`)(...Object.values(parameters));
316
+ }
317
+ catch (e) {
318
+ console.error(e);
319
+ return template;
320
+ }
321
+ }
322
+ function formatDate(dateStr, format) {
323
+ if (!format) {
324
+ return dateStr;
325
+ }
326
+ // Split the input date string
327
+ const [dd, mm, yyyy] = dateStr.split("-");
328
+ // Define replacements
329
+ const replacements = {
330
+ dd: dd,
331
+ mm: mm,
332
+ yyyy: yyyy,
333
+ };
334
+ // Replace format placeholders with actual values
335
+ return format.replace(/dd|mm|yyyy/g, (match) => replacements[match]);
336
+ }
337
+ function maskValue(value) {
338
+ if (!value) {
339
+ return value;
340
+ }
341
+ if (value.startsWith("secret:")) {
342
+ return "secret:****";
343
+ }
344
+ if (value.startsWith("totp:")) {
345
+ return "totp:****";
346
+ }
347
+ if (value.startsWith("mask:")) {
348
+ return "mask:****";
349
+ }
350
+ return value;
351
+ }
352
+ function _copyContext(from, to) {
353
+ to.browser = from.browser;
354
+ to.page = from.page;
355
+ to.context = from.context;
356
+ }
357
+ async function scrollPageToLoadLazyElements(page) {
358
+ let lastHeight = await page.evaluate(() => document.body.scrollHeight);
359
+ let retry = 0;
360
+ while (true) {
361
+ await page.evaluate(() => window.scrollBy(0, window.innerHeight));
362
+ await new Promise((resolve) => setTimeout(resolve, 1000));
363
+ let newHeight = await page.evaluate(() => document.body.scrollHeight);
364
+ if (newHeight === lastHeight) {
365
+ break;
366
+ }
367
+ lastHeight = newHeight;
368
+ retry++;
369
+ if (retry > 10) {
370
+ break;
371
+ }
372
+ }
373
+ await page.evaluate(() => window.scrollTo(0, 0));
374
+ }
375
+ function _fixUsingParams(text, _params) {
376
+ if (!_params || typeof text !== "string") {
377
+ return text;
378
+ }
379
+ for (let key in _params) {
380
+ let regValue = key;
381
+ if (key.startsWith("_")) {
382
+ // remove the _ prefix
383
+ regValue = key.substring(1);
384
+ }
385
+ text = text.replaceAll(new RegExp("{" + regValue + "}", "g"), _params[key]);
386
+ }
387
+ return text;
388
+ }
389
+ function getWebLogFile(logFolder) {
390
+ if (!fs.existsSync(logFolder)) {
391
+ fs.mkdirSync(logFolder, { recursive: true });
392
+ }
393
+ let nextIndex = 1;
394
+ while (fs.existsSync(path.join(logFolder, nextIndex.toString() + ".json"))) {
395
+ nextIndex++;
396
+ }
397
+ const fileName = nextIndex + ".json";
398
+ return path.join(logFolder, fileName);
399
+ }
400
+ function _fixLocatorUsingParams(locator, _params) {
401
+ // check if not null
402
+ if (!locator) {
403
+ return locator;
404
+ }
405
+ // clone the locator
406
+ locator = JSON.parse(JSON.stringify(locator));
407
+ scanAndManipulate(locator, _params);
408
+ return locator;
409
+ }
410
+ function _isObject(value) {
411
+ return value && typeof value === "object" && value.constructor === Object;
412
+ }
413
+ function scanAndManipulate(currentObj, _params) {
414
+ for (const key in currentObj) {
415
+ if (typeof currentObj[key] === "string") {
416
+ // Perform string manipulation
417
+ currentObj[key] = _fixUsingParams(currentObj[key], _params);
418
+ }
419
+ else if (_isObject(currentObj[key])) {
420
+ // Recursively scan nested objects
421
+ scanAndManipulate(currentObj[key], _params);
422
+ }
423
+ }
424
+ }
425
+ function extractStepExampleParameters(step) {
426
+ if (!step ||
427
+ !step.gherkinDocument ||
428
+ !step.pickle ||
429
+ !step.pickle.astNodeIds ||
430
+ !(step.pickle.astNodeIds.length > 1) ||
431
+ !step.gherkinDocument.feature ||
432
+ !step.gherkinDocument.feature.children) {
433
+ return {};
434
+ }
435
+ try {
436
+ const scenarioId = step.pickle.astNodeIds[0];
437
+ const exampleId = step.pickle.astNodeIds[1];
438
+ // find the scenario in the gherkin document
439
+ const scenario = step.gherkinDocument.feature.children.find((child) => child.scenario.id === scenarioId).scenario;
440
+ if (!scenario || !scenario.examples || !scenario.examples[0].tableBody) {
441
+ return {};
442
+ }
443
+ // find the table body in the examples
444
+ const row = scenario.examples[0].tableBody.find((r) => r.id === exampleId);
445
+ if (!row) {
446
+ return {};
447
+ }
448
+ // extract the cells values (row.cells.value) into an array
449
+ const values = row.cells.map((cell) => cell.value);
450
+ // extract the table headers keys (scenario.examples.tableHeader.cells.value) into an array
451
+ const keys = scenario.examples[0].tableHeader.cells.map((cell) => cell.value);
452
+ // create a dictionary of the keys and values
453
+ const params = {};
454
+ for (let i = 0; i < keys.length; i++) {
455
+ params[keys[i]] = values[i];
456
+ }
457
+ return params;
458
+ }
459
+ catch (e) {
460
+ console.error(e);
461
+ return {};
462
+ }
463
+ }
464
+ export async function performAction(action, element, options, web, state, _params) {
465
+ let usedOptions;
466
+ if (!options) {
467
+ options = {};
468
+ }
469
+ if (!element) {
470
+ throw new Error("Element not found");
471
+ }
472
+ switch (action) {
473
+ case "click":
474
+ // copy any of the following options to usedOptions: button, clickCount, delay, modifiers, force, position, trial
475
+ usedOptions = ["button", "clickCount", "delay", "modifiers", "force", "position", "trial", "timeout"].reduce((acc, key) => {
476
+ if (options[key]) {
477
+ acc[key] = options[key];
478
+ }
479
+ return acc;
480
+ }, {});
481
+ if (!usedOptions.timeout) {
482
+ usedOptions.timeout = 10000;
483
+ if (usedOptions.position) {
484
+ usedOptions.timeout = 1000;
485
+ }
486
+ }
487
+ if (usedOptions && usedOptions.clickCount) {
488
+ state.info.count = usedOptions.clickCount;
489
+ }
490
+ try {
491
+ await element.click(usedOptions);
492
+ }
493
+ catch (e) {
494
+ if (usedOptions.position) {
495
+ // find the element bounding box
496
+ const rect = await element.boundingBox();
497
+ // calculate the x and y position
498
+ const x = rect.x + rect.width / 2 + (usedOptions.position.x || 0);
499
+ const y = rect.y + rect.height / 2 + (usedOptions.position.y || 0);
500
+ // click on the x and y position
501
+ await web.page.mouse.click(x, y);
502
+ }
503
+ else {
504
+ if (state && state.selectors) {
505
+ state.element = await web._locate(state.selectors, state.info, _params);
506
+ element = state.element;
507
+ }
508
+ await element.dispatchEvent("click");
509
+ }
510
+ }
511
+ break;
512
+ case "hover":
513
+ usedOptions = ["position", "trial", "timeout"].reduce((acc, key) => {
514
+ acc[key] = options[key];
515
+ return acc;
516
+ }, {});
517
+ try {
518
+ await element.hover(usedOptions);
519
+ await new Promise((resolve) => setTimeout(resolve, 1000));
520
+ }
521
+ catch (e) {
522
+ if (state && state.selectors) {
523
+ state.info.log += "hover failed, will try again" + "\n";
524
+ state.element = await web._locate(state.selectors, state.info, _params);
525
+ element = state.element;
526
+ }
527
+ usedOptions.timeout = 10000;
528
+ await element.hover(usedOptions);
529
+ await new Promise((resolve) => setTimeout(resolve, 1000));
530
+ }
531
+ break;
532
+ case "hover+click":
533
+ await performAction("hover", element, options, web, state, _params);
534
+ await performAction("click", element, options, web, state, _params);
535
+ break;
536
+ default:
537
+ throw new Error(`Action ${action} not supported`);
538
+ }
539
+ }
540
+ const KEYBOARD_EVENTS = [
541
+ "ALT",
542
+ "AltGraph",
543
+ "CapsLock",
544
+ "Control",
545
+ "Fn",
546
+ "FnLock",
547
+ "Hyper",
548
+ "Meta",
549
+ "NumLock",
550
+ "ScrollLock",
551
+ "Shift",
552
+ "Super",
553
+ "Symbol",
554
+ "SymbolLock",
555
+ "Enter",
556
+ "Tab",
557
+ "ArrowDown",
558
+ "ArrowLeft",
559
+ "ArrowRight",
560
+ "ArrowUp",
561
+ "End",
562
+ "Home",
563
+ "PageDown",
564
+ "PageUp",
565
+ "Backspace",
566
+ "Clear",
567
+ "Copy",
568
+ "CrSel",
569
+ "Cut",
570
+ "Delete",
571
+ "EraseEof",
572
+ "ExSel",
573
+ "Insert",
574
+ "Paste",
575
+ "Redo",
576
+ "Undo",
577
+ "Accept",
578
+ "Again",
579
+ "Attn",
580
+ "Cancel",
581
+ "ContextMenu",
582
+ "Escape",
583
+ "Execute",
584
+ "Find",
585
+ "Finish",
586
+ "Help",
587
+ "Pause",
588
+ "Play",
589
+ "Props",
590
+ "Select",
591
+ "ZoomIn",
592
+ "ZoomOut",
593
+ "BrightnessDown",
594
+ "BrightnessUp",
595
+ "Eject",
596
+ "LogOff",
597
+ "Power",
598
+ "PowerOff",
599
+ "PrintScreen",
600
+ "Hibernate",
601
+ "Standby",
602
+ "WakeUp",
603
+ "AllCandidates",
604
+ "Alphanumeric",
605
+ "CodeInput",
606
+ "Compose",
607
+ "Convert",
608
+ "Dead",
609
+ "FinalMode",
610
+ "GroupFirst",
611
+ "GroupLast",
612
+ "GroupNext",
613
+ "GroupPrevious",
614
+ "ModeChange",
615
+ "NextCandidate",
616
+ "NonConvert",
617
+ "PreviousCandidate",
618
+ "Process",
619
+ "SingleCandidate",
620
+ "HangulMode",
621
+ "HanjaMode",
622
+ "JunjaMode",
623
+ "Eisu",
624
+ "Hankaku",
625
+ "Hiragana",
626
+ "HiraganaKatakana",
627
+ "KanaMode",
628
+ "KanjiMode",
629
+ "Katakana",
630
+ "Romaji",
631
+ "Zenkaku",
632
+ "ZenkakuHanaku",
633
+ "F1",
634
+ "F2",
635
+ "F3",
636
+ "F4",
637
+ "F5",
638
+ "F6",
639
+ "F7",
640
+ "F8",
641
+ "F9",
642
+ "F10",
643
+ "F11",
644
+ "F12",
645
+ "Soft1",
646
+ "Soft2",
647
+ "Soft3",
648
+ "Soft4",
649
+ "ChannelDown",
650
+ "ChannelUp",
651
+ "Close",
652
+ "MailForward",
653
+ "MailReply",
654
+ "MailSend",
655
+ "MediaFastForward",
656
+ "MediaPause",
657
+ "MediaPlay",
658
+ "MediaPlayPause",
659
+ "MediaRecord",
660
+ "MediaRewind",
661
+ "MediaStop",
662
+ "MediaTrackNext",
663
+ "MediaTrackPrevious",
664
+ "AudioBalanceLeft",
665
+ "AudioBalanceRight",
666
+ "AudioBassBoostDown",
667
+ "AudioBassBoostToggle",
668
+ "AudioBassBoostUp",
669
+ "AudioFaderFront",
670
+ "AudioFaderRear",
671
+ "AudioSurroundModeNext",
672
+ "AudioTrebleDown",
673
+ "AudioTrebleUp",
674
+ "AudioVolumeDown",
675
+ "AudioVolumeMute",
676
+ "AudioVolumeUp",
677
+ "MicrophoneToggle",
678
+ "MicrophoneVolumeDown",
679
+ "MicrophoneVolumeMute",
680
+ "MicrophoneVolumeUp",
681
+ "TV",
682
+ "TV3DMode",
683
+ "TVAntennaCable",
684
+ "TVAudioDescription",
685
+ ];
686
+ function unEscapeString(str) {
687
+ const placeholder = "\\n";
688
+ str = str.replace(new RegExp(placeholder, "g"), "\n");
689
+ return str;
690
+ }
691
+ function _getServerUrl() {
692
+ let serviceUrl = "https://api.blinq.io";
693
+ if (process.env.NODE_ENV_BLINQ === "dev") {
694
+ serviceUrl = "https://dev.api.blinq.io";
695
+ }
696
+ else if (process.env.NODE_ENV_BLINQ === "stage") {
697
+ serviceUrl = "https://stage.api.blinq.io";
698
+ }
699
+ else if (process.env.NODE_ENV_BLINQ === "prod") {
700
+ serviceUrl = "https://api.blinq.io";
701
+ }
702
+ else if (!process.env.NODE_ENV_BLINQ) {
703
+ serviceUrl = "https://api.blinq.io";
704
+ }
705
+ else {
706
+ serviceUrl = process.env.NODE_ENV_BLINQ;
707
+ }
708
+ return serviceUrl;
709
+ }
710
+ function tryParseJson(input) {
711
+ if (typeof input === "string") {
712
+ try {
713
+ return JSON.parse(input);
714
+ }
715
+ catch {
716
+ // If parsing fails, return the original input (assumed to be plain text or another format)
717
+ return input;
718
+ }
719
+ }
720
+ return input;
721
+ }
722
+ export { encrypt, decrypt, replaceWithLocalTestData, maskValue, _copyContext, scrollPageToLoadLazyElements, _fixUsingParams, getWebLogFile, _fixLocatorUsingParams, _isObject, scanAndManipulate, KEYBOARD_EVENTS, unEscapeString, _getServerUrl, _convertToRegexQuery, extractStepExampleParameters, _getDataFile, tryParseJson, getTestDataValue, replaceTestDataValue, _getTestData, };
51
723
  //# sourceMappingURL=utils.js.map