automation_model 1.0.712-dev → 1.0.712-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.
- package/README.md +4 -1
- package/lib/analyze_helper.js.map +1 -1
- package/lib/api.d.ts +0 -1
- package/lib/api.js +4 -3
- package/lib/api.js.map +1 -1
- package/lib/auto_page.d.ts +4 -2
- package/lib/auto_page.js +142 -86
- package/lib/auto_page.js.map +1 -1
- package/lib/browser_manager.js +22 -25
- package/lib/browser_manager.js.map +1 -1
- package/lib/bruno.js.map +1 -1
- package/lib/check_performance.d.ts +1 -0
- package/lib/check_performance.js +57 -0
- package/lib/check_performance.js.map +1 -0
- package/lib/command_common.d.ts +1 -1
- package/lib/command_common.js +25 -2
- package/lib/command_common.js.map +1 -1
- package/lib/date_time.js.map +1 -1
- package/lib/drawRect.js.map +1 -1
- package/lib/error-messages.js.map +1 -1
- package/lib/file_checker.js +129 -25
- package/lib/file_checker.js.map +1 -1
- package/lib/find_function.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/init_browser.js +115 -125
- package/lib/init_browser.js.map +1 -1
- package/lib/locate_element.js.map +1 -1
- package/lib/locator.d.ts +1 -0
- package/lib/locator.js +10 -3
- package/lib/locator.js.map +1 -1
- package/lib/locator_log.js +0 -3
- package/lib/locator_log.js.map +1 -1
- package/lib/network.d.ts +2 -0
- package/lib/network.js +334 -86
- package/lib/network.js.map +1 -1
- package/lib/route.d.ts +21 -0
- package/lib/route.js +521 -0
- package/lib/route.js.map +1 -0
- package/lib/scripts/axe.mini.js +3 -3
- package/lib/snapshot_validation.js +150 -39
- package/lib/snapshot_validation.js.map +1 -1
- package/lib/stable_browser.d.ts +62 -26
- package/lib/stable_browser.js +1020 -224
- package/lib/stable_browser.js.map +1 -1
- package/lib/table.d.ts +9 -7
- package/lib/table.js +82 -12
- package/lib/table.js.map +1 -1
- package/lib/table_analyze.js.map +1 -1
- package/lib/table_helper.js.map +1 -1
- package/lib/utils.d.ts +3 -1
- package/lib/utils.js +92 -63
- package/lib/utils.js.map +1 -1
- package/package.json +15 -9
package/lib/stable_browser.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
import { check_performance } from "./check_performance.js";
|
|
2
3
|
import { expect } from "@playwright/test";
|
|
3
4
|
import dayjs from "dayjs";
|
|
4
5
|
import fs from "fs";
|
|
@@ -10,7 +11,8 @@ import { getDateTimeValue } from "./date_time.js";
|
|
|
10
11
|
import drawRectangle from "./drawRect.js";
|
|
11
12
|
//import { closeUnexpectedPopups } from "./popups.js";
|
|
12
13
|
import { getTableCells, getTableData } from "./table_analyze.js";
|
|
13
|
-
import
|
|
14
|
+
import errorStackParser from "error-stack-parser";
|
|
15
|
+
import { _convertToRegexQuery, _copyContext, _fixLocatorUsingParams, _fixUsingParams, _getServerUrl, extractStepExampleParameters, KEYBOARD_EVENTS, maskValue, replaceWithLocalTestData, scrollPageToLoadLazyElements, unEscapeString, _getDataFile, testForRegex, performAction, _getTestData, } from "./utils.js";
|
|
14
16
|
import csv from "csv-parser";
|
|
15
17
|
import { Readable } from "node:stream";
|
|
16
18
|
import readline from "readline";
|
|
@@ -19,35 +21,42 @@ import { getTestData } from "./auto_page.js";
|
|
|
19
21
|
import { locate_element } from "./locate_element.js";
|
|
20
22
|
import { randomUUID } from "crypto";
|
|
21
23
|
import { _commandError, _commandFinally, _preCommand, _validateSelectors, _screenshot, _reportToWorld, } from "./command_common.js";
|
|
22
|
-
import { registerDownloadEvent, registerNetworkEvents } from "./network.js";
|
|
24
|
+
import { networkAfterStep, networkBeforeStep, registerDownloadEvent, registerNetworkEvents } from "./network.js";
|
|
23
25
|
import { LocatorLog } from "./locator_log.js";
|
|
24
26
|
import axios from "axios";
|
|
25
27
|
import { _findCellArea, findElementsInArea } from "./table_helper.js";
|
|
26
|
-
import { snapshotValidation } from "./snapshot_validation.js";
|
|
28
|
+
import { highlightSnapshot, snapshotValidation } from "./snapshot_validation.js";
|
|
27
29
|
import { loadBrunoParams } from "./bruno.js";
|
|
30
|
+
import { registerAfterStepRoutes, registerBeforeStepRoutes } from "./route.js";
|
|
31
|
+
import { existsSync } from "node:fs";
|
|
28
32
|
export const Types = {
|
|
29
33
|
CLICK: "click_element",
|
|
30
34
|
WAIT_ELEMENT: "wait_element",
|
|
31
35
|
NAVIGATE: "navigate",
|
|
36
|
+
GO_BACK: "go_back",
|
|
37
|
+
GO_FORWARD: "go_forward",
|
|
32
38
|
FILL: "fill_element",
|
|
33
|
-
EXECUTE: "execute_page_method",
|
|
34
|
-
OPEN: "open_environment",
|
|
39
|
+
EXECUTE: "execute_page_method", //
|
|
40
|
+
OPEN: "open_environment", //
|
|
35
41
|
COMPLETE: "step_complete",
|
|
36
42
|
ASK: "information_needed",
|
|
37
|
-
GET_PAGE_STATUS: "get_page_status",
|
|
38
|
-
CLICK_ROW_ACTION: "click_row_action",
|
|
43
|
+
GET_PAGE_STATUS: "get_page_status", ///
|
|
44
|
+
CLICK_ROW_ACTION: "click_row_action", //
|
|
39
45
|
VERIFY_ELEMENT_CONTAINS_TEXT: "verify_element_contains_text",
|
|
40
46
|
VERIFY_PAGE_CONTAINS_TEXT: "verify_page_contains_text",
|
|
41
47
|
VERIFY_PAGE_CONTAINS_NO_TEXT: "verify_page_contains_no_text",
|
|
42
48
|
ANALYZE_TABLE: "analyze_table",
|
|
43
|
-
SELECT: "select_combobox",
|
|
49
|
+
SELECT: "select_combobox", //
|
|
50
|
+
VERIFY_PROPERTY: "verify_element_property",
|
|
44
51
|
VERIFY_PAGE_PATH: "verify_page_path",
|
|
52
|
+
VERIFY_PAGE_TITLE: "verify_page_title",
|
|
45
53
|
TYPE_PRESS: "type_press",
|
|
46
54
|
PRESS: "press_key",
|
|
47
55
|
HOVER: "hover_element",
|
|
48
56
|
CHECK: "check_element",
|
|
49
57
|
UNCHECK: "uncheck_element",
|
|
50
58
|
EXTRACT: "extract_attribute",
|
|
59
|
+
EXTRACT_PROPERTY: "extract_property",
|
|
51
60
|
CLOSE_PAGE: "close_page",
|
|
52
61
|
TABLE_OPERATION: "table_operation",
|
|
53
62
|
SET_DATE_TIME: "set_date_time",
|
|
@@ -59,9 +68,13 @@ export const Types = {
|
|
|
59
68
|
VERIFY_ATTRIBUTE: "verify_element_attribute",
|
|
60
69
|
VERIFY_TEXT_WITH_RELATION: "verify_text_with_relation",
|
|
61
70
|
BRUNO: "bruno",
|
|
62
|
-
SNAPSHOT_VALIDATION: "snapshot_validation",
|
|
63
71
|
VERIFY_FILE_EXISTS: "verify_file_exists",
|
|
64
72
|
SET_INPUT_FILES: "set_input_files",
|
|
73
|
+
SNAPSHOT_VALIDATION: "snapshot_validation",
|
|
74
|
+
REPORT_COMMAND: "report_command",
|
|
75
|
+
STEP_COMPLETE: "step_complete",
|
|
76
|
+
SLEEP: "sleep",
|
|
77
|
+
CONDITIONAL_WAIT: "conditional_wait",
|
|
65
78
|
};
|
|
66
79
|
export const apps = {};
|
|
67
80
|
const formatElementName = (elementName) => {
|
|
@@ -73,6 +86,7 @@ class StableBrowser {
|
|
|
73
86
|
logger;
|
|
74
87
|
context;
|
|
75
88
|
world;
|
|
89
|
+
fastMode;
|
|
76
90
|
project_path = null;
|
|
77
91
|
webLogFile = null;
|
|
78
92
|
networkLogger = null;
|
|
@@ -81,12 +95,15 @@ class StableBrowser {
|
|
|
81
95
|
tags = null;
|
|
82
96
|
isRecording = false;
|
|
83
97
|
initSnapshotTaken = false;
|
|
84
|
-
|
|
98
|
+
abortedExecution = false;
|
|
99
|
+
onlyFailuresScreenshot = process.env.SCREENSHOT_ON_FAILURE_ONLY === "true";
|
|
100
|
+
constructor(browser, page, logger = null, context = null, world = null, fastMode = false) {
|
|
85
101
|
this.browser = browser;
|
|
86
102
|
this.page = page;
|
|
87
103
|
this.logger = logger;
|
|
88
104
|
this.context = context;
|
|
89
105
|
this.world = world;
|
|
106
|
+
this.fastMode = fastMode;
|
|
90
107
|
if (!this.logger) {
|
|
91
108
|
this.logger = console;
|
|
92
109
|
}
|
|
@@ -115,6 +132,19 @@ class StableBrowser {
|
|
|
115
132
|
context.pages = [this.page];
|
|
116
133
|
const logFolder = path.join(this.project_path, "logs", "web");
|
|
117
134
|
this.world = world;
|
|
135
|
+
if (this.configuration && this.configuration.fastMode === true) {
|
|
136
|
+
this.fastMode = true;
|
|
137
|
+
}
|
|
138
|
+
if (process.env.FAST_MODE === "true") {
|
|
139
|
+
// console.log("Fast mode enabled from environment variable");
|
|
140
|
+
this.fastMode = true;
|
|
141
|
+
}
|
|
142
|
+
if (process.env.FAST_MODE === "false") {
|
|
143
|
+
this.fastMode = false;
|
|
144
|
+
}
|
|
145
|
+
if (this.context) {
|
|
146
|
+
this.context.fastMode = this.fastMode;
|
|
147
|
+
}
|
|
118
148
|
this.registerEventListeners(this.context);
|
|
119
149
|
registerNetworkEvents(this.world, this, this.context, this.page);
|
|
120
150
|
registerDownloadEvent(this.page, this.world, this.context);
|
|
@@ -125,6 +155,9 @@ class StableBrowser {
|
|
|
125
155
|
if (!context.pageLoading) {
|
|
126
156
|
context.pageLoading = { status: false };
|
|
127
157
|
}
|
|
158
|
+
if (this.configuration && this.configuration.acceptDialog && this.page) {
|
|
159
|
+
this.page.on("dialog", (dialog) => dialog.accept());
|
|
160
|
+
}
|
|
128
161
|
context.playContext.on("page", async function (page) {
|
|
129
162
|
if (this.configuration && this.configuration.closePopups === true) {
|
|
130
163
|
console.log("close unexpected popups");
|
|
@@ -133,6 +166,14 @@ class StableBrowser {
|
|
|
133
166
|
}
|
|
134
167
|
context.pageLoading.status = true;
|
|
135
168
|
this.page = page;
|
|
169
|
+
try {
|
|
170
|
+
if (this.configuration && this.configuration.acceptDialog) {
|
|
171
|
+
await page.on("dialog", (dialog) => dialog.accept());
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.error("Error on dialog accept registration", error);
|
|
176
|
+
}
|
|
136
177
|
context.page = page;
|
|
137
178
|
context.pages.push(page);
|
|
138
179
|
registerNetworkEvents(this.world, this, context, this.page);
|
|
@@ -184,7 +225,9 @@ class StableBrowser {
|
|
|
184
225
|
if (newContextCreated) {
|
|
185
226
|
this.registerEventListeners(this.context);
|
|
186
227
|
await this.goto(this.context.environment.baseUrl);
|
|
187
|
-
|
|
228
|
+
if (!this.fastMode) {
|
|
229
|
+
await this.waitForPageLoad();
|
|
230
|
+
}
|
|
188
231
|
}
|
|
189
232
|
}
|
|
190
233
|
async switchTab(tabTitleOrIndex) {
|
|
@@ -278,6 +321,7 @@ class StableBrowser {
|
|
|
278
321
|
if (!url) {
|
|
279
322
|
throw new Error("url is null, verify that the environment file is correct");
|
|
280
323
|
}
|
|
324
|
+
url = await this._replaceWithLocalData(url, this.world);
|
|
281
325
|
if (!url.startsWith("http")) {
|
|
282
326
|
url = "https://" + url;
|
|
283
327
|
}
|
|
@@ -309,6 +353,64 @@ class StableBrowser {
|
|
|
309
353
|
await _commandFinally(state, this);
|
|
310
354
|
}
|
|
311
355
|
}
|
|
356
|
+
async goBack(options, world = null) {
|
|
357
|
+
const state = {
|
|
358
|
+
value: "",
|
|
359
|
+
world: world,
|
|
360
|
+
type: Types.GO_BACK,
|
|
361
|
+
text: `Browser navigate back`,
|
|
362
|
+
operation: "goBack",
|
|
363
|
+
log: "***** navigate back *****\n",
|
|
364
|
+
info: {},
|
|
365
|
+
locate: false,
|
|
366
|
+
scroll: false,
|
|
367
|
+
screenshot: false,
|
|
368
|
+
highlight: false,
|
|
369
|
+
};
|
|
370
|
+
try {
|
|
371
|
+
await _preCommand(state, this);
|
|
372
|
+
await this.page.goBack({
|
|
373
|
+
waitUntil: "load",
|
|
374
|
+
});
|
|
375
|
+
await _screenshot(state, this);
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
console.error("Error on goBack", error);
|
|
379
|
+
_commandError(state, error, this);
|
|
380
|
+
}
|
|
381
|
+
finally {
|
|
382
|
+
await _commandFinally(state, this);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
async goForward(options, world = null) {
|
|
386
|
+
const state = {
|
|
387
|
+
value: "",
|
|
388
|
+
world: world,
|
|
389
|
+
type: Types.GO_FORWARD,
|
|
390
|
+
text: `Browser navigate forward`,
|
|
391
|
+
operation: "goForward",
|
|
392
|
+
log: "***** navigate forward *****\n",
|
|
393
|
+
info: {},
|
|
394
|
+
locate: false,
|
|
395
|
+
scroll: false,
|
|
396
|
+
screenshot: false,
|
|
397
|
+
highlight: false,
|
|
398
|
+
};
|
|
399
|
+
try {
|
|
400
|
+
await _preCommand(state, this);
|
|
401
|
+
await this.page.goForward({
|
|
402
|
+
waitUntil: "load",
|
|
403
|
+
});
|
|
404
|
+
await _screenshot(state, this);
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
console.error("Error on goForward", error);
|
|
408
|
+
_commandError(state, error, this);
|
|
409
|
+
}
|
|
410
|
+
finally {
|
|
411
|
+
await _commandFinally(state, this);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
312
414
|
async _getLocator(locator, scope, _params) {
|
|
313
415
|
locator = _fixLocatorUsingParams(locator, _params);
|
|
314
416
|
// locator = await this._replaceWithLocalData(locator);
|
|
@@ -407,12 +509,6 @@ class StableBrowser {
|
|
|
407
509
|
if (!el.setAttribute) {
|
|
408
510
|
el = el.parentElement;
|
|
409
511
|
}
|
|
410
|
-
// remove any attributes start with data-blinq-id
|
|
411
|
-
// for (let i = 0; i < el.attributes.length; i++) {
|
|
412
|
-
// if (el.attributes[i].name.startsWith("data-blinq-id")) {
|
|
413
|
-
// el.removeAttribute(el.attributes[i].name);
|
|
414
|
-
// }
|
|
415
|
-
// }
|
|
416
512
|
el.setAttribute("data-blinq-id-" + randomToken, "");
|
|
417
513
|
return true;
|
|
418
514
|
}, [tag1, randomToken]))) {
|
|
@@ -422,7 +518,7 @@ class StableBrowser {
|
|
|
422
518
|
}
|
|
423
519
|
return { elementCount: tagCount, randomToken };
|
|
424
520
|
}
|
|
425
|
-
async _collectLocatorInformation(selectorHierarchy, index = 0, scope, foundLocators, _params, info, visibleOnly = true, allowDisabled = false, element_name = null) {
|
|
521
|
+
async _collectLocatorInformation(selectorHierarchy, index = 0, scope, foundLocators, _params, info, visibleOnly = true, allowDisabled = false, element_name = null, logErrors = false) {
|
|
426
522
|
if (!info) {
|
|
427
523
|
info = {};
|
|
428
524
|
}
|
|
@@ -434,14 +530,13 @@ class StableBrowser {
|
|
|
434
530
|
info.locatorLog = new LocatorLog(selectorHierarchy);
|
|
435
531
|
}
|
|
436
532
|
let locatorSearch = selectorHierarchy[index];
|
|
437
|
-
let originalLocatorSearch = "";
|
|
438
533
|
try {
|
|
439
|
-
|
|
440
|
-
locatorSearch = JSON.parse(originalLocatorSearch);
|
|
534
|
+
locatorSearch = _fixLocatorUsingParams(locatorSearch, _params);
|
|
441
535
|
}
|
|
442
536
|
catch (e) {
|
|
443
537
|
console.error(e);
|
|
444
538
|
}
|
|
539
|
+
let originalLocatorSearch = JSON.stringify(locatorSearch);
|
|
445
540
|
//info.log += "searching for locator " + JSON.stringify(locatorSearch) + "\n";
|
|
446
541
|
let locator = null;
|
|
447
542
|
if (locatorSearch.climb && locatorSearch.climb >= 0) {
|
|
@@ -489,7 +584,7 @@ class StableBrowser {
|
|
|
489
584
|
}
|
|
490
585
|
return;
|
|
491
586
|
}
|
|
492
|
-
if (info.locatorLog && count === 0) {
|
|
587
|
+
if (info.locatorLog && count === 0 && logErrors) {
|
|
493
588
|
info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "NOT_FOUND");
|
|
494
589
|
}
|
|
495
590
|
for (let j = 0; j < count; j++) {
|
|
@@ -504,7 +599,7 @@ class StableBrowser {
|
|
|
504
599
|
info.locatorLog.setLocatorSearchStatus(originalLocatorSearch, "FOUND");
|
|
505
600
|
}
|
|
506
601
|
}
|
|
507
|
-
else {
|
|
602
|
+
else if (logErrors) {
|
|
508
603
|
info.failCause.visible = visible;
|
|
509
604
|
info.failCause.enabled = enabled;
|
|
510
605
|
if (!info.printMessages) {
|
|
@@ -583,31 +678,148 @@ class StableBrowser {
|
|
|
583
678
|
}
|
|
584
679
|
return { rerun: false };
|
|
585
680
|
}
|
|
681
|
+
getFilePath() {
|
|
682
|
+
const stackFrames = errorStackParser.parse(new Error());
|
|
683
|
+
const stackFrame = stackFrames.findLast((frame) => frame.fileName && frame.fileName.endsWith(".mjs"));
|
|
684
|
+
// return stackFrame?.fileName || null;
|
|
685
|
+
const filepath = stackFrame?.fileName;
|
|
686
|
+
if (filepath) {
|
|
687
|
+
let jsonFilePath = filepath.replace(".mjs", ".json");
|
|
688
|
+
if (existsSync(jsonFilePath)) {
|
|
689
|
+
return jsonFilePath;
|
|
690
|
+
}
|
|
691
|
+
const config = this.configuration ?? {};
|
|
692
|
+
if (!config?.locatorsMetadataDir) {
|
|
693
|
+
config.locatorsMetadataDir = "features/step_definitions/locators";
|
|
694
|
+
}
|
|
695
|
+
if (config && config.locatorsMetadataDir) {
|
|
696
|
+
jsonFilePath = path.join(config.locatorsMetadataDir, path.basename(jsonFilePath));
|
|
697
|
+
}
|
|
698
|
+
if (existsSync(jsonFilePath)) {
|
|
699
|
+
return jsonFilePath;
|
|
700
|
+
}
|
|
701
|
+
return null;
|
|
702
|
+
}
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
getFullElementLocators(selectors, filePath) {
|
|
706
|
+
if (!filePath || !existsSync(filePath)) {
|
|
707
|
+
return null;
|
|
708
|
+
}
|
|
709
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
710
|
+
try {
|
|
711
|
+
const allElements = JSON.parse(content);
|
|
712
|
+
const element_key = selectors?.element_key;
|
|
713
|
+
if (element_key && allElements[element_key]) {
|
|
714
|
+
return allElements[element_key];
|
|
715
|
+
}
|
|
716
|
+
for (const elementKey in allElements) {
|
|
717
|
+
const element = allElements[elementKey];
|
|
718
|
+
let foundStrategy = null;
|
|
719
|
+
for (const key in element) {
|
|
720
|
+
if (key === "strategy") {
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
const locators = element[key];
|
|
724
|
+
if (!locators || !locators.length) {
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
for (const locator of locators) {
|
|
728
|
+
delete locator.score;
|
|
729
|
+
}
|
|
730
|
+
if (JSON.stringify(locators) === JSON.stringify(selectors.locators)) {
|
|
731
|
+
foundStrategy = key;
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (foundStrategy) {
|
|
736
|
+
return element;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
catch (error) {
|
|
741
|
+
console.error("Error parsing locators from file: " + filePath, error);
|
|
742
|
+
}
|
|
743
|
+
return null;
|
|
744
|
+
}
|
|
586
745
|
async _locate(selectors, info, _params, timeout, allowDisabled = false) {
|
|
587
746
|
if (!timeout) {
|
|
588
747
|
timeout = 30000;
|
|
589
748
|
}
|
|
749
|
+
let element = null;
|
|
750
|
+
let allStrategyLocators = null;
|
|
751
|
+
let selectedStrategy = null;
|
|
752
|
+
if (this.tryAllStrategies) {
|
|
753
|
+
allStrategyLocators = this.getFullElementLocators(selectors, this.getFilePath());
|
|
754
|
+
selectedStrategy = allStrategyLocators?.strategy;
|
|
755
|
+
}
|
|
590
756
|
for (let i = 0; i < 3; i++) {
|
|
591
|
-
|
|
592
|
-
info.log += "attempt " + i + ": total locators " + selectors.locators.length + "\n";
|
|
593
|
-
}
|
|
757
|
+
info.log += "attempt " + i + ": total locators " + selectors.locators.length + "\n";
|
|
594
758
|
for (let j = 0; j < selectors.locators.length; j++) {
|
|
595
759
|
let selector = selectors.locators[j];
|
|
596
|
-
|
|
597
|
-
|
|
760
|
+
info.log += "searching for locator " + j + ":" + JSON.stringify(selector) + "\n";
|
|
761
|
+
}
|
|
762
|
+
if (this.tryAllStrategies && selectedStrategy) {
|
|
763
|
+
const strategyLocators = allStrategyLocators[selectedStrategy];
|
|
764
|
+
let err;
|
|
765
|
+
if (strategyLocators && strategyLocators.length) {
|
|
766
|
+
try {
|
|
767
|
+
selectors.locators = strategyLocators;
|
|
768
|
+
element = await this._locate_internal(selectors, info, _params, 10_000, allowDisabled);
|
|
769
|
+
info.selectedStrategy = selectedStrategy;
|
|
770
|
+
info.log += "element found using strategy " + selectedStrategy + "\n";
|
|
771
|
+
}
|
|
772
|
+
catch (error) {
|
|
773
|
+
err = error;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
if (!element) {
|
|
777
|
+
for (const key in allStrategyLocators) {
|
|
778
|
+
if (key === "strategy" || key === selectedStrategy) {
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
const strategyLocators = allStrategyLocators[key];
|
|
782
|
+
if (strategyLocators && strategyLocators.length) {
|
|
783
|
+
try {
|
|
784
|
+
info.log += "using strategy " + key + " with locators " + JSON.stringify(strategyLocators) + "\n";
|
|
785
|
+
selectors.locators = strategyLocators;
|
|
786
|
+
element = await this._locate_internal(selectors, info, _params, 10_000, allowDisabled);
|
|
787
|
+
err = null;
|
|
788
|
+
info.selectedStrategy = key;
|
|
789
|
+
info.log += "element found using strategy " + key + "\n";
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
catch (error) {
|
|
793
|
+
err = error;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
if (err) {
|
|
799
|
+
throw err;
|
|
598
800
|
}
|
|
599
801
|
}
|
|
600
|
-
|
|
802
|
+
else {
|
|
803
|
+
element = await this._locate_internal(selectors, info, _params, timeout, allowDisabled);
|
|
804
|
+
}
|
|
601
805
|
if (!element.rerun) {
|
|
602
|
-
const randomToken = Math.random().toString(36).substring(7);
|
|
603
|
-
element.evaluate((el, randomToken) => {
|
|
604
|
-
|
|
806
|
+
const randomToken = "blinq_" + Math.random().toString(36).substring(7);
|
|
807
|
+
const id = await element.evaluate((el, randomToken) => {
|
|
808
|
+
// check if the element has id attribute
|
|
809
|
+
if (el.id) {
|
|
810
|
+
return el.id;
|
|
811
|
+
}
|
|
812
|
+
el.setAttribute("id", randomToken);
|
|
813
|
+
console.log("set id=" + randomToken + " on element", el);
|
|
814
|
+
return randomToken;
|
|
605
815
|
}, randomToken);
|
|
606
|
-
// if (element._frame) {
|
|
607
|
-
// return element;
|
|
608
|
-
// }
|
|
609
816
|
const scope = element._frame ?? element.page();
|
|
610
|
-
let newElementSelector = "
|
|
817
|
+
let newElementSelector = "#" + id;
|
|
818
|
+
// check if the id contains :
|
|
819
|
+
if (id.includes(":")) {
|
|
820
|
+
// //*[@id="radix-:r0:"]
|
|
821
|
+
newElementSelector = `//*[@id="${id}"]`;
|
|
822
|
+
}
|
|
611
823
|
let prefixSelector = "";
|
|
612
824
|
const frameControlSelector = " >> internal:control=enter-frame";
|
|
613
825
|
const frameSelectorIndex = element._selector.lastIndexOf(frameControlSelector);
|
|
@@ -623,12 +835,7 @@ class StableBrowser {
|
|
|
623
835
|
return scope.locator(newSelector);
|
|
624
836
|
}
|
|
625
837
|
}
|
|
626
|
-
|
|
627
|
-
throw new Error("unable to locate the element");
|
|
628
|
-
}
|
|
629
|
-
else {
|
|
630
|
-
throw new Error("unable to locate element " + JSON.stringify(selectors));
|
|
631
|
-
}
|
|
838
|
+
throw new Error("unable to locate element " + JSON.stringify(selectors));
|
|
632
839
|
}
|
|
633
840
|
async _findFrameScope(selectors, timeout = 30000, info) {
|
|
634
841
|
if (!info) {
|
|
@@ -658,7 +865,7 @@ class StableBrowser {
|
|
|
658
865
|
break;
|
|
659
866
|
}
|
|
660
867
|
catch (error) {
|
|
661
|
-
console.error("frame not found " + frameLocator.css);
|
|
868
|
+
// console.error("frame not found " + frameLocator.css);
|
|
662
869
|
}
|
|
663
870
|
}
|
|
664
871
|
}
|
|
@@ -736,7 +943,6 @@ class StableBrowser {
|
|
|
736
943
|
let locatorsCount = 0;
|
|
737
944
|
let lazy_scroll = false;
|
|
738
945
|
//let arrayMode = Array.isArray(selectors);
|
|
739
|
-
let scope = await this._findFrameScope(selectors, timeout, info);
|
|
740
946
|
let selectorsLocators = null;
|
|
741
947
|
selectorsLocators = selectors.locators;
|
|
742
948
|
// group selectors by priority
|
|
@@ -764,6 +970,7 @@ class StableBrowser {
|
|
|
764
970
|
let highPriorityOnly = true;
|
|
765
971
|
let visibleOnly = true;
|
|
766
972
|
while (true) {
|
|
973
|
+
let scope = await this._findFrameScope(selectors, timeout, info);
|
|
767
974
|
locatorsCount = 0;
|
|
768
975
|
let result = [];
|
|
769
976
|
let popupResult = await this.closeUnexpectedPopups(info, _params);
|
|
@@ -852,14 +1059,9 @@ class StableBrowser {
|
|
|
852
1059
|
if (!info?.failCause?.lastError) {
|
|
853
1060
|
info.failCause.lastError = `failed to locate ${formatElementName(selectors.element_name)}, ${locatorsCount > 0 ? `${locatorsCount} matching elements found` : "no matching elements found"}`;
|
|
854
1061
|
}
|
|
855
|
-
|
|
856
|
-
throw new Error("failed to locate first element no elements found");
|
|
857
|
-
}
|
|
858
|
-
else {
|
|
859
|
-
throw new Error("failed to locate first element no elements found, " + info.log);
|
|
860
|
-
}
|
|
1062
|
+
throw new Error("failed to locate first element no elements found, " + info.log);
|
|
861
1063
|
}
|
|
862
|
-
async _scanLocatorsGroup(locatorsGroup, scope, _params, info, visibleOnly, allowDisabled = false, element_name) {
|
|
1064
|
+
async _scanLocatorsGroup(locatorsGroup, scope, _params, info, visibleOnly, allowDisabled = false, element_name, logErrors = false) {
|
|
863
1065
|
let foundElements = [];
|
|
864
1066
|
const result = {
|
|
865
1067
|
foundElements: foundElements,
|
|
@@ -878,13 +1080,19 @@ class StableBrowser {
|
|
|
878
1080
|
await this._collectLocatorInformation(locatorsGroup, i, this.page, foundLocators, _params, info, visibleOnly, allowDisabled, element_name);
|
|
879
1081
|
}
|
|
880
1082
|
catch (e) {
|
|
881
|
-
|
|
1083
|
+
if (logErrors) {
|
|
1084
|
+
this.logger.info("unable to use locator (second try) " + JSON.stringify(locatorsGroup[i]));
|
|
1085
|
+
}
|
|
882
1086
|
}
|
|
883
1087
|
}
|
|
884
1088
|
if (foundLocators.length === 1) {
|
|
1089
|
+
let box = null;
|
|
1090
|
+
if (!this.onlyFailuresScreenshot) {
|
|
1091
|
+
box = await foundLocators[0].boundingBox();
|
|
1092
|
+
}
|
|
885
1093
|
result.foundElements.push({
|
|
886
1094
|
locator: foundLocators[0],
|
|
887
|
-
box:
|
|
1095
|
+
box: box,
|
|
888
1096
|
unique: true,
|
|
889
1097
|
});
|
|
890
1098
|
result.locatorIndex = i;
|
|
@@ -919,7 +1127,7 @@ class StableBrowser {
|
|
|
919
1127
|
});
|
|
920
1128
|
result.locatorIndex = i;
|
|
921
1129
|
}
|
|
922
|
-
else {
|
|
1130
|
+
else if (logErrors) {
|
|
923
1131
|
info.failCause.foundMultiple = true;
|
|
924
1132
|
if (info.locatorLog) {
|
|
925
1133
|
info.locatorLog.setLocatorSearchStatus(JSON.stringify(locatorsGroup[i]), "FOUND_NOT_UNIQUE");
|
|
@@ -1039,17 +1247,30 @@ class StableBrowser {
|
|
|
1039
1247
|
operation: "click",
|
|
1040
1248
|
log: "***** click on " + selectors.element_name + " *****\n",
|
|
1041
1249
|
};
|
|
1250
|
+
check_performance("click_all ***", this.context, true);
|
|
1042
1251
|
try {
|
|
1252
|
+
check_performance("click_preCommand", this.context, true);
|
|
1043
1253
|
await _preCommand(state, this);
|
|
1254
|
+
check_performance("click_preCommand", this.context, false);
|
|
1044
1255
|
await performAction("click", state.element, options, this, state, _params);
|
|
1045
|
-
|
|
1256
|
+
if (!this.fastMode) {
|
|
1257
|
+
check_performance("click_waitForPageLoad", this.context, true);
|
|
1258
|
+
await this.waitForPageLoad({ noSleep: true });
|
|
1259
|
+
check_performance("click_waitForPageLoad", this.context, false);
|
|
1260
|
+
}
|
|
1046
1261
|
return state.info;
|
|
1047
1262
|
}
|
|
1048
1263
|
catch (e) {
|
|
1049
1264
|
await _commandError(state, e, this);
|
|
1050
1265
|
}
|
|
1051
1266
|
finally {
|
|
1267
|
+
check_performance("click_commandFinally", this.context, true);
|
|
1052
1268
|
await _commandFinally(state, this);
|
|
1269
|
+
check_performance("click_commandFinally", this.context, false);
|
|
1270
|
+
check_performance("click_all ***", this.context, false);
|
|
1271
|
+
if (this.context.profile) {
|
|
1272
|
+
console.log(JSON.stringify(this.context.profile, null, 2));
|
|
1273
|
+
}
|
|
1053
1274
|
}
|
|
1054
1275
|
}
|
|
1055
1276
|
async waitForElement(selectors, _params, options = {}, world = null) {
|
|
@@ -1105,7 +1326,7 @@ class StableBrowser {
|
|
|
1105
1326
|
// if (world && world.screenshot && !world.screenshotPath) {
|
|
1106
1327
|
// console.log(`Highlighting while running from recorder`);
|
|
1107
1328
|
await this._highlightElements(state.element);
|
|
1108
|
-
await state.element.setChecked(checked);
|
|
1329
|
+
await state.element.setChecked(checked, { timeout: 2000 });
|
|
1109
1330
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
1110
1331
|
// await this._unHighlightElements(element);
|
|
1111
1332
|
// }
|
|
@@ -1117,14 +1338,31 @@ class StableBrowser {
|
|
|
1117
1338
|
this.logger.info("element did not change its state, ignoring...");
|
|
1118
1339
|
}
|
|
1119
1340
|
else {
|
|
1341
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
1120
1342
|
//await this.closeUnexpectedPopups();
|
|
1121
1343
|
state.info.log += "setCheck failed, will try again" + "\n";
|
|
1122
|
-
state.
|
|
1123
|
-
|
|
1124
|
-
|
|
1344
|
+
state.element_found = false;
|
|
1345
|
+
try {
|
|
1346
|
+
state.element = await this._locate(selectors, state.info, _params, 100);
|
|
1347
|
+
state.element_found = true;
|
|
1348
|
+
// check the check state
|
|
1349
|
+
}
|
|
1350
|
+
catch (error) {
|
|
1351
|
+
// element dismissed
|
|
1352
|
+
}
|
|
1353
|
+
if (state.element_found) {
|
|
1354
|
+
const isChecked = await state.element.isChecked();
|
|
1355
|
+
if (isChecked !== checked) {
|
|
1356
|
+
// perform click
|
|
1357
|
+
await state.element.click({ timeout: 2000, force: true });
|
|
1358
|
+
}
|
|
1359
|
+
else {
|
|
1360
|
+
this.logger.info(`Element ${selectors.element_name} is already in the desired state (${checked})`);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1125
1363
|
}
|
|
1126
1364
|
}
|
|
1127
|
-
await this.waitForPageLoad();
|
|
1365
|
+
//await this.waitForPageLoad();
|
|
1128
1366
|
return state.info;
|
|
1129
1367
|
}
|
|
1130
1368
|
catch (e) {
|
|
@@ -1150,7 +1388,7 @@ class StableBrowser {
|
|
|
1150
1388
|
await _preCommand(state, this);
|
|
1151
1389
|
await performAction("hover", state.element, options, this, state, _params);
|
|
1152
1390
|
await _screenshot(state, this);
|
|
1153
|
-
await this.waitForPageLoad();
|
|
1391
|
+
//await this.waitForPageLoad();
|
|
1154
1392
|
return state.info;
|
|
1155
1393
|
}
|
|
1156
1394
|
catch (e) {
|
|
@@ -1186,7 +1424,7 @@ class StableBrowser {
|
|
|
1186
1424
|
state.info.log += "selectOption failed, will try force" + "\n";
|
|
1187
1425
|
await state.element.selectOption(values, { timeout: 10000, force: true });
|
|
1188
1426
|
}
|
|
1189
|
-
await this.waitForPageLoad();
|
|
1427
|
+
//await this.waitForPageLoad();
|
|
1190
1428
|
return state.info;
|
|
1191
1429
|
}
|
|
1192
1430
|
catch (e) {
|
|
@@ -1417,7 +1655,9 @@ class StableBrowser {
|
|
|
1417
1655
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1418
1656
|
}
|
|
1419
1657
|
}
|
|
1658
|
+
//if (!this.fastMode) {
|
|
1420
1659
|
await _screenshot(state, this);
|
|
1660
|
+
//}
|
|
1421
1661
|
if (enter === true) {
|
|
1422
1662
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
1423
1663
|
await this.page.keyboard.press("Enter");
|
|
@@ -1466,8 +1706,8 @@ class StableBrowser {
|
|
|
1466
1706
|
if (enter) {
|
|
1467
1707
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
1468
1708
|
await this.page.keyboard.press("Enter");
|
|
1709
|
+
await this.waitForPageLoad();
|
|
1469
1710
|
}
|
|
1470
|
-
await this.waitForPageLoad();
|
|
1471
1711
|
return state.info;
|
|
1472
1712
|
}
|
|
1473
1713
|
catch (e) {
|
|
@@ -1759,11 +1999,16 @@ class StableBrowser {
|
|
|
1759
1999
|
throw new Error("Snapshot validation failed at line " + matchResult.errorLineText);
|
|
1760
2000
|
}
|
|
1761
2001
|
// highlight and screenshot
|
|
2002
|
+
try {
|
|
2003
|
+
await await highlightSnapshot(newValue, scope);
|
|
2004
|
+
await _screenshot(state, this);
|
|
2005
|
+
}
|
|
2006
|
+
catch (e) { }
|
|
1762
2007
|
return state.info;
|
|
1763
2008
|
}
|
|
1764
2009
|
catch (e) {
|
|
1765
2010
|
// Log error but continue retrying until timeout is reached
|
|
1766
|
-
this.logger.warn("Retrying snapshot validation due to: " + e.message);
|
|
2011
|
+
//this.logger.warn("Retrying snapshot validation due to: " + e.message);
|
|
1767
2012
|
}
|
|
1768
2013
|
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait 1 second before retrying
|
|
1769
2014
|
}
|
|
@@ -1917,12 +2162,7 @@ class StableBrowser {
|
|
|
1917
2162
|
}
|
|
1918
2163
|
}
|
|
1919
2164
|
getTestData(world = null) {
|
|
1920
|
-
|
|
1921
|
-
let data = {};
|
|
1922
|
-
if (fs.existsSync(dataFile)) {
|
|
1923
|
-
data = JSON.parse(fs.readFileSync(dataFile, "utf8"));
|
|
1924
|
-
}
|
|
1925
|
-
return data;
|
|
2165
|
+
return _getTestData(world, this.context, this);
|
|
1926
2166
|
}
|
|
1927
2167
|
async _screenShot(options = {}, world = null, info = null) {
|
|
1928
2168
|
// collect url/path/title
|
|
@@ -2142,6 +2382,77 @@ class StableBrowser {
|
|
|
2142
2382
|
await _commandFinally(state, this);
|
|
2143
2383
|
}
|
|
2144
2384
|
}
|
|
2385
|
+
async extractProperty(selectors, property, variable, _params = null, options = {}, world = null) {
|
|
2386
|
+
const state = {
|
|
2387
|
+
selectors,
|
|
2388
|
+
_params,
|
|
2389
|
+
property,
|
|
2390
|
+
variable,
|
|
2391
|
+
options,
|
|
2392
|
+
world,
|
|
2393
|
+
type: Types.EXTRACT_PROPERTY,
|
|
2394
|
+
text: `Extract property from element`,
|
|
2395
|
+
_text: `Extract property ${property} from ${selectors.element_name}`,
|
|
2396
|
+
operation: "extractProperty",
|
|
2397
|
+
log: "***** extract property " + property + " from " + selectors.element_name + " *****\n",
|
|
2398
|
+
allowDisabled: true,
|
|
2399
|
+
};
|
|
2400
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
2401
|
+
try {
|
|
2402
|
+
await _preCommand(state, this);
|
|
2403
|
+
switch (property) {
|
|
2404
|
+
case "inner_text":
|
|
2405
|
+
state.value = await state.element.innerText();
|
|
2406
|
+
break;
|
|
2407
|
+
case "href":
|
|
2408
|
+
state.value = await state.element.getAttribute("href");
|
|
2409
|
+
break;
|
|
2410
|
+
case "value":
|
|
2411
|
+
state.value = await state.element.inputValue();
|
|
2412
|
+
break;
|
|
2413
|
+
case "text":
|
|
2414
|
+
state.value = await state.element.textContent();
|
|
2415
|
+
break;
|
|
2416
|
+
default:
|
|
2417
|
+
if (property.startsWith("dataset.")) {
|
|
2418
|
+
const dataAttribute = property.substring(8);
|
|
2419
|
+
state.value = String(await state.element.getAttribute(`data-${dataAttribute}`)) || "";
|
|
2420
|
+
}
|
|
2421
|
+
else {
|
|
2422
|
+
state.value = String(await state.element.evaluate((element, prop) => element[prop], property));
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
if (options !== null) {
|
|
2426
|
+
if (options.regex && options.regex !== "") {
|
|
2427
|
+
// Construct a regex pattern from the provided string
|
|
2428
|
+
const regex = options.regex.slice(1, -1);
|
|
2429
|
+
const regexPattern = new RegExp(regex, "g");
|
|
2430
|
+
const matches = state.value.match(regexPattern);
|
|
2431
|
+
if (matches) {
|
|
2432
|
+
let newValue = "";
|
|
2433
|
+
for (const match of matches) {
|
|
2434
|
+
newValue += match;
|
|
2435
|
+
}
|
|
2436
|
+
state.value = newValue;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
if (options.trimSpaces && options.trimSpaces === true) {
|
|
2440
|
+
state.value = state.value.trim();
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
state.info.value = state.value;
|
|
2444
|
+
this.setTestData({ [variable]: state.value }, world);
|
|
2445
|
+
this.logger.info("set test data: " + variable + "=" + state.value);
|
|
2446
|
+
// await new Promise((resolve) => setTimeout(resolve, 500));
|
|
2447
|
+
return state.info;
|
|
2448
|
+
}
|
|
2449
|
+
catch (e) {
|
|
2450
|
+
await _commandError(state, e, this);
|
|
2451
|
+
}
|
|
2452
|
+
finally {
|
|
2453
|
+
await _commandFinally(state, this);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2145
2456
|
async verifyAttribute(selectors, attribute, value, _params = null, options = {}, world = null) {
|
|
2146
2457
|
const state = {
|
|
2147
2458
|
selectors,
|
|
@@ -2240,6 +2551,260 @@ class StableBrowser {
|
|
|
2240
2551
|
await _commandFinally(state, this);
|
|
2241
2552
|
}
|
|
2242
2553
|
}
|
|
2554
|
+
async verifyProperty(selectors, property, value, _params = null, options = {}, world = null) {
|
|
2555
|
+
const state = {
|
|
2556
|
+
selectors,
|
|
2557
|
+
_params,
|
|
2558
|
+
property,
|
|
2559
|
+
value,
|
|
2560
|
+
options,
|
|
2561
|
+
world,
|
|
2562
|
+
type: Types.VERIFY_PROPERTY,
|
|
2563
|
+
highlight: true,
|
|
2564
|
+
screenshot: true,
|
|
2565
|
+
text: `Verify element property`,
|
|
2566
|
+
_text: `Verify property ${property} from ${selectors.element_name} is ${value}`,
|
|
2567
|
+
operation: "verifyProperty",
|
|
2568
|
+
log: "***** verify property " + property + " from " + selectors.element_name + " *****\n",
|
|
2569
|
+
allowDisabled: true,
|
|
2570
|
+
};
|
|
2571
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
2572
|
+
let val;
|
|
2573
|
+
let expectedValue;
|
|
2574
|
+
try {
|
|
2575
|
+
await _preCommand(state, this);
|
|
2576
|
+
expectedValue = await replaceWithLocalTestData(state.value, world);
|
|
2577
|
+
state.info.expectedValue = expectedValue;
|
|
2578
|
+
switch (property) {
|
|
2579
|
+
case "innerText":
|
|
2580
|
+
val = String(await state.element.innerText());
|
|
2581
|
+
break;
|
|
2582
|
+
case "text":
|
|
2583
|
+
val = String(await state.element.textContent());
|
|
2584
|
+
break;
|
|
2585
|
+
case "value":
|
|
2586
|
+
val = String(await state.element.inputValue());
|
|
2587
|
+
break;
|
|
2588
|
+
case "checked":
|
|
2589
|
+
val = String(await state.element.isChecked());
|
|
2590
|
+
break;
|
|
2591
|
+
case "disabled":
|
|
2592
|
+
val = String(await state.element.isDisabled());
|
|
2593
|
+
break;
|
|
2594
|
+
case "readOnly":
|
|
2595
|
+
const isEditable = await state.element.isEditable();
|
|
2596
|
+
val = String(!isEditable);
|
|
2597
|
+
break;
|
|
2598
|
+
case "innerHTML":
|
|
2599
|
+
val = String(await state.element.innerHTML());
|
|
2600
|
+
break;
|
|
2601
|
+
case "outerHTML":
|
|
2602
|
+
val = String(await state.element.evaluate((element) => element.outerHTML));
|
|
2603
|
+
break;
|
|
2604
|
+
default:
|
|
2605
|
+
if (property.startsWith("dataset.")) {
|
|
2606
|
+
const dataAttribute = property.substring(8);
|
|
2607
|
+
val = String(await state.element.getAttribute(`data-${dataAttribute}`)) || "";
|
|
2608
|
+
}
|
|
2609
|
+
else {
|
|
2610
|
+
val = String(await state.element.evaluate((element, prop) => element[prop], property));
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
// Helper function to remove all style="" attributes
|
|
2614
|
+
const removeStyleAttributes = (htmlString) => {
|
|
2615
|
+
return htmlString.replace(/\s*style\s*=\s*"[^"]*"/gi, "");
|
|
2616
|
+
};
|
|
2617
|
+
// Remove style attributes for innerHTML and outerHTML properties
|
|
2618
|
+
if (property === "innerHTML" || property === "outerHTML") {
|
|
2619
|
+
val = removeStyleAttributes(val);
|
|
2620
|
+
expectedValue = removeStyleAttributes(expectedValue);
|
|
2621
|
+
}
|
|
2622
|
+
state.info.value = val;
|
|
2623
|
+
let regex;
|
|
2624
|
+
state.info.value = val;
|
|
2625
|
+
const isRegex = expectedValue.startsWith("regex:");
|
|
2626
|
+
const isContains = expectedValue.startsWith("contains:");
|
|
2627
|
+
const isExact = expectedValue.startsWith("exact:");
|
|
2628
|
+
let matchPassed = false;
|
|
2629
|
+
if (isRegex) {
|
|
2630
|
+
const rawPattern = expectedValue.slice(6); // remove "regex:"
|
|
2631
|
+
const lastSlashIndex = rawPattern.lastIndexOf("/");
|
|
2632
|
+
if (rawPattern.startsWith("/") && lastSlashIndex > 0) {
|
|
2633
|
+
const patternBody = rawPattern.slice(1, lastSlashIndex).replace(/\n/g, ".*");
|
|
2634
|
+
const flags = rawPattern.slice(lastSlashIndex + 1) || "gs";
|
|
2635
|
+
const regex = new RegExp(patternBody, flags);
|
|
2636
|
+
state.info.regex = true;
|
|
2637
|
+
matchPassed = regex.test(val);
|
|
2638
|
+
}
|
|
2639
|
+
else {
|
|
2640
|
+
// Fallback: treat as literal
|
|
2641
|
+
const escapedPattern = rawPattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2642
|
+
const regex = new RegExp(escapedPattern, "g");
|
|
2643
|
+
matchPassed = regex.test(val);
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
else if (isContains) {
|
|
2647
|
+
const containsValue = expectedValue.slice(9); // remove "contains:"
|
|
2648
|
+
matchPassed = val.includes(containsValue);
|
|
2649
|
+
}
|
|
2650
|
+
else if (isExact) {
|
|
2651
|
+
const exactValue = expectedValue.slice(6); // remove "exact:"
|
|
2652
|
+
matchPassed = val === exactValue;
|
|
2653
|
+
}
|
|
2654
|
+
else if (property === "innerText") {
|
|
2655
|
+
// Default innerText logic
|
|
2656
|
+
const normalizedExpectedValue = expectedValue.replace(/\\n/g, "\n");
|
|
2657
|
+
const valLines = val.split("\n");
|
|
2658
|
+
const expectedLines = normalizedExpectedValue.split("\n");
|
|
2659
|
+
matchPassed = expectedLines.every((expectedLine) => valLines.some((valLine) => valLine.trim() === expectedLine.trim()));
|
|
2660
|
+
}
|
|
2661
|
+
else {
|
|
2662
|
+
// Fallback exact or loose match
|
|
2663
|
+
const escapedPattern = expectedValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2664
|
+
const regex = new RegExp(escapedPattern, "g");
|
|
2665
|
+
matchPassed = regex.test(val);
|
|
2666
|
+
}
|
|
2667
|
+
if (!matchPassed) {
|
|
2668
|
+
let errorMessage = `The ${property} property has a value of "${val}", but the expected value is "${expectedValue}"`;
|
|
2669
|
+
state.info.failCause.assertionFailed = true;
|
|
2670
|
+
state.info.failCause.lastError = errorMessage;
|
|
2671
|
+
throw new Error(errorMessage);
|
|
2672
|
+
}
|
|
2673
|
+
return state.info;
|
|
2674
|
+
}
|
|
2675
|
+
catch (e) {
|
|
2676
|
+
await _commandError(state, e, this);
|
|
2677
|
+
}
|
|
2678
|
+
finally {
|
|
2679
|
+
await _commandFinally(state, this);
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
async conditionalWait(selectors, condition, timeout = 1000, _params = null, options = {}, world = null) {
|
|
2683
|
+
// Convert timeout from seconds to milliseconds
|
|
2684
|
+
const timeoutMs = timeout * 1000;
|
|
2685
|
+
const state = {
|
|
2686
|
+
selectors,
|
|
2687
|
+
_params,
|
|
2688
|
+
condition,
|
|
2689
|
+
timeout: timeoutMs, // Store as milliseconds for internal use
|
|
2690
|
+
options,
|
|
2691
|
+
world,
|
|
2692
|
+
type: Types.CONDITIONAL_WAIT,
|
|
2693
|
+
highlight: true,
|
|
2694
|
+
screenshot: true,
|
|
2695
|
+
text: `Conditional wait for element`,
|
|
2696
|
+
_text: `Wait for ${selectors.element_name} to be ${condition} (timeout: ${timeout}s)`, // Display original seconds
|
|
2697
|
+
operation: "conditionalWait",
|
|
2698
|
+
log: `***** conditional wait for ${condition} on ${selectors.element_name} *****\n`,
|
|
2699
|
+
allowDisabled: true,
|
|
2700
|
+
info: {},
|
|
2701
|
+
};
|
|
2702
|
+
// Initialize startTime outside try block to ensure it's always accessible
|
|
2703
|
+
const startTime = Date.now();
|
|
2704
|
+
let conditionMet = false;
|
|
2705
|
+
let currentValue = null;
|
|
2706
|
+
let lastError = null;
|
|
2707
|
+
// Main retry loop - continues until timeout or condition is met
|
|
2708
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
2709
|
+
const elapsedTime = Date.now() - startTime;
|
|
2710
|
+
const remainingTime = timeoutMs - elapsedTime;
|
|
2711
|
+
try {
|
|
2712
|
+
// Try to execute _preCommand (element location)
|
|
2713
|
+
await _preCommand(state, this);
|
|
2714
|
+
// If _preCommand succeeds, start condition checking
|
|
2715
|
+
const checkCondition = async () => {
|
|
2716
|
+
try {
|
|
2717
|
+
switch (condition.toLowerCase()) {
|
|
2718
|
+
case "checked":
|
|
2719
|
+
currentValue = await state.element.isChecked();
|
|
2720
|
+
return currentValue === true;
|
|
2721
|
+
case "unchecked":
|
|
2722
|
+
currentValue = await state.element.isChecked();
|
|
2723
|
+
return currentValue === false;
|
|
2724
|
+
case "visible":
|
|
2725
|
+
currentValue = await state.element.isVisible();
|
|
2726
|
+
return currentValue === true;
|
|
2727
|
+
case "hidden":
|
|
2728
|
+
currentValue = await state.element.isVisible();
|
|
2729
|
+
return currentValue === false;
|
|
2730
|
+
case "enabled":
|
|
2731
|
+
currentValue = await state.element.isDisabled();
|
|
2732
|
+
return currentValue === false;
|
|
2733
|
+
case "disabled":
|
|
2734
|
+
currentValue = await state.element.isDisabled();
|
|
2735
|
+
return currentValue === true;
|
|
2736
|
+
case "editable":
|
|
2737
|
+
// currentValue = await String(await state.element.evaluate((element, prop) => element[prop], "isContentEditable"));
|
|
2738
|
+
currentValue = await state.element.isContentEditable();
|
|
2739
|
+
return currentValue === true;
|
|
2740
|
+
default:
|
|
2741
|
+
state.info.message = `Unsupported condition: '${condition}'. Supported conditions are: checked, unchecked, visible, hidden, enabled, disabled, editable.`;
|
|
2742
|
+
state.info.success = false;
|
|
2743
|
+
return false;
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
catch (error) {
|
|
2747
|
+
// Don't throw here, just return false to continue retrying
|
|
2748
|
+
return false;
|
|
2749
|
+
}
|
|
2750
|
+
};
|
|
2751
|
+
// Inner loop for condition checking (once element is located)
|
|
2752
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
2753
|
+
const currentElapsedTime = Date.now() - startTime;
|
|
2754
|
+
conditionMet = await checkCondition();
|
|
2755
|
+
if (conditionMet) {
|
|
2756
|
+
break;
|
|
2757
|
+
}
|
|
2758
|
+
// Check if we still have time for another attempt
|
|
2759
|
+
if (Date.now() - startTime + 50 < timeoutMs) {
|
|
2760
|
+
await new Promise((res) => setTimeout(res, 50));
|
|
2761
|
+
}
|
|
2762
|
+
else {
|
|
2763
|
+
break;
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
// If we got here and condition is met, break out of main loop
|
|
2767
|
+
if (conditionMet) {
|
|
2768
|
+
break;
|
|
2769
|
+
}
|
|
2770
|
+
// If condition not met but no exception, we've timed out
|
|
2771
|
+
break;
|
|
2772
|
+
}
|
|
2773
|
+
catch (e) {
|
|
2774
|
+
lastError = e;
|
|
2775
|
+
const currentElapsedTime = Date.now() - startTime;
|
|
2776
|
+
const timeLeft = timeoutMs - currentElapsedTime;
|
|
2777
|
+
// Check if we have enough time left to retry
|
|
2778
|
+
if (timeLeft > 100) {
|
|
2779
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
2780
|
+
}
|
|
2781
|
+
else {
|
|
2782
|
+
break;
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
const actualWaitTime = Date.now() - startTime;
|
|
2787
|
+
state.info = {
|
|
2788
|
+
success: conditionMet,
|
|
2789
|
+
conditionMet,
|
|
2790
|
+
actualWaitTime,
|
|
2791
|
+
currentValue,
|
|
2792
|
+
lastError: lastError?.message || null,
|
|
2793
|
+
message: conditionMet
|
|
2794
|
+
? `Condition '${condition}' met after ${(actualWaitTime / 1000).toFixed(2)}s`
|
|
2795
|
+
: `Condition '${condition}' not met within ${timeout}s timeout`,
|
|
2796
|
+
};
|
|
2797
|
+
if (lastError) {
|
|
2798
|
+
state.log += `Last error: ${lastError.message}\n`;
|
|
2799
|
+
}
|
|
2800
|
+
try {
|
|
2801
|
+
await _commandFinally(state, this);
|
|
2802
|
+
}
|
|
2803
|
+
catch (finallyError) {
|
|
2804
|
+
state.log += `Error in _commandFinally: ${finallyError.message}\n`;
|
|
2805
|
+
}
|
|
2806
|
+
return state.info;
|
|
2807
|
+
}
|
|
2243
2808
|
async extractEmailData(emailAddress, options, world) {
|
|
2244
2809
|
if (!emailAddress) {
|
|
2245
2810
|
throw new Error("email address is null");
|
|
@@ -2397,56 +2962,49 @@ class StableBrowser {
|
|
|
2397
2962
|
console.debug(error);
|
|
2398
2963
|
}
|
|
2399
2964
|
}
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
// });
|
|
2443
|
-
// }
|
|
2444
|
-
// } catch (error) {
|
|
2445
|
-
// // console.debug(error);
|
|
2446
|
-
// }
|
|
2447
|
-
// }
|
|
2965
|
+
_matcher(text) {
|
|
2966
|
+
if (!text) {
|
|
2967
|
+
return { matcher: "contains", queryText: "" };
|
|
2968
|
+
}
|
|
2969
|
+
if (text.length < 2) {
|
|
2970
|
+
return { matcher: "contains", queryText: text };
|
|
2971
|
+
}
|
|
2972
|
+
const split = text.split(":");
|
|
2973
|
+
const matcher = split[0].toLowerCase();
|
|
2974
|
+
const queryText = split.slice(1).join(":").trim();
|
|
2975
|
+
return { matcher, queryText };
|
|
2976
|
+
}
|
|
2977
|
+
_getDomain(url) {
|
|
2978
|
+
if (url.length === 0 || (!url.startsWith("http://") && !url.startsWith("https://"))) {
|
|
2979
|
+
return "";
|
|
2980
|
+
}
|
|
2981
|
+
let hostnameFragments = url.split("/")[2].split(".");
|
|
2982
|
+
if (hostnameFragments.some((fragment) => fragment.includes(":"))) {
|
|
2983
|
+
return hostnameFragments.join("-").split(":").join("-");
|
|
2984
|
+
}
|
|
2985
|
+
let n = hostnameFragments.length;
|
|
2986
|
+
let fragments = [...hostnameFragments];
|
|
2987
|
+
while (n > 0 && hostnameFragments[n - 1].length <= 3) {
|
|
2988
|
+
hostnameFragments.pop();
|
|
2989
|
+
n = hostnameFragments.length;
|
|
2990
|
+
}
|
|
2991
|
+
if (n == 0) {
|
|
2992
|
+
if (fragments[0] === "www")
|
|
2993
|
+
fragments = fragments.slice(1);
|
|
2994
|
+
return fragments.length > 1 ? fragments.slice(0, fragments.length - 1).join("-") : fragments.join("-");
|
|
2995
|
+
}
|
|
2996
|
+
if (hostnameFragments[0] === "www")
|
|
2997
|
+
hostnameFragments = hostnameFragments.slice(1);
|
|
2998
|
+
return hostnameFragments.join(".");
|
|
2999
|
+
}
|
|
3000
|
+
/**
|
|
3001
|
+
* Verify the page path matches the given path.
|
|
3002
|
+
* @param {string} pathPart - The path to verify.
|
|
3003
|
+
* @param {object} options - Options for verification.
|
|
3004
|
+
* @param {object} world - The world context.
|
|
3005
|
+
* @returns {Promise<object>} - The state info after verification.
|
|
3006
|
+
*/
|
|
2448
3007
|
async verifyPagePath(pathPart, options = {}, world = null) {
|
|
2449
|
-
const startTime = Date.now();
|
|
2450
3008
|
let error = null;
|
|
2451
3009
|
let screenshotId = null;
|
|
2452
3010
|
let screenshotPath = null;
|
|
@@ -2460,113 +3018,212 @@ class StableBrowser {
|
|
|
2460
3018
|
pathPart = newValue;
|
|
2461
3019
|
}
|
|
2462
3020
|
info.pathPart = pathPart;
|
|
3021
|
+
const { matcher, queryText } = this._matcher(pathPart);
|
|
3022
|
+
const state = {
|
|
3023
|
+
text_search: queryText,
|
|
3024
|
+
options,
|
|
3025
|
+
world,
|
|
3026
|
+
locate: false,
|
|
3027
|
+
scroll: false,
|
|
3028
|
+
highlight: false,
|
|
3029
|
+
type: Types.VERIFY_PAGE_PATH,
|
|
3030
|
+
text: `Verify the page url is ${queryText}`,
|
|
3031
|
+
_text: `Verify the page url is ${queryText}`,
|
|
3032
|
+
operation: "verifyPagePath",
|
|
3033
|
+
log: "***** verify page url is " + queryText + " *****\n",
|
|
3034
|
+
};
|
|
2463
3035
|
try {
|
|
3036
|
+
await _preCommand(state, this);
|
|
3037
|
+
state.info.text = queryText;
|
|
2464
3038
|
for (let i = 0; i < 30; i++) {
|
|
2465
3039
|
const url = await this.page.url();
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
3040
|
+
switch (matcher) {
|
|
3041
|
+
case "exact":
|
|
3042
|
+
if (url !== queryText) {
|
|
3043
|
+
if (i === 29) {
|
|
3044
|
+
throw new Error(`Page URL ${url} is not equal to ${queryText}`);
|
|
3045
|
+
}
|
|
3046
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3047
|
+
continue;
|
|
3048
|
+
}
|
|
3049
|
+
break;
|
|
3050
|
+
case "contains":
|
|
3051
|
+
if (!url.includes(queryText)) {
|
|
3052
|
+
if (i === 29) {
|
|
3053
|
+
throw new Error(`Page URL ${url} doesn't contain ${queryText}`);
|
|
3054
|
+
}
|
|
3055
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3056
|
+
continue;
|
|
3057
|
+
}
|
|
3058
|
+
break;
|
|
3059
|
+
case "starts-with":
|
|
3060
|
+
{
|
|
3061
|
+
const domain = this._getDomain(url);
|
|
3062
|
+
if (domain.length > 0 && domain !== queryText) {
|
|
3063
|
+
if (i === 29) {
|
|
3064
|
+
throw new Error(`Page URL ${url} doesn't start with ${queryText}`);
|
|
3065
|
+
}
|
|
3066
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3067
|
+
continue;
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
break;
|
|
3071
|
+
case "ends-with":
|
|
3072
|
+
{
|
|
3073
|
+
const urlObj = new URL(url);
|
|
3074
|
+
let route = "/";
|
|
3075
|
+
if (urlObj.pathname !== "/") {
|
|
3076
|
+
route = urlObj.pathname.split("/").slice(-1)[0].trim();
|
|
3077
|
+
}
|
|
3078
|
+
else {
|
|
3079
|
+
route = "/";
|
|
3080
|
+
}
|
|
3081
|
+
if (route !== queryText) {
|
|
3082
|
+
if (i === 29) {
|
|
3083
|
+
throw new Error(`Page URL ${url} doesn't end with ${queryText}`);
|
|
3084
|
+
}
|
|
3085
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3086
|
+
continue;
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
break;
|
|
3090
|
+
case "regex":
|
|
3091
|
+
const regex = new RegExp(queryText.slice(1, -1), "g");
|
|
3092
|
+
if (!regex.test(url)) {
|
|
3093
|
+
if (i === 29) {
|
|
3094
|
+
throw new Error(`Page URL ${url} doesn't match regex ${queryText}`);
|
|
3095
|
+
}
|
|
3096
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3097
|
+
continue;
|
|
3098
|
+
}
|
|
3099
|
+
break;
|
|
3100
|
+
default:
|
|
3101
|
+
console.log("Unknown matching type, defaulting to contains matching");
|
|
3102
|
+
if (!url.includes(pathPart)) {
|
|
3103
|
+
if (i === 29) {
|
|
3104
|
+
throw new Error(`Page URL ${url} does not contain ${pathPart}`);
|
|
3105
|
+
}
|
|
3106
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3107
|
+
continue;
|
|
3108
|
+
}
|
|
2472
3109
|
}
|
|
2473
|
-
|
|
2474
|
-
return info;
|
|
3110
|
+
await _screenshot(state, this);
|
|
3111
|
+
return state.info;
|
|
2475
3112
|
}
|
|
2476
3113
|
}
|
|
2477
3114
|
catch (e) {
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
info.screenshotPath = screenshotPath;
|
|
2482
|
-
Object.assign(e, { info: info });
|
|
2483
|
-
error = e;
|
|
2484
|
-
// throw e;
|
|
2485
|
-
await _commandError({ text: "verifyPagePath", operation: "verifyPagePath", pathPart, info, throwError: true }, e, this);
|
|
3115
|
+
state.info.failCause.lastError = e.message;
|
|
3116
|
+
state.info.failCause.assertionFailed = true;
|
|
3117
|
+
await _commandError(state, e, this);
|
|
2486
3118
|
}
|
|
2487
3119
|
finally {
|
|
2488
|
-
|
|
2489
|
-
_reportToWorld(world, {
|
|
2490
|
-
type: Types.VERIFY_PAGE_PATH,
|
|
2491
|
-
text: "Verify page path",
|
|
2492
|
-
_text: "Verify the page path contains " + pathPart,
|
|
2493
|
-
screenshotId,
|
|
2494
|
-
result: error
|
|
2495
|
-
? {
|
|
2496
|
-
status: "FAILED",
|
|
2497
|
-
startTime,
|
|
2498
|
-
endTime,
|
|
2499
|
-
message: error?.message,
|
|
2500
|
-
}
|
|
2501
|
-
: {
|
|
2502
|
-
status: "PASSED",
|
|
2503
|
-
startTime,
|
|
2504
|
-
endTime,
|
|
2505
|
-
},
|
|
2506
|
-
info: info,
|
|
2507
|
-
});
|
|
3120
|
+
await _commandFinally(state, this);
|
|
2508
3121
|
}
|
|
2509
3122
|
}
|
|
3123
|
+
/**
|
|
3124
|
+
* Verify the page title matches the given title.
|
|
3125
|
+
* @param {string} title - The title to verify.
|
|
3126
|
+
* @param {object} options - Options for verification.
|
|
3127
|
+
* @param {object} world - The world context.
|
|
3128
|
+
* @returns {Promise<object>} - The state info after verification.
|
|
3129
|
+
*/
|
|
2510
3130
|
async verifyPageTitle(title, options = {}, world = null) {
|
|
2511
|
-
const startTime = Date.now();
|
|
2512
3131
|
let error = null;
|
|
2513
3132
|
let screenshotId = null;
|
|
2514
3133
|
let screenshotPath = null;
|
|
2515
3134
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
2516
|
-
const info = {};
|
|
2517
|
-
info.log = "***** verify page title " + title + " *****\n";
|
|
2518
|
-
info.operation = "verifyPageTitle";
|
|
2519
3135
|
const newValue = await this._replaceWithLocalData(title, world);
|
|
2520
3136
|
if (newValue !== title) {
|
|
2521
3137
|
this.logger.info(title + "=" + newValue);
|
|
2522
3138
|
title = newValue;
|
|
2523
3139
|
}
|
|
2524
|
-
|
|
3140
|
+
const { matcher, queryText } = this._matcher(title);
|
|
3141
|
+
const state = {
|
|
3142
|
+
text_search: queryText,
|
|
3143
|
+
options,
|
|
3144
|
+
world,
|
|
3145
|
+
locate: false,
|
|
3146
|
+
scroll: false,
|
|
3147
|
+
highlight: false,
|
|
3148
|
+
type: Types.VERIFY_PAGE_TITLE,
|
|
3149
|
+
text: `Verify the page title is ${queryText}`,
|
|
3150
|
+
_text: `Verify the page title is ${queryText}`,
|
|
3151
|
+
operation: "verifyPageTitle",
|
|
3152
|
+
log: "***** verify page title is " + queryText + " *****\n",
|
|
3153
|
+
};
|
|
2525
3154
|
try {
|
|
3155
|
+
await _preCommand(state, this);
|
|
3156
|
+
state.info.text = queryText;
|
|
2526
3157
|
for (let i = 0; i < 30; i++) {
|
|
2527
3158
|
const foundTitle = await this.page.title();
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
3159
|
+
switch (matcher) {
|
|
3160
|
+
case "exact":
|
|
3161
|
+
if (foundTitle !== queryText) {
|
|
3162
|
+
if (i === 29) {
|
|
3163
|
+
throw new Error(`Page Title ${foundTitle} is not equal to ${queryText}`);
|
|
3164
|
+
}
|
|
3165
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3166
|
+
continue;
|
|
3167
|
+
}
|
|
3168
|
+
break;
|
|
3169
|
+
case "contains":
|
|
3170
|
+
if (!foundTitle.includes(queryText)) {
|
|
3171
|
+
if (i === 29) {
|
|
3172
|
+
throw new Error(`Page Title ${foundTitle} doesn't contain ${queryText}`);
|
|
3173
|
+
}
|
|
3174
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3175
|
+
continue;
|
|
3176
|
+
}
|
|
3177
|
+
break;
|
|
3178
|
+
case "starts-with":
|
|
3179
|
+
if (!foundTitle.startsWith(queryText)) {
|
|
3180
|
+
if (i === 29) {
|
|
3181
|
+
throw new Error(`Page title ${foundTitle} doesn't start with ${queryText}`);
|
|
3182
|
+
}
|
|
3183
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3184
|
+
continue;
|
|
3185
|
+
}
|
|
3186
|
+
break;
|
|
3187
|
+
case "ends-with":
|
|
3188
|
+
if (!foundTitle.endsWith(queryText)) {
|
|
3189
|
+
if (i === 29) {
|
|
3190
|
+
throw new Error(`Page Title ${foundTitle} doesn't end with ${queryText}`);
|
|
3191
|
+
}
|
|
3192
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3193
|
+
continue;
|
|
3194
|
+
}
|
|
3195
|
+
break;
|
|
3196
|
+
case "regex":
|
|
3197
|
+
const regex = new RegExp(queryText.slice(1, -1), "g");
|
|
3198
|
+
if (!regex.test(foundTitle)) {
|
|
3199
|
+
if (i === 29) {
|
|
3200
|
+
throw new Error(`Page Title ${foundTitle} doesn't match regex ${queryText}`);
|
|
3201
|
+
}
|
|
3202
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3203
|
+
continue;
|
|
3204
|
+
}
|
|
3205
|
+
break;
|
|
3206
|
+
default:
|
|
3207
|
+
console.log("Unknown matching type, defaulting to contains matching");
|
|
3208
|
+
if (!foundTitle.includes(title)) {
|
|
3209
|
+
if (i === 29) {
|
|
3210
|
+
throw new Error(`Page Title ${foundTitle} does not contain ${title}`);
|
|
3211
|
+
}
|
|
3212
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3213
|
+
continue;
|
|
3214
|
+
}
|
|
2534
3215
|
}
|
|
2535
|
-
|
|
2536
|
-
return info;
|
|
3216
|
+
await _screenshot(state, this);
|
|
3217
|
+
return state.info;
|
|
2537
3218
|
}
|
|
2538
3219
|
}
|
|
2539
3220
|
catch (e) {
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
info.screenshotPath = screenshotPath;
|
|
2544
|
-
Object.assign(e, { info: info });
|
|
2545
|
-
error = e;
|
|
2546
|
-
// throw e;
|
|
2547
|
-
await _commandError({ text: "verifyPageTitle", operation: "verifyPageTitle", title, info, throwError: true }, e, this);
|
|
3221
|
+
state.info.failCause.lastError = e.message;
|
|
3222
|
+
state.info.failCause.assertionFailed = true;
|
|
3223
|
+
await _commandError(state, e, this);
|
|
2548
3224
|
}
|
|
2549
3225
|
finally {
|
|
2550
|
-
|
|
2551
|
-
_reportToWorld(world, {
|
|
2552
|
-
type: Types.VERIFY_PAGE_PATH,
|
|
2553
|
-
text: "Verify page title",
|
|
2554
|
-
_text: "Verify the page title contains " + title,
|
|
2555
|
-
screenshotId,
|
|
2556
|
-
result: error
|
|
2557
|
-
? {
|
|
2558
|
-
status: "FAILED",
|
|
2559
|
-
startTime,
|
|
2560
|
-
endTime,
|
|
2561
|
-
message: error?.message,
|
|
2562
|
-
}
|
|
2563
|
-
: {
|
|
2564
|
-
status: "PASSED",
|
|
2565
|
-
startTime,
|
|
2566
|
-
endTime,
|
|
2567
|
-
},
|
|
2568
|
-
info: info,
|
|
2569
|
-
});
|
|
3226
|
+
await _commandFinally(state, this);
|
|
2570
3227
|
}
|
|
2571
3228
|
}
|
|
2572
3229
|
async findTextInAllFrames(dateAlternatives, numberAlternatives, text, state, partial = true, ignoreCase = false) {
|
|
@@ -2650,27 +3307,10 @@ class StableBrowser {
|
|
|
2650
3307
|
const frame = resultWithElementsFound[0].frame;
|
|
2651
3308
|
const dataAttribute = `[data-blinq-id-${resultWithElementsFound[0].randomToken}]`;
|
|
2652
3309
|
await this._highlightElements(frame, dataAttribute);
|
|
2653
|
-
// if (world && world.screenshot && !world.screenshotPath) {
|
|
2654
|
-
// console.log(`Highlighting for verify text is found while running from recorder`);
|
|
2655
|
-
// this._highlightElements(frame, dataAttribute).then(async () => {
|
|
2656
|
-
// await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
2657
|
-
// this._unhighlightElements(frame, dataAttribute)
|
|
2658
|
-
// .then(async () => {
|
|
2659
|
-
// console.log(`Unhighlighted frame dataAttribute successfully`);
|
|
2660
|
-
// })
|
|
2661
|
-
// .catch(
|
|
2662
|
-
// (e) => {}
|
|
2663
|
-
// console.error(e)
|
|
2664
|
-
// );
|
|
2665
|
-
// });
|
|
2666
|
-
// }
|
|
2667
3310
|
const element = await frame.locator(dataAttribute).first();
|
|
2668
|
-
// await new Promise((resolve) => setTimeout(resolve, 100));
|
|
2669
|
-
// await this._unhighlightElements(frame, dataAttribute);
|
|
2670
3311
|
if (element) {
|
|
2671
3312
|
await this.scrollIfNeeded(element, state.info);
|
|
2672
3313
|
await element.dispatchEvent("bvt_verify_page_contains_text");
|
|
2673
|
-
// await _screenshot(state, this, element);
|
|
2674
3314
|
}
|
|
2675
3315
|
}
|
|
2676
3316
|
await _screenshot(state, this);
|
|
@@ -2680,7 +3320,6 @@ class StableBrowser {
|
|
|
2680
3320
|
console.error(error);
|
|
2681
3321
|
}
|
|
2682
3322
|
}
|
|
2683
|
-
// await expect(element).toHaveCount(1, { timeout: 10000 });
|
|
2684
3323
|
}
|
|
2685
3324
|
catch (e) {
|
|
2686
3325
|
await _commandError(state, e, this);
|
|
@@ -2762,6 +3401,8 @@ class StableBrowser {
|
|
|
2762
3401
|
operation: "verify_text_with_relation",
|
|
2763
3402
|
log: "***** search for " + textAnchor + " climb " + climb + " and verify " + textToVerify + " found *****\n",
|
|
2764
3403
|
};
|
|
3404
|
+
const cmdStartTime = Date.now();
|
|
3405
|
+
let cmdEndTime = null;
|
|
2765
3406
|
const timeout = this._getFindElementTimeout(options);
|
|
2766
3407
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
2767
3408
|
let newValue = await this._replaceWithLocalData(textAnchor, world);
|
|
@@ -2797,6 +3438,17 @@ class StableBrowser {
|
|
|
2797
3438
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
2798
3439
|
continue;
|
|
2799
3440
|
}
|
|
3441
|
+
else {
|
|
3442
|
+
cmdEndTime = Date.now();
|
|
3443
|
+
if (cmdEndTime - cmdStartTime > 55000) {
|
|
3444
|
+
if (foundAncore) {
|
|
3445
|
+
throw new Error(`Text ${textToVerify} not found in page`);
|
|
3446
|
+
}
|
|
3447
|
+
else {
|
|
3448
|
+
throw new Error(`Text ${textAnchor} not found in page`);
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
2800
3452
|
try {
|
|
2801
3453
|
for (let i = 0; i < resultWithElementsFound.length; i++) {
|
|
2802
3454
|
foundAncore = true;
|
|
@@ -3196,6 +3848,43 @@ class StableBrowser {
|
|
|
3196
3848
|
});
|
|
3197
3849
|
}
|
|
3198
3850
|
}
|
|
3851
|
+
/**
|
|
3852
|
+
* Explicit wait/sleep function that pauses execution for a specified duration
|
|
3853
|
+
* @param duration - Duration to sleep in milliseconds (default: 1000ms)
|
|
3854
|
+
* @param options - Optional configuration object
|
|
3855
|
+
* @param world - Optional world context
|
|
3856
|
+
* @returns Promise that resolves after the specified duration
|
|
3857
|
+
*/
|
|
3858
|
+
async sleep(duration = 1000, options = {}, world = null) {
|
|
3859
|
+
const state = {
|
|
3860
|
+
duration,
|
|
3861
|
+
options,
|
|
3862
|
+
world,
|
|
3863
|
+
locate: false,
|
|
3864
|
+
scroll: false,
|
|
3865
|
+
screenshot: false,
|
|
3866
|
+
highlight: false,
|
|
3867
|
+
type: Types.SLEEP,
|
|
3868
|
+
text: `Sleep for ${duration} ms`,
|
|
3869
|
+
_text: `Sleep for ${duration} ms`,
|
|
3870
|
+
operation: "sleep",
|
|
3871
|
+
log: `***** Sleep for ${duration} ms *****\n`,
|
|
3872
|
+
};
|
|
3873
|
+
try {
|
|
3874
|
+
await _preCommand(state, this);
|
|
3875
|
+
if (duration < 0) {
|
|
3876
|
+
throw new Error("Sleep duration cannot be negative");
|
|
3877
|
+
}
|
|
3878
|
+
await new Promise((resolve) => setTimeout(resolve, duration));
|
|
3879
|
+
return state.info;
|
|
3880
|
+
}
|
|
3881
|
+
catch (e) {
|
|
3882
|
+
await _commandError(state, e, this);
|
|
3883
|
+
}
|
|
3884
|
+
finally {
|
|
3885
|
+
await _commandFinally(state, this);
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3199
3888
|
async _replaceWithLocalData(value, world, _decrypt = true, totpWait = true) {
|
|
3200
3889
|
try {
|
|
3201
3890
|
return await replaceWithLocalTestData(value, world, _decrypt, totpWait, this.context, this);
|
|
@@ -3226,6 +3915,7 @@ class StableBrowser {
|
|
|
3226
3915
|
}
|
|
3227
3916
|
async saveStoreState(path = null, world = null) {
|
|
3228
3917
|
const storageState = await this.page.context().storageState();
|
|
3918
|
+
path = await this._replaceWithLocalData(path, this.world);
|
|
3229
3919
|
//const testDataFile = _getDataFile(world, this.context, this);
|
|
3230
3920
|
if (path) {
|
|
3231
3921
|
// save { storageState: storageState } into the path
|
|
@@ -3236,6 +3926,7 @@ class StableBrowser {
|
|
|
3236
3926
|
}
|
|
3237
3927
|
}
|
|
3238
3928
|
async restoreSaveState(path = null, world = null) {
|
|
3929
|
+
path = await this._replaceWithLocalData(path, this.world);
|
|
3239
3930
|
await refreshBrowser(this, path, world);
|
|
3240
3931
|
this.registerEventListeners(this.context);
|
|
3241
3932
|
registerNetworkEvents(this.world, this, this.context, this.page);
|
|
@@ -3245,6 +3936,22 @@ class StableBrowser {
|
|
|
3245
3936
|
}
|
|
3246
3937
|
}
|
|
3247
3938
|
async waitForPageLoad(options = {}, world = null) {
|
|
3939
|
+
// try {
|
|
3940
|
+
// let currentPagePath = null;
|
|
3941
|
+
// currentPagePath = new URL(this.page.url()).pathname;
|
|
3942
|
+
// if (this.latestPagePath) {
|
|
3943
|
+
// // get the currect page path and compare with the latest page path
|
|
3944
|
+
// if (this.latestPagePath === currentPagePath) {
|
|
3945
|
+
// // if the page path is the same, do not wait for page load
|
|
3946
|
+
// console.log("No page change: " + currentPagePath);
|
|
3947
|
+
// return;
|
|
3948
|
+
// }
|
|
3949
|
+
// }
|
|
3950
|
+
// this.latestPagePath = currentPagePath;
|
|
3951
|
+
// } catch (e) {
|
|
3952
|
+
// console.debug("Error getting current page path: ", e);
|
|
3953
|
+
// }
|
|
3954
|
+
//console.log("Waiting for page load");
|
|
3248
3955
|
let timeout = this._getLoadTimeout(options);
|
|
3249
3956
|
const promiseArray = [];
|
|
3250
3957
|
// let waitForNetworkIdle = true;
|
|
@@ -3277,10 +3984,12 @@ class StableBrowser {
|
|
|
3277
3984
|
else if (e.label === "domcontentloaded") {
|
|
3278
3985
|
console.log("waited for the domcontent loaded timeout");
|
|
3279
3986
|
}
|
|
3280
|
-
console.log(".");
|
|
3281
3987
|
}
|
|
3282
3988
|
finally {
|
|
3283
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3989
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
3990
|
+
if (options && !options.noSleep) {
|
|
3991
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
3992
|
+
}
|
|
3284
3993
|
({ screenshotId, screenshotPath } = await this._screenShot(options, world));
|
|
3285
3994
|
const endTime = Date.now();
|
|
3286
3995
|
_reportToWorld(world, {
|
|
@@ -3321,7 +4030,6 @@ class StableBrowser {
|
|
|
3321
4030
|
await this.page.close();
|
|
3322
4031
|
}
|
|
3323
4032
|
catch (e) {
|
|
3324
|
-
console.log(".");
|
|
3325
4033
|
await _commandError(state, e, this);
|
|
3326
4034
|
}
|
|
3327
4035
|
finally {
|
|
@@ -3436,7 +4144,6 @@ class StableBrowser {
|
|
|
3436
4144
|
await this.page.setViewportSize({ width: width, height: hight });
|
|
3437
4145
|
}
|
|
3438
4146
|
catch (e) {
|
|
3439
|
-
console.log(".");
|
|
3440
4147
|
await _commandError({ text: "setViewportSize", operation: "setViewportSize", width, hight, info }, e, this);
|
|
3441
4148
|
}
|
|
3442
4149
|
finally {
|
|
@@ -3474,7 +4181,6 @@ class StableBrowser {
|
|
|
3474
4181
|
await this.page.reload();
|
|
3475
4182
|
}
|
|
3476
4183
|
catch (e) {
|
|
3477
|
-
console.log(".");
|
|
3478
4184
|
await _commandError({ text: "reloadPage", operation: "reloadPage", info }, e, this);
|
|
3479
4185
|
}
|
|
3480
4186
|
finally {
|
|
@@ -3518,6 +4224,10 @@ class StableBrowser {
|
|
|
3518
4224
|
}
|
|
3519
4225
|
}
|
|
3520
4226
|
async beforeScenario(world, scenario) {
|
|
4227
|
+
if (world && world.attach) {
|
|
4228
|
+
world.attach(this.context.reportFolder, { mediaType: "text/plain" });
|
|
4229
|
+
}
|
|
4230
|
+
this.context.loadedRoutes = null;
|
|
3521
4231
|
this.beforeScenarioCalled = true;
|
|
3522
4232
|
if (scenario && scenario.pickle && scenario.pickle.name) {
|
|
3523
4233
|
this.scenarioName = scenario.pickle.name;
|
|
@@ -3541,14 +4251,18 @@ class StableBrowser {
|
|
|
3541
4251
|
envName = this.context.environment.name;
|
|
3542
4252
|
}
|
|
3543
4253
|
if (!process.env.TEMP_RUN) {
|
|
3544
|
-
await getTestData(envName, world, undefined, this.featureName, this.scenarioName);
|
|
4254
|
+
await getTestData(envName, world, undefined, this.featureName, this.scenarioName, this.context);
|
|
3545
4255
|
}
|
|
3546
4256
|
await loadBrunoParams(this.context, this.context.environment.name);
|
|
3547
4257
|
}
|
|
3548
4258
|
async afterScenario(world, scenario) { }
|
|
3549
4259
|
async beforeStep(world, step) {
|
|
4260
|
+
if (this.abortedExecution) {
|
|
4261
|
+
throw new Error("Aborted");
|
|
4262
|
+
}
|
|
3550
4263
|
if (!this.beforeScenarioCalled) {
|
|
3551
4264
|
this.beforeScenario(world, step);
|
|
4265
|
+
this.context.loadedRoutes = null;
|
|
3552
4266
|
}
|
|
3553
4267
|
if (this.stepIndex === undefined) {
|
|
3554
4268
|
this.stepIndex = 0;
|
|
@@ -3573,13 +4287,16 @@ class StableBrowser {
|
|
|
3573
4287
|
}
|
|
3574
4288
|
if (this.initSnapshotTaken === false) {
|
|
3575
4289
|
this.initSnapshotTaken = true;
|
|
3576
|
-
if (world && world.attach && !process.env.DISABLE_SNAPSHOT) {
|
|
4290
|
+
if (world && world.attach && !process.env.DISABLE_SNAPSHOT && !this.fastMode) {
|
|
3577
4291
|
const snapshot = await this.getAriaSnapshot();
|
|
3578
4292
|
if (snapshot) {
|
|
3579
4293
|
await world.attach(JSON.stringify(snapshot), "application/json+snapshot-before");
|
|
3580
4294
|
}
|
|
3581
4295
|
}
|
|
3582
4296
|
}
|
|
4297
|
+
this.context.routeResults = null;
|
|
4298
|
+
await registerBeforeStepRoutes(this.context, this.stepName);
|
|
4299
|
+
networkBeforeStep(this.stepName);
|
|
3583
4300
|
}
|
|
3584
4301
|
async getAriaSnapshot() {
|
|
3585
4302
|
try {
|
|
@@ -3599,12 +4316,18 @@ class StableBrowser {
|
|
|
3599
4316
|
try {
|
|
3600
4317
|
// Ensure frame is attached and has body
|
|
3601
4318
|
const body = frame.locator("body");
|
|
3602
|
-
await body.waitFor({ timeout:
|
|
4319
|
+
//await body.waitFor({ timeout: 2000 }); // wait explicitly
|
|
3603
4320
|
const snapshot = await body.ariaSnapshot({ timeout });
|
|
4321
|
+
if (!snapshot) {
|
|
4322
|
+
continue;
|
|
4323
|
+
}
|
|
3604
4324
|
content.push(`- frame: ${i}`);
|
|
3605
4325
|
content.push(snapshot);
|
|
3606
4326
|
}
|
|
3607
|
-
catch (innerErr) {
|
|
4327
|
+
catch (innerErr) {
|
|
4328
|
+
console.warn(`Frame ${i} snapshot failed:`, innerErr);
|
|
4329
|
+
content.push(`- frame: ${i} - error: ${innerErr.message}`);
|
|
4330
|
+
}
|
|
3608
4331
|
}
|
|
3609
4332
|
return content.join("\n");
|
|
3610
4333
|
}
|
|
@@ -3614,6 +4337,49 @@ class StableBrowser {
|
|
|
3614
4337
|
}
|
|
3615
4338
|
return null;
|
|
3616
4339
|
}
|
|
4340
|
+
/**
|
|
4341
|
+
* Sends command with custom payload to report.
|
|
4342
|
+
* @param commandText - Title of the command to be shown in the report.
|
|
4343
|
+
* @param commandStatus - Status of the command (e.g. "PASSED", "FAILED").
|
|
4344
|
+
* @param content - Content of the command to be shown in the report.
|
|
4345
|
+
* @param options - Options for the command. Example: { type: "json", screenshot: true }
|
|
4346
|
+
* @param world - Optional world context.
|
|
4347
|
+
* @public
|
|
4348
|
+
*/
|
|
4349
|
+
async addCommandToReport(commandText, commandStatus, content, options = {}, world = null) {
|
|
4350
|
+
const state = {
|
|
4351
|
+
options,
|
|
4352
|
+
world,
|
|
4353
|
+
locate: false,
|
|
4354
|
+
scroll: false,
|
|
4355
|
+
screenshot: options.screenshot ?? false,
|
|
4356
|
+
highlight: options.highlight ?? false,
|
|
4357
|
+
type: Types.REPORT_COMMAND,
|
|
4358
|
+
text: commandText,
|
|
4359
|
+
_text: commandText,
|
|
4360
|
+
operation: "report_command",
|
|
4361
|
+
log: "***** " + commandText + " *****\n",
|
|
4362
|
+
};
|
|
4363
|
+
try {
|
|
4364
|
+
await _preCommand(state, this);
|
|
4365
|
+
const payload = {
|
|
4366
|
+
type: options.type ?? "text",
|
|
4367
|
+
content: content,
|
|
4368
|
+
screenshotId: null,
|
|
4369
|
+
};
|
|
4370
|
+
state.payload = payload;
|
|
4371
|
+
if (commandStatus === "FAILED") {
|
|
4372
|
+
state.throwError = true;
|
|
4373
|
+
throw new Error("Command failed");
|
|
4374
|
+
}
|
|
4375
|
+
}
|
|
4376
|
+
catch (e) {
|
|
4377
|
+
await _commandError(state, e, this);
|
|
4378
|
+
}
|
|
4379
|
+
finally {
|
|
4380
|
+
await _commandFinally(state, this);
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
3617
4383
|
async afterStep(world, step) {
|
|
3618
4384
|
this.stepName = null;
|
|
3619
4385
|
if (this.context && this.context.browserObject && this.context.browserObject.trace === true) {
|
|
@@ -3633,13 +4399,43 @@ class StableBrowser {
|
|
|
3633
4399
|
if (this.context) {
|
|
3634
4400
|
this.context.examplesRow = null;
|
|
3635
4401
|
}
|
|
3636
|
-
if (world && world.attach && !process.env.DISABLE_SNAPSHOT) {
|
|
4402
|
+
if (world && world.attach && !process.env.DISABLE_SNAPSHOT && !this.fastMode) {
|
|
3637
4403
|
const snapshot = await this.getAriaSnapshot();
|
|
3638
4404
|
if (snapshot) {
|
|
3639
4405
|
const obj = {};
|
|
3640
4406
|
await world.attach(JSON.stringify(snapshot), "application/json+snapshot-after");
|
|
3641
4407
|
}
|
|
3642
4408
|
}
|
|
4409
|
+
this.context.routeResults = await registerAfterStepRoutes(this.context, world);
|
|
4410
|
+
if (this.context.routeResults) {
|
|
4411
|
+
if (world && world.attach) {
|
|
4412
|
+
await world.attach(JSON.stringify(this.context.routeResults), "application/json+intercept-results");
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4415
|
+
if (!process.env.TEMP_RUN) {
|
|
4416
|
+
const state = {
|
|
4417
|
+
world,
|
|
4418
|
+
locate: false,
|
|
4419
|
+
scroll: false,
|
|
4420
|
+
screenshot: true,
|
|
4421
|
+
highlight: true,
|
|
4422
|
+
type: Types.STEP_COMPLETE,
|
|
4423
|
+
text: "end of scenario",
|
|
4424
|
+
_text: "end of scenario",
|
|
4425
|
+
operation: "step_complete",
|
|
4426
|
+
log: "***** " + "end of scenario" + " *****\n",
|
|
4427
|
+
};
|
|
4428
|
+
try {
|
|
4429
|
+
await _preCommand(state, this);
|
|
4430
|
+
}
|
|
4431
|
+
catch (e) {
|
|
4432
|
+
await _commandError(state, e, this);
|
|
4433
|
+
}
|
|
4434
|
+
finally {
|
|
4435
|
+
await _commandFinally(state, this);
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
networkAfterStep(this.stepName);
|
|
3643
4439
|
}
|
|
3644
4440
|
}
|
|
3645
4441
|
function createTimedPromise(promise, label) {
|