automation_model 1.0.728-dev → 1.0.728-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/api.js +4 -3
- package/lib/api.js.map +1 -1
- package/lib/auto_page.d.ts +4 -2
- package/lib/auto_page.js +153 -86
- package/lib/auto_page.js.map +1 -1
- package/lib/browser_manager.js +19 -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.js +18 -2
- package/lib/command_common.js.map +1 -1
- package/lib/file_checker.js +129 -25
- package/lib/file_checker.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/init_browser.d.ts +1 -2
- package/lib/init_browser.js +121 -125
- package/lib/init_browser.js.map +1 -1
- package/lib/locator.d.ts +1 -0
- package/lib/locator.js +9 -2
- package/lib/locator.js.map +1 -1
- package/lib/network.d.ts +2 -0
- package/lib/network.js +374 -86
- package/lib/network.js.map +1 -1
- package/lib/route.d.ts +21 -0
- package/lib/route.js +533 -0
- package/lib/route.js.map +1 -0
- package/lib/scripts/axe.mini.js +3 -3
- package/lib/snapshot_validation.js.map +1 -1
- package/lib/stable_browser.d.ts +25 -2
- package/lib/stable_browser.js +796 -81
- 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_helper.js +14 -0
- package/lib/table_helper.js.map +1 -1
- package/lib/test_context.d.ts +1 -0
- package/lib/test_context.js +1 -0
- package/lib/test_context.js.map +1 -1
- package/lib/utils.d.ts +3 -1
- package/lib/utils.js +38 -6
- package/lib/utils.js.map +1 -1
- package/package.json +11 -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,16 +21,20 @@ 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
|
-
NAVIGATE: "navigate",
|
|
35
|
+
NAVIGATE: "navigate",
|
|
36
|
+
GO_BACK: "go_back",
|
|
37
|
+
GO_FORWARD: "go_forward",
|
|
32
38
|
FILL: "fill_element",
|
|
33
39
|
EXECUTE: "execute_page_method", //
|
|
34
40
|
OPEN: "open_environment", //
|
|
@@ -41,6 +47,7 @@ export const Types = {
|
|
|
41
47
|
VERIFY_PAGE_CONTAINS_NO_TEXT: "verify_page_contains_no_text",
|
|
42
48
|
ANALYZE_TABLE: "analyze_table",
|
|
43
49
|
SELECT: "select_combobox", //
|
|
50
|
+
VERIFY_PROPERTY: "verify_element_property",
|
|
44
51
|
VERIFY_PAGE_PATH: "verify_page_path",
|
|
45
52
|
VERIFY_PAGE_TITLE: "verify_page_title",
|
|
46
53
|
TYPE_PRESS: "type_press",
|
|
@@ -49,6 +56,7 @@ export const Types = {
|
|
|
49
56
|
CHECK: "check_element",
|
|
50
57
|
UNCHECK: "uncheck_element",
|
|
51
58
|
EXTRACT: "extract_attribute",
|
|
59
|
+
EXTRACT_PROPERTY: "extract_property",
|
|
52
60
|
CLOSE_PAGE: "close_page",
|
|
53
61
|
TABLE_OPERATION: "table_operation",
|
|
54
62
|
SET_DATE_TIME: "set_date_time",
|
|
@@ -60,11 +68,13 @@ export const Types = {
|
|
|
60
68
|
VERIFY_ATTRIBUTE: "verify_element_attribute",
|
|
61
69
|
VERIFY_TEXT_WITH_RELATION: "verify_text_with_relation",
|
|
62
70
|
BRUNO: "bruno",
|
|
63
|
-
SNAPSHOT_VALIDATION: "snapshot_validation",
|
|
64
71
|
VERIFY_FILE_EXISTS: "verify_file_exists",
|
|
65
72
|
SET_INPUT_FILES: "set_input_files",
|
|
73
|
+
SNAPSHOT_VALIDATION: "snapshot_validation",
|
|
66
74
|
REPORT_COMMAND: "report_command",
|
|
67
75
|
STEP_COMPLETE: "step_complete",
|
|
76
|
+
SLEEP: "sleep",
|
|
77
|
+
CONDITIONAL_WAIT: "conditional_wait",
|
|
68
78
|
};
|
|
69
79
|
export const apps = {};
|
|
70
80
|
const formatElementName = (elementName) => {
|
|
@@ -76,6 +86,7 @@ class StableBrowser {
|
|
|
76
86
|
logger;
|
|
77
87
|
context;
|
|
78
88
|
world;
|
|
89
|
+
fastMode;
|
|
79
90
|
project_path = null;
|
|
80
91
|
webLogFile = null;
|
|
81
92
|
networkLogger = null;
|
|
@@ -84,12 +95,14 @@ class StableBrowser {
|
|
|
84
95
|
tags = null;
|
|
85
96
|
isRecording = false;
|
|
86
97
|
initSnapshotTaken = false;
|
|
87
|
-
|
|
98
|
+
onlyFailuresScreenshot = process.env.SCREENSHOT_ON_FAILURE_ONLY === "true";
|
|
99
|
+
constructor(browser, page, logger = null, context = null, world = null, fastMode = false) {
|
|
88
100
|
this.browser = browser;
|
|
89
101
|
this.page = page;
|
|
90
102
|
this.logger = logger;
|
|
91
103
|
this.context = context;
|
|
92
104
|
this.world = world;
|
|
105
|
+
this.fastMode = fastMode;
|
|
93
106
|
if (!this.logger) {
|
|
94
107
|
this.logger = console;
|
|
95
108
|
}
|
|
@@ -118,6 +131,19 @@ class StableBrowser {
|
|
|
118
131
|
context.pages = [this.page];
|
|
119
132
|
const logFolder = path.join(this.project_path, "logs", "web");
|
|
120
133
|
this.world = world;
|
|
134
|
+
if (this.configuration && this.configuration.fastMode === true) {
|
|
135
|
+
this.fastMode = true;
|
|
136
|
+
}
|
|
137
|
+
if (process.env.FAST_MODE === "true") {
|
|
138
|
+
// console.log("Fast mode enabled from environment variable");
|
|
139
|
+
this.fastMode = true;
|
|
140
|
+
}
|
|
141
|
+
if (process.env.FAST_MODE === "false") {
|
|
142
|
+
this.fastMode = false;
|
|
143
|
+
}
|
|
144
|
+
if (this.context) {
|
|
145
|
+
this.context.fastMode = this.fastMode;
|
|
146
|
+
}
|
|
121
147
|
this.registerEventListeners(this.context);
|
|
122
148
|
registerNetworkEvents(this.world, this, this.context, this.page);
|
|
123
149
|
registerDownloadEvent(this.page, this.world, this.context);
|
|
@@ -128,6 +154,9 @@ class StableBrowser {
|
|
|
128
154
|
if (!context.pageLoading) {
|
|
129
155
|
context.pageLoading = { status: false };
|
|
130
156
|
}
|
|
157
|
+
if (this.configuration && this.configuration.acceptDialog && this.page) {
|
|
158
|
+
this.page.on("dialog", (dialog) => dialog.accept());
|
|
159
|
+
}
|
|
131
160
|
context.playContext.on("page", async function (page) {
|
|
132
161
|
if (this.configuration && this.configuration.closePopups === true) {
|
|
133
162
|
console.log("close unexpected popups");
|
|
@@ -136,11 +165,20 @@ class StableBrowser {
|
|
|
136
165
|
}
|
|
137
166
|
context.pageLoading.status = true;
|
|
138
167
|
this.page = page;
|
|
168
|
+
try {
|
|
169
|
+
if (this.configuration && this.configuration.acceptDialog) {
|
|
170
|
+
await page.on("dialog", (dialog) => dialog.accept());
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
console.error("Error on dialog accept registration", error);
|
|
175
|
+
}
|
|
139
176
|
context.page = page;
|
|
140
177
|
context.pages.push(page);
|
|
141
178
|
registerNetworkEvents(this.world, this, context, this.page);
|
|
142
179
|
registerDownloadEvent(this.page, this.world, context);
|
|
143
180
|
page.on("close", async () => {
|
|
181
|
+
// return if browser context is already closed
|
|
144
182
|
if (this.context && this.context.pages && this.context.pages.length > 1) {
|
|
145
183
|
this.context.pages.pop();
|
|
146
184
|
this.page = this.context.pages[this.context.pages.length - 1];
|
|
@@ -150,7 +188,12 @@ class StableBrowser {
|
|
|
150
188
|
console.log("Switched to page " + title);
|
|
151
189
|
}
|
|
152
190
|
catch (error) {
|
|
153
|
-
|
|
191
|
+
if (error?.message?.includes("Target page, context or browser has been closed")) {
|
|
192
|
+
// Ignore this error
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
console.error("Error on page close", error);
|
|
196
|
+
}
|
|
154
197
|
}
|
|
155
198
|
}
|
|
156
199
|
});
|
|
@@ -159,7 +202,12 @@ class StableBrowser {
|
|
|
159
202
|
console.log("Switch page: " + (await page.title()));
|
|
160
203
|
}
|
|
161
204
|
catch (e) {
|
|
162
|
-
|
|
205
|
+
if (e?.message?.includes("Target page, context or browser has been closed")) {
|
|
206
|
+
// Ignore this error
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
this.logger.error("error on page load " + e);
|
|
210
|
+
}
|
|
163
211
|
}
|
|
164
212
|
context.pageLoading.status = false;
|
|
165
213
|
}.bind(this));
|
|
@@ -187,7 +235,9 @@ class StableBrowser {
|
|
|
187
235
|
if (newContextCreated) {
|
|
188
236
|
this.registerEventListeners(this.context);
|
|
189
237
|
await this.goto(this.context.environment.baseUrl);
|
|
190
|
-
|
|
238
|
+
if (!this.fastMode) {
|
|
239
|
+
await this.waitForPageLoad();
|
|
240
|
+
}
|
|
191
241
|
}
|
|
192
242
|
}
|
|
193
243
|
async switchTab(tabTitleOrIndex) {
|
|
@@ -313,6 +363,64 @@ class StableBrowser {
|
|
|
313
363
|
await _commandFinally(state, this);
|
|
314
364
|
}
|
|
315
365
|
}
|
|
366
|
+
async goBack(options, world = null) {
|
|
367
|
+
const state = {
|
|
368
|
+
value: "",
|
|
369
|
+
world: world,
|
|
370
|
+
type: Types.GO_BACK,
|
|
371
|
+
text: `Browser navigate back`,
|
|
372
|
+
operation: "goBack",
|
|
373
|
+
log: "***** navigate back *****\n",
|
|
374
|
+
info: {},
|
|
375
|
+
locate: false,
|
|
376
|
+
scroll: false,
|
|
377
|
+
screenshot: false,
|
|
378
|
+
highlight: false,
|
|
379
|
+
};
|
|
380
|
+
try {
|
|
381
|
+
await _preCommand(state, this);
|
|
382
|
+
await this.page.goBack({
|
|
383
|
+
waitUntil: "load",
|
|
384
|
+
});
|
|
385
|
+
await _screenshot(state, this);
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
console.error("Error on goBack", error);
|
|
389
|
+
_commandError(state, error, this);
|
|
390
|
+
}
|
|
391
|
+
finally {
|
|
392
|
+
await _commandFinally(state, this);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
async goForward(options, world = null) {
|
|
396
|
+
const state = {
|
|
397
|
+
value: "",
|
|
398
|
+
world: world,
|
|
399
|
+
type: Types.GO_FORWARD,
|
|
400
|
+
text: `Browser navigate forward`,
|
|
401
|
+
operation: "goForward",
|
|
402
|
+
log: "***** navigate forward *****\n",
|
|
403
|
+
info: {},
|
|
404
|
+
locate: false,
|
|
405
|
+
scroll: false,
|
|
406
|
+
screenshot: false,
|
|
407
|
+
highlight: false,
|
|
408
|
+
};
|
|
409
|
+
try {
|
|
410
|
+
await _preCommand(state, this);
|
|
411
|
+
await this.page.goForward({
|
|
412
|
+
waitUntil: "load",
|
|
413
|
+
});
|
|
414
|
+
await _screenshot(state, this);
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
console.error("Error on goForward", error);
|
|
418
|
+
_commandError(state, error, this);
|
|
419
|
+
}
|
|
420
|
+
finally {
|
|
421
|
+
await _commandFinally(state, this);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
316
424
|
async _getLocator(locator, scope, _params) {
|
|
317
425
|
locator = _fixLocatorUsingParams(locator, _params);
|
|
318
426
|
// locator = await this._replaceWithLocalData(locator);
|
|
@@ -411,12 +519,6 @@ class StableBrowser {
|
|
|
411
519
|
if (!el.setAttribute) {
|
|
412
520
|
el = el.parentElement;
|
|
413
521
|
}
|
|
414
|
-
// remove any attributes start with data-blinq-id
|
|
415
|
-
// for (let i = 0; i < el.attributes.length; i++) {
|
|
416
|
-
// if (el.attributes[i].name.startsWith("data-blinq-id")) {
|
|
417
|
-
// el.removeAttribute(el.attributes[i].name);
|
|
418
|
-
// }
|
|
419
|
-
// }
|
|
420
522
|
el.setAttribute("data-blinq-id-" + randomToken, "");
|
|
421
523
|
return true;
|
|
422
524
|
}, [tag1, randomToken]))) {
|
|
@@ -438,14 +540,13 @@ class StableBrowser {
|
|
|
438
540
|
info.locatorLog = new LocatorLog(selectorHierarchy);
|
|
439
541
|
}
|
|
440
542
|
let locatorSearch = selectorHierarchy[index];
|
|
441
|
-
let originalLocatorSearch = "";
|
|
442
543
|
try {
|
|
443
|
-
|
|
444
|
-
locatorSearch = JSON.parse(originalLocatorSearch);
|
|
544
|
+
locatorSearch = _fixLocatorUsingParams(locatorSearch, _params);
|
|
445
545
|
}
|
|
446
546
|
catch (e) {
|
|
447
547
|
console.error(e);
|
|
448
548
|
}
|
|
549
|
+
let originalLocatorSearch = JSON.stringify(locatorSearch);
|
|
449
550
|
//info.log += "searching for locator " + JSON.stringify(locatorSearch) + "\n";
|
|
450
551
|
let locator = null;
|
|
451
552
|
if (locatorSearch.climb && locatorSearch.climb >= 0) {
|
|
@@ -587,34 +688,183 @@ class StableBrowser {
|
|
|
587
688
|
}
|
|
588
689
|
return { rerun: false };
|
|
589
690
|
}
|
|
691
|
+
getFilePath() {
|
|
692
|
+
const stackFrames = errorStackParser.parse(new Error());
|
|
693
|
+
const stackFrame = stackFrames.findLast((frame) => frame.fileName && frame.fileName.endsWith(".mjs"));
|
|
694
|
+
// return stackFrame?.fileName || null;
|
|
695
|
+
const filepath = stackFrame?.fileName;
|
|
696
|
+
if (filepath) {
|
|
697
|
+
let jsonFilePath = filepath.replace(".mjs", ".json");
|
|
698
|
+
if (existsSync(jsonFilePath)) {
|
|
699
|
+
return jsonFilePath;
|
|
700
|
+
}
|
|
701
|
+
const config = this.configuration ?? {};
|
|
702
|
+
if (!config?.locatorsMetadataDir) {
|
|
703
|
+
config.locatorsMetadataDir = "features/step_definitions/locators";
|
|
704
|
+
}
|
|
705
|
+
if (config && config.locatorsMetadataDir) {
|
|
706
|
+
jsonFilePath = path.join(config.locatorsMetadataDir, path.basename(jsonFilePath));
|
|
707
|
+
}
|
|
708
|
+
if (existsSync(jsonFilePath)) {
|
|
709
|
+
return jsonFilePath;
|
|
710
|
+
}
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
return null;
|
|
714
|
+
}
|
|
715
|
+
getFullElementLocators(selectors, filePath) {
|
|
716
|
+
if (!filePath || !existsSync(filePath)) {
|
|
717
|
+
return null;
|
|
718
|
+
}
|
|
719
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
720
|
+
try {
|
|
721
|
+
const allElements = JSON.parse(content);
|
|
722
|
+
const element_key = selectors?.element_key;
|
|
723
|
+
if (element_key && allElements[element_key]) {
|
|
724
|
+
return allElements[element_key];
|
|
725
|
+
}
|
|
726
|
+
for (const elementKey in allElements) {
|
|
727
|
+
const element = allElements[elementKey];
|
|
728
|
+
let foundStrategy = null;
|
|
729
|
+
for (const key in element) {
|
|
730
|
+
if (key === "strategy") {
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
const locators = element[key];
|
|
734
|
+
if (!locators || !locators.length) {
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
for (const locator of locators) {
|
|
738
|
+
delete locator.score;
|
|
739
|
+
}
|
|
740
|
+
if (JSON.stringify(locators) === JSON.stringify(selectors.locators)) {
|
|
741
|
+
foundStrategy = key;
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (foundStrategy) {
|
|
746
|
+
return element;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
catch (error) {
|
|
751
|
+
console.error("Error parsing locators from file: " + filePath, error);
|
|
752
|
+
}
|
|
753
|
+
return null;
|
|
754
|
+
}
|
|
590
755
|
async _locate(selectors, info, _params, timeout, allowDisabled = false) {
|
|
591
756
|
if (!timeout) {
|
|
592
757
|
timeout = 30000;
|
|
593
758
|
}
|
|
759
|
+
let element = null;
|
|
760
|
+
let allStrategyLocators = null;
|
|
761
|
+
let selectedStrategy = null;
|
|
762
|
+
if (this.tryAllStrategies) {
|
|
763
|
+
allStrategyLocators = this.getFullElementLocators(selectors, this.getFilePath());
|
|
764
|
+
selectedStrategy = allStrategyLocators?.strategy;
|
|
765
|
+
}
|
|
594
766
|
for (let i = 0; i < 3; i++) {
|
|
595
767
|
info.log += "attempt " + i + ": total locators " + selectors.locators.length + "\n";
|
|
596
768
|
for (let j = 0; j < selectors.locators.length; j++) {
|
|
597
769
|
let selector = selectors.locators[j];
|
|
598
770
|
info.log += "searching for locator " + j + ":" + JSON.stringify(selector) + "\n";
|
|
599
771
|
}
|
|
600
|
-
|
|
772
|
+
if (this.tryAllStrategies && selectedStrategy) {
|
|
773
|
+
const strategyLocators = allStrategyLocators[selectedStrategy];
|
|
774
|
+
let err;
|
|
775
|
+
if (strategyLocators && strategyLocators.length) {
|
|
776
|
+
try {
|
|
777
|
+
selectors.locators = strategyLocators;
|
|
778
|
+
element = await this._locate_internal(selectors, info, _params, 10_000, allowDisabled);
|
|
779
|
+
info.selectedStrategy = selectedStrategy;
|
|
780
|
+
info.log += "element found using strategy " + selectedStrategy + "\n";
|
|
781
|
+
}
|
|
782
|
+
catch (error) {
|
|
783
|
+
err = error;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (!element) {
|
|
787
|
+
for (const key in allStrategyLocators) {
|
|
788
|
+
if (key === "strategy" || key === selectedStrategy) {
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
const strategyLocators = allStrategyLocators[key];
|
|
792
|
+
if (strategyLocators && strategyLocators.length) {
|
|
793
|
+
try {
|
|
794
|
+
info.log += "using strategy " + key + " with locators " + JSON.stringify(strategyLocators) + "\n";
|
|
795
|
+
selectors.locators = strategyLocators;
|
|
796
|
+
element = await this._locate_internal(selectors, info, _params, 10_000, allowDisabled);
|
|
797
|
+
err = null;
|
|
798
|
+
info.selectedStrategy = key;
|
|
799
|
+
info.log += "element found using strategy " + key + "\n";
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
catch (error) {
|
|
803
|
+
err = error;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (err) {
|
|
809
|
+
throw err;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
element = await this._locate_internal(selectors, info, _params, timeout, allowDisabled);
|
|
814
|
+
}
|
|
601
815
|
if (!element.rerun) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
816
|
+
let newElementSelector = "";
|
|
817
|
+
if (this.configuration && this.configuration.stableLocatorStrategy === "csschain") {
|
|
818
|
+
const cssSelector = await element.evaluate((el) => {
|
|
819
|
+
function getCssSelector(el) {
|
|
820
|
+
if (!el || el.nodeType !== 1 || el === document.body)
|
|
821
|
+
return el.tagName.toLowerCase();
|
|
822
|
+
const parent = el.parentElement;
|
|
823
|
+
const tag = el.tagName.toLowerCase();
|
|
824
|
+
// Find the index of the element among its siblings of the same tag
|
|
825
|
+
let index = 1;
|
|
826
|
+
for (let sibling = el.previousElementSibling; sibling; sibling = sibling.previousElementSibling) {
|
|
827
|
+
if (sibling.tagName === el.tagName) {
|
|
828
|
+
index++;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
// Use nth-child if necessary (i.e., if there's more than one of the same tag)
|
|
832
|
+
const siblings = Array.from(parent.children).filter((child) => child.tagName === el.tagName);
|
|
833
|
+
const needsNthChild = siblings.length > 1;
|
|
834
|
+
const selector = needsNthChild ? `${tag}:nth-child(${[...parent.children].indexOf(el) + 1})` : tag;
|
|
835
|
+
return getCssSelector(parent) + " > " + selector;
|
|
836
|
+
}
|
|
837
|
+
const cssSelector = getCssSelector(el);
|
|
838
|
+
return cssSelector;
|
|
839
|
+
});
|
|
840
|
+
newElementSelector = cssSelector;
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
const randomToken = "blinq_" + Math.random().toString(36).substring(7);
|
|
844
|
+
const id = await element.evaluate((el, randomToken) => {
|
|
845
|
+
// check if the element has id attribute
|
|
846
|
+
if (el.id) {
|
|
847
|
+
return el.id;
|
|
848
|
+
}
|
|
849
|
+
el.setAttribute("id", randomToken);
|
|
850
|
+
console.log("set id=" + randomToken + " on element", el);
|
|
851
|
+
return randomToken;
|
|
852
|
+
}, randomToken);
|
|
853
|
+
newElementSelector = "#" + id;
|
|
854
|
+
// check if the id contains :
|
|
855
|
+
if (id.includes(":")) {
|
|
856
|
+
// //*[@id="radix-:r0:"]
|
|
857
|
+
newElementSelector = `//*[@id="${id}"]`;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
609
860
|
const scope = element._frame ?? element.page();
|
|
610
|
-
let newElementSelector = "[data-blinq-id-" + randomToken + "]";
|
|
611
861
|
let prefixSelector = "";
|
|
612
862
|
const frameControlSelector = " >> internal:control=enter-frame";
|
|
613
863
|
const frameSelectorIndex = element._selector.lastIndexOf(frameControlSelector);
|
|
614
864
|
if (frameSelectorIndex !== -1) {
|
|
615
865
|
// remove everything after the >> internal:control=enter-frame
|
|
616
866
|
const frameSelector = element._selector.substring(0, frameSelectorIndex);
|
|
617
|
-
prefixSelector = frameSelector + " >> internal:control=enter-frame >>";
|
|
867
|
+
prefixSelector = frameSelector + " >> internal:control=enter-frame >> ";
|
|
618
868
|
}
|
|
619
869
|
// if (element?._frame?._selector) {
|
|
620
870
|
// prefixSelector = element._frame._selector + " >> " + prefixSelector;
|
|
@@ -653,7 +903,7 @@ class StableBrowser {
|
|
|
653
903
|
break;
|
|
654
904
|
}
|
|
655
905
|
catch (error) {
|
|
656
|
-
console.error("frame not found " + frameLocator.css);
|
|
906
|
+
// console.error("frame not found " + frameLocator.css);
|
|
657
907
|
}
|
|
658
908
|
}
|
|
659
909
|
}
|
|
@@ -731,7 +981,6 @@ class StableBrowser {
|
|
|
731
981
|
let locatorsCount = 0;
|
|
732
982
|
let lazy_scroll = false;
|
|
733
983
|
//let arrayMode = Array.isArray(selectors);
|
|
734
|
-
let scope = await this._findFrameScope(selectors, timeout, info);
|
|
735
984
|
let selectorsLocators = null;
|
|
736
985
|
selectorsLocators = selectors.locators;
|
|
737
986
|
// group selectors by priority
|
|
@@ -759,6 +1008,7 @@ class StableBrowser {
|
|
|
759
1008
|
let highPriorityOnly = true;
|
|
760
1009
|
let visibleOnly = true;
|
|
761
1010
|
while (true) {
|
|
1011
|
+
let scope = await this._findFrameScope(selectors, timeout, info);
|
|
762
1012
|
locatorsCount = 0;
|
|
763
1013
|
let result = [];
|
|
764
1014
|
let popupResult = await this.closeUnexpectedPopups(info, _params);
|
|
@@ -874,9 +1124,13 @@ class StableBrowser {
|
|
|
874
1124
|
}
|
|
875
1125
|
}
|
|
876
1126
|
if (foundLocators.length === 1) {
|
|
1127
|
+
let box = null;
|
|
1128
|
+
if (!this.onlyFailuresScreenshot) {
|
|
1129
|
+
box = await foundLocators[0].boundingBox();
|
|
1130
|
+
}
|
|
877
1131
|
result.foundElements.push({
|
|
878
1132
|
locator: foundLocators[0],
|
|
879
|
-
box:
|
|
1133
|
+
box: box,
|
|
880
1134
|
unique: true,
|
|
881
1135
|
});
|
|
882
1136
|
result.locatorIndex = i;
|
|
@@ -1031,17 +1285,30 @@ class StableBrowser {
|
|
|
1031
1285
|
operation: "click",
|
|
1032
1286
|
log: "***** click on " + selectors.element_name + " *****\n",
|
|
1033
1287
|
};
|
|
1288
|
+
check_performance("click_all ***", this.context, true);
|
|
1034
1289
|
try {
|
|
1290
|
+
check_performance("click_preCommand", this.context, true);
|
|
1035
1291
|
await _preCommand(state, this);
|
|
1292
|
+
check_performance("click_preCommand", this.context, false);
|
|
1036
1293
|
await performAction("click", state.element, options, this, state, _params);
|
|
1037
|
-
|
|
1294
|
+
if (!this.fastMode) {
|
|
1295
|
+
check_performance("click_waitForPageLoad", this.context, true);
|
|
1296
|
+
await this.waitForPageLoad({ noSleep: true });
|
|
1297
|
+
check_performance("click_waitForPageLoad", this.context, false);
|
|
1298
|
+
}
|
|
1038
1299
|
return state.info;
|
|
1039
1300
|
}
|
|
1040
1301
|
catch (e) {
|
|
1041
1302
|
await _commandError(state, e, this);
|
|
1042
1303
|
}
|
|
1043
1304
|
finally {
|
|
1305
|
+
check_performance("click_commandFinally", this.context, true);
|
|
1044
1306
|
await _commandFinally(state, this);
|
|
1307
|
+
check_performance("click_commandFinally", this.context, false);
|
|
1308
|
+
check_performance("click_all ***", this.context, false);
|
|
1309
|
+
if (this.context.profile) {
|
|
1310
|
+
console.log(JSON.stringify(this.context.profile, null, 2));
|
|
1311
|
+
}
|
|
1045
1312
|
}
|
|
1046
1313
|
}
|
|
1047
1314
|
async waitForElement(selectors, _params, options = {}, world = null) {
|
|
@@ -1097,7 +1364,7 @@ class StableBrowser {
|
|
|
1097
1364
|
// if (world && world.screenshot && !world.screenshotPath) {
|
|
1098
1365
|
// console.log(`Highlighting while running from recorder`);
|
|
1099
1366
|
await this._highlightElements(state.element);
|
|
1100
|
-
await state.element.setChecked(checked);
|
|
1367
|
+
await state.element.setChecked(checked, { timeout: 2000 });
|
|
1101
1368
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
1102
1369
|
// await this._unHighlightElements(element);
|
|
1103
1370
|
// }
|
|
@@ -1109,14 +1376,31 @@ class StableBrowser {
|
|
|
1109
1376
|
this.logger.info("element did not change its state, ignoring...");
|
|
1110
1377
|
}
|
|
1111
1378
|
else {
|
|
1379
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
1112
1380
|
//await this.closeUnexpectedPopups();
|
|
1113
1381
|
state.info.log += "setCheck failed, will try again" + "\n";
|
|
1114
|
-
state.
|
|
1115
|
-
|
|
1116
|
-
|
|
1382
|
+
state.element_found = false;
|
|
1383
|
+
try {
|
|
1384
|
+
state.element = await this._locate(selectors, state.info, _params, 100);
|
|
1385
|
+
state.element_found = true;
|
|
1386
|
+
// check the check state
|
|
1387
|
+
}
|
|
1388
|
+
catch (error) {
|
|
1389
|
+
// element dismissed
|
|
1390
|
+
}
|
|
1391
|
+
if (state.element_found) {
|
|
1392
|
+
const isChecked = await state.element.isChecked();
|
|
1393
|
+
if (isChecked !== checked) {
|
|
1394
|
+
// perform click
|
|
1395
|
+
await state.element.click({ timeout: 2000, force: true });
|
|
1396
|
+
}
|
|
1397
|
+
else {
|
|
1398
|
+
this.logger.info(`Element ${selectors.element_name} is already in the desired state (${checked})`);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1117
1401
|
}
|
|
1118
1402
|
}
|
|
1119
|
-
await this.waitForPageLoad();
|
|
1403
|
+
//await this.waitForPageLoad();
|
|
1120
1404
|
return state.info;
|
|
1121
1405
|
}
|
|
1122
1406
|
catch (e) {
|
|
@@ -1142,7 +1426,7 @@ class StableBrowser {
|
|
|
1142
1426
|
await _preCommand(state, this);
|
|
1143
1427
|
await performAction("hover", state.element, options, this, state, _params);
|
|
1144
1428
|
await _screenshot(state, this);
|
|
1145
|
-
await this.waitForPageLoad();
|
|
1429
|
+
//await this.waitForPageLoad();
|
|
1146
1430
|
return state.info;
|
|
1147
1431
|
}
|
|
1148
1432
|
catch (e) {
|
|
@@ -1178,7 +1462,7 @@ class StableBrowser {
|
|
|
1178
1462
|
state.info.log += "selectOption failed, will try force" + "\n";
|
|
1179
1463
|
await state.element.selectOption(values, { timeout: 10000, force: true });
|
|
1180
1464
|
}
|
|
1181
|
-
await this.waitForPageLoad();
|
|
1465
|
+
//await this.waitForPageLoad();
|
|
1182
1466
|
return state.info;
|
|
1183
1467
|
}
|
|
1184
1468
|
catch (e) {
|
|
@@ -1409,7 +1693,9 @@ class StableBrowser {
|
|
|
1409
1693
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1410
1694
|
}
|
|
1411
1695
|
}
|
|
1696
|
+
//if (!this.fastMode) {
|
|
1412
1697
|
await _screenshot(state, this);
|
|
1698
|
+
//}
|
|
1413
1699
|
if (enter === true) {
|
|
1414
1700
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
1415
1701
|
await this.page.keyboard.press("Enter");
|
|
@@ -1458,8 +1744,8 @@ class StableBrowser {
|
|
|
1458
1744
|
if (enter) {
|
|
1459
1745
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
1460
1746
|
await this.page.keyboard.press("Enter");
|
|
1747
|
+
await this.waitForPageLoad();
|
|
1461
1748
|
}
|
|
1462
|
-
await this.waitForPageLoad();
|
|
1463
1749
|
return state.info;
|
|
1464
1750
|
}
|
|
1465
1751
|
catch (e) {
|
|
@@ -1751,6 +2037,11 @@ class StableBrowser {
|
|
|
1751
2037
|
throw new Error("Snapshot validation failed at line " + matchResult.errorLineText);
|
|
1752
2038
|
}
|
|
1753
2039
|
// highlight and screenshot
|
|
2040
|
+
try {
|
|
2041
|
+
await await highlightSnapshot(newValue, scope);
|
|
2042
|
+
await _screenshot(state, this);
|
|
2043
|
+
}
|
|
2044
|
+
catch (e) { }
|
|
1754
2045
|
return state.info;
|
|
1755
2046
|
}
|
|
1756
2047
|
catch (e) {
|
|
@@ -1909,12 +2200,7 @@ class StableBrowser {
|
|
|
1909
2200
|
}
|
|
1910
2201
|
}
|
|
1911
2202
|
getTestData(world = null) {
|
|
1912
|
-
|
|
1913
|
-
let data = {};
|
|
1914
|
-
if (fs.existsSync(dataFile)) {
|
|
1915
|
-
data = JSON.parse(fs.readFileSync(dataFile, "utf8"));
|
|
1916
|
-
}
|
|
1917
|
-
return data;
|
|
2203
|
+
return _getTestData(world, this.context, this);
|
|
1918
2204
|
}
|
|
1919
2205
|
async _screenShot(options = {}, world = null, info = null) {
|
|
1920
2206
|
// collect url/path/title
|
|
@@ -2134,6 +2420,77 @@ class StableBrowser {
|
|
|
2134
2420
|
await _commandFinally(state, this);
|
|
2135
2421
|
}
|
|
2136
2422
|
}
|
|
2423
|
+
async extractProperty(selectors, property, variable, _params = null, options = {}, world = null) {
|
|
2424
|
+
const state = {
|
|
2425
|
+
selectors,
|
|
2426
|
+
_params,
|
|
2427
|
+
property,
|
|
2428
|
+
variable,
|
|
2429
|
+
options,
|
|
2430
|
+
world,
|
|
2431
|
+
type: Types.EXTRACT_PROPERTY,
|
|
2432
|
+
text: `Extract property from element`,
|
|
2433
|
+
_text: `Extract property ${property} from ${selectors.element_name}`,
|
|
2434
|
+
operation: "extractProperty",
|
|
2435
|
+
log: "***** extract property " + property + " from " + selectors.element_name + " *****\n",
|
|
2436
|
+
allowDisabled: true,
|
|
2437
|
+
};
|
|
2438
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
2439
|
+
try {
|
|
2440
|
+
await _preCommand(state, this);
|
|
2441
|
+
switch (property) {
|
|
2442
|
+
case "inner_text":
|
|
2443
|
+
state.value = await state.element.innerText();
|
|
2444
|
+
break;
|
|
2445
|
+
case "href":
|
|
2446
|
+
state.value = await state.element.getAttribute("href");
|
|
2447
|
+
break;
|
|
2448
|
+
case "value":
|
|
2449
|
+
state.value = await state.element.inputValue();
|
|
2450
|
+
break;
|
|
2451
|
+
case "text":
|
|
2452
|
+
state.value = await state.element.textContent();
|
|
2453
|
+
break;
|
|
2454
|
+
default:
|
|
2455
|
+
if (property.startsWith("dataset.")) {
|
|
2456
|
+
const dataAttribute = property.substring(8);
|
|
2457
|
+
state.value = String(await state.element.getAttribute(`data-${dataAttribute}`)) || "";
|
|
2458
|
+
}
|
|
2459
|
+
else {
|
|
2460
|
+
state.value = String(await state.element.evaluate((element, prop) => element[prop], property));
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
if (options !== null) {
|
|
2464
|
+
if (options.regex && options.regex !== "") {
|
|
2465
|
+
// Construct a regex pattern from the provided string
|
|
2466
|
+
const regex = options.regex.slice(1, -1);
|
|
2467
|
+
const regexPattern = new RegExp(regex, "g");
|
|
2468
|
+
const matches = state.value.match(regexPattern);
|
|
2469
|
+
if (matches) {
|
|
2470
|
+
let newValue = "";
|
|
2471
|
+
for (const match of matches) {
|
|
2472
|
+
newValue += match;
|
|
2473
|
+
}
|
|
2474
|
+
state.value = newValue;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
if (options.trimSpaces && options.trimSpaces === true) {
|
|
2478
|
+
state.value = state.value.trim();
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
state.info.value = state.value;
|
|
2482
|
+
this.setTestData({ [variable]: state.value }, world);
|
|
2483
|
+
this.logger.info("set test data: " + variable + "=" + state.value);
|
|
2484
|
+
// await new Promise((resolve) => setTimeout(resolve, 500));
|
|
2485
|
+
return state.info;
|
|
2486
|
+
}
|
|
2487
|
+
catch (e) {
|
|
2488
|
+
await _commandError(state, e, this);
|
|
2489
|
+
}
|
|
2490
|
+
finally {
|
|
2491
|
+
await _commandFinally(state, this);
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2137
2494
|
async verifyAttribute(selectors, attribute, value, _params = null, options = {}, world = null) {
|
|
2138
2495
|
const state = {
|
|
2139
2496
|
selectors,
|
|
@@ -2232,6 +2589,261 @@ class StableBrowser {
|
|
|
2232
2589
|
await _commandFinally(state, this);
|
|
2233
2590
|
}
|
|
2234
2591
|
}
|
|
2592
|
+
async verifyProperty(selectors, property, value, _params = null, options = {}, world = null) {
|
|
2593
|
+
const state = {
|
|
2594
|
+
selectors,
|
|
2595
|
+
_params,
|
|
2596
|
+
property,
|
|
2597
|
+
value,
|
|
2598
|
+
options,
|
|
2599
|
+
world,
|
|
2600
|
+
type: Types.VERIFY_PROPERTY,
|
|
2601
|
+
highlight: true,
|
|
2602
|
+
screenshot: true,
|
|
2603
|
+
text: `Verify element property`,
|
|
2604
|
+
_text: `Verify property ${property} from ${selectors.element_name} is ${value}`,
|
|
2605
|
+
operation: "verifyProperty",
|
|
2606
|
+
log: "***** verify property " + property + " from " + selectors.element_name + " *****\n",
|
|
2607
|
+
allowDisabled: true,
|
|
2608
|
+
};
|
|
2609
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
2610
|
+
let val;
|
|
2611
|
+
let expectedValue;
|
|
2612
|
+
try {
|
|
2613
|
+
await _preCommand(state, this);
|
|
2614
|
+
expectedValue = await replaceWithLocalTestData(state.value, world);
|
|
2615
|
+
state.info.expectedValue = expectedValue;
|
|
2616
|
+
switch (property) {
|
|
2617
|
+
case "innerText":
|
|
2618
|
+
val = String(await state.element.innerText());
|
|
2619
|
+
break;
|
|
2620
|
+
case "text":
|
|
2621
|
+
val = String(await state.element.textContent());
|
|
2622
|
+
break;
|
|
2623
|
+
case "value":
|
|
2624
|
+
val = String(await state.element.inputValue());
|
|
2625
|
+
break;
|
|
2626
|
+
case "checked":
|
|
2627
|
+
val = String(await state.element.isChecked());
|
|
2628
|
+
break;
|
|
2629
|
+
case "disabled":
|
|
2630
|
+
val = String(await state.element.isDisabled());
|
|
2631
|
+
break;
|
|
2632
|
+
case "readOnly":
|
|
2633
|
+
const isEditable = await state.element.isEditable();
|
|
2634
|
+
val = String(!isEditable);
|
|
2635
|
+
break;
|
|
2636
|
+
case "innerHTML":
|
|
2637
|
+
val = String(await state.element.innerHTML());
|
|
2638
|
+
break;
|
|
2639
|
+
case "outerHTML":
|
|
2640
|
+
val = String(await state.element.evaluate((element) => element.outerHTML));
|
|
2641
|
+
break;
|
|
2642
|
+
default:
|
|
2643
|
+
if (property.startsWith("dataset.")) {
|
|
2644
|
+
const dataAttribute = property.substring(8);
|
|
2645
|
+
val = String(await state.element.getAttribute(`data-${dataAttribute}`)) || "";
|
|
2646
|
+
}
|
|
2647
|
+
else {
|
|
2648
|
+
val = String(await state.element.evaluate((element, prop) => element[prop], property));
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
// Helper function to remove all style="" attributes
|
|
2652
|
+
const removeStyleAttributes = (htmlString) => {
|
|
2653
|
+
return htmlString.replace(/\s*style\s*=\s*"[^"]*"/gi, "");
|
|
2654
|
+
};
|
|
2655
|
+
// Remove style attributes for innerHTML and outerHTML properties
|
|
2656
|
+
if (property === "innerHTML" || property === "outerHTML") {
|
|
2657
|
+
val = removeStyleAttributes(val);
|
|
2658
|
+
expectedValue = removeStyleAttributes(expectedValue);
|
|
2659
|
+
}
|
|
2660
|
+
state.info.value = val;
|
|
2661
|
+
let regex;
|
|
2662
|
+
state.info.value = val;
|
|
2663
|
+
const isRegex = expectedValue.startsWith("regex:");
|
|
2664
|
+
const isContains = expectedValue.startsWith("contains:");
|
|
2665
|
+
const isExact = expectedValue.startsWith("exact:");
|
|
2666
|
+
let matchPassed = false;
|
|
2667
|
+
if (isRegex) {
|
|
2668
|
+
const rawPattern = expectedValue.slice(6); // remove "regex:"
|
|
2669
|
+
const lastSlashIndex = rawPattern.lastIndexOf("/");
|
|
2670
|
+
if (rawPattern.startsWith("/") && lastSlashIndex > 0) {
|
|
2671
|
+
const patternBody = rawPattern.slice(1, lastSlashIndex).replace(/\n/g, ".*");
|
|
2672
|
+
const flags = rawPattern.slice(lastSlashIndex + 1) || "gs";
|
|
2673
|
+
const regex = new RegExp(patternBody, flags);
|
|
2674
|
+
state.info.regex = true;
|
|
2675
|
+
matchPassed = regex.test(val);
|
|
2676
|
+
}
|
|
2677
|
+
else {
|
|
2678
|
+
// Fallback: treat as literal
|
|
2679
|
+
const escapedPattern = rawPattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2680
|
+
const regex = new RegExp(escapedPattern, "g");
|
|
2681
|
+
matchPassed = regex.test(val);
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
else if (isContains) {
|
|
2685
|
+
const containsValue = expectedValue.slice(9); // remove "contains:"
|
|
2686
|
+
matchPassed = val.includes(containsValue);
|
|
2687
|
+
}
|
|
2688
|
+
else if (isExact) {
|
|
2689
|
+
const exactValue = expectedValue.slice(6); // remove "exact:"
|
|
2690
|
+
matchPassed = val === exactValue;
|
|
2691
|
+
}
|
|
2692
|
+
else if (property === "innerText") {
|
|
2693
|
+
// Default innerText logic
|
|
2694
|
+
const normalizedExpectedValue = expectedValue.replace(/\\n/g, "\n");
|
|
2695
|
+
const valLines = val.split("\n");
|
|
2696
|
+
const expectedLines = normalizedExpectedValue.split("\n");
|
|
2697
|
+
matchPassed = expectedLines.every((expectedLine) => valLines.some((valLine) => valLine.trim() === expectedLine.trim()));
|
|
2698
|
+
}
|
|
2699
|
+
else {
|
|
2700
|
+
// Fallback exact or loose match
|
|
2701
|
+
const escapedPattern = expectedValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2702
|
+
const regex = new RegExp(escapedPattern, "g");
|
|
2703
|
+
matchPassed = regex.test(val);
|
|
2704
|
+
}
|
|
2705
|
+
if (!matchPassed) {
|
|
2706
|
+
let errorMessage = `The ${property} property has a value of "${val}", but the expected value is "${expectedValue}"`;
|
|
2707
|
+
state.info.failCause.assertionFailed = true;
|
|
2708
|
+
state.info.failCause.lastError = errorMessage;
|
|
2709
|
+
throw new Error(errorMessage);
|
|
2710
|
+
}
|
|
2711
|
+
return state.info;
|
|
2712
|
+
}
|
|
2713
|
+
catch (e) {
|
|
2714
|
+
await _commandError(state, e, this);
|
|
2715
|
+
}
|
|
2716
|
+
finally {
|
|
2717
|
+
await _commandFinally(state, this);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
async conditionalWait(selectors, condition, timeout = 1000, _params = null, options = {}, world = null) {
|
|
2721
|
+
// Convert timeout from seconds to milliseconds
|
|
2722
|
+
const timeoutMs = timeout * 1000;
|
|
2723
|
+
const state = {
|
|
2724
|
+
selectors,
|
|
2725
|
+
_params,
|
|
2726
|
+
condition,
|
|
2727
|
+
timeout: timeoutMs, // Store as milliseconds for internal use
|
|
2728
|
+
options,
|
|
2729
|
+
world,
|
|
2730
|
+
type: Types.CONDITIONAL_WAIT,
|
|
2731
|
+
highlight: true,
|
|
2732
|
+
screenshot: true,
|
|
2733
|
+
text: `Conditional wait for element`,
|
|
2734
|
+
_text: `Wait for ${selectors.element_name} to be ${condition} (timeout: ${timeout}s)`, // Display original seconds
|
|
2735
|
+
operation: "conditionalWait",
|
|
2736
|
+
log: `***** conditional wait for ${condition} on ${selectors.element_name} *****\n`,
|
|
2737
|
+
allowDisabled: true,
|
|
2738
|
+
info: {},
|
|
2739
|
+
};
|
|
2740
|
+
state.options ??= { timeout: timeoutMs };
|
|
2741
|
+
// Initialize startTime outside try block to ensure it's always accessible
|
|
2742
|
+
const startTime = Date.now();
|
|
2743
|
+
let conditionMet = false;
|
|
2744
|
+
let currentValue = null;
|
|
2745
|
+
let lastError = null;
|
|
2746
|
+
// Main retry loop - continues until timeout or condition is met
|
|
2747
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
2748
|
+
const elapsedTime = Date.now() - startTime;
|
|
2749
|
+
const remainingTime = timeoutMs - elapsedTime;
|
|
2750
|
+
try {
|
|
2751
|
+
// Try to execute _preCommand (element location)
|
|
2752
|
+
await _preCommand(state, this);
|
|
2753
|
+
// If _preCommand succeeds, start condition checking
|
|
2754
|
+
const checkCondition = async () => {
|
|
2755
|
+
try {
|
|
2756
|
+
switch (condition.toLowerCase()) {
|
|
2757
|
+
case "checked":
|
|
2758
|
+
currentValue = await state.element.isChecked();
|
|
2759
|
+
return currentValue === true;
|
|
2760
|
+
case "unchecked":
|
|
2761
|
+
currentValue = await state.element.isChecked();
|
|
2762
|
+
return currentValue === false;
|
|
2763
|
+
case "visible":
|
|
2764
|
+
currentValue = await state.element.isVisible();
|
|
2765
|
+
return currentValue === true;
|
|
2766
|
+
case "hidden":
|
|
2767
|
+
currentValue = await state.element.isVisible();
|
|
2768
|
+
return currentValue === false;
|
|
2769
|
+
case "enabled":
|
|
2770
|
+
currentValue = await state.element.isDisabled();
|
|
2771
|
+
return currentValue === false;
|
|
2772
|
+
case "disabled":
|
|
2773
|
+
currentValue = await state.element.isDisabled();
|
|
2774
|
+
return currentValue === true;
|
|
2775
|
+
case "editable":
|
|
2776
|
+
// currentValue = await String(await state.element.evaluate((element, prop) => element[prop], "isContentEditable"));
|
|
2777
|
+
currentValue = await state.element.isContentEditable();
|
|
2778
|
+
return currentValue === true;
|
|
2779
|
+
default:
|
|
2780
|
+
state.info.message = `Unsupported condition: '${condition}'. Supported conditions are: checked, unchecked, visible, hidden, enabled, disabled, editable.`;
|
|
2781
|
+
state.info.success = false;
|
|
2782
|
+
return false;
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
catch (error) {
|
|
2786
|
+
// Don't throw here, just return false to continue retrying
|
|
2787
|
+
return false;
|
|
2788
|
+
}
|
|
2789
|
+
};
|
|
2790
|
+
// Inner loop for condition checking (once element is located)
|
|
2791
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
2792
|
+
const currentElapsedTime = Date.now() - startTime;
|
|
2793
|
+
conditionMet = await checkCondition();
|
|
2794
|
+
if (conditionMet) {
|
|
2795
|
+
break;
|
|
2796
|
+
}
|
|
2797
|
+
// Check if we still have time for another attempt
|
|
2798
|
+
if (Date.now() - startTime + 50 < timeoutMs) {
|
|
2799
|
+
await new Promise((res) => setTimeout(res, 50));
|
|
2800
|
+
}
|
|
2801
|
+
else {
|
|
2802
|
+
break;
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
// If we got here and condition is met, break out of main loop
|
|
2806
|
+
if (conditionMet) {
|
|
2807
|
+
break;
|
|
2808
|
+
}
|
|
2809
|
+
// If condition not met but no exception, we've timed out
|
|
2810
|
+
break;
|
|
2811
|
+
}
|
|
2812
|
+
catch (e) {
|
|
2813
|
+
lastError = e;
|
|
2814
|
+
const currentElapsedTime = Date.now() - startTime;
|
|
2815
|
+
const timeLeft = timeoutMs - currentElapsedTime;
|
|
2816
|
+
// Check if we have enough time left to retry
|
|
2817
|
+
if (timeLeft > 100) {
|
|
2818
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
2819
|
+
}
|
|
2820
|
+
else {
|
|
2821
|
+
break;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
const actualWaitTime = Date.now() - startTime;
|
|
2826
|
+
state.info = {
|
|
2827
|
+
success: conditionMet,
|
|
2828
|
+
conditionMet,
|
|
2829
|
+
actualWaitTime,
|
|
2830
|
+
currentValue,
|
|
2831
|
+
lastError: lastError?.message || null,
|
|
2832
|
+
message: conditionMet
|
|
2833
|
+
? `Condition '${condition}' met after ${(actualWaitTime / 1000).toFixed(2)}s`
|
|
2834
|
+
: `Condition '${condition}' not met within ${timeout}s timeout`,
|
|
2835
|
+
};
|
|
2836
|
+
if (lastError) {
|
|
2837
|
+
state.log += `Last error: ${lastError.message}\n`;
|
|
2838
|
+
}
|
|
2839
|
+
try {
|
|
2840
|
+
await _commandFinally(state, this);
|
|
2841
|
+
}
|
|
2842
|
+
catch (finallyError) {
|
|
2843
|
+
state.log += `Error in _commandFinally: ${finallyError.message}\n`;
|
|
2844
|
+
}
|
|
2845
|
+
return state.info;
|
|
2846
|
+
}
|
|
2235
2847
|
async extractEmailData(emailAddress, options, world) {
|
|
2236
2848
|
if (!emailAddress) {
|
|
2237
2849
|
throw new Error("email address is null");
|
|
@@ -2828,6 +3440,8 @@ class StableBrowser {
|
|
|
2828
3440
|
operation: "verify_text_with_relation",
|
|
2829
3441
|
log: "***** search for " + textAnchor + " climb " + climb + " and verify " + textToVerify + " found *****\n",
|
|
2830
3442
|
};
|
|
3443
|
+
const cmdStartTime = Date.now();
|
|
3444
|
+
let cmdEndTime = null;
|
|
2831
3445
|
const timeout = this._getFindElementTimeout(options);
|
|
2832
3446
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
2833
3447
|
let newValue = await this._replaceWithLocalData(textAnchor, world);
|
|
@@ -2863,6 +3477,17 @@ class StableBrowser {
|
|
|
2863
3477
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
2864
3478
|
continue;
|
|
2865
3479
|
}
|
|
3480
|
+
else {
|
|
3481
|
+
cmdEndTime = Date.now();
|
|
3482
|
+
if (cmdEndTime - cmdStartTime > 55000) {
|
|
3483
|
+
if (foundAncore) {
|
|
3484
|
+
throw new Error(`Text ${textToVerify} not found in page`);
|
|
3485
|
+
}
|
|
3486
|
+
else {
|
|
3487
|
+
throw new Error(`Text ${textAnchor} not found in page`);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
}
|
|
2866
3491
|
try {
|
|
2867
3492
|
for (let i = 0; i < resultWithElementsFound.length; i++) {
|
|
2868
3493
|
foundAncore = true;
|
|
@@ -3262,6 +3887,43 @@ class StableBrowser {
|
|
|
3262
3887
|
});
|
|
3263
3888
|
}
|
|
3264
3889
|
}
|
|
3890
|
+
/**
|
|
3891
|
+
* Explicit wait/sleep function that pauses execution for a specified duration
|
|
3892
|
+
* @param duration - Duration to sleep in milliseconds (default: 1000ms)
|
|
3893
|
+
* @param options - Optional configuration object
|
|
3894
|
+
* @param world - Optional world context
|
|
3895
|
+
* @returns Promise that resolves after the specified duration
|
|
3896
|
+
*/
|
|
3897
|
+
async sleep(duration = 1000, options = {}, world = null) {
|
|
3898
|
+
const state = {
|
|
3899
|
+
duration,
|
|
3900
|
+
options,
|
|
3901
|
+
world,
|
|
3902
|
+
locate: false,
|
|
3903
|
+
scroll: false,
|
|
3904
|
+
screenshot: false,
|
|
3905
|
+
highlight: false,
|
|
3906
|
+
type: Types.SLEEP,
|
|
3907
|
+
text: `Sleep for ${duration} ms`,
|
|
3908
|
+
_text: `Sleep for ${duration} ms`,
|
|
3909
|
+
operation: "sleep",
|
|
3910
|
+
log: `***** Sleep for ${duration} ms *****\n`,
|
|
3911
|
+
};
|
|
3912
|
+
try {
|
|
3913
|
+
await _preCommand(state, this);
|
|
3914
|
+
if (duration < 0) {
|
|
3915
|
+
throw new Error("Sleep duration cannot be negative");
|
|
3916
|
+
}
|
|
3917
|
+
await new Promise((resolve) => setTimeout(resolve, duration));
|
|
3918
|
+
return state.info;
|
|
3919
|
+
}
|
|
3920
|
+
catch (e) {
|
|
3921
|
+
await _commandError(state, e, this);
|
|
3922
|
+
}
|
|
3923
|
+
finally {
|
|
3924
|
+
await _commandFinally(state, this);
|
|
3925
|
+
}
|
|
3926
|
+
}
|
|
3265
3927
|
async _replaceWithLocalData(value, world, _decrypt = true, totpWait = true) {
|
|
3266
3928
|
try {
|
|
3267
3929
|
return await replaceWithLocalTestData(value, world, _decrypt, totpWait, this.context, this);
|
|
@@ -3313,6 +3975,22 @@ class StableBrowser {
|
|
|
3313
3975
|
}
|
|
3314
3976
|
}
|
|
3315
3977
|
async waitForPageLoad(options = {}, world = null) {
|
|
3978
|
+
// try {
|
|
3979
|
+
// let currentPagePath = null;
|
|
3980
|
+
// currentPagePath = new URL(this.page.url()).pathname;
|
|
3981
|
+
// if (this.latestPagePath) {
|
|
3982
|
+
// // get the currect page path and compare with the latest page path
|
|
3983
|
+
// if (this.latestPagePath === currentPagePath) {
|
|
3984
|
+
// // if the page path is the same, do not wait for page load
|
|
3985
|
+
// console.log("No page change: " + currentPagePath);
|
|
3986
|
+
// return;
|
|
3987
|
+
// }
|
|
3988
|
+
// }
|
|
3989
|
+
// this.latestPagePath = currentPagePath;
|
|
3990
|
+
// } catch (e) {
|
|
3991
|
+
// console.debug("Error getting current page path: ", e);
|
|
3992
|
+
// }
|
|
3993
|
+
//console.log("Waiting for page load");
|
|
3316
3994
|
let timeout = this._getLoadTimeout(options);
|
|
3317
3995
|
const promiseArray = [];
|
|
3318
3996
|
// let waitForNetworkIdle = true;
|
|
@@ -3345,10 +4023,12 @@ class StableBrowser {
|
|
|
3345
4023
|
else if (e.label === "domcontentloaded") {
|
|
3346
4024
|
console.log("waited for the domcontent loaded timeout");
|
|
3347
4025
|
}
|
|
3348
|
-
console.log(".");
|
|
3349
4026
|
}
|
|
3350
4027
|
finally {
|
|
3351
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
4028
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
4029
|
+
if (options && !options.noSleep) {
|
|
4030
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
4031
|
+
}
|
|
3352
4032
|
({ screenshotId, screenshotPath } = await this._screenShot(options, world));
|
|
3353
4033
|
const endTime = Date.now();
|
|
3354
4034
|
_reportToWorld(world, {
|
|
@@ -3389,7 +4069,6 @@ class StableBrowser {
|
|
|
3389
4069
|
await this.page.close();
|
|
3390
4070
|
}
|
|
3391
4071
|
catch (e) {
|
|
3392
|
-
console.log(".");
|
|
3393
4072
|
await _commandError(state, e, this);
|
|
3394
4073
|
}
|
|
3395
4074
|
finally {
|
|
@@ -3403,7 +4082,7 @@ class StableBrowser {
|
|
|
3403
4082
|
}
|
|
3404
4083
|
operation = options.operation;
|
|
3405
4084
|
// validate operation is one of the supported operations
|
|
3406
|
-
if (operation != "click" && operation != "hover+click") {
|
|
4085
|
+
if (operation != "click" && operation != "hover+click" && operation != "hover") {
|
|
3407
4086
|
throw new Error("operation is not supported");
|
|
3408
4087
|
}
|
|
3409
4088
|
const state = {
|
|
@@ -3472,6 +4151,17 @@ class StableBrowser {
|
|
|
3472
4151
|
state.element = results[0];
|
|
3473
4152
|
await performAction("hover+click", state.element, options, this, state, _params);
|
|
3474
4153
|
break;
|
|
4154
|
+
case "hover":
|
|
4155
|
+
if (!options.css) {
|
|
4156
|
+
throw new Error("css is not defined");
|
|
4157
|
+
}
|
|
4158
|
+
const result1 = await findElementsInArea(options.css, cellArea, this, options);
|
|
4159
|
+
if (result1.length === 0) {
|
|
4160
|
+
throw new Error(`Element not found in cell area`);
|
|
4161
|
+
}
|
|
4162
|
+
state.element = result1[0];
|
|
4163
|
+
await performAction("hover", state.element, options, this, state, _params);
|
|
4164
|
+
break;
|
|
3475
4165
|
default:
|
|
3476
4166
|
throw new Error("operation is not supported");
|
|
3477
4167
|
}
|
|
@@ -3504,7 +4194,6 @@ class StableBrowser {
|
|
|
3504
4194
|
await this.page.setViewportSize({ width: width, height: hight });
|
|
3505
4195
|
}
|
|
3506
4196
|
catch (e) {
|
|
3507
|
-
console.log(".");
|
|
3508
4197
|
await _commandError({ text: "setViewportSize", operation: "setViewportSize", width, hight, info }, e, this);
|
|
3509
4198
|
}
|
|
3510
4199
|
finally {
|
|
@@ -3542,7 +4231,6 @@ class StableBrowser {
|
|
|
3542
4231
|
await this.page.reload();
|
|
3543
4232
|
}
|
|
3544
4233
|
catch (e) {
|
|
3545
|
-
console.log(".");
|
|
3546
4234
|
await _commandError({ text: "reloadPage", operation: "reloadPage", info }, e, this);
|
|
3547
4235
|
}
|
|
3548
4236
|
finally {
|
|
@@ -3586,6 +4274,10 @@ class StableBrowser {
|
|
|
3586
4274
|
}
|
|
3587
4275
|
}
|
|
3588
4276
|
async beforeScenario(world, scenario) {
|
|
4277
|
+
if (world && world.attach) {
|
|
4278
|
+
world.attach(this.context.reportFolder, { mediaType: "text/plain" });
|
|
4279
|
+
}
|
|
4280
|
+
this.context.loadedRoutes = null;
|
|
3589
4281
|
this.beforeScenarioCalled = true;
|
|
3590
4282
|
if (scenario && scenario.pickle && scenario.pickle.name) {
|
|
3591
4283
|
this.scenarioName = scenario.pickle.name;
|
|
@@ -3609,36 +4301,15 @@ class StableBrowser {
|
|
|
3609
4301
|
envName = this.context.environment.name;
|
|
3610
4302
|
}
|
|
3611
4303
|
if (!process.env.TEMP_RUN) {
|
|
3612
|
-
await getTestData(envName, world, undefined, this.featureName, this.scenarioName);
|
|
4304
|
+
await getTestData(envName, world, undefined, this.featureName, this.scenarioName, this.context);
|
|
3613
4305
|
}
|
|
3614
4306
|
await loadBrunoParams(this.context, this.context.environment.name);
|
|
3615
4307
|
}
|
|
3616
|
-
async afterScenario(world, scenario) {
|
|
3617
|
-
const state = {
|
|
3618
|
-
world,
|
|
3619
|
-
locate: false,
|
|
3620
|
-
scroll: false,
|
|
3621
|
-
screenshot: true,
|
|
3622
|
-
highlight: true,
|
|
3623
|
-
type: Types.STEP_COMPLETE,
|
|
3624
|
-
text: "end of scenario",
|
|
3625
|
-
_text: "end of scenario",
|
|
3626
|
-
operation: "step_complete",
|
|
3627
|
-
log: "***** " + "end of scenario" + " *****\n",
|
|
3628
|
-
};
|
|
3629
|
-
try {
|
|
3630
|
-
await _preCommand(state, this);
|
|
3631
|
-
}
|
|
3632
|
-
catch (e) {
|
|
3633
|
-
await _commandError(state, e, this);
|
|
3634
|
-
}
|
|
3635
|
-
finally {
|
|
3636
|
-
await _commandFinally(state, this);
|
|
3637
|
-
}
|
|
3638
|
-
}
|
|
4308
|
+
async afterScenario(world, scenario) { }
|
|
3639
4309
|
async beforeStep(world, step) {
|
|
3640
4310
|
if (!this.beforeScenarioCalled) {
|
|
3641
4311
|
this.beforeScenario(world, step);
|
|
4312
|
+
this.context.loadedRoutes = null;
|
|
3642
4313
|
}
|
|
3643
4314
|
if (this.stepIndex === undefined) {
|
|
3644
4315
|
this.stepIndex = 0;
|
|
@@ -3648,7 +4319,12 @@ class StableBrowser {
|
|
|
3648
4319
|
}
|
|
3649
4320
|
if (step && step.pickleStep && step.pickleStep.text) {
|
|
3650
4321
|
this.stepName = step.pickleStep.text;
|
|
3651
|
-
|
|
4322
|
+
let printableStepName = this.stepName;
|
|
4323
|
+
// take the printableStepName and replace quated value with \x1b[33m and \x1b[0m
|
|
4324
|
+
printableStepName = printableStepName.replace(/"([^"]*)"/g, (match, p1) => {
|
|
4325
|
+
return `\x1b[33m"${p1}"\x1b[0m`;
|
|
4326
|
+
});
|
|
4327
|
+
this.logger.info("\x1b[38;5;208mstep:\x1b[0m " + printableStepName);
|
|
3652
4328
|
}
|
|
3653
4329
|
else if (step && step.text) {
|
|
3654
4330
|
this.stepName = step.text;
|
|
@@ -3663,13 +4339,16 @@ class StableBrowser {
|
|
|
3663
4339
|
}
|
|
3664
4340
|
if (this.initSnapshotTaken === false) {
|
|
3665
4341
|
this.initSnapshotTaken = true;
|
|
3666
|
-
if (world && world.attach && !process.env.DISABLE_SNAPSHOT) {
|
|
4342
|
+
if (world && world.attach && !process.env.DISABLE_SNAPSHOT && !this.fastMode) {
|
|
3667
4343
|
const snapshot = await this.getAriaSnapshot();
|
|
3668
4344
|
if (snapshot) {
|
|
3669
4345
|
await world.attach(JSON.stringify(snapshot), "application/json+snapshot-before");
|
|
3670
4346
|
}
|
|
3671
4347
|
}
|
|
3672
4348
|
}
|
|
4349
|
+
this.context.routeResults = null;
|
|
4350
|
+
await registerBeforeStepRoutes(this.context, this.stepName);
|
|
4351
|
+
networkBeforeStep(this.stepName);
|
|
3673
4352
|
}
|
|
3674
4353
|
async getAriaSnapshot() {
|
|
3675
4354
|
try {
|
|
@@ -3689,12 +4368,18 @@ class StableBrowser {
|
|
|
3689
4368
|
try {
|
|
3690
4369
|
// Ensure frame is attached and has body
|
|
3691
4370
|
const body = frame.locator("body");
|
|
3692
|
-
await body.waitFor({ timeout:
|
|
4371
|
+
//await body.waitFor({ timeout: 2000 }); // wait explicitly
|
|
3693
4372
|
const snapshot = await body.ariaSnapshot({ timeout });
|
|
4373
|
+
if (!snapshot) {
|
|
4374
|
+
continue;
|
|
4375
|
+
}
|
|
3694
4376
|
content.push(`- frame: ${i}`);
|
|
3695
4377
|
content.push(snapshot);
|
|
3696
4378
|
}
|
|
3697
|
-
catch (innerErr) {
|
|
4379
|
+
catch (innerErr) {
|
|
4380
|
+
console.warn(`Frame ${i} snapshot failed:`, innerErr);
|
|
4381
|
+
content.push(`- frame: ${i} - error: ${innerErr.message}`);
|
|
4382
|
+
}
|
|
3698
4383
|
}
|
|
3699
4384
|
return content.join("\n");
|
|
3700
4385
|
}
|
|
@@ -3766,13 +4451,43 @@ class StableBrowser {
|
|
|
3766
4451
|
if (this.context) {
|
|
3767
4452
|
this.context.examplesRow = null;
|
|
3768
4453
|
}
|
|
3769
|
-
if (world && world.attach && !process.env.DISABLE_SNAPSHOT) {
|
|
4454
|
+
if (world && world.attach && !process.env.DISABLE_SNAPSHOT && !this.fastMode) {
|
|
3770
4455
|
const snapshot = await this.getAriaSnapshot();
|
|
3771
4456
|
if (snapshot) {
|
|
3772
4457
|
const obj = {};
|
|
3773
4458
|
await world.attach(JSON.stringify(snapshot), "application/json+snapshot-after");
|
|
3774
4459
|
}
|
|
3775
4460
|
}
|
|
4461
|
+
this.context.routeResults = await registerAfterStepRoutes(this.context, world);
|
|
4462
|
+
if (this.context.routeResults) {
|
|
4463
|
+
if (world && world.attach) {
|
|
4464
|
+
await world.attach(JSON.stringify(this.context.routeResults), "application/json+intercept-results");
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
if (!process.env.TEMP_RUN) {
|
|
4468
|
+
const state = {
|
|
4469
|
+
world,
|
|
4470
|
+
locate: false,
|
|
4471
|
+
scroll: false,
|
|
4472
|
+
screenshot: true,
|
|
4473
|
+
highlight: true,
|
|
4474
|
+
type: Types.STEP_COMPLETE,
|
|
4475
|
+
text: "end of scenario",
|
|
4476
|
+
_text: "end of scenario",
|
|
4477
|
+
operation: "step_complete",
|
|
4478
|
+
log: "***** " + "end of scenario" + " *****\n",
|
|
4479
|
+
};
|
|
4480
|
+
try {
|
|
4481
|
+
await _preCommand(state, this);
|
|
4482
|
+
}
|
|
4483
|
+
catch (e) {
|
|
4484
|
+
await _commandError(state, e, this);
|
|
4485
|
+
}
|
|
4486
|
+
finally {
|
|
4487
|
+
await _commandFinally(state, this);
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
networkAfterStep(this.stepName);
|
|
3776
4491
|
}
|
|
3777
4492
|
}
|
|
3778
4493
|
function createTimedPromise(promise, label) {
|