automation_model 1.0.503-dev → 1.0.503-stage

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 (47) hide show
  1. package/lib/api.d.ts +2 -1
  2. package/lib/api.js +98 -98
  3. package/lib/api.js.map +1 -1
  4. package/lib/auto_page.d.ts +2 -1
  5. package/lib/auto_page.js +19 -2
  6. package/lib/auto_page.js.map +1 -1
  7. package/lib/browser_manager.d.ts +6 -3
  8. package/lib/browser_manager.js +90 -32
  9. package/lib/browser_manager.js.map +1 -1
  10. package/lib/command_common.d.ts +1 -0
  11. package/lib/command_common.js +43 -7
  12. package/lib/command_common.js.map +1 -1
  13. package/lib/error-messages.js +15 -3
  14. package/lib/error-messages.js.map +1 -1
  15. package/lib/generation_scripts.d.ts +4 -0
  16. package/lib/generation_scripts.js +2 -0
  17. package/lib/generation_scripts.js.map +1 -0
  18. package/lib/index.d.ts +1 -0
  19. package/lib/index.js +1 -0
  20. package/lib/index.js.map +1 -1
  21. package/lib/init_browser.d.ts +2 -1
  22. package/lib/init_browser.js +20 -6
  23. package/lib/init_browser.js.map +1 -1
  24. package/lib/locate_element.js +15 -13
  25. package/lib/locate_element.js.map +1 -1
  26. package/lib/locator.d.ts +36 -0
  27. package/lib/locator.js +165 -0
  28. package/lib/locator.js.map +1 -1
  29. package/lib/locator_log.d.ts +26 -0
  30. package/lib/locator_log.js +69 -0
  31. package/lib/locator_log.js.map +1 -0
  32. package/lib/network.js +16 -3
  33. package/lib/network.js.map +1 -1
  34. package/lib/stable_browser.d.ts +53 -15
  35. package/lib/stable_browser.js +577 -594
  36. package/lib/stable_browser.js.map +1 -1
  37. package/lib/table.d.ts +13 -0
  38. package/lib/table.js +187 -0
  39. package/lib/table.js.map +1 -0
  40. package/lib/test_context.d.ts +1 -0
  41. package/lib/test_context.js +1 -0
  42. package/lib/test_context.js.map +1 -1
  43. package/lib/utils.d.ts +13 -1
  44. package/lib/utils.js +273 -3
  45. package/lib/utils.js.map +1 -1
  46. package/package.json +6 -5
  47. /package/lib/{axe → scripts}/axe.mini.js +0 -0
@@ -10,15 +10,17 @@ import { getDateTimeValue } from "./date_time.js";
10
10
  import drawRectangle from "./drawRect.js";
11
11
  //import { closeUnexpectedPopups } from "./popups.js";
12
12
  import { getTableCells, getTableData } from "./table_analyze.js";
13
- import { maskValue, replaceWithLocalTestData } from "./utils.js";
13
+ import { _convertToRegexQuery, _copyContext, _fixLocatorUsingParams, _fixUsingParams, _getServerUrl, KEYBOARD_EVENTS, maskValue, replaceWithLocalTestData, scrollPageToLoadLazyElements, unEscapeString, } from "./utils.js";
14
14
  import csv from "csv-parser";
15
15
  import { Readable } from "node:stream";
16
16
  import readline from "readline";
17
17
  import { getContext } from "./init_browser.js";
18
18
  import { locate_element } from "./locate_element.js";
19
- import { _commandError, _commandFinally, _preCommand, _validateSelectors, _screenshot } from "./command_common.js";
19
+ import { randomUUID } from "crypto";
20
+ import { _commandError, _commandFinally, _preCommand, _validateSelectors, _screenshot, _reportToWorld, } from "./command_common.js";
20
21
  import { registerDownloadEvent, registerNetworkEvents } from "./network.js";
21
- const Types = {
22
+ import { LocatorLog } from "./locator_log.js";
23
+ export const Types = {
22
24
  CLICK: "click_element",
23
25
  NAVIGATE: "navigate",
24
26
  FILL: "fill_element",
@@ -29,6 +31,8 @@ const Types = {
29
31
  GET_PAGE_STATUS: "get_page_status",
30
32
  CLICK_ROW_ACTION: "click_row_action",
31
33
  VERIFY_ELEMENT_CONTAINS_TEXT: "verify_element_contains_text",
34
+ VERIFY_PAGE_CONTAINS_TEXT: "verify_page_contains_text",
35
+ VERIFY_PAGE_CONTAINS_NO_TEXT: "verify_page_contains_no_text",
32
36
  ANALYZE_TABLE: "analyze_table",
33
37
  SELECT: "select_combobox",
34
38
  VERIFY_PAGE_PATH: "verify_page_path",
@@ -44,6 +48,9 @@ const Types = {
44
48
  VERIFY_VISUAL: "verify_visual",
45
49
  LOAD_DATA: "load_data",
46
50
  SET_INPUT: "set_input",
51
+ WAIT_FOR_TEXT_TO_DISAPPEAR: "wait_for_text_to_disappear",
52
+ VERIFY_ATTRIBUTE: "verify_element_attribute",
53
+ VERIFY_TEXT_WITH_RELATION: "verify_text_with_relation",
47
54
  };
48
55
  export const apps = {};
49
56
  class StableBrowser {
@@ -57,6 +64,7 @@ class StableBrowser {
57
64
  networkLogger = null;
58
65
  configuration = null;
59
66
  appName = "main";
67
+ tags = null;
60
68
  constructor(browser, page, logger = null, context = null, world = null) {
61
69
  this.browser = browser;
62
70
  this.page = page;
@@ -87,17 +95,17 @@ class StableBrowser {
87
95
  catch (e) {
88
96
  this.logger.error("unable to read ai_config.json");
89
97
  }
90
- context.pageLoading = { status: false };
91
- context.pages = [this.page];
92
98
  const logFolder = path.join(this.project_path, "logs", "web");
93
99
  this.world = world;
100
+ context.pages = [this.page];
101
+ context.pageLoading = { status: false };
94
102
  this.registerEventListeners(this.context);
95
103
  registerNetworkEvents(this.world, this, this.context, this.page);
96
104
  registerDownloadEvent(this.page, this.world, this.context);
97
105
  }
98
106
  registerEventListeners(context) {
99
107
  this.registerConsoleLogListener(this.page, context);
100
- this.registerRequestListener(this.page, context, this.webLogFile);
108
+ // this.registerRequestListener(this.page, context, this.webLogFile);
101
109
  if (!context.pageLoading) {
102
110
  context.pageLoading = { status: false };
103
111
  }
@@ -142,9 +150,9 @@ class StableBrowser {
142
150
  if (this.appName === appName) {
143
151
  return;
144
152
  }
145
- let newContextCreated = false;
153
+ let navigate = false;
146
154
  if (!apps[appName]) {
147
- let newContext = await getContext(null, this.context.headless ? this.context.headless : false, this, this.logger, appName, false, this);
155
+ let newContext = await getContext(null, this.context.headless ? this.context.headless : false, this, this.logger, appName, false, this, -1, this.context.reportFolder);
148
156
  newContextCreated = true;
149
157
  apps[appName] = {
150
158
  context: newContext,
@@ -153,32 +161,15 @@ class StableBrowser {
153
161
  };
154
162
  }
155
163
  const tempContext = {};
156
- this._copyContext(this, tempContext);
157
- this._copyContext(apps[appName], this);
164
+ _copyContext(this, tempContext);
165
+ _copyContext(apps[appName], this);
158
166
  apps[this.appName] = tempContext;
159
167
  this.appName = appName;
160
- if (newContextCreated) {
161
- this.registerEventListeners(this.context);
168
+ if (navigate) {
162
169
  await this.goto(this.context.environment.baseUrl);
163
170
  await this.waitForPageLoad();
164
171
  }
165
172
  }
166
- _copyContext(from, to) {
167
- to.browser = from.browser;
168
- to.page = from.page;
169
- to.context = from.context;
170
- }
171
- getWebLogFile(logFolder) {
172
- if (!fs.existsSync(logFolder)) {
173
- fs.mkdirSync(logFolder, { recursive: true });
174
- }
175
- let nextIndex = 1;
176
- while (fs.existsSync(path.join(logFolder, nextIndex.toString() + ".json"))) {
177
- nextIndex++;
178
- }
179
- const fileName = nextIndex + ".json";
180
- return path.join(logFolder, fileName);
181
- }
182
173
  registerConsoleLogListener(page, context) {
183
174
  if (!this.context.webLogger) {
184
175
  this.context.webLogger = [];
@@ -228,7 +219,7 @@ class StableBrowser {
228
219
  this.world?.attach(JSON.stringify(obj), { mediaType: "application/json+network" });
229
220
  }
230
221
  catch (error) {
231
- console.error("Error in request listener", error);
222
+ // console.error("Error in request listener", error);
232
223
  context.networkLogger.push({
233
224
  error: "not able to listen",
234
225
  message: error.message,
@@ -242,55 +233,48 @@ class StableBrowser {
242
233
  // async closeUnexpectedPopups() {
243
234
  // await closeUnexpectedPopups(this.page);
244
235
  // }
245
- async goto(url) {
236
+ async goto(url, world = null) {
246
237
  if (!url.startsWith("http")) {
247
238
  url = "https://" + url;
248
239
  }
249
- await this.page.goto(url, {
250
- timeout: 60000,
251
- });
252
- }
253
- _fixUsingParams(text, _params) {
254
- if (!_params || typeof text !== "string") {
255
- return text;
240
+ const state = {
241
+ value: url,
242
+ world: world,
243
+ type: Types.NAVIGATE,
244
+ text: `Navigate Page to: ${url}`,
245
+ operation: "goto",
246
+ log: "***** navigate page to " + url + " *****\n",
247
+ info: {},
248
+ locate: false,
249
+ scroll: false,
250
+ screenshot: false,
251
+ highlight: false,
252
+ };
253
+ try {
254
+ await _preCommand(state, this);
255
+ await this.page.goto(url, {
256
+ timeout: 60000,
257
+ });
258
+ await _screenshot(state, this);
256
259
  }
257
- for (let key in _params) {
258
- let regValue = key;
259
- if (key.startsWith("_")) {
260
- // remove the _ prefix
261
- regValue = key.substring(1);
262
- }
263
- text = text.replaceAll(new RegExp("{" + regValue + "}", "g"), _params[key]);
260
+ catch (error) {
261
+ console.error("Error on goto", error);
262
+ _commandError(state, error, this);
264
263
  }
265
- return text;
266
- }
267
- _fixLocatorUsingParams(locator, _params) {
268
- // check if not null
269
- if (!locator) {
270
- return locator;
264
+ finally {
265
+ _commandFinally(state, this);
271
266
  }
272
- // clone the locator
273
- locator = JSON.parse(JSON.stringify(locator));
274
- this.scanAndManipulate(locator, _params);
275
- return locator;
276
267
  }
277
- _isObject(value) {
278
- return value && typeof value === "object" && value.constructor === Object;
279
- }
280
- scanAndManipulate(currentObj, _params) {
281
- for (const key in currentObj) {
282
- if (typeof currentObj[key] === "string") {
283
- // Perform string manipulation
284
- currentObj[key] = this._fixUsingParams(currentObj[key], _params);
285
- }
286
- else if (this._isObject(currentObj[key])) {
287
- // Recursively scan nested objects
288
- this.scanAndManipulate(currentObj[key], _params);
268
+ async _getLocator(locator, scope, _params) {
269
+ locator = _fixLocatorUsingParams(locator, _params);
270
+ // locator = await this._replaceWithLocalData(locator);
271
+ for (let key in locator) {
272
+ if (typeof locator[key] !== "string")
273
+ continue;
274
+ if (locator[key].includes("{{") && locator[key].includes("}}")) {
275
+ locator[key] = await this._replaceWithLocalData(locator[key], this.world);
289
276
  }
290
277
  }
291
- }
292
- _getLocator(locator, scope, _params) {
293
- locator = this._fixLocatorUsingParams(locator, _params);
294
278
  let locatorReturn;
295
279
  if (locator.role) {
296
280
  if (locator.role[1].nameReg) {
@@ -298,7 +282,7 @@ class StableBrowser {
298
282
  delete locator.role[1].nameReg;
299
283
  }
300
284
  // if (locator.role[1].name) {
301
- // locator.role[1].name = this._fixUsingParams(locator.role[1].name, _params);
285
+ // locator.role[1].name = _fixUsingParams(locator.role[1].name, _params);
302
286
  // }
303
287
  locatorReturn = scope.getByRole(locator.role[0], locator.role[1]);
304
288
  }
@@ -341,7 +325,7 @@ class StableBrowser {
341
325
  if (css && css.locator) {
342
326
  css = css.locator;
343
327
  }
344
- let result = await this._locateElementByText(scope, this._fixUsingParams(text, _params), "*:not(script, style, head)", false, false, _params);
328
+ let result = await this._locateElementByText(scope, _fixUsingParams(text, _params), "*:not(script, style, head)", false, false, true, _params);
345
329
  if (result.elementCount === 0) {
346
330
  return;
347
331
  }
@@ -352,132 +336,58 @@ class StableBrowser {
352
336
  climbArray.push("..");
353
337
  }
354
338
  let climbXpath = "xpath=" + climbArray.join("/");
355
- return textElementCss + " >> " + climbXpath + " >> " + css;
356
- }
357
- async _locateElementByText(scope, text1, tag1, regex1 = false, partial1, _params) {
358
- //const stringifyText = JSON.stringify(text);
359
- return await scope.locator(":root").evaluate((_node, [text, tag, regex, partial]) => {
360
- function isParent(parent, child) {
361
- let currentNode = child.parentNode;
362
- while (currentNode !== null) {
363
- if (currentNode === parent) {
364
- return true;
339
+ let resultCss = textElementCss + " >> " + climbXpath;
340
+ if (css) {
341
+ resultCss = resultCss + " >> " + css;
342
+ }
343
+ return resultCss;
344
+ }
345
+ async _locateElementByText(scope, text1, tag1, regex1 = false, partial1, ignoreCase = true, _params) {
346
+ const query = _convertToRegexQuery(text1, regex1, !partial1, ignoreCase);
347
+ const locator = scope.locator(query);
348
+ const count = await locator.count();
349
+ if (!tag1) {
350
+ tag1 = "*";
351
+ }
352
+ const randomToken = Math.random().toString(36).substring(7);
353
+ let tagCount = 0;
354
+ for (let i = 0; i < count; i++) {
355
+ const element = locator.nth(i);
356
+ // check if the tag matches
357
+ if (!(await element.evaluate((el, [tag, randomToken]) => {
358
+ if (!tag.startsWith("*")) {
359
+ if (el.tagName.toLowerCase() !== tag) {
360
+ return false;
365
361
  }
366
- currentNode = currentNode.parentNode;
367
- }
368
- return false;
369
- }
370
- document.isParent = isParent;
371
- function getRegex(str) {
372
- const match = str.match(/^\/(.*?)\/([gimuy]*)$/);
373
- if (!match) {
374
- return null;
375
- }
376
- let [_, pattern, flags] = match;
377
- return new RegExp(pattern, flags);
378
- }
379
- document.getRegex = getRegex;
380
- function collectAllShadowDomElements(element, result = []) {
381
- // Check and add the element if it has a shadow root
382
- if (element.shadowRoot) {
383
- result.push(element);
384
- // Also search within the shadow root
385
- document.collectAllShadowDomElements(element.shadowRoot, result);
386
- }
387
- // Iterate over child nodes
388
- element.childNodes.forEach((child) => {
389
- // Recursively call the function for each child node
390
- document.collectAllShadowDomElements(child, result);
391
- });
392
- return result;
393
- }
394
- document.collectAllShadowDomElements = collectAllShadowDomElements;
395
- if (!tag) {
396
- tag = "*:not(script, style, head)";
397
- }
398
- let regexpSearch = document.getRegex(text);
399
- if (regexpSearch) {
400
- regex = true;
401
- }
402
- let elements = Array.from(document.querySelectorAll(tag));
403
- let shadowHosts = [];
404
- document.collectAllShadowDomElements(document, shadowHosts);
405
- for (let i = 0; i < shadowHosts.length; i++) {
406
- let shadowElement = shadowHosts[i].shadowRoot;
407
- if (!shadowElement) {
408
- console.log("shadowElement is null, for host " + shadowHosts[i]);
409
- continue;
410
- }
411
- let shadowElements = Array.from(shadowElement.querySelectorAll(tag));
412
- elements = elements.concat(shadowElements);
413
- }
414
- let randomToken = null;
415
- const foundElements = [];
416
- if (regex) {
417
- if (!regexpSearch) {
418
- regexpSearch = new RegExp(text, "im");
419
362
  }
420
- for (let i = 0; i < elements.length; i++) {
421
- const element = elements[i];
422
- if ((element.innerText && regexpSearch.test(element.innerText)) ||
423
- (element.value && regexpSearch.test(element.value))) {
424
- foundElements.push(element);
425
- }
426
- }
427
- }
428
- else {
429
- text = text.trim();
430
- for (let i = 0; i < elements.length; i++) {
431
- const element = elements[i];
432
- if (partial) {
433
- if ((element.innerText && element.innerText.toLowerCase().trim().includes(text.toLowerCase())) ||
434
- (element.value && element.value.toLowerCase().includes(text.toLowerCase()))) {
435
- foundElements.push(element);
436
- }
437
- }
438
- else {
439
- if ((element.innerText && element.innerText.trim() === text) ||
440
- (element.value && element.value === text)) {
441
- foundElements.push(element);
442
- }
443
- }
444
- }
445
- }
446
- let noChildElements = [];
447
- for (let i = 0; i < foundElements.length; i++) {
448
- let element = foundElements[i];
449
- let hasChild = false;
450
- for (let j = 0; j < foundElements.length; j++) {
451
- if (i === j) {
452
- continue;
453
- }
454
- if (isParent(element, foundElements[j])) {
455
- hasChild = true;
456
- break;
457
- }
458
- }
459
- if (!hasChild) {
460
- noChildElements.push(element);
461
- }
462
- }
463
- let elementCount = 0;
464
- if (noChildElements.length > 0) {
465
- for (let i = 0; i < noChildElements.length; i++) {
466
- if (randomToken === null) {
467
- randomToken = Math.random().toString(36).substring(7);
468
- }
469
- let element = noChildElements[i];
470
- element.setAttribute("data-blinq-id", "blinq-id-" + randomToken);
471
- elementCount++;
363
+ if (!el.setAttribute) {
364
+ el = el.parentElement;
472
365
  }
366
+ el.setAttribute("data-blinq-id", "blinq-id-" + randomToken);
367
+ return true;
368
+ }, [tag1, randomToken]))) {
369
+ continue;
473
370
  }
474
- return { elementCount: elementCount, randomToken: randomToken };
475
- }, [text1, tag1, regex1, partial1]);
371
+ tagCount++;
372
+ }
373
+ return { elementCount: tagCount, randomToken };
476
374
  }
477
375
  async _collectLocatorInformation(selectorHierarchy, index = 0, scope, foundLocators, _params, info, visibleOnly = true) {
376
+ if (!info) {
377
+ info = {};
378
+ }
379
+ if (!info.failCause) {
380
+ info.failCause = {};
381
+ }
382
+ if (!info.log) {
383
+ info.log = "";
384
+ info.locatorLog = new LocatorLog(selectorHierarchy);
385
+ }
478
386
  let locatorSearch = selectorHierarchy[index];
387
+ let originalLocatorSearch = "";
479
388
  try {
480
- locatorSearch = JSON.parse(this._fixUsingParams(JSON.stringify(locatorSearch), _params));
389
+ originalLocatorSearch = _fixUsingParams(JSON.stringify(locatorSearch), _params);
390
+ locatorSearch = JSON.parse(originalLocatorSearch);
481
391
  }
482
392
  catch (e) {
483
393
  console.error(e);
@@ -491,11 +401,11 @@ class StableBrowser {
491
401
  info.failCause.lastError = "failed to locate element by text: " + locatorSearch.text;
492
402
  return;
493
403
  }
494
- locator = this._getLocator({ css: locatorString }, scope, _params);
404
+ locator = await this._getLocator({ css: locatorString }, scope, _params);
495
405
  }
496
406
  else if (locatorSearch.text) {
497
- let text = this._fixUsingParams(locatorSearch.text, _params);
498
- let result = await this._locateElementByText(scope, text, locatorSearch.tag, false, locatorSearch.partial === true, _params);
407
+ let text = _fixUsingParams(locatorSearch.text, _params);
408
+ let result = await this._locateElementByText(scope, text, locatorSearch.tag, false, locatorSearch.partial === true, true, _params);
499
409
  if (result.elementCount === 0) {
500
410
  info.failCause.textNotFound = true;
501
411
  info.failCause.lastError = "failed to locate element by text: " + text;
@@ -505,10 +415,10 @@ class StableBrowser {
505
415
  if (locatorSearch.childCss) {
506
416
  locatorSearch.css = locatorSearch.css + " " + locatorSearch.childCss;
507
417
  }
508
- locator = this._getLocator(locatorSearch, scope, _params);
418
+ locator = await this._getLocator(locatorSearch, scope, _params);
509
419
  }
510
420
  else {
511
- locator = this._getLocator(locatorSearch, scope, _params);
421
+ locator = await this._getLocator(locatorSearch, scope, _params);
512
422
  }
513
423
  // let cssHref = false;
514
424
  // if (locatorSearch.css && locatorSearch.css.includes("href=")) {
@@ -521,10 +431,16 @@ class StableBrowser {
521
431
  //info.log += "total elements found " + count + "\n";
522
432
  //let visibleCount = 0;
523
433
  let visibleLocator = null;
524
- if (locatorSearch.index && locatorSearch.index < count) {
434
+ if (typeof locatorSearch.index === "number" && locatorSearch.index < count) {
525
435
  foundLocators.push(locator.nth(locatorSearch.index));
436
+ if (info.locatorLog) {
437
+ info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "FOUND");
438
+ }
526
439
  return;
527
440
  }
441
+ if (info.locatorLog && count === 0) {
442
+ info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "NOT_FOUND");
443
+ }
528
444
  for (let j = 0; j < count; j++) {
529
445
  let visible = await locator.nth(j).isVisible();
530
446
  const enabled = await locator.nth(j).isEnabled();
@@ -533,6 +449,9 @@ class StableBrowser {
533
449
  }
534
450
  if (visible && enabled) {
535
451
  foundLocators.push(locator.nth(j));
452
+ if (info.locatorLog) {
453
+ info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "FOUND");
454
+ }
536
455
  }
537
456
  else {
538
457
  info.failCause.visible = visible;
@@ -540,8 +459,14 @@ class StableBrowser {
540
459
  if (!info.printMessages) {
541
460
  info.printMessages = {};
542
461
  }
462
+ if (info.locatorLog && !visible) {
463
+ info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "FOUND_NOT_VISIBLE");
464
+ }
465
+ if (info.locatorLog && !enabled) {
466
+ info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "FOUND_NOT_ENABLED");
467
+ }
543
468
  if (!info.printMessages[j.toString()]) {
544
- info.log += "element " + locator + " visible " + visible + " enabled " + enabled + "\n";
469
+ //info.log += "element " + locator + " visible " + visible + " enabled " + enabled + "\n";
545
470
  info.printMessages[j.toString()] = true;
546
471
  }
547
472
  }
@@ -557,7 +482,7 @@ class StableBrowser {
557
482
  if (!info) {
558
483
  info = {};
559
484
  }
560
- info.log += "scan for popup handlers" + "\n";
485
+ //info.log += "scan for popup handlers" + "\n";
561
486
  const handlerGroup = [];
562
487
  for (let i = 0; i < this.configuration.popupHandlers.length; i++) {
563
488
  handlerGroup.push(this.configuration.popupHandlers[i].locator);
@@ -584,9 +509,21 @@ class StableBrowser {
584
509
  }
585
510
  if (result.foundElements.length > 0) {
586
511
  let dialogCloseLocator = result.foundElements[0].locator;
587
- await dialogCloseLocator.click();
588
- // wait for the dialog to close
589
- await dialogCloseLocator.waitFor({ state: "hidden" });
512
+ try {
513
+ await scope?.evaluate(() => {
514
+ window.__isClosingPopups = true;
515
+ });
516
+ await dialogCloseLocator.click();
517
+ // wait for the dialog to close
518
+ await dialogCloseLocator.waitFor({ state: "hidden" });
519
+ }
520
+ catch (e) {
521
+ }
522
+ finally {
523
+ await scope?.evaluate(() => {
524
+ window.__isClosingPopups = false;
525
+ });
526
+ }
590
527
  return { rerun: true };
591
528
  }
592
529
  }
@@ -616,6 +553,7 @@ class StableBrowser {
616
553
  info.failCause = {};
617
554
  info.log = "";
618
555
  }
556
+ let startTime = Date.now();
619
557
  let scope = this.page;
620
558
  if (selectors.frame) {
621
559
  return selectors.frame;
@@ -646,9 +584,11 @@ class StableBrowser {
646
584
  }
647
585
  return framescope;
648
586
  };
587
+ let fLocator = null;
649
588
  while (true) {
650
589
  let frameFound = false;
651
590
  if (selectors.nestFrmLoc) {
591
+ fLocator = selectors.nestFrmLoc;
652
592
  scope = await findFrame(selectors.nestFrmLoc, scope);
653
593
  frameFound = true;
654
594
  break;
@@ -657,6 +597,7 @@ class StableBrowser {
657
597
  for (let i = 0; i < selectors.frameLocators.length; i++) {
658
598
  let frameLocator = selectors.frameLocators[i];
659
599
  if (frameLocator.css) {
600
+ fLocator = frameLocator.css;
660
601
  scope = scope.frameLocator(frameLocator.css);
661
602
  frameFound = true;
662
603
  break;
@@ -664,11 +605,15 @@ class StableBrowser {
664
605
  }
665
606
  }
666
607
  if (!frameFound && selectors.iframe_src) {
608
+ fLocator = selectors.iframe_src;
667
609
  scope = this.page.frame({ url: selectors.iframe_src });
668
610
  }
669
611
  if (!scope) {
670
- info.log += "unable to locate iframe " + selectors.iframe_src + "\n";
671
- if (performance.now() - startTime > timeout) {
612
+ if (info && info.locatorLog) {
613
+ info.locatorLog.setLocatorSearchStatus("frame-" + fLocator, "NOT_FOUND");
614
+ }
615
+ //info.log += "unable to locate iframe " + selectors.iframe_src + "\n";
616
+ if (Date.now() - startTime > timeout) {
672
617
  info.failCause.iframeNotFound = true;
673
618
  info.failCause.lastError = "unable to locate iframe " + selectors.iframe_src;
674
619
  throw new Error("unable to locate iframe " + selectors.iframe_src);
@@ -676,6 +621,9 @@ class StableBrowser {
676
621
  await new Promise((resolve) => setTimeout(resolve, 1000));
677
622
  }
678
623
  else {
624
+ if (info && info.locatorLog) {
625
+ info.locatorLog.setLocatorSearchStatus("frame-" + fLocator, "FOUND");
626
+ }
679
627
  break;
680
628
  }
681
629
  }
@@ -697,11 +645,13 @@ class StableBrowser {
697
645
  info = {};
698
646
  info.failCause = {};
699
647
  info.log = "";
648
+ info.locatorLog = new LocatorLog(selectors);
700
649
  }
701
650
  let highPriorityTimeout = 5000;
702
651
  let visibleOnlyTimeout = 6000;
703
- let startTime = performance.now();
652
+ let startTime = Date.now();
704
653
  let locatorsCount = 0;
654
+ let lazy_scroll = false;
705
655
  //let arrayMode = Array.isArray(selectors);
706
656
  let scope = await this._findFrameScope(selectors, timeout, info);
707
657
  let selectorsLocators = null;
@@ -790,21 +740,31 @@ class StableBrowser {
790
740
  return maxCountElement.locator;
791
741
  }
792
742
  }
793
- if (performance.now() - startTime > timeout) {
743
+ if (Date.now() - startTime > timeout) {
794
744
  break;
795
745
  }
796
- if (performance.now() - startTime > highPriorityTimeout) {
797
- info.log += "high priority timeout, will try all elements" + "\n";
746
+ if (Date.now() - startTime > highPriorityTimeout) {
747
+ //info.log += "high priority timeout, will try all elements" + "\n";
798
748
  highPriorityOnly = false;
749
+ if (this.configuration && this.configuration.load_all_lazy === true && !lazy_scroll) {
750
+ lazy_scroll = true;
751
+ await scrollPageToLoadLazyElements(this.page);
752
+ }
799
753
  }
800
- if (performance.now() - startTime > visibleOnlyTimeout) {
801
- info.log += "visible only timeout, will try all elements" + "\n";
754
+ if (Date.now() - startTime > visibleOnlyTimeout) {
755
+ //info.log += "visible only timeout, will try all elements" + "\n";
802
756
  visibleOnly = false;
803
757
  }
804
758
  await new Promise((resolve) => setTimeout(resolve, 1000));
805
759
  }
806
760
  this.logger.debug("unable to locate unique element, total elements found " + locatorsCount);
807
- info.log += "failed to locate unique element, total elements found " + locatorsCount + "\n";
761
+ // if (info.locatorLog) {
762
+ // const lines = info.locatorLog.toString().split("\n");
763
+ // for (let line of lines) {
764
+ // this.logger.debug(line);
765
+ // }
766
+ // }
767
+ //info.log += "failed to locate unique element, total elements found " + locatorsCount + "\n";
808
768
  info.failCause.locatorNotFound = true;
809
769
  info.failCause.lastError = "failed to locate unique element";
810
770
  throw new Error("failed to locate first element no elements found, " + info.log);
@@ -820,8 +780,9 @@ class StableBrowser {
820
780
  await this._collectLocatorInformation(locatorsGroup, i, scope, foundLocators, _params, info, visibleOnly);
821
781
  }
822
782
  catch (e) {
823
- this.logger.debug("unable to use locator " + JSON.stringify(locatorsGroup[i]));
824
- this.logger.debug(e);
783
+ // this call can fail it the browser is navigating
784
+ // this.logger.debug("unable to use locator " + JSON.stringify(locatorsGroup[i]));
785
+ // this.logger.debug(e);
825
786
  foundLocators = [];
826
787
  try {
827
788
  await this._collectLocatorInformation(locatorsGroup, i, this.page, foundLocators, _params, info, visibleOnly);
@@ -840,11 +801,27 @@ class StableBrowser {
840
801
  }
841
802
  if (foundLocators.length > 1) {
842
803
  info.failCause.foundMultiple = true;
804
+ if (info.locatorLog) {
805
+ info.locatorLog.setLocatorSearchStatus(JSON.stringify(locatorsGroup[i]), "FOUND_NOT_UNIQUE");
806
+ }
843
807
  }
844
808
  }
845
809
  return result;
846
810
  }
847
811
  async simpleClick(elementDescription, _params, options = {}, world = null) {
812
+ const state = {
813
+ locate: false,
814
+ scroll: false,
815
+ highlight: false,
816
+ _params,
817
+ options,
818
+ world,
819
+ type: Types.CLICK,
820
+ text: "Click element",
821
+ operation: "simpleClick",
822
+ log: "***** click on " + elementDescription + " *****\n",
823
+ };
824
+ _preCommand(state, this);
848
825
  const startTime = Date.now();
849
826
  let timeout = 30000;
850
827
  if (options && options.timeout) {
@@ -869,13 +846,31 @@ class StableBrowser {
869
846
  catch (e) {
870
847
  if (performance.now() - startTime > timeout) {
871
848
  // throw e;
872
- await _commandError({ text: "simpleClick", operation: "simpleClick", elementDescription, info: {} }, e, this);
849
+ try {
850
+ await _commandError(state, "timeout looking for " + elementDescription, this);
851
+ }
852
+ finally {
853
+ _commandFinally(state, this);
854
+ }
873
855
  }
874
856
  }
875
857
  await new Promise((resolve) => setTimeout(resolve, 3000));
876
858
  }
877
859
  }
878
860
  async simpleClickType(elementDescription, value, _params, options = {}, world = null) {
861
+ const state = {
862
+ locate: false,
863
+ scroll: false,
864
+ highlight: false,
865
+ _params,
866
+ options,
867
+ world,
868
+ type: Types.FILL,
869
+ text: "Fill element",
870
+ operation: "simpleClickType",
871
+ log: "***** click type on " + elementDescription + " *****\n",
872
+ };
873
+ _preCommand(state, this);
879
874
  const startTime = Date.now();
880
875
  let timeout = 30000;
881
876
  if (options && options.timeout) {
@@ -900,7 +895,12 @@ class StableBrowser {
900
895
  catch (e) {
901
896
  if (performance.now() - startTime > timeout) {
902
897
  // throw e;
903
- await _commandError({ text: "simpleClickType", operation: "simpleClickType", value, elementDescription, info: {} }, e, this);
898
+ try {
899
+ await _commandError(state, "timeout looking for " + elementDescription, this);
900
+ }
901
+ finally {
902
+ _commandFinally(state, this);
903
+ }
904
904
  }
905
905
  }
906
906
  await new Promise((resolve) => setTimeout(resolve, 3000));
@@ -919,18 +919,18 @@ class StableBrowser {
919
919
  };
920
920
  try {
921
921
  await _preCommand(state, this);
922
- if (state.options && state.options.context) {
923
- state.selectors.locators[0].text = state.options.context;
924
- }
922
+ // if (state.options && state.options.context) {
923
+ // state.selectors.locators[0].text = state.options.context;
924
+ // }
925
925
  try {
926
926
  await state.element.click();
927
- await new Promise((resolve) => setTimeout(resolve, 1000));
927
+ // await new Promise((resolve) => setTimeout(resolve, 1000));
928
928
  }
929
929
  catch (e) {
930
930
  // await this.closeUnexpectedPopups();
931
931
  state.element = await this._locate(selectors, state.info, _params);
932
932
  await state.element.dispatchEvent("click");
933
- await new Promise((resolve) => setTimeout(resolve, 1000));
933
+ // await new Promise((resolve) => setTimeout(resolve, 1000));
934
934
  }
935
935
  await this.waitForPageLoad();
936
936
  return state.info;
@@ -1009,7 +1009,6 @@ class StableBrowser {
1009
1009
  await state.element.hover({ timeout: 10000 });
1010
1010
  await new Promise((resolve) => setTimeout(resolve, 1000));
1011
1011
  }
1012
- await _screenshot(state, this);
1013
1012
  await this.waitForPageLoad();
1014
1013
  return state.info;
1015
1014
  }
@@ -1137,33 +1136,30 @@ class StableBrowser {
1137
1136
  }
1138
1137
  }
1139
1138
  async setDateTime(selectors, value, format = null, enter = false, _params = null, options = {}, world = null) {
1140
- _validateSelectors(selectors);
1141
- const startTime = Date.now();
1142
- let error = null;
1143
- let screenshotId = null;
1144
- let screenshotPath = null;
1145
- const info = {};
1146
- info.log = "";
1147
- info.operation = Types.SET_DATE_TIME;
1148
- info.selectors = selectors;
1149
- info.value = value;
1139
+ const state = {
1140
+ selectors,
1141
+ _params,
1142
+ value: await this._replaceWithLocalData(value, this),
1143
+ options,
1144
+ world,
1145
+ type: Types.SET_DATE_TIME,
1146
+ text: `Set date time value: ${value}`,
1147
+ operation: "setDateTime",
1148
+ log: "***** set date time value " + selectors.element_name + " *****\n",
1149
+ throwError: false,
1150
+ };
1150
1151
  try {
1151
- value = await this._replaceWithLocalData(value, this);
1152
- let element = await this._locate(selectors, info, _params);
1153
- //insert red border around the element
1154
- await this.scrollIfNeeded(element, info);
1155
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
1156
- await this._highlightElements(element);
1152
+ await _preCommand(state, this);
1157
1153
  try {
1158
- await element.click();
1154
+ await state.element.click();
1159
1155
  await new Promise((resolve) => setTimeout(resolve, 500));
1160
1156
  if (format) {
1161
- value = dayjs(value).format(format);
1162
- await element.fill(value);
1157
+ state.value = dayjs(state.value).format(format);
1158
+ await state.element.fill(state.value);
1163
1159
  }
1164
1160
  else {
1165
- const dateTimeValue = await getDateTimeValue({ value, element });
1166
- await element.evaluateHandle((el, dateTimeValue) => {
1161
+ const dateTimeValue = await getDateTimeValue({ value: state.value, element: state.element });
1162
+ await state.element.evaluateHandle((el, dateTimeValue) => {
1167
1163
  el.value = ""; // clear input
1168
1164
  el.value = dateTimeValue;
1169
1165
  }, dateTimeValue);
@@ -1176,20 +1172,19 @@ class StableBrowser {
1176
1172
  }
1177
1173
  catch (err) {
1178
1174
  //await this.closeUnexpectedPopups();
1179
- this.logger.error("setting date time input failed " + JSON.stringify(info));
1175
+ this.logger.error("setting date time input failed " + JSON.stringify(state.info));
1180
1176
  this.logger.info("Trying again");
1181
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
1182
- info.screenshotPath = screenshotPath;
1183
- Object.assign(err, { info: info });
1177
+ await _screenshot(state, this);
1178
+ Object.assign(err, { info: state.info });
1184
1179
  await element.click();
1185
1180
  await new Promise((resolve) => setTimeout(resolve, 500));
1186
1181
  if (format) {
1187
- value = dayjs(value).format(format);
1188
- await element.fill(value);
1182
+ state.value = dayjs(state.value).format(format);
1183
+ await state.element.fill(state.value);
1189
1184
  }
1190
1185
  else {
1191
- const dateTimeValue = await getDateTimeValue({ value, element });
1192
- await element.evaluateHandle((el, dateTimeValue) => {
1186
+ const dateTimeValue = await getDateTimeValue({ value: state.value, element: state.element });
1187
+ await state.element.evaluateHandle((el, dateTimeValue) => {
1193
1188
  el.value = ""; // clear input
1194
1189
  el.value = dateTimeValue;
1195
1190
  }, dateTimeValue);
@@ -1202,32 +1197,10 @@ class StableBrowser {
1202
1197
  }
1203
1198
  }
1204
1199
  catch (e) {
1205
- error = e;
1206
- // throw e;
1207
- await _commandError({ text: "setDateTime", operation: "setDateTime", selectors, value, info }, e, this);
1200
+ await _commandError(state, e, this);
1208
1201
  }
1209
1202
  finally {
1210
- const endTime = Date.now();
1211
- this._reportToWorld(world, {
1212
- element_name: selectors.element_name,
1213
- type: Types.SET_DATE_TIME,
1214
- screenshotId,
1215
- value: value,
1216
- text: `setDateTime input with value: ${value}`,
1217
- result: error
1218
- ? {
1219
- status: "FAILED",
1220
- startTime,
1221
- endTime,
1222
- message: error === null || error === void 0 ? void 0 : error.message,
1223
- }
1224
- : {
1225
- status: "PASSED",
1226
- startTime,
1227
- endTime,
1228
- },
1229
- info: info,
1230
- });
1203
+ _commandFinally(state, this);
1231
1204
  }
1232
1205
  }
1233
1206
  async clickType(selectors, _value, enter = false, _params = null, options = {}, world = null) {
@@ -1364,6 +1337,7 @@ class StableBrowser {
1364
1337
  let screenshotPath = null;
1365
1338
  if (!info.log) {
1366
1339
  info.log = "";
1340
+ info.locatorLog = new LocatorLog(selectors);
1367
1341
  }
1368
1342
  info.operation = "getText";
1369
1343
  info.selectors = selectors;
@@ -1702,11 +1676,9 @@ class StableBrowser {
1702
1676
  if (!fs.existsSync(world.screenshotPath)) {
1703
1677
  fs.mkdirSync(world.screenshotPath, { recursive: true });
1704
1678
  }
1705
- let nextIndex = 1;
1706
- while (fs.existsSync(path.join(world.screenshotPath, nextIndex + ".png"))) {
1707
- nextIndex++;
1708
- }
1709
- const screenshotPath = path.join(world.screenshotPath, nextIndex + ".png");
1679
+ // to make sure the path doesn't start with -
1680
+ const uuidStr = "id_" + randomUUID();
1681
+ const screenshotPath = path.join(world.screenshotPath, uuidStr + ".png");
1710
1682
  try {
1711
1683
  await this.takeScreenshot(screenshotPath);
1712
1684
  // let buffer = await this.page.screenshot({ timeout: 4000 });
@@ -1720,7 +1692,7 @@ class StableBrowser {
1720
1692
  catch (e) {
1721
1693
  this.logger.info("unable to take screenshot, ignored");
1722
1694
  }
1723
- result.screenshotId = nextIndex;
1695
+ result.screenshotId = uuidStr;
1724
1696
  result.screenshotPath = screenshotPath;
1725
1697
  if (info && info.box) {
1726
1698
  await drawRectangle(screenshotPath, info.box.x, info.box.y, info.box.width, info.box.height);
@@ -1818,75 +1790,105 @@ class StableBrowser {
1818
1790
  }
1819
1791
  }
1820
1792
  async extractAttribute(selectors, attribute, variable, _params = null, options = {}, world = null) {
1821
- _validateSelectors(selectors);
1822
- const startTime = Date.now();
1823
- let error = null;
1824
- let screenshotId = null;
1825
- let screenshotPath = null;
1793
+ const state = {
1794
+ selectors,
1795
+ _params,
1796
+ attribute,
1797
+ variable,
1798
+ options,
1799
+ world,
1800
+ type: Types.EXTRACT,
1801
+ text: `Extract attribute from element`,
1802
+ operation: "extractAttribute",
1803
+ log: "***** extract attribute " + attribute + " from " + selectors.element_name + " *****\n",
1804
+ };
1826
1805
  await new Promise((resolve) => setTimeout(resolve, 2000));
1827
- const info = {};
1828
- info.log = "***** extract attribute " + attribute + " from " + selectors.element_name + " *****\n";
1829
- info.operation = "extract";
1830
- info.selectors = selectors;
1831
1806
  try {
1832
- const element = await this._locate(selectors, info, _params);
1833
- await this._highlightElements(element);
1834
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
1807
+ await _preCommand(state, this);
1835
1808
  switch (attribute) {
1836
1809
  case "inner_text":
1837
- info.value = await element.innerText();
1810
+ state.value = await state.element.innerText();
1838
1811
  break;
1839
1812
  case "href":
1840
- info.value = await element.getAttribute("href");
1813
+ state.value = await state.element.getAttribute("href");
1841
1814
  break;
1842
1815
  case "value":
1843
- info.value = await element.inputValue();
1816
+ state.value = await state.element.inputValue();
1844
1817
  break;
1845
1818
  default:
1846
- info.value = await element.getAttribute(attribute);
1819
+ state.value = await state.element.getAttribute(attribute);
1847
1820
  break;
1848
1821
  }
1849
- this[variable] = info.value;
1850
- if (world) {
1851
- world[variable] = info.value;
1822
+ state.info.value = state.value;
1823
+ this.setTestData({ [variable]: state.value }, world);
1824
+ this.logger.info("set test data: " + variable + "=" + state.value);
1825
+ return state.info;
1826
+ }
1827
+ catch (e) {
1828
+ await _commandError(state, e, this);
1829
+ }
1830
+ finally {
1831
+ _commandFinally(state, this);
1832
+ }
1833
+ }
1834
+ async verifyAttribute(selectors, attribute, value, _params = null, options = {}, world = null) {
1835
+ const state = {
1836
+ selectors,
1837
+ _params,
1838
+ attribute,
1839
+ value,
1840
+ options,
1841
+ world,
1842
+ type: Types.VERIFY_ATTRIBUTE,
1843
+ text: `Verify element attribute`,
1844
+ operation: "verifyAttribute",
1845
+ log: "***** verify attribute " + attribute + " from " + selectors.element_name + " *****\n",
1846
+ };
1847
+ await new Promise((resolve) => setTimeout(resolve, 2000));
1848
+ let val;
1849
+ try {
1850
+ await _preCommand(state, this);
1851
+ switch (attribute) {
1852
+ case "innerText":
1853
+ val = String(await state.element.innerText());
1854
+ break;
1855
+ case "value":
1856
+ val = String(await state.element.inputValue());
1857
+ break;
1858
+ case "checked":
1859
+ val = String(await state.element.isChecked());
1860
+ break;
1861
+ case "disabled":
1862
+ val = String(await state.element.isDisabled());
1863
+ break;
1864
+ case "readOnly":
1865
+ const isEditable = await state.element.isEditable();
1866
+ val = String(!isEditable);
1867
+ break;
1868
+ default:
1869
+ val = String(await state.element.getAttribute(attribute));
1870
+ break;
1852
1871
  }
1853
- this.setTestData({ [variable]: info.value }, world);
1854
- this.logger.info("set test data: " + variable + "=" + info.value);
1855
- return info;
1872
+ state.info.expectedValue = val;
1873
+ let regex;
1874
+ if (value.startsWith("/") && value.endsWith("/")) {
1875
+ const patternBody = value.slice(1, -1);
1876
+ regex = new RegExp(patternBody, "g");
1877
+ }
1878
+ else {
1879
+ const escapedPattern = value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1880
+ regex = new RegExp(escapedPattern, "g");
1881
+ }
1882
+ if (!val.match(regex)) {
1883
+ throw new Error(`The ${attribute} attribute has a value of "${val}", but the expected value is "${value}"`);
1884
+ }
1885
+ return state.info;
1856
1886
  }
1857
1887
  catch (e) {
1858
- //await this.closeUnexpectedPopups();
1859
- this.logger.error("extract failed " + info.log);
1860
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
1861
- info.screenshotPath = screenshotPath;
1862
- Object.assign(e, { info: info });
1863
- error = e;
1864
- // throw e;
1865
- await _commandError({ text: "extractAttribute", operation: "extractAttribute", selectors, attribute, variable }, e, this);
1888
+ await _commandError(state, e, this);
1866
1889
  }
1867
1890
  finally {
1868
- const endTime = Date.now();
1869
- this._reportToWorld(world, {
1870
- element_name: selectors.element_name,
1871
- type: Types.EXTRACT_ATTRIBUTE,
1872
- variable: variable,
1873
- value: info.value,
1874
- text: "Extract attribute from element",
1875
- screenshotId,
1876
- result: error
1877
- ? {
1878
- status: "FAILED",
1879
- startTime,
1880
- endTime,
1881
- message: error?.message,
1882
- }
1883
- : {
1884
- status: "PASSED",
1885
- startTime,
1886
- endTime,
1887
- },
1888
- info: info,
1889
- });
1891
+ _commandFinally(state, this);
1890
1892
  }
1891
1893
  }
1892
1894
  async extractEmailData(emailAddress, options, world) {
@@ -1907,7 +1909,7 @@ class StableBrowser {
1907
1909
  if (options && options.timeout) {
1908
1910
  timeout = options.timeout;
1909
1911
  }
1910
- const serviceUrl = this._getServerUrl() + "/api/mail/createLinkOrCodeFromEmail";
1912
+ const serviceUrl = _getServerUrl() + "/api/mail/createLinkOrCodeFromEmail";
1911
1913
  const request = {
1912
1914
  method: "POST",
1913
1915
  url: serviceUrl,
@@ -2080,7 +2082,7 @@ class StableBrowser {
2080
2082
  }
2081
2083
  finally {
2082
2084
  const endTime = Date.now();
2083
- this._reportToWorld(world, {
2085
+ _reportToWorld(world, {
2084
2086
  type: Types.VERIFY_PAGE_PATH,
2085
2087
  text: "Verify page path",
2086
2088
  screenshotId,
@@ -2100,54 +2102,65 @@ class StableBrowser {
2100
2102
  });
2101
2103
  }
2102
2104
  }
2105
+ async findTextInAllFrames(dateAlternatives, numberAlternatives, text, state) {
2106
+ const frames = this.page.frames();
2107
+ let results = [];
2108
+ let ignoreCase = false;
2109
+ for (let i = 0; i < frames.length; i++) {
2110
+ if (dateAlternatives.date) {
2111
+ for (let j = 0; j < dateAlternatives.dates.length; j++) {
2112
+ const result = await this._locateElementByText(frames[i], dateAlternatives.dates[j], "*:not(script, style, head)", false, true, ignoreCase, {});
2113
+ result.frame = frames[i];
2114
+ results.push(result);
2115
+ }
2116
+ }
2117
+ else if (numberAlternatives.number) {
2118
+ for (let j = 0; j < numberAlternatives.numbers.length; j++) {
2119
+ const result = await this._locateElementByText(frames[i], numberAlternatives.numbers[j], "*:not(script, style, head)", false, true, ignoreCase, {});
2120
+ result.frame = frames[i];
2121
+ results.push(result);
2122
+ }
2123
+ }
2124
+ else {
2125
+ const result = await this._locateElementByText(frames[i], text, "*:not(script, style, head)", false, true, ignoreCase, {});
2126
+ result.frame = frames[i];
2127
+ results.push(result);
2128
+ }
2129
+ }
2130
+ state.info.results = results;
2131
+ const resultWithElementsFound = results.filter((result) => result.elementCount > 0);
2132
+ return resultWithElementsFound;
2133
+ }
2103
2134
  async verifyTextExistInPage(text, options = {}, world = null) {
2104
2135
  text = unEscapeString(text);
2105
- const startTime = Date.now();
2136
+ const state = {
2137
+ text_search: text,
2138
+ options,
2139
+ world,
2140
+ locate: false,
2141
+ scroll: false,
2142
+ highlight: false,
2143
+ type: Types.VERIFY_PAGE_CONTAINS_TEXT,
2144
+ text: `Verify text exists in page`,
2145
+ operation: "verifyTextExistInPage",
2146
+ log: "***** verify text " + text + " exists in page *****\n",
2147
+ };
2106
2148
  const timeout = this._getLoadTimeout(options);
2107
- let error = null;
2108
- let screenshotId = null;
2109
- let screenshotPath = null;
2110
2149
  await new Promise((resolve) => setTimeout(resolve, 2000));
2111
- const info = {};
2112
- info.log = "***** verify text " + text + " exists in page *****\n";
2113
- info.operation = "verifyTextExistInPage";
2114
2150
  const newValue = await this._replaceWithLocalData(text, world);
2115
2151
  if (newValue !== text) {
2116
2152
  this.logger.info(text + "=" + newValue);
2117
2153
  text = newValue;
2118
2154
  }
2119
- info.text = text;
2120
2155
  let dateAlternatives = findDateAlternatives(text);
2121
2156
  let numberAlternatives = findNumberAlternatives(text);
2122
2157
  try {
2158
+ await _preCommand(state, this);
2159
+ state.info.text = text;
2123
2160
  while (true) {
2124
- const frames = this.page.frames();
2125
- let results = [];
2126
- for (let i = 0; i < frames.length; i++) {
2127
- if (dateAlternatives.date) {
2128
- for (let j = 0; j < dateAlternatives.dates.length; j++) {
2129
- const result = await this._locateElementByText(frames[i], dateAlternatives.dates[j], "*:not(script, style, head)", true, true, {});
2130
- result.frame = frames[i];
2131
- results.push(result);
2132
- }
2133
- }
2134
- else if (numberAlternatives.number) {
2135
- for (let j = 0; j < numberAlternatives.numbers.length; j++) {
2136
- const result = await this._locateElementByText(frames[i], numberAlternatives.numbers[j], "*:not(script, style, head)", true, true, {});
2137
- result.frame = frames[i];
2138
- results.push(result);
2139
- }
2140
- }
2141
- else {
2142
- const result = await this._locateElementByText(frames[i], text, "*:not(script, style, head)", true, true, {});
2143
- result.frame = frames[i];
2144
- results.push(result);
2145
- }
2146
- }
2147
- info.results = results;
2148
- const resultWithElementsFound = results.filter((result) => result.elementCount > 0);
2161
+ const resultWithElementsFound = await this.findTextInAllFrames(dateAlternatives, numberAlternatives, text, state);
2149
2162
  if (resultWithElementsFound.length === 0) {
2150
- if (Date.now() - startTime > timeout) {
2163
+ if (Date.now() - state.startTime > timeout) {
2151
2164
  throw new Error(`Text ${text} not found in page`);
2152
2165
  }
2153
2166
  await new Promise((resolve) => setTimeout(resolve, 1000));
@@ -2157,58 +2170,151 @@ class StableBrowser {
2157
2170
  const frame = resultWithElementsFound[0].frame;
2158
2171
  const dataAttribute = `[data-blinq-id="blinq-id-${resultWithElementsFound[0].randomToken}"]`;
2159
2172
  await this._highlightElements(frame, dataAttribute);
2160
- const element = await frame.$(dataAttribute);
2173
+ const element = await frame.locator(dataAttribute).first();
2161
2174
  if (element) {
2162
- await this.scrollIfNeeded(element, info);
2175
+ await this.scrollIfNeeded(element, state.info);
2163
2176
  await element.dispatchEvent("bvt_verify_page_contains_text");
2164
2177
  }
2165
2178
  }
2166
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
2167
- return info;
2179
+ await _screenshot(state, this);
2180
+ return state.info;
2168
2181
  }
2169
2182
  // await expect(element).toHaveCount(1, { timeout: 10000 });
2170
2183
  }
2171
2184
  catch (e) {
2172
- //await this.closeUnexpectedPopups();
2173
- this.logger.error("verify text exist in page failed " + info.log);
2174
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
2175
- info.screenshotPath = screenshotPath;
2176
- Object.assign(e, { info: info });
2177
- error = e;
2178
- // throw e;
2179
- await _commandError({ text: "verifyTextExistInPage", operation: "verifyTextExistInPage", text, info }, e, this);
2185
+ await _commandError(state, e, this);
2180
2186
  }
2181
2187
  finally {
2182
- const endTime = Date.now();
2183
- this._reportToWorld(world, {
2184
- type: Types.VERIFY_ELEMENT_CONTAINS_TEXT,
2185
- text: "Verify text exists in page",
2186
- screenshotId,
2187
- result: error
2188
- ? {
2189
- status: "FAILED",
2190
- startTime,
2191
- endTime,
2192
- message: error?.message,
2193
- }
2194
- : {
2195
- status: "PASSED",
2196
- startTime,
2197
- endTime,
2198
- },
2199
- info: info,
2200
- });
2188
+ _commandFinally(state, this);
2201
2189
  }
2202
2190
  }
2203
- _getServerUrl() {
2204
- let serviceUrl = "https://api.blinq.io";
2205
- if (process.env.NODE_ENV_BLINQ === "dev") {
2206
- serviceUrl = "https://dev.api.blinq.io";
2191
+ async waitForTextToDisappear(text, options = {}, world = null) {
2192
+ text = unEscapeString(text);
2193
+ const state = {
2194
+ text_search: text,
2195
+ options,
2196
+ world,
2197
+ locate: false,
2198
+ scroll: false,
2199
+ highlight: false,
2200
+ type: Types.WAIT_FOR_TEXT_TO_DISAPPEAR,
2201
+ text: `Verify text does not exist in page`,
2202
+ operation: "verifyTextNotExistInPage",
2203
+ log: "***** verify text " + text + " does not exist in page *****\n",
2204
+ };
2205
+ const timeout = this._getLoadTimeout(options);
2206
+ await new Promise((resolve) => setTimeout(resolve, 2000));
2207
+ const newValue = await this._replaceWithLocalData(text, world);
2208
+ if (newValue !== text) {
2209
+ this.logger.info(text + "=" + newValue);
2210
+ text = newValue;
2207
2211
  }
2208
- else if (process.env.NODE_ENV_BLINQ === "stage") {
2209
- serviceUrl = "https://stage.api.blinq.io";
2212
+ let dateAlternatives = findDateAlternatives(text);
2213
+ let numberAlternatives = findNumberAlternatives(text);
2214
+ try {
2215
+ await _preCommand(state, this);
2216
+ state.info.text = text;
2217
+ while (true) {
2218
+ const resultWithElementsFound = await this.findTextInAllFrames(dateAlternatives, numberAlternatives, text, state);
2219
+ if (resultWithElementsFound.length === 0) {
2220
+ await _screenshot(state, this);
2221
+ return state.info;
2222
+ }
2223
+ if (Date.now() - state.startTime > timeout) {
2224
+ throw new Error(`Text ${text} found in page`);
2225
+ }
2226
+ await new Promise((resolve) => setTimeout(resolve, 1000));
2227
+ }
2228
+ }
2229
+ catch (e) {
2230
+ await _commandError(state, e, this);
2231
+ }
2232
+ finally {
2233
+ _commandFinally(state, this);
2234
+ }
2235
+ }
2236
+ async verifyTextRelatedToText(textAnchor, climb, textToVerify, options = {}, world = null) {
2237
+ textAnchor = unEscapeString(textAnchor);
2238
+ textToVerify = unEscapeString(textToVerify);
2239
+ const state = {
2240
+ text_search: textToVerify,
2241
+ options,
2242
+ world,
2243
+ locate: false,
2244
+ scroll: false,
2245
+ highlight: false,
2246
+ type: Types.VERIFY_TEXT_WITH_RELATION,
2247
+ text: `Verify text with relation to another text`,
2248
+ operation: "verify_text_with_relation",
2249
+ log: "***** search for " + textAnchor + " climb " + climb + " and verify " + textToVerify + " found *****\n",
2250
+ };
2251
+ const timeout = this._getLoadTimeout(options);
2252
+ await new Promise((resolve) => setTimeout(resolve, 2000));
2253
+ let newValue = await this._replaceWithLocalData(textAnchor, world);
2254
+ if (newValue !== textAnchor) {
2255
+ this.logger.info(textAnchor + "=" + newValue);
2256
+ textAnchor = newValue;
2257
+ }
2258
+ newValue = await this._replaceWithLocalData(textToVerify, world);
2259
+ if (newValue !== textToVerify) {
2260
+ this.logger.info(textToVerify + "=" + newValue);
2261
+ textToVerify = newValue;
2262
+ }
2263
+ let dateAlternatives = findDateAlternatives(textToVerify);
2264
+ let numberAlternatives = findNumberAlternatives(textToVerify);
2265
+ let foundAncore = false;
2266
+ try {
2267
+ await _preCommand(state, this);
2268
+ state.info.text = textToVerify;
2269
+ while (true) {
2270
+ const resultWithElementsFound = await this.findTextInAllFrames(dateAlternatives, numberAlternatives, textAnchor, state);
2271
+ if (resultWithElementsFound.length === 0) {
2272
+ if (Date.now() - state.startTime > timeout) {
2273
+ throw new Error(`Text ${foundAncore ? textToVerify : textAnchor} not found in page`);
2274
+ }
2275
+ await new Promise((resolve) => setTimeout(resolve, 1000));
2276
+ continue;
2277
+ }
2278
+ for (let i = 0; i < resultWithElementsFound.length; i++) {
2279
+ foundAncore = true;
2280
+ const result = resultWithElementsFound[i];
2281
+ const token = result.randomToken;
2282
+ const frame = result.frame;
2283
+ let css = `[data-blinq-id="blinq-id-${token}"]`;
2284
+ const climbArray1 = [];
2285
+ for (let i = 0; i < climb; i++) {
2286
+ climbArray1.push("..");
2287
+ }
2288
+ let climbXpath = "xpath=" + climbArray1.join("/");
2289
+ css = css + " >> " + climbXpath;
2290
+ const count = await frame.locator(css).count();
2291
+ for (let j = 0; j < count; j++) {
2292
+ const continer = await frame.locator(css).nth(j);
2293
+ const result = await this._locateElementByText(continer, textToVerify, "*", false, true, true, {});
2294
+ if (result.elementCount > 0) {
2295
+ const dataAttribute = "[data-blinq-id='blinq-id-" + result.randomToken + "']";
2296
+ //const cssAnchor = `[data-blinq-id="blinq-id-${token}-anchor"]`;
2297
+ await this._highlightElements(frame, dataAttribute);
2298
+ //await this._highlightElements(frame, cssAnchor);
2299
+ const element = await frame.locator(dataAttribute).first();
2300
+ if (element) {
2301
+ await this.scrollIfNeeded(element, state.info);
2302
+ await element.dispatchEvent("bvt_verify_page_contains_text");
2303
+ }
2304
+ await _screenshot(state, this);
2305
+ return state.info;
2306
+ }
2307
+ }
2308
+ }
2309
+ }
2310
+ // await expect(element).toHaveCount(1, { timeout: 10000 });
2311
+ }
2312
+ catch (e) {
2313
+ await _commandError(state, e, this);
2314
+ }
2315
+ finally {
2316
+ _commandFinally(state, this);
2210
2317
  }
2211
- return serviceUrl;
2212
2318
  }
2213
2319
  async visualVerification(text, options = {}, world = null) {
2214
2320
  const startTime = Date.now();
@@ -2224,7 +2330,7 @@ class StableBrowser {
2224
2330
  throw new Error("TOKEN is not set");
2225
2331
  }
2226
2332
  try {
2227
- let serviceUrl = this._getServerUrl();
2333
+ let serviceUrl = _getServerUrl();
2228
2334
  ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
2229
2335
  info.screenshotPath = screenshotPath;
2230
2336
  const screenshot = await this.takeScreenshot();
@@ -2265,7 +2371,7 @@ class StableBrowser {
2265
2371
  }
2266
2372
  finally {
2267
2373
  const endTime = Date.now();
2268
- this._reportToWorld(world, {
2374
+ _reportToWorld(world, {
2269
2375
  type: Types.VERIFY_VISUAL,
2270
2376
  text: "Visual verification",
2271
2377
  screenshotId,
@@ -2313,6 +2419,7 @@ class StableBrowser {
2313
2419
  let screenshotPath = null;
2314
2420
  const info = {};
2315
2421
  info.log = "";
2422
+ info.locatorLog = new LocatorLog(selectors);
2316
2423
  info.operation = "getTableData";
2317
2424
  info.selectors = selectors;
2318
2425
  try {
@@ -2333,7 +2440,7 @@ class StableBrowser {
2333
2440
  }
2334
2441
  finally {
2335
2442
  const endTime = Date.now();
2336
- this._reportToWorld(world, {
2443
+ _reportToWorld(world, {
2337
2444
  element_name: selectors.element_name,
2338
2445
  type: Types.GET_TABLE_DATA,
2339
2446
  text: "Get table data",
@@ -2388,7 +2495,7 @@ class StableBrowser {
2388
2495
  info.operation = "analyzeTable";
2389
2496
  info.selectors = selectors;
2390
2497
  info.query = query;
2391
- query = this._fixUsingParams(query, _params);
2498
+ query = _fixUsingParams(query, _params);
2392
2499
  info.query_fixed = query;
2393
2500
  info.operator = operator;
2394
2501
  info.value = value;
@@ -2499,7 +2606,7 @@ class StableBrowser {
2499
2606
  }
2500
2607
  finally {
2501
2608
  const endTime = Date.now();
2502
- this._reportToWorld(world, {
2609
+ _reportToWorld(world, {
2503
2610
  element_name: selectors.element_name,
2504
2611
  type: Types.ANALYZE_TABLE,
2505
2612
  text: "Analyze table",
@@ -2572,7 +2679,7 @@ class StableBrowser {
2572
2679
  await new Promise((resolve) => setTimeout(resolve, 2000));
2573
2680
  ({ screenshotId, screenshotPath } = await this._screenShot(options, world));
2574
2681
  const endTime = Date.now();
2575
- this._reportToWorld(world, {
2682
+ _reportToWorld(world, {
2576
2683
  type: Types.GET_PAGE_STATUS,
2577
2684
  text: "Wait for page load",
2578
2685
  screenshotId,
@@ -2592,42 +2699,35 @@ class StableBrowser {
2592
2699
  }
2593
2700
  }
2594
2701
  async closePage(options = {}, world = null) {
2595
- const startTime = Date.now();
2596
- let error = null;
2597
- let screenshotId = null;
2598
- let screenshotPath = null;
2599
- const info = {};
2702
+ const state = {
2703
+ options,
2704
+ world,
2705
+ locate: false,
2706
+ scroll: false,
2707
+ highlight: false,
2708
+ type: Types.CLOSE_PAGE,
2709
+ text: `Close page`,
2710
+ operation: "closePage",
2711
+ log: "***** close page *****\n",
2712
+ throwError: false,
2713
+ };
2600
2714
  try {
2715
+ await _preCommand(state, this);
2601
2716
  await this.page.close();
2602
2717
  }
2603
2718
  catch (e) {
2604
2719
  console.log(".");
2605
- await _commandError({ text: "closePage", operation: "closePage", info }, e, this);
2720
+ await _commandError(state, e, this);
2606
2721
  }
2607
2722
  finally {
2608
- await new Promise((resolve) => setTimeout(resolve, 2000));
2609
- ({ screenshotId, screenshotPath } = await this._screenShot(options, world));
2610
- const endTime = Date.now();
2611
- this._reportToWorld(world, {
2612
- type: Types.CLOSE_PAGE,
2613
- text: "close page",
2614
- screenshotId,
2615
- result: error
2616
- ? {
2617
- status: "FAILED",
2618
- startTime,
2619
- endTime,
2620
- message: error?.message,
2621
- }
2622
- : {
2623
- status: "PASSED",
2624
- startTime,
2625
- endTime,
2626
- },
2627
- info: info,
2628
- });
2723
+ _commandFinally(state, this);
2629
2724
  }
2630
2725
  }
2726
+ saveTestDataAsGlobal(options, world) {
2727
+ const dataFile = this._getDataFile(world);
2728
+ process.env.GLOBAL_TEST_DATA_FILE = dataFile;
2729
+ this.logger.info("Save the scenario test data as global for the following scenarios.");
2730
+ }
2631
2731
  async setViewportSize(width, hight, options = {}, world = null) {
2632
2732
  const startTime = Date.now();
2633
2733
  let error = null;
@@ -2651,7 +2751,7 @@ class StableBrowser {
2651
2751
  await new Promise((resolve) => setTimeout(resolve, 2000));
2652
2752
  ({ screenshotId, screenshotPath } = await this._screenShot(options, world));
2653
2753
  const endTime = Date.now();
2654
- this._reportToWorld(world, {
2754
+ _reportToWorld(world, {
2655
2755
  type: Types.SET_VIEWPORT,
2656
2756
  text: "set viewport size to " + width + "x" + hight,
2657
2757
  screenshotId,
@@ -2688,7 +2788,7 @@ class StableBrowser {
2688
2788
  await new Promise((resolve) => setTimeout(resolve, 2000));
2689
2789
  ({ screenshotId, screenshotPath } = await this._screenShot(options, world, info));
2690
2790
  const endTime = Date.now();
2691
- this._reportToWorld(world, {
2791
+ _reportToWorld(world, {
2692
2792
  type: Types.GET_PAGE_STATUS,
2693
2793
  text: "page relaod",
2694
2794
  screenshotId,
@@ -2724,11 +2824,45 @@ class StableBrowser {
2724
2824
  console.log("#-#");
2725
2825
  }
2726
2826
  }
2727
- _reportToWorld(world, properties) {
2728
- if (!world || !world.attach) {
2729
- return;
2827
+ async beforeStep(world, step) {
2828
+ if (this.stepIndex === undefined) {
2829
+ this.stepIndex = 0;
2830
+ }
2831
+ else {
2832
+ this.stepIndex++;
2833
+ }
2834
+ if (step && step.pickleStep && step.pickleStep.text) {
2835
+ this.stepName = step.pickleStep.text;
2836
+ this.logger.info("step: " + this.stepName);
2837
+ }
2838
+ else if (step && step.text) {
2839
+ this.stepName = step.text;
2840
+ }
2841
+ else {
2842
+ this.stepName = "step " + this.stepIndex;
2843
+ }
2844
+ if (this.context && this.context.browserObject && this.context.browserObject.trace === true) {
2845
+ if (this.context.browserObject.context) {
2846
+ await this.context.browserObject.context.tracing.startChunk({ title: this.stepName });
2847
+ }
2848
+ }
2849
+ if (this.tags === null && step && step.pickle && step.pickle.tags) {
2850
+ this.tags = step.pickle.tags.map((tag) => tag.name);
2851
+ // check if @global_test_data tag is present
2852
+ if (this.tags.includes("@global_test_data")) {
2853
+ this.saveTestDataAsGlobal({}, world);
2854
+ }
2855
+ }
2856
+ }
2857
+ async afterStep(world, step) {
2858
+ this.stepName = null;
2859
+ if (this.context && this.context.browserObject && this.context.browserObject.trace === true) {
2860
+ if (this.context.browserObject.context) {
2861
+ await this.context.browserObject.context.tracing.stopChunk({
2862
+ path: path.join(this.context.browserObject.traceFolder, `trace-${this.stepIndex}.zip`),
2863
+ });
2864
+ }
2730
2865
  }
2731
- world.attach(JSON.stringify(properties), { mediaType: "application/json" });
2732
2866
  }
2733
2867
  }
2734
2868
  function createTimedPromise(promise, label) {
@@ -2736,156 +2870,5 @@ function createTimedPromise(promise, label) {
2736
2870
  .then((result) => ({ status: "fulfilled", label, result }))
2737
2871
  .catch((error) => Promise.reject({ status: "rejected", label, error }));
2738
2872
  }
2739
- const KEYBOARD_EVENTS = [
2740
- "ALT",
2741
- "AltGraph",
2742
- "CapsLock",
2743
- "Control",
2744
- "Fn",
2745
- "FnLock",
2746
- "Hyper",
2747
- "Meta",
2748
- "NumLock",
2749
- "ScrollLock",
2750
- "Shift",
2751
- "Super",
2752
- "Symbol",
2753
- "SymbolLock",
2754
- "Enter",
2755
- "Tab",
2756
- "ArrowDown",
2757
- "ArrowLeft",
2758
- "ArrowRight",
2759
- "ArrowUp",
2760
- "End",
2761
- "Home",
2762
- "PageDown",
2763
- "PageUp",
2764
- "Backspace",
2765
- "Clear",
2766
- "Copy",
2767
- "CrSel",
2768
- "Cut",
2769
- "Delete",
2770
- "EraseEof",
2771
- "ExSel",
2772
- "Insert",
2773
- "Paste",
2774
- "Redo",
2775
- "Undo",
2776
- "Accept",
2777
- "Again",
2778
- "Attn",
2779
- "Cancel",
2780
- "ContextMenu",
2781
- "Escape",
2782
- "Execute",
2783
- "Find",
2784
- "Finish",
2785
- "Help",
2786
- "Pause",
2787
- "Play",
2788
- "Props",
2789
- "Select",
2790
- "ZoomIn",
2791
- "ZoomOut",
2792
- "BrightnessDown",
2793
- "BrightnessUp",
2794
- "Eject",
2795
- "LogOff",
2796
- "Power",
2797
- "PowerOff",
2798
- "PrintScreen",
2799
- "Hibernate",
2800
- "Standby",
2801
- "WakeUp",
2802
- "AllCandidates",
2803
- "Alphanumeric",
2804
- "CodeInput",
2805
- "Compose",
2806
- "Convert",
2807
- "Dead",
2808
- "FinalMode",
2809
- "GroupFirst",
2810
- "GroupLast",
2811
- "GroupNext",
2812
- "GroupPrevious",
2813
- "ModeChange",
2814
- "NextCandidate",
2815
- "NonConvert",
2816
- "PreviousCandidate",
2817
- "Process",
2818
- "SingleCandidate",
2819
- "HangulMode",
2820
- "HanjaMode",
2821
- "JunjaMode",
2822
- "Eisu",
2823
- "Hankaku",
2824
- "Hiragana",
2825
- "HiraganaKatakana",
2826
- "KanaMode",
2827
- "KanjiMode",
2828
- "Katakana",
2829
- "Romaji",
2830
- "Zenkaku",
2831
- "ZenkakuHanaku",
2832
- "F1",
2833
- "F2",
2834
- "F3",
2835
- "F4",
2836
- "F5",
2837
- "F6",
2838
- "F7",
2839
- "F8",
2840
- "F9",
2841
- "F10",
2842
- "F11",
2843
- "F12",
2844
- "Soft1",
2845
- "Soft2",
2846
- "Soft3",
2847
- "Soft4",
2848
- "ChannelDown",
2849
- "ChannelUp",
2850
- "Close",
2851
- "MailForward",
2852
- "MailReply",
2853
- "MailSend",
2854
- "MediaFastForward",
2855
- "MediaPause",
2856
- "MediaPlay",
2857
- "MediaPlayPause",
2858
- "MediaRecord",
2859
- "MediaRewind",
2860
- "MediaStop",
2861
- "MediaTrackNext",
2862
- "MediaTrackPrevious",
2863
- "AudioBalanceLeft",
2864
- "AudioBalanceRight",
2865
- "AudioBassBoostDown",
2866
- "AudioBassBoostToggle",
2867
- "AudioBassBoostUp",
2868
- "AudioFaderFront",
2869
- "AudioFaderRear",
2870
- "AudioSurroundModeNext",
2871
- "AudioTrebleDown",
2872
- "AudioTrebleUp",
2873
- "AudioVolumeDown",
2874
- "AudioVolumeMute",
2875
- "AudioVolumeUp",
2876
- "MicrophoneToggle",
2877
- "MicrophoneVolumeDown",
2878
- "MicrophoneVolumeMute",
2879
- "MicrophoneVolumeUp",
2880
- "TV",
2881
- "TV3DMode",
2882
- "TVAntennaCable",
2883
- "TVAudioDescription",
2884
- ];
2885
- function unEscapeString(str) {
2886
- const placeholder = "__NEWLINE__";
2887
- str = str.replace(new RegExp(placeholder, "g"), "\n");
2888
- return str;
2889
- }
2890
2873
  export { StableBrowser };
2891
2874
  //# sourceMappingURL=stable_browser.js.map