automation_model 1.0.457-dev → 1.0.457

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