automation_model 1.0.897-dev → 1.0.899-dev

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.
@@ -47,6 +47,7 @@ export const Types = {
47
47
  VERIFY_PAGE_CONTAINS_NO_TEXT: "verify_page_contains_no_text",
48
48
  ANALYZE_TABLE: "analyze_table",
49
49
  SELECT: "select_combobox", //
50
+ VERIFY_PROPERTY: "verify_element_property",
50
51
  VERIFY_PAGE_PATH: "verify_page_path",
51
52
  VERIFY_PAGE_TITLE: "verify_page_title",
52
53
  TYPE_PRESS: "type_press",
@@ -65,12 +66,11 @@ export const Types = {
65
66
  SET_INPUT: "set_input",
66
67
  WAIT_FOR_TEXT_TO_DISAPPEAR: "wait_for_text_to_disappear",
67
68
  VERIFY_ATTRIBUTE: "verify_element_attribute",
68
- VERIFY_PROPERTY: "verify_element_property",
69
69
  VERIFY_TEXT_WITH_RELATION: "verify_text_with_relation",
70
70
  BRUNO: "bruno",
71
- SNAPSHOT_VALIDATION: "snapshot_validation",
72
71
  VERIFY_FILE_EXISTS: "verify_file_exists",
73
72
  SET_INPUT_FILES: "set_input_files",
73
+ SNAPSHOT_VALIDATION: "snapshot_validation",
74
74
  REPORT_COMMAND: "report_command",
75
75
  STEP_COMPLETE: "step_complete",
76
76
  SLEEP: "sleep",
@@ -136,11 +136,10 @@ class StableBrowser {
136
136
  const logFolder = path.join(this.project_path, "logs", "web");
137
137
  this.world = world;
138
138
  if (this.configuration && this.configuration.fastMode === true) {
139
- console.log("Fast mode enabled from ai_config.json");
140
139
  this.fastMode = true;
141
140
  }
142
141
  if (process.env.FAST_MODE === "true") {
143
- console.log("Fast mode enabled from environment variable");
142
+ // console.log("Fast mode enabled from environment variable");
144
143
  this.fastMode = true;
145
144
  }
146
145
  if (process.env.FAST_MODE === "false") {
@@ -354,6 +353,9 @@ class StableBrowser {
354
353
  highlight: false,
355
354
  };
356
355
  let timeout = 60000;
356
+ if (this.configuration && this.configuration.page_timeout) {
357
+ timeout = this.configuration.page_timeout;
358
+ }
357
359
  if (options && options["timeout"]) {
358
360
  timeout = options["timeout"];
359
361
  }
@@ -589,8 +591,7 @@ class StableBrowser {
589
591
  // if (locatorSearch.css && locatorSearch.css.includes("href=")) {
590
592
  // cssHref = true;
591
593
  // }
592
- const _locator = locator.locator("visible=true");
593
- let count = await _locator.count();
594
+ let count = await locator.count();
594
595
  if (count > 0 && !info.failCause.count) {
595
596
  info.failCause.count = count;
596
597
  }
@@ -598,7 +599,7 @@ class StableBrowser {
598
599
  //let visibleCount = 0;
599
600
  let visibleLocator = null;
600
601
  if (typeof locatorSearch.index === "number" && locatorSearch.index < count) {
601
- foundLocators.push(_locator.nth(locatorSearch.index));
602
+ foundLocators.push(locator.nth(locatorSearch.index));
602
603
  if (info.locatorLog) {
603
604
  info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "FOUND");
604
605
  }
@@ -608,13 +609,13 @@ class StableBrowser {
608
609
  info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "NOT_FOUND");
609
610
  }
610
611
  for (let j = 0; j < count; j++) {
611
- let visible = await _locator.nth(j).isVisible();
612
- const enabled = await _locator.nth(j).isEnabled();
612
+ let visible = await locator.nth(j).isVisible();
613
+ const enabled = await locator.nth(j).isEnabled();
613
614
  if (!visibleOnly) {
614
615
  visible = true;
615
616
  }
616
617
  if (visible && (allowDisabled || enabled)) {
617
- foundLocators.push(_locator.nth(j));
618
+ foundLocators.push(locator.nth(j));
618
619
  if (info.locatorLog) {
619
620
  info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "FOUND");
620
621
  }
@@ -2082,7 +2083,13 @@ class StableBrowser {
2082
2083
  scope = await this._findFrameScope(frameSelectors, timeout, state.info);
2083
2084
  }
2084
2085
  const snapshot = await scope.locator("body").ariaSnapshot({ timeout });
2086
+ if (snapshot && snapshot.length <= 10) {
2087
+ console.log("Page snapshot length is suspiciously small:", snapshot);
2088
+ }
2085
2089
  matchResult = snapshotValidation(snapshot, newValue, referanceSnapshot);
2090
+ if (matchResult === undefined) {
2091
+ console.log("snapshotValidation returned undefined");
2092
+ }
2086
2093
  if (matchResult.errorLine !== -1) {
2087
2094
  throw new Error("Snapshot validation failed at line " + matchResult.errorLineText);
2088
2095
  }
@@ -2457,6 +2464,12 @@ class StableBrowser {
2457
2464
  state.info.value = state.value;
2458
2465
  this.setTestData({ [variable]: state.value }, world);
2459
2466
  this.logger.info("set test data: " + variable + "=" + state.value);
2467
+ if (process.env.MODE === "executions") {
2468
+ const globalDataFile = "global_test_data.json";
2469
+ if (existsSync(globalDataFile)) {
2470
+ this.saveTestDataAsGlobal({}, world);
2471
+ }
2472
+ }
2460
2473
  // await new Promise((resolve) => setTimeout(resolve, 500));
2461
2474
  return state.info;
2462
2475
  }
@@ -2528,6 +2541,12 @@ class StableBrowser {
2528
2541
  state.info.value = state.value;
2529
2542
  this.setTestData({ [variable]: state.value }, world);
2530
2543
  this.logger.info("set test data: " + variable + "=" + state.value);
2544
+ if (process.env.MODE === "executions") {
2545
+ const globalDataFile = "global_test_data.json";
2546
+ if (existsSync(globalDataFile)) {
2547
+ this.saveTestDataAsGlobal({}, world);
2548
+ }
2549
+ }
2531
2550
  // await new Promise((resolve) => setTimeout(resolve, 500));
2532
2551
  return state.info;
2533
2552
  }
@@ -2954,6 +2973,12 @@ class StableBrowser {
2954
2973
  emailUrl = url;
2955
2974
  codeOrUrlFound = true;
2956
2975
  }
2976
+ if (process.env.MODE === "executions") {
2977
+ const globalDataFile = "global_test_data.json";
2978
+ if (existsSync(globalDataFile)) {
2979
+ this.saveTestDataAsGlobal({}, world);
2980
+ }
2981
+ }
2957
2982
  if (codeOrUrlFound) {
2958
2983
  return { emailUrl, emailCode };
2959
2984
  }
@@ -3501,6 +3526,8 @@ class StableBrowser {
3501
3526
  operation: "verify_text_with_relation",
3502
3527
  log: "***** search for " + textAnchor + " climb " + climb + " and verify " + textToVerify + " found *****\n",
3503
3528
  };
3529
+ const cmdStartTime = Date.now();
3530
+ let cmdEndTime = null;
3504
3531
  const timeout = this._getFindElementTimeout(options);
3505
3532
  await new Promise((resolve) => setTimeout(resolve, 2000));
3506
3533
  let newValue = await this._replaceWithLocalData(textAnchor, world);
@@ -3536,6 +3563,17 @@ class StableBrowser {
3536
3563
  await new Promise((resolve) => setTimeout(resolve, 1000));
3537
3564
  continue;
3538
3565
  }
3566
+ else {
3567
+ cmdEndTime = Date.now();
3568
+ if (cmdEndTime - cmdStartTime > 55000) {
3569
+ if (foundAncore) {
3570
+ throw new Error(`Text ${textToVerify} not found in page`);
3571
+ }
3572
+ else {
3573
+ throw new Error(`Text ${textAnchor} not found in page`);
3574
+ }
3575
+ }
3576
+ }
3539
3577
  try {
3540
3578
  for (let i = 0; i < resultWithElementsFound.length; i++) {
3541
3579
  foundAncore = true;
@@ -4331,6 +4369,7 @@ class StableBrowser {
4331
4369
  if (world && world.attach) {
4332
4370
  world.attach(this.context.reportFolder, { mediaType: "text/plain" });
4333
4371
  }
4372
+ this.context.loadedRoutes = null;
4334
4373
  this.beforeScenarioCalled = true;
4335
4374
  if (scenario && scenario.pickle && scenario.pickle.name) {
4336
4375
  this.scenarioName = scenario.pickle.name;
@@ -4382,6 +4421,7 @@ class StableBrowser {
4382
4421
  this.stepTags = [];
4383
4422
  if (!this.beforeScenarioCalled) {
4384
4423
  this.beforeScenario(world, step);
4424
+ this.context.loadedRoutes = null;
4385
4425
  }
4386
4426
  if (this.stepIndex === undefined) {
4387
4427
  this.stepIndex = 0;