playwright-ts-automationframework 1.1.69 → 1.1.70

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