automation_model 1.0.626-dev → 1.0.626-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 +130 -0
- package/lib/api.js +35 -21
- package/lib/api.js.map +1 -1
- package/lib/auto_page.d.ts +1 -1
- package/lib/auto_page.js +99 -28
- package/lib/auto_page.js.map +1 -1
- package/lib/browser_manager.js +68 -23
- package/lib/browser_manager.js.map +1 -1
- package/lib/bruno.d.ts +2 -0
- package/lib/bruno.js +381 -0
- package/lib/bruno.js.map +1 -0
- package/lib/command_common.d.ts +4 -4
- package/lib/command_common.js +33 -16
- package/lib/command_common.js.map +1 -1
- package/lib/environment.d.ts +1 -0
- package/lib/environment.js +1 -0
- package/lib/environment.js.map +1 -1
- package/lib/file_checker.d.ts +1 -0
- package/lib/file_checker.js +61 -0
- package/lib/file_checker.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/init_browser.d.ts +2 -2
- package/lib/init_browser.js +33 -27
- package/lib/init_browser.js.map +1 -1
- package/lib/locate_element.js +2 -2
- package/lib/locate_element.js.map +1 -1
- package/lib/network.d.ts +1 -1
- package/lib/network.js +5 -5
- package/lib/network.js.map +1 -1
- package/lib/snapshot_validation.d.ts +37 -0
- package/lib/snapshot_validation.js +280 -0
- package/lib/snapshot_validation.js.map +1 -0
- package/lib/stable_browser.d.ts +20 -1
- package/lib/stable_browser.js +587 -108
- package/lib/stable_browser.js.map +1 -1
- package/lib/table_helper.d.ts +19 -0
- package/lib/table_helper.js +116 -0
- package/lib/table_helper.js.map +1 -0
- package/lib/test_context.d.ts +2 -0
- package/lib/test_context.js +2 -0
- package/lib/test_context.js.map +1 -1
- package/lib/utils.d.ts +8 -4
- package/lib/utils.js +221 -20
- package/lib/utils.js.map +1 -1
- package/package.json +9 -8
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
export async function highlightSnapshot(snapshot, scope) { }
|
|
2
|
+
/*
|
|
3
|
+
- banner:
|
|
4
|
+
- heading "Shop NOW" [level=6]
|
|
5
|
+
- text: Log In Username
|
|
6
|
+
- textbox "Username"
|
|
7
|
+
- text: Password
|
|
8
|
+
- textbox "Password"
|
|
9
|
+
- button "Login"
|
|
10
|
+
- paragraph: "Accepted usernames are:"
|
|
11
|
+
- list:
|
|
12
|
+
- listitem:
|
|
13
|
+
- paragraph: blinq_user
|
|
14
|
+
- listitem:
|
|
15
|
+
- paragraph: blinq_admin
|
|
16
|
+
- paragraph: "Password for all users:"
|
|
17
|
+
- paragraph: let_me_in
|
|
18
|
+
*/
|
|
19
|
+
class SnapshotNode {
|
|
20
|
+
key;
|
|
21
|
+
value;
|
|
22
|
+
role;
|
|
23
|
+
name;
|
|
24
|
+
children = [];
|
|
25
|
+
parent = null;
|
|
26
|
+
constructor(key, value) {
|
|
27
|
+
this.key = key;
|
|
28
|
+
this.value = value;
|
|
29
|
+
if (!key) {
|
|
30
|
+
throw new Error("Key cannot be null or undefined");
|
|
31
|
+
}
|
|
32
|
+
this.role = key.split(" ")[0];
|
|
33
|
+
if (this.value) {
|
|
34
|
+
this.name = this.value;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// the value will be from the first " to the last "
|
|
38
|
+
const start = key.indexOf('"') + 1;
|
|
39
|
+
const end = key.lastIndexOf('"');
|
|
40
|
+
if (start > -1 && end > -1 && start < end) {
|
|
41
|
+
this.name = key.substring(start, end);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.name = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
generateNodeLocator() {
|
|
49
|
+
let locator = `internal:role=${this.role}`;
|
|
50
|
+
switch (this.role) {
|
|
51
|
+
case "paragraph":
|
|
52
|
+
// internal:role=paragraph >> internal:text='blinq_user'"
|
|
53
|
+
return `internal:role=${this.role} >> internal:text='${this.name}'`;
|
|
54
|
+
default:
|
|
55
|
+
// "internal:role=textbox[name=\"Password\"]"
|
|
56
|
+
if (this.name) {
|
|
57
|
+
locator += `[name="${this.name}"]`;
|
|
58
|
+
}
|
|
59
|
+
return locator;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getFullLocator() {
|
|
63
|
+
// create an array of all the parents and current node locators
|
|
64
|
+
const locators = [];
|
|
65
|
+
let currentNode = this;
|
|
66
|
+
while (currentNode) {
|
|
67
|
+
locators.unshift(currentNode.generateNodeLocator());
|
|
68
|
+
currentNode = currentNode.parent;
|
|
69
|
+
}
|
|
70
|
+
// join the locators with " >> "
|
|
71
|
+
return locators.join(" >> ");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function fromLinesToSnapshotLines(lines) {
|
|
75
|
+
// the input is yaml text split into lines, 2 spaces is 1 level
|
|
76
|
+
const nodes = [];
|
|
77
|
+
// identify the space count for tabulation
|
|
78
|
+
let previouseLineSpaceCount = -1;
|
|
79
|
+
let foundTabulationCount = -1;
|
|
80
|
+
// look for 2 consecutive lines that have different space counts, the absolute difference is the space count for tabulation
|
|
81
|
+
for (let i = 0; i < lines.length; i++) {
|
|
82
|
+
const line = lines[i];
|
|
83
|
+
const trimmedLine = line.trim();
|
|
84
|
+
if (trimmedLine.length === 0) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// count the number of leading spaces
|
|
88
|
+
const match = line.match(/^ */); // Matches spaces at the beginning
|
|
89
|
+
const count = match ? match[0].length : 0;
|
|
90
|
+
if (previouseLineSpaceCount !== -1 && previouseLineSpaceCount !== count) {
|
|
91
|
+
foundTabulationCount = Math.abs(previouseLineSpaceCount - count);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
previouseLineSpaceCount = count;
|
|
95
|
+
}
|
|
96
|
+
if (foundTabulationCount === -1) {
|
|
97
|
+
foundTabulationCount = 2;
|
|
98
|
+
}
|
|
99
|
+
for (let i = 0; i < lines.length; i++) {
|
|
100
|
+
const line = lines[i];
|
|
101
|
+
const trimmedLine = line.trim();
|
|
102
|
+
if (trimmedLine.length === 0) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
// count the number of leading spaces
|
|
106
|
+
let level = 0;
|
|
107
|
+
const match = line.match(/^ */); // Matches spaces at the beginning
|
|
108
|
+
const count = match ? match[0].length : 0;
|
|
109
|
+
level = count / foundTabulationCount; // 2 spaces is 1 level
|
|
110
|
+
// find the start of the line: - and space
|
|
111
|
+
const start = line.indexOf("- ") + 2;
|
|
112
|
+
if (start === -1) {
|
|
113
|
+
// no - found, set it to error
|
|
114
|
+
nodes.push({
|
|
115
|
+
line: i,
|
|
116
|
+
line_text: line,
|
|
117
|
+
key: line,
|
|
118
|
+
value: null,
|
|
119
|
+
level,
|
|
120
|
+
error: "No - found",
|
|
121
|
+
regex: false,
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
// first we need to extract the role, we should find the first space or : after the start
|
|
126
|
+
const end = line.indexOf(" ", start);
|
|
127
|
+
const end2 = line.indexOf(":", start);
|
|
128
|
+
if (end === -1 && end2 === -1) {
|
|
129
|
+
// no space or : found, set it to error
|
|
130
|
+
nodes.push({
|
|
131
|
+
line: i,
|
|
132
|
+
line_text: line,
|
|
133
|
+
key: line,
|
|
134
|
+
value: null,
|
|
135
|
+
level,
|
|
136
|
+
error: "No space or : found",
|
|
137
|
+
regex: false,
|
|
138
|
+
});
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const endIndex = end === -1 ? end2 : end2 === -1 ? end : Math.min(end, end2);
|
|
142
|
+
const key = line.substring(start, endIndex).trim();
|
|
143
|
+
// define value is string or null
|
|
144
|
+
let value = line.substring(endIndex + 1).trim();
|
|
145
|
+
if (value.startsWith('"')) {
|
|
146
|
+
const lastQuote = value.lastIndexOf('"');
|
|
147
|
+
if (lastQuote !== -1) {
|
|
148
|
+
value = value.substring(0, lastQuote + 1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// improved regex detection
|
|
152
|
+
const rawValue = value.endsWith(":") ? value.slice(0, -1) : value;
|
|
153
|
+
const regex = rawValue.startsWith("/") && /\/[a-z]*$/.test(rawValue);
|
|
154
|
+
nodes.push({
|
|
155
|
+
line: i,
|
|
156
|
+
line_text: line,
|
|
157
|
+
key,
|
|
158
|
+
value: value.length > 0 ? value : null,
|
|
159
|
+
level,
|
|
160
|
+
error: null,
|
|
161
|
+
regex,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return nodes;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Turn a “/pattern/flags” string into a real RegExp.
|
|
168
|
+
*/
|
|
169
|
+
function toRegExp(raw) {
|
|
170
|
+
// Remove trailing colon from YAML-style key: /pattern/: → /pattern/
|
|
171
|
+
const sanitized = raw.endsWith(":") ? raw.slice(0, -1) : raw;
|
|
172
|
+
if (!sanitized.startsWith("/"))
|
|
173
|
+
return new RegExp(sanitized);
|
|
174
|
+
const lastSlash = sanitized.lastIndexOf("/");
|
|
175
|
+
const pattern = sanitized.slice(1, lastSlash);
|
|
176
|
+
const flags = sanitized.slice(lastSlash + 1); // i, g, etc.
|
|
177
|
+
return new RegExp(pattern, flags);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Single-line comparison with fixed regex handling.
|
|
181
|
+
*/
|
|
182
|
+
function lineMatches(full, sub) {
|
|
183
|
+
let status = { status: false };
|
|
184
|
+
if (full.key !== sub.key)
|
|
185
|
+
return status;
|
|
186
|
+
// We handle level offset outside this function
|
|
187
|
+
if (sub.value === null) {
|
|
188
|
+
status.status = true;
|
|
189
|
+
return status;
|
|
190
|
+
}
|
|
191
|
+
if (sub.regex) {
|
|
192
|
+
status.status = toRegExp(sub.value).test(full.value ?? "");
|
|
193
|
+
}
|
|
194
|
+
else if (full.regex) {
|
|
195
|
+
status.status = toRegExp(full.value).test(sub.value ?? "");
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
status.status = full.value === sub.value;
|
|
199
|
+
}
|
|
200
|
+
return status;
|
|
201
|
+
}
|
|
202
|
+
export function snapshotValidation(snapshot, referanceSnapshot, snapshotName) {
|
|
203
|
+
const lines = snapshot.split("\n");
|
|
204
|
+
const nodes = fromLinesToSnapshotLines(lines);
|
|
205
|
+
const subLines = referanceSnapshot.split("\n");
|
|
206
|
+
const subNodes = fromLinesToSnapshotLines(subLines);
|
|
207
|
+
return matchSnapshot(nodes, subNodes, snapshotName);
|
|
208
|
+
}
|
|
209
|
+
export function matchSnapshot(full, sub, snapshotName) {
|
|
210
|
+
const parentIdx = sub.map((_, i) => {
|
|
211
|
+
for (let j = i - 1; j >= 0; j--)
|
|
212
|
+
if (sub[j].level < sub[i].level)
|
|
213
|
+
return j;
|
|
214
|
+
return -1;
|
|
215
|
+
});
|
|
216
|
+
const fullIdx = new Array(sub.length);
|
|
217
|
+
const mapping = new Array(sub.length);
|
|
218
|
+
let failureAt = -1;
|
|
219
|
+
function dfs(s, fFrom, baseLevelOffset) {
|
|
220
|
+
if (s === sub.length)
|
|
221
|
+
return true;
|
|
222
|
+
for (let f = fFrom; f < full.length; f++) {
|
|
223
|
+
let levelMatch = true;
|
|
224
|
+
if (baseLevelOffset !== null) {
|
|
225
|
+
// Must match levels relative to initial offset
|
|
226
|
+
if (full[f].level !== sub[s].level + baseLevelOffset)
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const status = lineMatches(full[f], sub[s]);
|
|
230
|
+
if (!status.status)
|
|
231
|
+
continue;
|
|
232
|
+
// For first match, set level offset
|
|
233
|
+
const nextBaseOffset = baseLevelOffset !== null ? baseLevelOffset : full[f].level - sub[s].level;
|
|
234
|
+
const pSub = parentIdx[s];
|
|
235
|
+
if (pSub !== -1) {
|
|
236
|
+
let pFull = f - 1;
|
|
237
|
+
while (pFull >= 0 && full[pFull].level >= full[f].level)
|
|
238
|
+
pFull--;
|
|
239
|
+
if (pFull < 0 || pFull !== fullIdx[pSub])
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
fullIdx[s] = f;
|
|
243
|
+
mapping[s] = full[f].line;
|
|
244
|
+
if (dfs(s + 1, f + 1, nextBaseOffset))
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
if (failureAt === -1)
|
|
248
|
+
failureAt = s;
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
const found = dfs(0, 0, null);
|
|
252
|
+
let error = null;
|
|
253
|
+
if (!found) {
|
|
254
|
+
error = `Snapshot file: ${snapshotName}\nLine no.: ${sub[failureAt].line}\nLine: ${sub[failureAt].line_text}`;
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
matchingLines: found ? mapping : mapping.slice(0, failureAt),
|
|
258
|
+
errorLine: found ? -1 : failureAt,
|
|
259
|
+
errorLineText: error,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
// let ttt = `- banner:
|
|
263
|
+
// - heading "Shop NOW" [level=6]
|
|
264
|
+
// - text: Log In Username
|
|
265
|
+
// - textbox "Username"
|
|
266
|
+
// - text: Password
|
|
267
|
+
// - textbox "Password"
|
|
268
|
+
// - button "Login"
|
|
269
|
+
// - paragraph: "Accepted usernames are:"
|
|
270
|
+
// - list:
|
|
271
|
+
// - listitem:
|
|
272
|
+
// - paragraph: blinq_user
|
|
273
|
+
// - listitem:
|
|
274
|
+
// - paragraph: blinq_admin
|
|
275
|
+
// - paragraph: "Password for all users:"
|
|
276
|
+
// - paragraph: let_me_in`;
|
|
277
|
+
// const lines = ttt.split("\n");
|
|
278
|
+
// const nodes = fromLinesToSnapshotLines(lines);
|
|
279
|
+
// console.log("nodes", nodes);
|
|
280
|
+
//# sourceMappingURL=snapshot_validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot_validation.js","sourceRoot":"","sources":["../../src/snapshot_validation.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAa,EAAE,KAAU,IAAG,CA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AuB;AACvB,mBAAmB;AACnB,yCAAyC;AACzC,UAAU;AACV,gBAAgB;AAChB,8BAA8B;AAC9B,gBAAgB;AAChB,+BAA+B;AAC/B,yCAAyC;AACzC,2BAA2B;AAC3B,iCAAiC;AACjC,iDAAiD;AACjD,+BAA+B"}
|
package/lib/stable_browser.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Browser, Page } from "playwright";
|
|
|
2
2
|
import { Params } from "./utils.js";
|
|
3
3
|
export declare const Types: {
|
|
4
4
|
CLICK: string;
|
|
5
|
+
WAIT_ELEMENT: string;
|
|
5
6
|
NAVIGATE: string;
|
|
6
7
|
FILL: string;
|
|
7
8
|
EXECUTE: string;
|
|
@@ -23,6 +24,7 @@ export declare const Types: {
|
|
|
23
24
|
UNCHECK: string;
|
|
24
25
|
EXTRACT: string;
|
|
25
26
|
CLOSE_PAGE: string;
|
|
27
|
+
TABLE_OPERATION: string;
|
|
26
28
|
SET_DATE_TIME: string;
|
|
27
29
|
SET_VIEWPORT: string;
|
|
28
30
|
VERIFY_VISUAL: string;
|
|
@@ -31,6 +33,10 @@ export declare const Types: {
|
|
|
31
33
|
WAIT_FOR_TEXT_TO_DISAPPEAR: string;
|
|
32
34
|
VERIFY_ATTRIBUTE: string;
|
|
33
35
|
VERIFY_TEXT_WITH_RELATION: string;
|
|
36
|
+
BRUNO: string;
|
|
37
|
+
VERIFY_FILE_EXISTS: string;
|
|
38
|
+
SET_INPUT_FILES: string;
|
|
39
|
+
SNAPSHOT_VALIDATION: string;
|
|
34
40
|
};
|
|
35
41
|
export declare const apps: {};
|
|
36
42
|
declare class StableBrowser {
|
|
@@ -50,6 +56,7 @@ declare class StableBrowser {
|
|
|
50
56
|
constructor(browser: Browser, page: Page, logger?: any, context?: any, world?: any);
|
|
51
57
|
registerEventListeners(context: any): void;
|
|
52
58
|
switchApp(appName: any): Promise<void>;
|
|
59
|
+
switchTab(tabTitleOrIndex: number | string): Promise<void>;
|
|
53
60
|
registerConsoleLogListener(page: Page, context: any): void;
|
|
54
61
|
registerRequestListener(page: Page, context: any, logFile: string): void;
|
|
55
62
|
goto(url: string, world?: null): Promise<void>;
|
|
@@ -73,6 +80,7 @@ declare class StableBrowser {
|
|
|
73
80
|
simpleClick(elementDescription: any, _params?: Params, options?: {}, world?: null): Promise<void>;
|
|
74
81
|
simpleClickType(elementDescription: any, value: any, _params?: Params, options?: {}, world?: null): Promise<void>;
|
|
75
82
|
click(selectors: any, _params?: Params, options?: {}, world?: null): Promise<any>;
|
|
83
|
+
waitForElement(selectors: any, _params?: Params, options?: {}, world?: null): Promise<boolean>;
|
|
76
84
|
setCheck(selectors: any, checked?: boolean, _params?: Params, options?: {}, world?: null): Promise<any>;
|
|
77
85
|
hover(selectors: any, _params?: Params, options?: {}, world?: null): Promise<any>;
|
|
78
86
|
selectOption(selectors: any, values: any, _params?: null, options?: {}, world?: null): Promise<any>;
|
|
@@ -81,6 +89,7 @@ declare class StableBrowser {
|
|
|
81
89
|
setDateTime(selectors: any, value: any, format?: null, enter?: boolean, _params?: null, options?: {}, world?: null): Promise<void>;
|
|
82
90
|
clickType(selectors: any, _value: any, enter?: boolean, _params?: null, options?: {}, world?: null): Promise<any>;
|
|
83
91
|
fill(selectors: any, value: any, enter?: boolean, _params?: null, options?: {}, world?: null): Promise<any>;
|
|
92
|
+
setInputFiles(selectors: any, files: any, _params?: null, options?: {}, world?: null): Promise<any>;
|
|
84
93
|
getText(selectors: any, _params?: null, options?: {}, info?: {}, world?: null): Promise<{
|
|
85
94
|
text: any;
|
|
86
95
|
screenshotId: any;
|
|
@@ -109,8 +118,10 @@ declare class StableBrowser {
|
|
|
109
118
|
}>;
|
|
110
119
|
containsPattern(selectors: any, pattern: any, text: any, _params?: null, options?: {}, world?: null): Promise<any>;
|
|
111
120
|
containsText(selectors: any, text: any, climb: any, _params?: null, options?: {}, world?: null): Promise<any>;
|
|
121
|
+
snapshotValidation(frameSelectors: any, referanceSnapshot: any, _params?: null, options?: {}, world?: null): Promise<any>;
|
|
112
122
|
waitForUserInput(message: any, world?: null): Promise<void>;
|
|
113
123
|
setTestData(testData: any, world?: null): void;
|
|
124
|
+
overwriteTestData(testData: any, world?: null): void;
|
|
114
125
|
_getDataFilePath(fileName: any): string;
|
|
115
126
|
_parseCSVSync(filePath: any): Promise<unknown>;
|
|
116
127
|
loadTestData(type: string, dataSelector: string, world?: null): {
|
|
@@ -131,13 +142,18 @@ declare class StableBrowser {
|
|
|
131
142
|
}>;
|
|
132
143
|
_highlightElements(scope: any, css: any): Promise<void>;
|
|
133
144
|
verifyPagePath(pathPart: any, options?: {}, world?: null): Promise<{} | undefined>;
|
|
134
|
-
|
|
145
|
+
verifyPageTitle(title: any, options?: {}, world?: null): Promise<{} | undefined>;
|
|
146
|
+
findTextInAllFrames(dateAlternatives: any, numberAlternatives: any, text: any, state: any, partial?: boolean, ignoreCase?: boolean): Promise<{
|
|
135
147
|
elementCount: number;
|
|
136
148
|
randomToken: string;
|
|
137
149
|
}[]>;
|
|
138
150
|
verifyTextExistInPage(text: any, options?: {}, world?: null): Promise<any>;
|
|
139
151
|
waitForTextToDisappear(text: any, options?: {}, world?: null): Promise<any>;
|
|
140
152
|
verifyTextRelatedToText(textAnchor: string, climb: number, textToVerify: string, options?: {}, world?: any): Promise<any>;
|
|
153
|
+
findRelatedTextInAllFrames(textAnchor: string, climb: number, textToVerify: string, params?: Params, options?: {}, world?: any): Promise<{
|
|
154
|
+
elementCount: number;
|
|
155
|
+
randomToken: string;
|
|
156
|
+
}[]>;
|
|
141
157
|
visualVerification(text: any, options?: {}, world?: null): Promise<{} | undefined>;
|
|
142
158
|
verifyTableData(selectors: any, data: any, _params?: null, options?: {}, world?: null): Promise<void>;
|
|
143
159
|
getTableData(selectors: any, _params?: null, options?: {}, world?: null): Promise<any>;
|
|
@@ -149,10 +165,13 @@ declare class StableBrowser {
|
|
|
149
165
|
restoreSaveState(path?: string | null, world?: any): Promise<void>;
|
|
150
166
|
waitForPageLoad(options?: {}, world?: null): Promise<void>;
|
|
151
167
|
closePage(options?: {}, world?: null): Promise<void>;
|
|
168
|
+
tableCellOperation(headerText: string, rowText: string, options: any, _params: Params, world?: null): Promise<void>;
|
|
152
169
|
saveTestDataAsGlobal(options: any, world: any): void;
|
|
153
170
|
setViewportSize(width: number, hight: number, options?: {}, world?: null): Promise<void>;
|
|
154
171
|
reloadPage(options?: {}, world?: null): Promise<void>;
|
|
155
172
|
scrollIfNeeded(element: any, info: any): Promise<void>;
|
|
173
|
+
beforeScenario(world: any, scenario: any): Promise<void>;
|
|
174
|
+
afterScenario(world: any, scenario: any): Promise<void>;
|
|
156
175
|
beforeStep(world: any, step: any): Promise<void>;
|
|
157
176
|
getAriaSnapshot(): Promise<string | null>;
|
|
158
177
|
afterStep(world: any, step: any): Promise<void>;
|