playwright-ts-automationframework 1.1.69 → 1.1.71
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/lib/core/actions.core.d.ts +13 -1
- package/lib/core/actions.core.js +224 -81
- package/lib/core/assertion.core.js +282 -146
- package/package.json +1 -1
|
@@ -186,6 +186,18 @@ export declare class Actions extends BasePage {
|
|
|
186
186
|
* let textboxValue = getTextboxValue(usernameTxtbx);
|
|
187
187
|
*/
|
|
188
188
|
getTextboxValue(control: WebControl): Promise<string>;
|
|
189
|
+
/**
|
|
190
|
+
* Read input value of an element
|
|
191
|
+
*
|
|
192
|
+
* @param WebControl textbox Control.
|
|
193
|
+
*
|
|
194
|
+
* Example:
|
|
195
|
+
*
|
|
196
|
+
* usernameTxtbx = new WebControl(this.page.locator("#username"), 'Username textbox');
|
|
197
|
+
*
|
|
198
|
+
* let inputValue = getInputValue(usernameTxtbx);
|
|
199
|
+
*/
|
|
200
|
+
getInputValue(control: WebControl): Promise<string>;
|
|
189
201
|
/**
|
|
190
202
|
* Read selected dropdown item.
|
|
191
203
|
*
|
|
@@ -278,7 +290,7 @@ export declare class Actions extends BasePage {
|
|
|
278
290
|
*
|
|
279
291
|
* let title = getTitle();
|
|
280
292
|
*/
|
|
281
|
-
getTitle(): Promise<
|
|
293
|
+
getTitle(): Promise<string>;
|
|
282
294
|
/**
|
|
283
295
|
* Wait till URL contains value
|
|
284
296
|
*
|
package/lib/core/actions.core.js
CHANGED
|
@@ -24,10 +24,9 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
24
24
|
*/
|
|
25
25
|
async click(control, isforceful = false) {
|
|
26
26
|
await control.controlLocator.first().click({ force: isforceful }).then(() => {
|
|
27
|
-
(0, logs_core_1.logAction)(
|
|
27
|
+
(0, logs_core_1.logAction)(`Clicked on '${control.controlDescription}'`);
|
|
28
28
|
}, (error) => {
|
|
29
|
-
(0, logs_core_1.logError)(`❌ Unable to click on '${control.controlDescription}'`);
|
|
30
|
-
(0, logs_core_1.logConsole)(`Error: '${error}'`);
|
|
29
|
+
(0, logs_core_1.logError)(`❌ Unable to click on '${control.controlDescription}' due to reason: '${error}'`);
|
|
31
30
|
throw error;
|
|
32
31
|
});
|
|
33
32
|
}
|
|
@@ -44,10 +43,10 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
44
43
|
*/
|
|
45
44
|
async mouseHover(control) {
|
|
46
45
|
await control.controlLocator.first().hover().then(() => {
|
|
47
|
-
(0, logs_core_1.logAction)(
|
|
46
|
+
(0, logs_core_1.logAction)(`Mouse hover on '${control.controlDescription}'`);
|
|
48
47
|
}, (error) => {
|
|
49
|
-
(0, logs_core_1.logError)(`❌ Unable to mouse hover on '${control.controlDescription}'`);
|
|
50
|
-
|
|
48
|
+
(0, logs_core_1.logError)(`❌ Unable to mouse hover on '${control.controlDescription}' due to reason: '${error}'`);
|
|
49
|
+
throw error;
|
|
51
50
|
});
|
|
52
51
|
}
|
|
53
52
|
/**
|
|
@@ -63,7 +62,13 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
63
62
|
* focusAndPressSpace(loginBtn, "Enter");
|
|
64
63
|
*/
|
|
65
64
|
async focusAndPressKeyboardEvent(control, action) {
|
|
66
|
-
|
|
65
|
+
try {
|
|
66
|
+
await control.controlLocator.first().focus();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
(0, logs_core_1.logError)(`❌ Unable to focus on '${control.controlDescription}' before key '${action}' due to reason: '${error}'`);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
67
72
|
await this.pressKeyboardEvent(control, action);
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
@@ -86,7 +91,7 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
86
91
|
(0, logs_core_1.logAction)(`Entered '${textTobeEntered}' in '${control.controlDescription}' textbox`);
|
|
87
92
|
}
|
|
88
93
|
}, (error) => {
|
|
89
|
-
(0, logs_core_1.logError)(`❌ Unable to enter text in '${control.controlDescription}' textbox due to reason: ${error}`);
|
|
94
|
+
(0, logs_core_1.logError)(`❌ Unable to enter text in '${control.controlDescription}' textbox due to reason: '${error}'`);
|
|
90
95
|
throw error;
|
|
91
96
|
});
|
|
92
97
|
}
|
|
@@ -99,7 +104,7 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
99
104
|
(0, logs_core_1.logAction)(`Entered '********' in '${control.controlDescription}' textbox`);
|
|
100
105
|
}
|
|
101
106
|
}, (error) => {
|
|
102
|
-
(0, logs_core_1.logError)(`❌ Unable to enter text in '${control.controlDescription}' textbox due to reason: ${error}`);
|
|
107
|
+
(0, logs_core_1.logError)(`❌ Unable to enter text in '${control.controlDescription}' textbox due to reason: '${error}'`);
|
|
103
108
|
throw error;
|
|
104
109
|
});
|
|
105
110
|
}
|
|
@@ -118,6 +123,8 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
118
123
|
async pressKeyboardEvent(control, key) {
|
|
119
124
|
await control.controlLocator.first().press(key).then(() => {
|
|
120
125
|
(0, logs_core_1.logAction)(`Press Key '${key.toUpperCase()}' on '${control.controlDescription}'`);
|
|
126
|
+
}, (error) => {
|
|
127
|
+
(0, logs_core_1.logError)(`❌ Unable to press keyboard event '${key}' on '${control.controlDescription}' due to reason: '${error}'`);
|
|
121
128
|
});
|
|
122
129
|
}
|
|
123
130
|
/**
|
|
@@ -133,11 +140,10 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
133
140
|
* selectFromDropdownByValue(cityDrpdwn, "Sydney");
|
|
134
141
|
*/
|
|
135
142
|
async selectFromDropdownByValue(control, optionTobeSelcted) {
|
|
136
|
-
await control.controlLocator.first().selectOption({ value: optionTobeSelcted }).then(
|
|
137
|
-
(0, logs_core_1.logAction)(
|
|
138
|
-
},
|
|
139
|
-
(0, logs_core_1.logError)(`❌ Unable to select '${optionTobeSelcted}' from '${control.controlDescription}'`);
|
|
140
|
-
(0, logs_core_1.logConsole)(`Error: '${error}'`);
|
|
143
|
+
await control.controlLocator.first().selectOption({ value: optionTobeSelcted }).then(() => {
|
|
144
|
+
(0, logs_core_1.logAction)(`Selected '${optionTobeSelcted}' from '${control.controlDescription}'`);
|
|
145
|
+
}, (error) => {
|
|
146
|
+
(0, logs_core_1.logError)(`❌ Unable to select '${optionTobeSelcted}' from '${control.controlDescription}' due to reason: '${error}'`);
|
|
141
147
|
throw error;
|
|
142
148
|
});
|
|
143
149
|
}
|
|
@@ -156,14 +162,20 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
156
162
|
async selectFromDropdownByText(control, optionTobeSelcted) {
|
|
157
163
|
await control.controlLocator.first().selectOption({ label: optionTobeSelcted }).then(() => {
|
|
158
164
|
(0, logs_core_1.logAction)(`Selected '${optionTobeSelcted}' from '${control.controlDescription}'`);
|
|
159
|
-
},
|
|
160
|
-
(0, logs_core_1.logError)(`❌ Unable to select '${optionTobeSelcted}' from '${control.controlDescription}'`);
|
|
161
|
-
(0, logs_core_1.logConsole)(`Error: '${error}'`);
|
|
165
|
+
}, (error) => {
|
|
166
|
+
(0, logs_core_1.logError)(`❌ Unable to select '${optionTobeSelcted}' from '${control.controlDescription}' due to reason: '${error}'`);
|
|
162
167
|
throw error;
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
170
|
async selectFromDropdownByPartialText(control, partialText) {
|
|
166
|
-
|
|
171
|
+
let options;
|
|
172
|
+
try {
|
|
173
|
+
options = await control.controlLocator.first().locator('option').allInnerTexts();
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
(0, logs_core_1.logError)(`❌ Unable to read dropdown options for partial match '${partialText}' in '${control.controlDescription}' due to reason: '${error}'`);
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
167
179
|
const matchingOption = options.find(option => option.includes(partialText));
|
|
168
180
|
if (!matchingOption) {
|
|
169
181
|
(0, logs_core_1.logError)(`❌ No option found containing '${partialText}' in '${control.controlDescription}'`);
|
|
@@ -171,9 +183,8 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
171
183
|
}
|
|
172
184
|
await control.controlLocator.first().selectOption({ label: matchingOption }).then(() => {
|
|
173
185
|
(0, logs_core_1.logAction)(`Selected '${matchingOption}' from '${control.controlDescription}'`);
|
|
174
|
-
},
|
|
175
|
-
(0, logs_core_1.logError)(`❌ Unable to select '${matchingOption}' from '${control.controlDescription}'`);
|
|
176
|
-
(0, logs_core_1.logConsole)(`Error: '${error}'`);
|
|
186
|
+
}, (error) => {
|
|
187
|
+
(0, logs_core_1.logError)(`❌ Unable to select '${matchingOption}' from '${control.controlDescription}' due to reason: '${error}'`);
|
|
177
188
|
throw error;
|
|
178
189
|
});
|
|
179
190
|
}
|
|
@@ -190,11 +201,10 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
190
201
|
* selectFromDropdownByIndex(cityDrpdwn, 1);
|
|
191
202
|
*/
|
|
192
203
|
async selectFromDropdownByIndex(control, index) {
|
|
193
|
-
await control.controlLocator.first().selectOption({ index
|
|
194
|
-
(0, logs_core_1.logAction)(
|
|
195
|
-
},
|
|
196
|
-
(0, logs_core_1.logError)(`❌ Unable to select '${index}' option from '${control.controlDescription}'`);
|
|
197
|
-
(0, logs_core_1.logConsole)(`Error: '${error}'`);
|
|
204
|
+
await control.controlLocator.first().selectOption({ index }).then(() => {
|
|
205
|
+
(0, logs_core_1.logAction)(`Selected '${index}' option from '${control.controlDescription}'`);
|
|
206
|
+
}, (error) => {
|
|
207
|
+
(0, logs_core_1.logError)(`❌ Unable to select '${index}' option from '${control.controlDescription}' due to reason: '${error}'`);
|
|
198
208
|
throw error;
|
|
199
209
|
});
|
|
200
210
|
}
|
|
@@ -215,15 +225,15 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
215
225
|
try {
|
|
216
226
|
if (expectedCheckboxValue) {
|
|
217
227
|
await control.controlLocator.first().check();
|
|
218
|
-
(0, logs_core_1.logAction)(
|
|
228
|
+
(0, logs_core_1.logAction)(`Set checkbox value of '${control.controlDescription}' as checked`);
|
|
219
229
|
}
|
|
220
230
|
else {
|
|
221
231
|
await control.controlLocator.first().uncheck();
|
|
222
|
-
(0, logs_core_1.logAction)(
|
|
232
|
+
(0, logs_core_1.logAction)(`Set checkbox value of '${control.controlDescription}' as unchecked`);
|
|
223
233
|
}
|
|
224
234
|
}
|
|
225
235
|
catch (error) {
|
|
226
|
-
(0, logs_core_1.logError)(`❌ Unable to set checkbox value of '${control.controlDescription}' as ${expectedCheckboxValue ? "checked" : "unchecked"}`);
|
|
236
|
+
(0, logs_core_1.logError)(`❌ Unable to set checkbox value of '${control.controlDescription}' as ${expectedCheckboxValue ? "checked" : "unchecked"} due to reason: '${error}'`);
|
|
227
237
|
throw error;
|
|
228
238
|
}
|
|
229
239
|
}
|
|
@@ -240,12 +250,18 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
240
250
|
* let checkboxValue = isSelected(isMinorChkbx);
|
|
241
251
|
*/
|
|
242
252
|
async isSelected(control) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
253
|
+
try {
|
|
254
|
+
const isChecked = await control.controlLocator.first().isChecked();
|
|
255
|
+
if (isChecked)
|
|
256
|
+
(0, logs_core_1.logConsole)(`'${control.controlDescription}' is selected`);
|
|
257
|
+
else
|
|
258
|
+
(0, logs_core_1.logConsole)(`'${control.controlDescription}' is NOT selected`);
|
|
259
|
+
return isChecked;
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
(0, logs_core_1.logError)(`❌ Unable to read selected state of '${control.controlDescription}' due to reason: '${error}'`);
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
249
265
|
}
|
|
250
266
|
/**
|
|
251
267
|
* Info to get wheather element is enabled or not.
|
|
@@ -260,13 +276,18 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
260
276
|
* let enabledValue = isEnabled(loginBtn);
|
|
261
277
|
*/
|
|
262
278
|
async isEnabled(control) {
|
|
263
|
-
|
|
279
|
+
try {
|
|
280
|
+
const value = await control.controlLocator.first().isEnabled();
|
|
264
281
|
if (value)
|
|
265
|
-
(0, logs_core_1.logConsole)(
|
|
282
|
+
(0, logs_core_1.logConsole)(`'${control.controlDescription}' is enabled`);
|
|
266
283
|
else
|
|
267
|
-
(0, logs_core_1.logConsole)(
|
|
284
|
+
(0, logs_core_1.logConsole)(`'${control.controlDescription}' is NOT enabled`);
|
|
268
285
|
return value;
|
|
269
|
-
}
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
(0, logs_core_1.logError)(`❌ Unable to read enabled state of '${control.controlDescription}' due to reason: '${error}'`);
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
270
291
|
}
|
|
271
292
|
/**
|
|
272
293
|
* Info to get wheather element is displayed or not.
|
|
@@ -281,12 +302,18 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
281
302
|
* let displayedValue = isDisplayed(loginBtn);
|
|
282
303
|
*/
|
|
283
304
|
async isDisplayed(control) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
305
|
+
try {
|
|
306
|
+
const isVisible = await control.controlLocator.first().isVisible();
|
|
307
|
+
if (isVisible)
|
|
308
|
+
(0, logs_core_1.logConsole)(`'${control.controlDescription}' is displayed`);
|
|
309
|
+
else
|
|
310
|
+
(0, logs_core_1.logConsole)(`'${control.controlDescription}' is NOT displayed`);
|
|
311
|
+
return isVisible;
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
(0, logs_core_1.logError)(`❌ Unable to read visibility of '${control.controlDescription}' due to reason: '${error}'`);
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
290
317
|
}
|
|
291
318
|
/**
|
|
292
319
|
* Read text of an element
|
|
@@ -306,8 +333,8 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
306
333
|
return text;
|
|
307
334
|
}
|
|
308
335
|
catch (error) {
|
|
309
|
-
(0, logs_core_1.logError)(`❌ Unable to read the text from '${control.controlDescription}' due to reason: ${error}`);
|
|
310
|
-
|
|
336
|
+
(0, logs_core_1.logError)(`❌ Unable to read the text from '${control.controlDescription}' due to reason: '${error}'`);
|
|
337
|
+
throw error;
|
|
311
338
|
}
|
|
312
339
|
}
|
|
313
340
|
/**
|
|
@@ -328,8 +355,30 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
328
355
|
return value;
|
|
329
356
|
}
|
|
330
357
|
catch (error) {
|
|
331
|
-
(0, logs_core_1.logError)(`❌ Unable to read the value from '${control.controlDescription}' due to reason: ${error}`);
|
|
332
|
-
|
|
358
|
+
(0, logs_core_1.logError)(`❌ Unable to read the value from '${control.controlDescription}' due to reason: '${error}'`);
|
|
359
|
+
throw error;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Read input value of an element
|
|
364
|
+
*
|
|
365
|
+
* @param WebControl textbox Control.
|
|
366
|
+
*
|
|
367
|
+
* Example:
|
|
368
|
+
*
|
|
369
|
+
* usernameTxtbx = new WebControl(this.page.locator("#username"), 'Username textbox');
|
|
370
|
+
*
|
|
371
|
+
* let inputValue = getInputValue(usernameTxtbx);
|
|
372
|
+
*/
|
|
373
|
+
async getInputValue(control) {
|
|
374
|
+
try {
|
|
375
|
+
const value = await control.controlLocator.first().inputValue();
|
|
376
|
+
(0, logs_core_1.logConsole)(`Value read from input '${control.controlDescription}' is: '${value}'`);
|
|
377
|
+
return value;
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
(0, logs_core_1.logError)(`❌ Unable to read the value from '${control.controlDescription}' due to reason: '${error}'`);
|
|
381
|
+
throw error;
|
|
333
382
|
}
|
|
334
383
|
}
|
|
335
384
|
/**
|
|
@@ -346,12 +395,12 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
346
395
|
async getSelectedItemFromDropdown(control) {
|
|
347
396
|
try {
|
|
348
397
|
const value = await control.controlLocator.first().inputValue();
|
|
349
|
-
(0, logs_core_1.logConsole)(`Value read from '${control.controlDescription}' is: '${value}'`);
|
|
398
|
+
(0, logs_core_1.logConsole)(`Value read from dropdown '${control.controlDescription}' is: '${value}'`);
|
|
350
399
|
return value;
|
|
351
400
|
}
|
|
352
401
|
catch (error) {
|
|
353
|
-
(0, logs_core_1.logError)(`❌ Unable to read the value from '${control.controlDescription}' due to reason: ${error}`);
|
|
354
|
-
|
|
402
|
+
(0, logs_core_1.logError)(`❌ Unable to read the value from '${control.controlDescription}' due to reason: '${error}'`);
|
|
403
|
+
throw error;
|
|
355
404
|
}
|
|
356
405
|
}
|
|
357
406
|
/**
|
|
@@ -373,8 +422,8 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
373
422
|
return value;
|
|
374
423
|
}
|
|
375
424
|
catch (error) {
|
|
376
|
-
(0, logs_core_1.logError)(`❌ Unable to read attribute value from '${control.controlDescription}'
|
|
377
|
-
|
|
425
|
+
(0, logs_core_1.logError)(`❌ Unable to read attribute value from '${control.controlDescription}' due to reason: '${error}'`);
|
|
426
|
+
throw error;
|
|
378
427
|
}
|
|
379
428
|
}
|
|
380
429
|
/**
|
|
@@ -389,7 +438,12 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
389
438
|
* scrollToControl(loginBtn);
|
|
390
439
|
*/
|
|
391
440
|
async scrollToControl(control) {
|
|
392
|
-
|
|
441
|
+
try {
|
|
442
|
+
await control.controlLocator.first().scrollIntoViewIfNeeded();
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
(0, logs_core_1.logError)(`❌ Unable to scroll to '${control.controlDescription}' due to reason: '${error}'`);
|
|
446
|
+
}
|
|
393
447
|
}
|
|
394
448
|
/**
|
|
395
449
|
* Navigate back on browser.
|
|
@@ -399,7 +453,13 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
399
453
|
* navigateBack();
|
|
400
454
|
*/
|
|
401
455
|
async navigateBack() {
|
|
402
|
-
|
|
456
|
+
try {
|
|
457
|
+
await this.page.goBack();
|
|
458
|
+
}
|
|
459
|
+
catch (error) {
|
|
460
|
+
(0, logs_core_1.logError)(`❌ Unable to navigate back in the browser due to reason: '${error}'`);
|
|
461
|
+
throw error;
|
|
462
|
+
}
|
|
403
463
|
}
|
|
404
464
|
/**
|
|
405
465
|
* Handle web Alert by accepting or dismissing it
|
|
@@ -417,7 +477,7 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
417
477
|
(0, logs_core_1.logAction)('Alert is accepted');
|
|
418
478
|
return true;
|
|
419
479
|
}, (error) => {
|
|
420
|
-
(0, logs_core_1.logError)(`❌ Unable to accept alert: ${error}`);
|
|
480
|
+
(0, logs_core_1.logError)(`❌ Unable to accept alert due to reason: '${error}'`);
|
|
421
481
|
throw error;
|
|
422
482
|
});
|
|
423
483
|
}
|
|
@@ -426,7 +486,7 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
426
486
|
(0, logs_core_1.logAction)('Alert is dismissed');
|
|
427
487
|
return false;
|
|
428
488
|
}, (error) => {
|
|
429
|
-
(0, logs_core_1.logError)(`❌ Unable to dismiss alert: ${error}`);
|
|
489
|
+
(0, logs_core_1.logError)(`❌ Unable to dismiss alert due to reason: '${error}'`);
|
|
430
490
|
throw error;
|
|
431
491
|
});
|
|
432
492
|
}
|
|
@@ -441,7 +501,15 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
441
501
|
*/
|
|
442
502
|
async getAlertDialogMessage() {
|
|
443
503
|
this.page.on('dialog', async (dialog) => {
|
|
444
|
-
|
|
504
|
+
try {
|
|
505
|
+
const message = dialog.message();
|
|
506
|
+
(0, logs_core_1.logAction)(`Alert is displayed with text: '${message}'`);
|
|
507
|
+
return message;
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
(0, logs_core_1.logError)(`❌ Unable to read the alert message due to reason: '${error}'`);
|
|
511
|
+
throw error;
|
|
512
|
+
}
|
|
445
513
|
});
|
|
446
514
|
return this.page.on('dialog', dialog => dialog.message());
|
|
447
515
|
}
|
|
@@ -458,18 +526,33 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
458
526
|
*/
|
|
459
527
|
async findAll(control) {
|
|
460
528
|
await this.waitTillElementIsPresent(control);
|
|
461
|
-
|
|
462
|
-
|
|
529
|
+
try {
|
|
530
|
+
return await control.controlLocator.all();
|
|
531
|
+
}
|
|
532
|
+
catch (error) {
|
|
533
|
+
(0, logs_core_1.logError)(`❌ Unable to find all elements for '${control.controlDescription}' due to reason: '${error}'`);
|
|
534
|
+
throw error;
|
|
535
|
+
}
|
|
463
536
|
}
|
|
464
537
|
async getAllInnerText(control) {
|
|
465
538
|
await this.waitTillElementIsPresent(control);
|
|
466
|
-
|
|
467
|
-
|
|
539
|
+
try {
|
|
540
|
+
return await control.controlLocator.allInnerTexts();
|
|
541
|
+
}
|
|
542
|
+
catch (error) {
|
|
543
|
+
(0, logs_core_1.logError)(`❌ Unable to get inner text for all elements of '${control.controlDescription}' due to reason: '${error}'`);
|
|
544
|
+
throw error;
|
|
545
|
+
}
|
|
468
546
|
}
|
|
469
547
|
async getAllTextContents(control) {
|
|
470
548
|
await this.waitTillElementIsPresent(control);
|
|
471
|
-
|
|
472
|
-
|
|
549
|
+
try {
|
|
550
|
+
return await control.controlLocator.allTextContents();
|
|
551
|
+
}
|
|
552
|
+
catch (error) {
|
|
553
|
+
(0, logs_core_1.logError)(`❌ Unable to get text contents for all elements of '${control.controlDescription}' due to reason: '${error}'`);
|
|
554
|
+
throw error;
|
|
555
|
+
}
|
|
473
556
|
}
|
|
474
557
|
/**
|
|
475
558
|
* Read the web URL
|
|
@@ -479,7 +562,13 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
479
562
|
* let url = getURL();
|
|
480
563
|
*/
|
|
481
564
|
async getURL() {
|
|
482
|
-
|
|
565
|
+
try {
|
|
566
|
+
return this.page.url();
|
|
567
|
+
}
|
|
568
|
+
catch (error) {
|
|
569
|
+
(0, logs_core_1.logError)(`❌ Unable to read the current page URL due to reason: '${error}'`);
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
483
572
|
}
|
|
484
573
|
/**
|
|
485
574
|
* Read the title of web Page
|
|
@@ -489,9 +578,15 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
489
578
|
* let title = getTitle();
|
|
490
579
|
*/
|
|
491
580
|
async getTitle() {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
581
|
+
try {
|
|
582
|
+
const value = await this.page.title();
|
|
583
|
+
(0, logs_core_1.logAction)(`Title of the webpage is: '${value}'`);
|
|
584
|
+
return value;
|
|
585
|
+
}
|
|
586
|
+
catch (error) {
|
|
587
|
+
(0, logs_core_1.logError)(`❌ Unable to read the page title due to reason: '${error}'`);
|
|
588
|
+
throw error;
|
|
589
|
+
}
|
|
495
590
|
}
|
|
496
591
|
/**
|
|
497
592
|
* Wait till URL contains value
|
|
@@ -509,7 +604,10 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
509
604
|
waitUntil: "load"
|
|
510
605
|
});
|
|
511
606
|
}
|
|
512
|
-
catch (error) {
|
|
607
|
+
catch (error) {
|
|
608
|
+
(0, logs_core_1.logError)(`❌ Page URL did not match or load within ${timeoutInSeconds}s. Expected: '${url}' due to reason: '${error}'`);
|
|
609
|
+
throw error;
|
|
610
|
+
}
|
|
513
611
|
}
|
|
514
612
|
/**
|
|
515
613
|
* Wait till element is present
|
|
@@ -523,14 +621,17 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
523
621
|
* waitTillElementIsPresent(usernameTxtbx);
|
|
524
622
|
*/
|
|
525
623
|
async waitTillElementIsPresent(control, timeoutInSeconds = 60) {
|
|
526
|
-
await this.page.waitForLoadState("domcontentloaded");
|
|
527
624
|
try {
|
|
625
|
+
await this.page.waitForLoadState("domcontentloaded");
|
|
528
626
|
await control.controlLocator.first().waitFor({
|
|
529
627
|
state: "visible",
|
|
530
628
|
timeout: timeoutInSeconds * 1000,
|
|
531
629
|
});
|
|
532
630
|
}
|
|
533
|
-
catch (error) {
|
|
631
|
+
catch (error) {
|
|
632
|
+
(0, logs_core_1.logError)(`❌ waitTillElementIsPresent failed for '${control.controlDescription}' (visible, ${timeoutInSeconds}s) due to reason: '${error}'`);
|
|
633
|
+
throw error;
|
|
634
|
+
}
|
|
534
635
|
}
|
|
535
636
|
/**
|
|
536
637
|
* Wait till element is attached to the dom
|
|
@@ -544,14 +645,17 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
544
645
|
* waitTillElementIsAttached(usernameTxtbx);
|
|
545
646
|
*/
|
|
546
647
|
async waitTillElementIsAttached(control, timeoutInSeconds = 60) {
|
|
547
|
-
await this.page.waitForLoadState("domcontentloaded");
|
|
548
648
|
try {
|
|
649
|
+
await this.page.waitForLoadState("domcontentloaded");
|
|
549
650
|
await control.controlLocator.first().waitFor({
|
|
550
651
|
state: "attached",
|
|
551
652
|
timeout: timeoutInSeconds * 1000,
|
|
552
653
|
});
|
|
553
654
|
}
|
|
554
|
-
catch (error) {
|
|
655
|
+
catch (error) {
|
|
656
|
+
(0, logs_core_1.logError)(`❌ waitTillElementIsAttached failed for '${control.controlDescription}' (attached, ${timeoutInSeconds}s) due to reason: '${error}'`);
|
|
657
|
+
throw error;
|
|
658
|
+
}
|
|
555
659
|
}
|
|
556
660
|
/**
|
|
557
661
|
* Wait till element is not displayed
|
|
@@ -571,7 +675,10 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
571
675
|
timeout: timeoutInSeconds * 1000,
|
|
572
676
|
});
|
|
573
677
|
}
|
|
574
|
-
catch (error) {
|
|
678
|
+
catch (error) {
|
|
679
|
+
(0, logs_core_1.logError)(`❌ Element did not become hidden within ${timeoutInSeconds}s: '${control.controlDescription}' due to reason: '${error}'`);
|
|
680
|
+
throw error;
|
|
681
|
+
}
|
|
575
682
|
}
|
|
576
683
|
/**
|
|
577
684
|
* Wait for execution to stop for given time
|
|
@@ -586,19 +693,49 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
586
693
|
await new Promise(resolve => setTimeout(resolve, timeInSeconds * 1000));
|
|
587
694
|
}
|
|
588
695
|
async waitForPageTimeout(timeoutInSeconds = 5) {
|
|
589
|
-
|
|
696
|
+
try {
|
|
697
|
+
await this.page.waitForTimeout(timeoutInSeconds * 1000);
|
|
698
|
+
}
|
|
699
|
+
catch (error) {
|
|
700
|
+
(0, logs_core_1.logError)(`❌ waitForPageTimeout failed after ${timeoutInSeconds}s due to reason: '${error}'`);
|
|
701
|
+
throw error;
|
|
702
|
+
}
|
|
590
703
|
}
|
|
591
704
|
async waitForPageLoad(timeInSeconds = 30) {
|
|
592
|
-
|
|
705
|
+
try {
|
|
706
|
+
await this.page.waitForLoadState("load", { timeout: timeInSeconds * 1000 });
|
|
707
|
+
}
|
|
708
|
+
catch (error) {
|
|
709
|
+
(0, logs_core_1.logError)(`❌ Page did not reach load state within ${timeInSeconds}s due to reason: '${error}'`);
|
|
710
|
+
throw error;
|
|
711
|
+
}
|
|
593
712
|
}
|
|
594
713
|
async waitForPageDOMcontentLoaded(timeInSeconds = 30) {
|
|
595
|
-
|
|
714
|
+
try {
|
|
715
|
+
await this.page.waitForLoadState("domcontentloaded", { timeout: timeInSeconds * 1000 });
|
|
716
|
+
}
|
|
717
|
+
catch (error) {
|
|
718
|
+
(0, logs_core_1.logError)(`❌ Page did not reach DOM content loaded within ${timeInSeconds}s due to reason: '${error}'`);
|
|
719
|
+
throw error;
|
|
720
|
+
}
|
|
596
721
|
}
|
|
597
722
|
async waitForNetworkIdle(timeInSeconds = 30) {
|
|
598
|
-
|
|
723
|
+
try {
|
|
724
|
+
await this.page.waitForLoadState("networkidle", { timeout: timeInSeconds * 1000 });
|
|
725
|
+
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
(0, logs_core_1.logError)(`❌ Network did not become idle within ${timeInSeconds}s due to reason: '${error}'`);
|
|
728
|
+
throw error;
|
|
729
|
+
}
|
|
599
730
|
}
|
|
600
731
|
async refreshWebPage(timeInSeconds = 30) {
|
|
601
|
-
|
|
732
|
+
try {
|
|
733
|
+
await this.page.reload({ waitUntil: "load", timeout: timeInSeconds * 1000 });
|
|
734
|
+
}
|
|
735
|
+
catch (error) {
|
|
736
|
+
(0, logs_core_1.logError)(`❌ Unable to refresh the page due to reason: '${error}'`);
|
|
737
|
+
throw error;
|
|
738
|
+
}
|
|
602
739
|
}
|
|
603
740
|
/**
|
|
604
741
|
* Close the browser instance
|
|
@@ -606,7 +743,13 @@ class Actions extends basePage_core_1.BasePage {
|
|
|
606
743
|
* closeBrowser();
|
|
607
744
|
*/
|
|
608
745
|
async closeBrowser() {
|
|
609
|
-
|
|
746
|
+
try {
|
|
747
|
+
await this.page.close();
|
|
748
|
+
}
|
|
749
|
+
catch (error) {
|
|
750
|
+
(0, logs_core_1.logError)(`❌ Unable to close the browser page due to reason: '${error}'`);
|
|
751
|
+
throw error;
|
|
752
|
+
}
|
|
610
753
|
}
|
|
611
754
|
}
|
|
612
755
|
exports.Actions = Actions;
|
|
@@ -30,7 +30,7 @@ class Assertion extends actions_core_1.Actions {
|
|
|
30
30
|
test_1.expect.soft(object1, logText).toEqual(object2);
|
|
31
31
|
}
|
|
32
32
|
catch (error1) {
|
|
33
|
-
(0, logs_core_1.logError)(
|
|
33
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Expected: '${object1}' Actual: '${object2}' due to reason: '${error1}'`);
|
|
34
34
|
throw error1;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -42,7 +42,7 @@ class Assertion extends actions_core_1.Actions {
|
|
|
42
42
|
test_1.expect.soft(object1, logText).not.toEqual(object2);
|
|
43
43
|
}
|
|
44
44
|
catch (error1) {
|
|
45
|
-
(0, logs_core_1.logError)(
|
|
45
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Expected: '${object1}' is NOT equal to Actual: '${object2}' due to reason: '${error1}'`);
|
|
46
46
|
throw error1;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -66,7 +66,7 @@ class Assertion extends actions_core_1.Actions {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
catch (error1) {
|
|
69
|
-
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Expected: '${object1}' Actual: '${object2}'`);
|
|
69
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Expected: '${object1}' Actual: '${object2}' due to reason: '${error1}'`);
|
|
70
70
|
throw error1;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -88,7 +88,7 @@ class Assertion extends actions_core_1.Actions {
|
|
|
88
88
|
test_1.expect.soft(actual.trim(), logText).toContain(expected.trim());
|
|
89
89
|
}
|
|
90
90
|
catch (error1) {
|
|
91
|
-
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Actual: '${
|
|
91
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Actual: '${actual}' should contain Expected: '${expected}' due to reason: '${error1}'`);
|
|
92
92
|
throw error1;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -107,14 +107,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
107
107
|
async verifyIsDisplayed(control, expectedIsDisplayed = true) {
|
|
108
108
|
if (expectedIsDisplayed) {
|
|
109
109
|
await this.waitTillElementIsPresent(control);
|
|
110
|
-
|
|
110
|
+
try {
|
|
111
|
+
const value = await this.isDisplayed(control);
|
|
111
112
|
const verificationResult = value === expectedIsDisplayed ? "✅ PASSED" : "❌ FAILED";
|
|
112
|
-
|
|
113
|
+
const logText = `VERIFICATION: '${verificationResult}' '${control.controlDescription}' displayed status is '${value}' Expected: '${expectedIsDisplayed}'`;
|
|
113
114
|
(0, logs_core_1.logVerification)(logText);
|
|
114
115
|
test_1.expect.soft(value, logText).toBe(expectedIsDisplayed);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. '${control.controlDescription}' displayed status could not be verified. Expected: '${expectedIsDisplayed}' due to reason: '${error}'`);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
118
121
|
}
|
|
119
122
|
else {
|
|
120
123
|
await this.verifyIsNotDisplayed(control);
|
|
@@ -133,12 +136,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
133
136
|
* verifyIsNotDisplayed(loginBtn, true);
|
|
134
137
|
*/
|
|
135
138
|
async verifyIsNotDisplayed(control, isAlreadyHidden = false) {
|
|
136
|
-
|
|
139
|
+
try {
|
|
140
|
+
const value = await control.controlLocator.isHidden();
|
|
137
141
|
const verificationResult = value === true ? "✅ PASSED" : "❌ FAILED";
|
|
138
|
-
|
|
142
|
+
const logText = `VERIFICATION: '${verificationResult}'. '${control.controlDescription}' hidden status is '${value}' Expected: 'true'`;
|
|
139
143
|
(0, logs_core_1.logVerification)(logText);
|
|
140
144
|
test_1.expect.soft(value, logText).toBe(true);
|
|
141
|
-
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. '${control.controlDescription}' hidden status could not be verified due to reason: '${error}'`);
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
142
150
|
}
|
|
143
151
|
/**
|
|
144
152
|
* Verify attribute value of the control
|
|
@@ -155,12 +163,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
155
163
|
* verifyAttributeValue(loginBtn, "value", "Submit");
|
|
156
164
|
*/
|
|
157
165
|
async verifyAttributeValue(control, attributeName, expectedAttributeValue) {
|
|
158
|
-
|
|
166
|
+
try {
|
|
167
|
+
const value = await this.getAttributeValue(control, attributeName);
|
|
159
168
|
const verificationResult = value?.trim() === expectedAttributeValue ? "✅ PASSED" : "❌ FAILED";
|
|
160
|
-
|
|
169
|
+
const logText = `VERIFICATION: '${verificationResult}'. Attribute value of '${control.controlDescription}' Expected: '${expectedAttributeValue}' Actual : '${value}'`;
|
|
161
170
|
(0, logs_core_1.logVerification)(logText);
|
|
162
171
|
test_1.expect.soft(value, logText).toBe(expectedAttributeValue);
|
|
163
|
-
}
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Attribute '${attributeName}' on '${control.controlDescription}' could not be verified due to reason: '${error}'`);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
164
177
|
}
|
|
165
178
|
/**
|
|
166
179
|
* Verify element's attribute value contains expected value
|
|
@@ -177,18 +190,24 @@ class Assertion extends actions_core_1.Actions {
|
|
|
177
190
|
* verifyAttributeValueContains(loginBtn, "value", "Submit");
|
|
178
191
|
*/
|
|
179
192
|
async verifyAttributeValueContains(control, attributeName, attributeValue) {
|
|
180
|
-
|
|
193
|
+
try {
|
|
194
|
+
const value = await this.getAttributeValue(control, attributeName);
|
|
181
195
|
if (value != null) {
|
|
182
196
|
const verificationResult = value.trim().includes(attributeValue) ? "✅ PASSED" : "❌ FAILED";
|
|
183
|
-
|
|
197
|
+
const logText = `VERIFICATION: '${verificationResult}'. Attribute value of '${control.controlDescription}' Expected: '${attributeValue}' contained in Actual: '${value}'`;
|
|
184
198
|
(0, logs_core_1.logVerification)(logText);
|
|
185
|
-
test_1.expect.soft(
|
|
199
|
+
test_1.expect.soft(value, logText).toContain(attributeValue);
|
|
186
200
|
}
|
|
187
201
|
else {
|
|
188
|
-
|
|
189
|
-
|
|
202
|
+
const failText = `VERIFICATION: '❌ FAILED'. Attribute '${attributeName}' on '${control.controlDescription}' is null. Expected to contain: '${attributeValue}'`;
|
|
203
|
+
(0, logs_core_1.logVerification)(failText);
|
|
204
|
+
test_1.expect.soft(value, failText).toContain(attributeValue);
|
|
190
205
|
}
|
|
191
|
-
}
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Attribute '${attributeName}' contains check on '${control.controlDescription}' failed due to reason: '${error}'`);
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
192
211
|
}
|
|
193
212
|
/**
|
|
194
213
|
* Verify element's enabled/disabled status as per expected value
|
|
@@ -207,12 +226,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
207
226
|
await this.page.waitForLoadState("load");
|
|
208
227
|
}
|
|
209
228
|
if (expValue) {
|
|
210
|
-
|
|
229
|
+
try {
|
|
230
|
+
const value = await control.controlLocator.isEnabled();
|
|
211
231
|
const verificationResult = value === true ? "✅ PASSED" : "❌ FAILED";
|
|
212
|
-
|
|
232
|
+
const logText = `VERIFICATION: '${verificationResult}'. '${control.controlDescription}' enabled status is: '${value}'`;
|
|
213
233
|
(0, logs_core_1.logVerification)(logText);
|
|
214
234
|
test_1.expect.soft(value, logText).toBe(true);
|
|
215
|
-
}
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. '${control.controlDescription}' enabled status could not be verified due to reason: '${error}'`);
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
216
240
|
}
|
|
217
241
|
else {
|
|
218
242
|
await this.verifyIsDisabled(control, true);
|
|
@@ -222,12 +246,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
222
246
|
if (expValue == true) {
|
|
223
247
|
await this.page.waitForLoadState("load");
|
|
224
248
|
}
|
|
225
|
-
|
|
249
|
+
try {
|
|
250
|
+
const value = await control.controlLocator.isDisabled();
|
|
226
251
|
const verificationResult = value === true ? "✅ PASSED" : "❌ FAILED";
|
|
227
|
-
|
|
252
|
+
const logText = `VERIFICATION: '${verificationResult}'. '${control.controlDescription}' disabled status is: '${value}'`;
|
|
228
253
|
(0, logs_core_1.logVerification)(logText);
|
|
229
254
|
test_1.expect.soft(value, logText).toBe(true);
|
|
230
|
-
}
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. '${control.controlDescription}' disabled status could not be verified due to reason: '${error}'`);
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
231
260
|
}
|
|
232
261
|
/**
|
|
233
262
|
* The function `verifyIsSelected` asynchronously verifies if a web control is selected with an
|
|
@@ -242,12 +271,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
242
271
|
if (expValue == true) {
|
|
243
272
|
await this.page.waitForLoadState("load");
|
|
244
273
|
}
|
|
245
|
-
|
|
274
|
+
try {
|
|
275
|
+
const isChecked = await control.controlLocator.first().isChecked();
|
|
246
276
|
const verificationResult = isChecked === expValue ? "✅ PASSED" : "❌ FAILED";
|
|
247
|
-
|
|
277
|
+
const logText = `VERIFICATION: '${verificationResult}' '${control.controlDescription}' selected status is: '${isChecked}' Expected: '${expValue}'`;
|
|
248
278
|
(0, logs_core_1.logVerification)(logText);
|
|
249
279
|
test_1.expect.soft(isChecked, logText).toBe(expValue);
|
|
250
|
-
}
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. '${control.controlDescription}' selected status could not be verified due to reason: '${error}'`);
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
251
285
|
}
|
|
252
286
|
/**
|
|
253
287
|
* Verify element's text as per expected value
|
|
@@ -262,12 +296,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
262
296
|
* verifyDisplayedText(loginBtn, "Invalid Username Test User");
|
|
263
297
|
*/
|
|
264
298
|
async verifyDisplayedText(control, expectedText) {
|
|
265
|
-
|
|
299
|
+
try {
|
|
300
|
+
const value = await this.getText(control);
|
|
266
301
|
const verificationResult = value?.trim() === expectedText.trim() ? "✅ PASSED" : "❌ FAILED";
|
|
267
|
-
|
|
302
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify text of '${control.controlDescription}'. Expected: '${expectedText}' Actual: '${value}'`;
|
|
268
303
|
(0, logs_core_1.logVerification)(logText);
|
|
269
304
|
test_1.expect.soft(value?.trim(), logText).toBe(expectedText.trim());
|
|
270
|
-
}
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Displayed text of '${control.controlDescription}' could not be verified due to reason: '${error}'`);
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
271
310
|
}
|
|
272
311
|
/**
|
|
273
312
|
* Verify element's text contains partial expected value
|
|
@@ -282,12 +321,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
282
321
|
* verifyDisplayedTextContains(loginBtn, "Invalid Username");
|
|
283
322
|
*/
|
|
284
323
|
async verifyDisplayedTextContains(control, expectedText) {
|
|
285
|
-
|
|
324
|
+
try {
|
|
325
|
+
const value = await this.getText(control);
|
|
286
326
|
const verificationResult = value?.trim().includes(expectedText.trim()) ? "✅ PASSED" : "❌ FAILED";
|
|
287
|
-
|
|
327
|
+
const logText = `VERIFICATION: '${verificationResult}'. Verify text of '${control.controlDescription}'. Expected: '${expectedText.trim()}' is present in Actual: '${value?.trim()}'`;
|
|
288
328
|
(0, logs_core_1.logVerification)(logText);
|
|
289
329
|
test_1.expect.soft(value?.trim(), logText).toContain(expectedText.trim());
|
|
290
|
-
}
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Text contains check on '${control.controlDescription}' could not be completed due to reason: '${error}'`);
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
291
335
|
}
|
|
292
336
|
/**
|
|
293
337
|
* Verify element's text does not contains expected value
|
|
@@ -302,12 +346,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
302
346
|
* verifyDisplayedTextDoesNotContains(loginBtn, "Enter User");
|
|
303
347
|
*/
|
|
304
348
|
async verifyDisplayedTextDoesNotContains(control, expectedText) {
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
|
|
349
|
+
try {
|
|
350
|
+
const value = await this.getText(control);
|
|
351
|
+
const verificationResult = !value?.trim().includes(expectedText.trim()) ? "✅ PASSED" : "❌ FAILED";
|
|
352
|
+
const logText = `VERIFICATION: '${verificationResult}'. Verify text of '${control.controlDescription}' Expected: '${expectedText}' does not contain Actual: '${value}'`;
|
|
308
353
|
(0, logs_core_1.logVerification)(logText);
|
|
309
354
|
test_1.expect.soft(false, logText).toBe(value?.trim().includes(expectedText.trim()));
|
|
310
|
-
}
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Text does-not-contain check on '${control.controlDescription}' could not be completed due to reason: '${error}'`);
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
311
360
|
}
|
|
312
361
|
/**
|
|
313
362
|
* Verify element's textbox is equal to expected value
|
|
@@ -322,20 +371,30 @@ class Assertion extends actions_core_1.Actions {
|
|
|
322
371
|
* verifyTextboxValue(usernameTxtbx, "Test@Adactin");
|
|
323
372
|
*/
|
|
324
373
|
async verifyTextboxValue(control, expectedText) {
|
|
325
|
-
|
|
374
|
+
try {
|
|
375
|
+
const value = await control.controlLocator.first().getAttribute("value");
|
|
326
376
|
const verificationResult = value?.trim() === expectedText ? "✅ PASSED" : "❌ FAILED";
|
|
327
|
-
|
|
377
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify textbox value of '${control.controlDescription}'. Expected: '${expectedText}' Actual: '${value}'`;
|
|
328
378
|
(0, logs_core_1.logVerification)(logText);
|
|
329
379
|
test_1.expect.soft(value?.trim(), logText).toEqual(expectedText);
|
|
330
|
-
}
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Textbox value of '${control.controlDescription}' could not be verified due to reason: '${error}'`);
|
|
383
|
+
throw error;
|
|
384
|
+
}
|
|
331
385
|
}
|
|
332
386
|
async verifyTextboxValueContains(control, expectedText) {
|
|
333
|
-
|
|
387
|
+
try {
|
|
388
|
+
const value = await control.controlLocator.first().getAttribute("value");
|
|
334
389
|
const verificationResult = value?.trim().includes(expectedText) ? "✅ PASSED" : "❌ FAILED";
|
|
335
|
-
|
|
390
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify textbox value of '${control.controlDescription}'. Expected: '${expectedText}' Actual: '${value}'`;
|
|
336
391
|
(0, logs_core_1.logVerification)(logText);
|
|
337
392
|
test_1.expect.soft(value?.trim(), logText).toContain(expectedText);
|
|
338
|
-
}
|
|
393
|
+
}
|
|
394
|
+
catch (error) {
|
|
395
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Textbox value contains check on '${control.controlDescription}' could not be completed due to reason: '${error}'`);
|
|
396
|
+
throw error;
|
|
397
|
+
}
|
|
339
398
|
}
|
|
340
399
|
/**
|
|
341
400
|
* Verify element's inner text is equal to expected value
|
|
@@ -350,20 +409,30 @@ class Assertion extends actions_core_1.Actions {
|
|
|
350
409
|
* verifyTextboxValue(usernameTxtbx, "Test@Gmail.com");
|
|
351
410
|
*/
|
|
352
411
|
async verifyInnerText(control, expectedText) {
|
|
353
|
-
|
|
412
|
+
try {
|
|
413
|
+
const value = await control.controlLocator.first().innerText();
|
|
354
414
|
const verificationResult = value.trim() === expectedText ? "✅ PASSED" : "❌ FAILED";
|
|
355
|
-
|
|
415
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify value of '${control.controlDescription}'. Expected: '${expectedText}' Actual: '${value}'`;
|
|
356
416
|
(0, logs_core_1.logVerification)(logText);
|
|
357
417
|
test_1.expect.soft(value.trim(), logText).toEqual(expectedText);
|
|
358
|
-
}
|
|
418
|
+
}
|
|
419
|
+
catch (error) {
|
|
420
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. innerText of '${control.controlDescription}' could not be verified due to reason: '${error}'`);
|
|
421
|
+
throw error;
|
|
422
|
+
}
|
|
359
423
|
}
|
|
360
424
|
async verifyInnerTextContains(control, expectedText) {
|
|
361
|
-
|
|
425
|
+
try {
|
|
426
|
+
const value = await control.controlLocator.first().innerText();
|
|
362
427
|
const verificationResult = value.trim().includes(expectedText) ? "✅ PASSED" : "❌ FAILED";
|
|
363
|
-
|
|
428
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify value of '${control.controlDescription}'. Expected: '${expectedText}' Actual: '${value}'`;
|
|
364
429
|
(0, logs_core_1.logVerification)(logText);
|
|
365
430
|
test_1.expect.soft(value.trim(), logText).toContain(expectedText);
|
|
366
|
-
}
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. innerText contains check on '${control.controlDescription}' could not be completed due to reason: '${error}'`);
|
|
434
|
+
throw error;
|
|
435
|
+
}
|
|
367
436
|
}
|
|
368
437
|
/**
|
|
369
438
|
* Verify element's input text is equal to expected value
|
|
@@ -378,20 +447,30 @@ class Assertion extends actions_core_1.Actions {
|
|
|
378
447
|
* verifyTextboxValue(usernameTxtbx, "Test@Adactin");
|
|
379
448
|
*/
|
|
380
449
|
async verifyInputValue(control, expectedText) {
|
|
381
|
-
|
|
450
|
+
try {
|
|
451
|
+
const value = await control.controlLocator.first().inputValue();
|
|
382
452
|
const verificationResult = value.trim() === expectedText ? "✅ PASSED" : "❌ FAILED";
|
|
383
|
-
|
|
453
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify value of '${control.controlDescription}'. Expected: '${expectedText}' Actual: '${value}'`;
|
|
384
454
|
(0, logs_core_1.logVerification)(logText);
|
|
385
455
|
test_1.expect.soft(value.trim(), logText).toEqual(expectedText);
|
|
386
|
-
}
|
|
456
|
+
}
|
|
457
|
+
catch (error) {
|
|
458
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. inputValue of '${control.controlDescription}' could not be verified due to reason: '${error}'`);
|
|
459
|
+
throw error;
|
|
460
|
+
}
|
|
387
461
|
}
|
|
388
462
|
async verifyInputValueContains(control, expectedText) {
|
|
389
|
-
|
|
463
|
+
try {
|
|
464
|
+
const value = await control.controlLocator.first().inputValue();
|
|
390
465
|
const verificationResult = value.trim().includes(expectedText) ? "✅ PASSED" : "❌ FAILED";
|
|
391
|
-
|
|
466
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify value of '${control.controlDescription}'. Expected: '${expectedText}' Actual: '${value}'`;
|
|
392
467
|
(0, logs_core_1.logVerification)(logText);
|
|
393
468
|
test_1.expect.soft(value.trim(), logText).toContain(expectedText);
|
|
394
|
-
}
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. inputValue contains check on '${control.controlDescription}' could not be completed due to reason: '${error}'`);
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
395
474
|
}
|
|
396
475
|
/**
|
|
397
476
|
* Verify element's checkbox/radio value is equal to expected value
|
|
@@ -406,12 +485,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
406
485
|
* verifyCheckboxValue(isMinor, true);
|
|
407
486
|
*/
|
|
408
487
|
async verifyCheckboxValue(control, value) {
|
|
409
|
-
|
|
488
|
+
try {
|
|
489
|
+
const isChecked = await this.isSelected(control);
|
|
410
490
|
const verificationResult = value === isChecked ? "✅ PASSED" : "❌ FAILED";
|
|
411
|
-
|
|
491
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify checkbox value of '${control.controlDescription}'. Expected: '${value}' Actual: '${isChecked}'`;
|
|
412
492
|
(0, logs_core_1.logVerification)(logText);
|
|
413
493
|
test_1.expect.soft(isChecked, logText).toBe(value);
|
|
414
|
-
}
|
|
494
|
+
}
|
|
495
|
+
catch (error) {
|
|
496
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Checkbox value of '${control.controlDescription}' could not be verified due to reason: '${error}'`);
|
|
497
|
+
throw error;
|
|
498
|
+
}
|
|
415
499
|
}
|
|
416
500
|
/**
|
|
417
501
|
* Verify element's tagname is equal to expected value
|
|
@@ -426,80 +510,108 @@ class Assertion extends actions_core_1.Actions {
|
|
|
426
510
|
* verifyTagName(isMinor, "a");
|
|
427
511
|
*/
|
|
428
512
|
async verifyTagName(control, expectedTagName) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
513
|
+
try {
|
|
514
|
+
const parent = control.controlLocator.first();
|
|
515
|
+
const tagName = await parent.evaluate((e) => e.tagName);
|
|
516
|
+
const verificationResult = tagName?.toLowerCase() == expectedTagName.toLowerCase() ? "✅ PASSED" : "❌ FAILED";
|
|
517
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify Tagname of '${control.controlDescription}'. Expected: '${expectedTagName.toLowerCase()}' Actual: '${tagName?.toLowerCase()}'`;
|
|
518
|
+
(0, logs_core_1.logVerification)(logText);
|
|
519
|
+
test_1.expect.soft(tagName?.toLowerCase(), logText).toBe(expectedTagName.toLowerCase());
|
|
520
|
+
}
|
|
521
|
+
catch (error) {
|
|
522
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Tag name of '${control.controlDescription}' could not be verified due to reason: '${error}'`);
|
|
523
|
+
throw error;
|
|
433
524
|
}
|
|
434
|
-
const verificationResult = tagName?.toLowerCase() == expectedTagName.toLowerCase() ? "✅ PASSED" : "❌ FAILED";
|
|
435
|
-
let logText = `VERIFICATION: '${verificationResult}' Verify Tagname of ${control.controlDescription}. Expected: '${expectedTagName.toLowerCase()}' Actual: '${tagName?.toLowerCase()}'`;
|
|
436
|
-
(0, logs_core_1.logVerification)(logText);
|
|
437
|
-
test_1.expect.soft(tagName?.toLowerCase(), logText).toBe(expectedTagName.toLowerCase());
|
|
438
525
|
}
|
|
439
526
|
async verifyListContainsValue(control, valueToVerify) {
|
|
440
|
-
|
|
441
|
-
const count = listOfElements.filter(async function (elem) {
|
|
442
|
-
return await elem.innerText().then(async function (text) {
|
|
443
|
-
return text.trim().includes(valueToVerify);
|
|
444
|
-
});
|
|
445
|
-
}).length;
|
|
446
|
-
const verificationResult = count >= 1 ? "✅ PASSED" : "❌ FAILED";
|
|
447
|
-
let logText = `VERIFICATION: '${verificationResult}'. '${valueToVerify}' is Present in list '${control.controlDescription}'`;
|
|
448
|
-
(0, logs_core_1.logVerification)(logText);
|
|
449
|
-
test_1.expect.soft(count, logText).toBeGreaterThanOrEqual(1);
|
|
450
|
-
}
|
|
451
|
-
async verifyListContainsMultipleValues(control, listOfValueToVerify, waitTillElementIsDisplayed = true) {
|
|
452
|
-
if (waitTillElementIsDisplayed) {
|
|
453
|
-
await this.waitTillElementIsPresent(control);
|
|
454
|
-
}
|
|
455
|
-
listOfValueToVerify.forEach(async (expectedValue) => {
|
|
527
|
+
try {
|
|
456
528
|
const listOfElements = await control.controlLocator.all();
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
529
|
+
let count = 0;
|
|
530
|
+
for (const elem of listOfElements) {
|
|
531
|
+
const text = (await elem.innerText()).trim();
|
|
532
|
+
if (text.includes(valueToVerify)) {
|
|
533
|
+
count++;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
462
536
|
const verificationResult = count >= 1 ? "✅ PASSED" : "❌ FAILED";
|
|
463
|
-
|
|
537
|
+
const logText = `VERIFICATION: '${verificationResult}'. '${valueToVerify}' is Present in list '${control.controlDescription}'`;
|
|
464
538
|
(0, logs_core_1.logVerification)(logText);
|
|
465
539
|
test_1.expect.soft(count, logText).toBeGreaterThanOrEqual(1);
|
|
466
|
-
}
|
|
540
|
+
}
|
|
541
|
+
catch (error) {
|
|
542
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. verifyListContainsValue for '${control.controlDescription}' due to reason: '${error}'`);
|
|
543
|
+
throw error;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
async verifyListContainsMultipleValues(control, listOfValueToVerify, waitTillElementIsDisplayed = true) {
|
|
547
|
+
try {
|
|
548
|
+
if (waitTillElementIsDisplayed) {
|
|
549
|
+
await this.waitTillElementIsPresent(control);
|
|
550
|
+
}
|
|
551
|
+
for (const expectedValue of listOfValueToVerify) {
|
|
552
|
+
const listOfElements = await control.controlLocator.all();
|
|
553
|
+
let count = 0;
|
|
554
|
+
for (const element of listOfElements) {
|
|
555
|
+
const text = (await element.innerText()).trim();
|
|
556
|
+
if (text.includes(expectedValue)) {
|
|
557
|
+
count++;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
const verificationResult = count >= 1 ? "✅ PASSED" : "❌ FAILED";
|
|
561
|
+
const logText = `VERIFICATION: '${verificationResult}'. '${expectedValue}' is Present in list '${control.controlDescription}'`;
|
|
562
|
+
(0, logs_core_1.logVerification)(logText);
|
|
563
|
+
test_1.expect.soft(count, logText).toBeGreaterThanOrEqual(1);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
catch (error) {
|
|
567
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. verifyListContainsMultipleValues for '${control.controlDescription}' due to reason: '${error}'`);
|
|
568
|
+
throw error;
|
|
569
|
+
}
|
|
467
570
|
}
|
|
468
571
|
async verifyDropdownOptions(control, listOfValueToVerify, waitTillElementIsDisplayed = true) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
572
|
+
try {
|
|
573
|
+
if (waitTillElementIsDisplayed) {
|
|
574
|
+
await this.waitTillElementIsPresent(control);
|
|
575
|
+
}
|
|
576
|
+
const options = await control.controlLocator.locator('option').all();
|
|
577
|
+
const listOfOptions = [];
|
|
578
|
+
for (const option of options) {
|
|
579
|
+
const value = await option.innerText();
|
|
580
|
+
if (value) {
|
|
581
|
+
listOfOptions.push(value);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
for (const expectedValue of listOfValueToVerify) {
|
|
585
|
+
const count = listOfOptions.filter((o) => o.trim().includes(expectedValue)).length;
|
|
586
|
+
const verificationResult = count >= 1 ? "✅ PASSED" : "❌ FAILED";
|
|
587
|
+
const logText = `VERIFICATION: '${verificationResult}'. '${expectedValue}' is Present in list '${control.controlDescription}'`;
|
|
588
|
+
(0, logs_core_1.logVerification)(logText);
|
|
589
|
+
test_1.expect.soft(count, logText).toBeGreaterThanOrEqual(1);
|
|
475
590
|
}
|
|
476
591
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
return text.trim().includes(expectedValue);
|
|
482
|
-
});
|
|
483
|
-
}).length;
|
|
484
|
-
const verificationResult = count >= 1 ? "✅ PASSED" : "❌ FAILED";
|
|
485
|
-
let logText = `VERIFICATION: '${verificationResult}'. '${expectedValue}' is Present in list '${control.controlDescription}'`;
|
|
486
|
-
(0, logs_core_1.logVerification)(logText);
|
|
487
|
-
test_1.expect.soft(count, logText).toBeGreaterThanOrEqual(1);
|
|
488
|
-
});
|
|
592
|
+
catch (error) {
|
|
593
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. verifyDropdownOptions for '${control.controlDescription}' due to reason: '${error}'`);
|
|
594
|
+
throw error;
|
|
595
|
+
}
|
|
489
596
|
}
|
|
490
597
|
async verifyListForMultipleValues(control, listOfValueToVerify, waitTillElementIsDisplayed = true) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
598
|
+
try {
|
|
599
|
+
if (waitTillElementIsDisplayed) {
|
|
600
|
+
await this.waitTillElementIsPresent(control);
|
|
601
|
+
}
|
|
602
|
+
const list = await control.controlLocator.all();
|
|
603
|
+
for (let i = 0; i < listOfValueToVerify.length; i++) {
|
|
604
|
+
await list[i].waitFor({ state: "visible" });
|
|
605
|
+
const value = await list[i].innerText();
|
|
498
606
|
const verificationResult = value.trim().includes(listOfValueToVerify[i]) ? "✅ PASSED" : "❌ FAILED";
|
|
499
|
-
|
|
607
|
+
const logText = `VERIFICATION: '${verificationResult}'. '${control.controlDescription}' Expected: '${listOfValueToVerify[i]}' Actual: '${value}'`;
|
|
500
608
|
(0, logs_core_1.logVerification)(logText);
|
|
501
609
|
test_1.expect.soft(value.trim(), logText).toContain(listOfValueToVerify[i]);
|
|
502
|
-
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
catch (error) {
|
|
613
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. verifyListForMultipleValues for '${control.controlDescription}' due to reason: '${error}'`);
|
|
614
|
+
throw error;
|
|
503
615
|
}
|
|
504
616
|
}
|
|
505
617
|
/**
|
|
@@ -513,10 +625,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
513
625
|
*/
|
|
514
626
|
async verifyAlertText(expectedText) {
|
|
515
627
|
this.page.on('dialog', async (dialog) => {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
628
|
+
try {
|
|
629
|
+
const message = dialog.message();
|
|
630
|
+
const verificationResult = message.trim().includes(expectedText.trim()) ? "✅ PASSED" : "❌ FAILED";
|
|
631
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify alert text. Expected: '${expectedText}' Actual: '${message}'`;
|
|
632
|
+
(0, logs_core_1.logVerification)(logText);
|
|
633
|
+
test_1.expect.soft(message.trim(), logText).toContain(expectedText.trim());
|
|
634
|
+
}
|
|
635
|
+
catch (error) {
|
|
636
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. verifyAlertText could not be completed. Expected to contain: '${expectedText}' due to reason: '${error}'`);
|
|
637
|
+
throw error;
|
|
638
|
+
}
|
|
520
639
|
});
|
|
521
640
|
}
|
|
522
641
|
/**
|
|
@@ -529,12 +648,17 @@ class Assertion extends actions_core_1.Actions {
|
|
|
529
648
|
* verifyURLContains("google.com");
|
|
530
649
|
*/
|
|
531
650
|
async verifyURLContains(subString) {
|
|
532
|
-
|
|
651
|
+
try {
|
|
652
|
+
const value = await this.getURL();
|
|
533
653
|
const verificationResult = value.trim().includes(subString.trim()) ? "✅ PASSED" : "❌ FAILED";
|
|
534
|
-
|
|
654
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify URL contains. Expected: '${subString}' Actual: '${value}'`;
|
|
535
655
|
(0, logs_core_1.logVerification)(logText);
|
|
536
656
|
test_1.expect.soft(value.trim(), logText).toContain(subString.trim());
|
|
537
|
-
}
|
|
657
|
+
}
|
|
658
|
+
catch (error) {
|
|
659
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. URL contains check for '${subString}' could not be completed due to reason: '${error}'`);
|
|
660
|
+
throw error;
|
|
661
|
+
}
|
|
538
662
|
}
|
|
539
663
|
/**
|
|
540
664
|
* Verify count of elements which matched the control
|
|
@@ -548,28 +672,43 @@ class Assertion extends actions_core_1.Actions {
|
|
|
548
672
|
* verifyCountOfElements(isMinor, 5);
|
|
549
673
|
*/
|
|
550
674
|
async verifyCountOfElements(control, expectedCount) {
|
|
551
|
-
|
|
675
|
+
try {
|
|
676
|
+
const value = await control.controlLocator.count();
|
|
552
677
|
const verificationResult = value == expectedCount ? "✅ PASSED" : "❌ FAILED";
|
|
553
|
-
|
|
678
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify count of elements of '${control.controlDescription}'. Expected: '${expectedCount}' Actual: '${value}'`;
|
|
554
679
|
(0, logs_core_1.logVerification)(logText);
|
|
555
680
|
test_1.expect.soft(value, logText).toBe(expectedCount);
|
|
556
|
-
}
|
|
681
|
+
}
|
|
682
|
+
catch (error) {
|
|
683
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. verifyCountOfElements for '${control.controlDescription}' could not be completed due to reason: '${error}'`);
|
|
684
|
+
throw error;
|
|
685
|
+
}
|
|
557
686
|
}
|
|
558
687
|
async verifyCountOfElementsIsGreaterOrEqual(control, expectedCount) {
|
|
559
|
-
|
|
688
|
+
try {
|
|
689
|
+
const value = await control.controlLocator.count();
|
|
560
690
|
const verificationResult = value >= expectedCount ? "✅ PASSED" : "❌ FAILED";
|
|
561
|
-
|
|
691
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify count of elements of '${control.controlDescription}'. Expected: '${expectedCount}' Actual: '${value}'`;
|
|
562
692
|
(0, logs_core_1.logVerification)(logText);
|
|
563
693
|
test_1.expect.soft(value, logText).toBeGreaterThanOrEqual(expectedCount);
|
|
564
|
-
}
|
|
694
|
+
}
|
|
695
|
+
catch (error) {
|
|
696
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. verifyCountOfElementsIsGreaterOrEqual for '${control.controlDescription}' could not be completed due to reason: '${error}'`);
|
|
697
|
+
throw error;
|
|
698
|
+
}
|
|
565
699
|
}
|
|
566
700
|
async verifyCountOfElementsIsLesseOrEqual(control, expectedCount) {
|
|
567
|
-
|
|
701
|
+
try {
|
|
702
|
+
const value = await control.controlLocator.count();
|
|
568
703
|
const verificationResult = value <= expectedCount ? "✅ PASSED" : "❌ FAILED";
|
|
569
|
-
|
|
704
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify count of elements of '${control.controlDescription}'. Expected: '${expectedCount}' Actual: '${value}'`;
|
|
570
705
|
(0, logs_core_1.logVerification)(logText);
|
|
571
706
|
test_1.expect.soft(value, logText).toBeLessThanOrEqual(expectedCount);
|
|
572
|
-
}
|
|
707
|
+
}
|
|
708
|
+
catch (error) {
|
|
709
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. verifyCountOfElementsIsLesseOrEqual for '${control.controlDescription}' could not be completed due to reason: '${error}'`);
|
|
710
|
+
throw error;
|
|
711
|
+
}
|
|
573
712
|
}
|
|
574
713
|
/**
|
|
575
714
|
* Verify title of web page contains expected value
|
|
@@ -582,18 +721,15 @@ class Assertion extends actions_core_1.Actions {
|
|
|
582
721
|
*/
|
|
583
722
|
async verifyPageTitleContains(expectedText) {
|
|
584
723
|
try {
|
|
585
|
-
await this.page.title()
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}, function (reason) {
|
|
591
|
-
(0, logs_core_1.logError)('❌ Error : ' + reason);
|
|
592
|
-
});
|
|
724
|
+
const value = await this.page.title();
|
|
725
|
+
const verificationResult = value.trim().includes(expectedText) ? "✅ PASSED" : "❌ FAILED";
|
|
726
|
+
const logText = `VERIFICATION: '${verificationResult}' Verify title contains. Expected: '${expectedText}' Actual: '${value}'`;
|
|
727
|
+
(0, logs_core_1.logVerification)(logText);
|
|
728
|
+
test_1.expect.soft(value.trim(), logText).toContain(expectedText);
|
|
593
729
|
}
|
|
594
|
-
catch (
|
|
595
|
-
(0, logs_core_1.logError)(
|
|
596
|
-
throw
|
|
730
|
+
catch (error) {
|
|
731
|
+
(0, logs_core_1.logError)(`VERIFICATION: '❌ FAILED'. Page title could not be verified. Expected: '${expectedText}' to be present in title due to reason: '${error}'`);
|
|
732
|
+
throw error;
|
|
597
733
|
}
|
|
598
734
|
}
|
|
599
735
|
}
|