playwright-ts-automationframework 1.1.16 → 1.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/core/actions.core.d.ts +10 -9
- package/lib/core/actions.core.js +109 -80
- package/lib/core/assertion.core.js +7 -7
- package/lib/core/basePage.core.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Playwright Typescript Automation framework library
|
|
2
2
|
|
|
3
|
+
Sample Project: https://github.com/ketanp88/PlaywrightFrameworkDemoProject
|
|
4
|
+
|
|
3
5
|
Playwright Typescript Automation framework
|
|
4
6
|
|
|
5
7
|
This is a test automation framework around Playwright - for end-to-end testing. This is Playwright Automation framework has all wrapper actions methods and assertions method along with logger. This is plug and play Playwright Test Automation framework in Typescript.
|
|
@@ -171,7 +171,7 @@ export declare class Actions extends BasePage {
|
|
|
171
171
|
*
|
|
172
172
|
* let errorMessage = getText(errorMsg);
|
|
173
173
|
*/
|
|
174
|
-
getText(control: WebControl): Promise<string>;
|
|
174
|
+
getText(control: WebControl): Promise<string | void>;
|
|
175
175
|
/**
|
|
176
176
|
* Read textbox value of an element
|
|
177
177
|
*
|
|
@@ -183,7 +183,7 @@ export declare class Actions extends BasePage {
|
|
|
183
183
|
*
|
|
184
184
|
* let textboxValue = getTextboxValue(usernameTxtbx);
|
|
185
185
|
*/
|
|
186
|
-
getTextboxValue(control: WebControl): Promise<string>;
|
|
186
|
+
getTextboxValue(control: WebControl): Promise<string | void>;
|
|
187
187
|
/**
|
|
188
188
|
* Read selected dropdown item.
|
|
189
189
|
*
|
|
@@ -195,7 +195,7 @@ export declare class Actions extends BasePage {
|
|
|
195
195
|
*
|
|
196
196
|
* let selectedItem = getSelectedItemFromDropdown(cityDrpdwn);
|
|
197
197
|
*/
|
|
198
|
-
getSelectedItemFromDropdown(control: WebControl): Promise<string>;
|
|
198
|
+
getSelectedItemFromDropdown(control: WebControl): Promise<string | void>;
|
|
199
199
|
/**
|
|
200
200
|
* Read attribute value of element.
|
|
201
201
|
*
|
|
@@ -208,7 +208,7 @@ export declare class Actions extends BasePage {
|
|
|
208
208
|
*
|
|
209
209
|
* let attributeValue = getAttributeValue(usernameTxtbx, "title");
|
|
210
210
|
*/
|
|
211
|
-
getAttributeValue(control: WebControl, attributeName: string): Promise<string | null>;
|
|
211
|
+
getAttributeValue(control: WebControl, attributeName: string): Promise<string | void | null>;
|
|
212
212
|
/**
|
|
213
213
|
* Scroll to an element.
|
|
214
214
|
*
|
|
@@ -284,7 +284,7 @@ export declare class Actions extends BasePage {
|
|
|
284
284
|
*
|
|
285
285
|
* waitTillPageURLContains("https://www.google.com/");
|
|
286
286
|
*/
|
|
287
|
-
waitTillPageURLContains(url: string): Promise<void>;
|
|
287
|
+
waitTillPageURLContains(url: string, timeoutInSeconds?: number): Promise<void>;
|
|
288
288
|
/**
|
|
289
289
|
* Wait till element is present
|
|
290
290
|
*
|
|
@@ -296,7 +296,7 @@ export declare class Actions extends BasePage {
|
|
|
296
296
|
*
|
|
297
297
|
* waitTillElementIsPresent(usernameTxtbx);
|
|
298
298
|
*/
|
|
299
|
-
waitTillElementIsPresent(control: WebControl): Promise<void>;
|
|
299
|
+
waitTillElementIsPresent(control: WebControl, timeoutInSeconds?: number): Promise<void>;
|
|
300
300
|
/**
|
|
301
301
|
* Wait till element is attached to the dom
|
|
302
302
|
*
|
|
@@ -308,7 +308,7 @@ export declare class Actions extends BasePage {
|
|
|
308
308
|
*
|
|
309
309
|
* waitTillElementIsAttached(usernameTxtbx);
|
|
310
310
|
*/
|
|
311
|
-
waitTillElementIsAttached(control: WebControl): Promise<void>;
|
|
311
|
+
waitTillElementIsAttached(control: WebControl, timeoutInSeconds?: number): Promise<void>;
|
|
312
312
|
/**
|
|
313
313
|
* Wait till element is not displayed
|
|
314
314
|
*
|
|
@@ -320,7 +320,7 @@ export declare class Actions extends BasePage {
|
|
|
320
320
|
*
|
|
321
321
|
* waitTillElementIsNotPresent(usernameTxtbx);
|
|
322
322
|
*/
|
|
323
|
-
waitTillElementIsNotPresent(control: WebControl): Promise<void>;
|
|
323
|
+
waitTillElementIsNotPresent(control: WebControl, timeoutInSeconds?: number): Promise<void>;
|
|
324
324
|
/**
|
|
325
325
|
* Wait for execution to stop for given time
|
|
326
326
|
*
|
|
@@ -330,7 +330,8 @@ export declare class Actions extends BasePage {
|
|
|
330
330
|
*
|
|
331
331
|
* sleep(10);
|
|
332
332
|
*/
|
|
333
|
-
sleep(timeInSeconds?: number): Promise<
|
|
333
|
+
sleep(timeInSeconds?: number): Promise<void>;
|
|
334
|
+
waitForPageTimeout(timeoutInSeconds?: number): Promise<void>;
|
|
334
335
|
/**
|
|
335
336
|
* Close the browser instance
|
|
336
337
|
*
|
package/lib/core/actions.core.js
CHANGED
|
@@ -79,10 +79,12 @@ var Actions = /** @class */ (function (_super) {
|
|
|
79
79
|
if (isforceful === void 0) { isforceful = false; }
|
|
80
80
|
return __generator(this, function (_a) {
|
|
81
81
|
switch (_a.label) {
|
|
82
|
-
case 0: return [4 /*yield*/, control.controlLocator.click({ force: isforceful }).then(function () {
|
|
82
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().click({ force: isforceful }).then(function () {
|
|
83
83
|
(0, logs_core_1.logAction)("Clicked on '" + control.controlDescription + "'");
|
|
84
84
|
}, function (error) {
|
|
85
85
|
(0, logs_core_1.errorLog)("Unable to click on '" + control.controlDescription + "'");
|
|
86
|
+
(0, logs_core_1.consoleLog)("Error: '" + error + "'");
|
|
87
|
+
throw error;
|
|
86
88
|
})];
|
|
87
89
|
case 1:
|
|
88
90
|
_a.sent();
|
|
@@ -106,10 +108,11 @@ var Actions = /** @class */ (function (_super) {
|
|
|
106
108
|
return __awaiter(this, void 0, void 0, function () {
|
|
107
109
|
return __generator(this, function (_a) {
|
|
108
110
|
switch (_a.label) {
|
|
109
|
-
case 0: return [4 /*yield*/, control.controlLocator.hover().then(function () {
|
|
111
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().hover().then(function () {
|
|
110
112
|
(0, logs_core_1.logAction)("Mouse hover to '" + control.controlDescription + "'");
|
|
111
113
|
}, function (error) {
|
|
112
114
|
(0, logs_core_1.errorLog)("Unable to mouse hover on :'" + control.controlDescription + "'");
|
|
115
|
+
(0, logs_core_1.consoleLog)("Error: '" + error + "'");
|
|
113
116
|
})];
|
|
114
117
|
case 1:
|
|
115
118
|
_a.sent();
|
|
@@ -134,7 +137,7 @@ var Actions = /** @class */ (function (_super) {
|
|
|
134
137
|
return __awaiter(this, void 0, void 0, function () {
|
|
135
138
|
return __generator(this, function (_a) {
|
|
136
139
|
switch (_a.label) {
|
|
137
|
-
case 0: return [4 /*yield*/, control.controlLocator.focus()];
|
|
140
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().focus()];
|
|
138
141
|
case 1:
|
|
139
142
|
_a.sent();
|
|
140
143
|
return [4 /*yield*/, this.pressKeyboardEvent(control, action)];
|
|
@@ -160,7 +163,7 @@ var Actions = /** @class */ (function (_super) {
|
|
|
160
163
|
return __awaiter(this, void 0, void 0, function () {
|
|
161
164
|
return __generator(this, function (_a) {
|
|
162
165
|
switch (_a.label) {
|
|
163
|
-
case 0: return [4 /*yield*/, control.controlLocator.fill(textTobeEntered).then(function () {
|
|
166
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().fill(textTobeEntered).then(function () {
|
|
164
167
|
if (control.controlDescription.trim().toLowerCase().endsWith('textbox')) {
|
|
165
168
|
(0, logs_core_1.logAction)("Entered '" + textTobeEntered + "' in '" + control.controlDescription + "'");
|
|
166
169
|
}
|
|
@@ -169,6 +172,7 @@ var Actions = /** @class */ (function (_super) {
|
|
|
169
172
|
}
|
|
170
173
|
}, function (error) {
|
|
171
174
|
(0, logs_core_1.errorLog)("Unable to enter text in '" + control.controlDescription + "' textbox due to reason: " + error);
|
|
175
|
+
throw error;
|
|
172
176
|
})];
|
|
173
177
|
case 1:
|
|
174
178
|
_a.sent();
|
|
@@ -193,7 +197,7 @@ var Actions = /** @class */ (function (_super) {
|
|
|
193
197
|
return __awaiter(this, void 0, void 0, function () {
|
|
194
198
|
return __generator(this, function (_a) {
|
|
195
199
|
switch (_a.label) {
|
|
196
|
-
case 0: return [4 /*yield*/, control.controlLocator.press(key).then(function () {
|
|
200
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().press(key).then(function () {
|
|
197
201
|
(0, logs_core_1.logAction)("Press Key '" + key.toUpperCase() + "' on '" + control.controlDescription + "'");
|
|
198
202
|
})];
|
|
199
203
|
case 1:
|
|
@@ -218,12 +222,18 @@ var Actions = /** @class */ (function (_super) {
|
|
|
218
222
|
Actions.prototype.selectFromDropdownByValue = function (control, optionTobeSelcted) {
|
|
219
223
|
return __awaiter(this, void 0, void 0, function () {
|
|
220
224
|
return __generator(this, function (_a) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
switch (_a.label) {
|
|
226
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().selectOption({ value: optionTobeSelcted }).then(function () {
|
|
227
|
+
(0, logs_core_1.logAction)("Selected '" + optionTobeSelcted + "' from '" + control.controlDescription + "'");
|
|
228
|
+
}, function (error) {
|
|
229
|
+
(0, logs_core_1.errorLog)("Unable to select '" + optionTobeSelcted + "' from '" + control.controlDescription + "'");
|
|
230
|
+
(0, logs_core_1.consoleLog)("Error: '" + error + "'");
|
|
231
|
+
throw error;
|
|
232
|
+
})];
|
|
233
|
+
case 1:
|
|
234
|
+
_a.sent();
|
|
235
|
+
return [2 /*return*/];
|
|
236
|
+
}
|
|
227
237
|
});
|
|
228
238
|
});
|
|
229
239
|
};
|
|
@@ -242,12 +252,18 @@ var Actions = /** @class */ (function (_super) {
|
|
|
242
252
|
Actions.prototype.selectDropDownByText = function (control, optionTobeSelcted) {
|
|
243
253
|
return __awaiter(this, void 0, void 0, function () {
|
|
244
254
|
return __generator(this, function (_a) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
255
|
+
switch (_a.label) {
|
|
256
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().selectOption({ label: optionTobeSelcted }).then(function () {
|
|
257
|
+
(0, logs_core_1.logAction)("Selected '" + optionTobeSelcted + "' from '" + control.controlDescription + "'");
|
|
258
|
+
}, function (error) {
|
|
259
|
+
(0, logs_core_1.errorLog)("Unable to select '" + optionTobeSelcted + "' from '" + control.controlDescription + "");
|
|
260
|
+
(0, logs_core_1.consoleLog)("Error: '" + error + "'");
|
|
261
|
+
throw error;
|
|
262
|
+
})];
|
|
263
|
+
case 1:
|
|
264
|
+
_a.sent();
|
|
265
|
+
return [2 /*return*/];
|
|
266
|
+
}
|
|
251
267
|
});
|
|
252
268
|
});
|
|
253
269
|
};
|
|
@@ -266,12 +282,18 @@ var Actions = /** @class */ (function (_super) {
|
|
|
266
282
|
Actions.prototype.selectFromDropdownByIndex = function (control, index) {
|
|
267
283
|
return __awaiter(this, void 0, void 0, function () {
|
|
268
284
|
return __generator(this, function (_a) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
285
|
+
switch (_a.label) {
|
|
286
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().selectOption({ index: index }).then(function () {
|
|
287
|
+
(0, logs_core_1.logAction)("Selected '" + index + "' option from '" + control.controlDescription + "'");
|
|
288
|
+
}, function (error) {
|
|
289
|
+
(0, logs_core_1.errorLog)("Unable to select '" + index + "' option from '" + control.controlDescription + "'");
|
|
290
|
+
(0, logs_core_1.errorLog)("Error: '" + error + "'");
|
|
291
|
+
throw error;
|
|
292
|
+
})];
|
|
293
|
+
case 1:
|
|
294
|
+
_a.sent();
|
|
295
|
+
return [2 /*return*/];
|
|
296
|
+
}
|
|
275
297
|
});
|
|
276
298
|
});
|
|
277
299
|
};
|
|
@@ -298,10 +320,16 @@ var Actions = /** @class */ (function (_super) {
|
|
|
298
320
|
if (!(expectedCheckboxValue == true)) return [3 /*break*/, 2];
|
|
299
321
|
control.controlLocator.first().check().then(function () {
|
|
300
322
|
(0, logs_core_1.logAction)("Set checkbox value of '" + control.controlDescription + "' as checked");
|
|
323
|
+
}, function (error) {
|
|
324
|
+
(0, logs_core_1.errorLog)("Unable Set checkbox value of '" + control.controlDescription + "' as checked");
|
|
325
|
+
throw error;
|
|
301
326
|
});
|
|
302
327
|
return [3 /*break*/, 4];
|
|
303
328
|
case 2: return [4 /*yield*/, control.controlLocator.first().uncheck().then(function () {
|
|
304
329
|
(0, logs_core_1.logAction)("Set checkbox value of '" + control.controlDescription + "' as unchecked");
|
|
330
|
+
}, function (error) {
|
|
331
|
+
(0, logs_core_1.errorLog)("Unable Set checkbox value of '" + control.controlDescription + "' as unchecked");
|
|
332
|
+
throw error;
|
|
305
333
|
})];
|
|
306
334
|
case 3:
|
|
307
335
|
_a.sent();
|
|
@@ -325,19 +353,14 @@ var Actions = /** @class */ (function (_super) {
|
|
|
325
353
|
*/
|
|
326
354
|
Actions.prototype.isSelected = function (control) {
|
|
327
355
|
return __awaiter(this, void 0, void 0, function () {
|
|
356
|
+
var isChecked;
|
|
328
357
|
return __generator(this, function (_a) {
|
|
329
358
|
switch (_a.label) {
|
|
330
|
-
case 0: return [4 /*yield*/, control.controlLocator.first().isChecked()
|
|
331
|
-
if (value) {
|
|
332
|
-
(0, logs_core_1.consoleLog)("'" + control.controlDescription + "' checkbox is selected");
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
(0, logs_core_1.consoleLog)("'" + control.controlDescription + "' checkbox is not selected");
|
|
336
|
-
}
|
|
337
|
-
})];
|
|
359
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().isChecked()];
|
|
338
360
|
case 1:
|
|
339
|
-
_a.sent();
|
|
340
|
-
|
|
361
|
+
isChecked = _a.sent();
|
|
362
|
+
(0, logs_core_1.consoleLog)("'".concat(control.controlDescription, "' checkbox is ").concat(isChecked ? 'selected' : 'not selected'));
|
|
363
|
+
return [2 /*return*/, isChecked];
|
|
341
364
|
}
|
|
342
365
|
});
|
|
343
366
|
});
|
|
@@ -359,16 +382,10 @@ var Actions = /** @class */ (function (_super) {
|
|
|
359
382
|
return __generator(this, function (_a) {
|
|
360
383
|
switch (_a.label) {
|
|
361
384
|
case 0: return [4 /*yield*/, control.controlLocator.first().isEnabled().then(function (value) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
(0, logs_core_1.consoleLog)("'" + control.controlDescription + "' is not enabled");
|
|
367
|
-
}
|
|
385
|
+
(0, logs_core_1.consoleLog)("'".concat(control.controlDescription, "' is ").concat(value ? 'enabled' : 'not enabled'));
|
|
386
|
+
return value;
|
|
368
387
|
})];
|
|
369
|
-
case 1:
|
|
370
|
-
_a.sent();
|
|
371
|
-
return [2 /*return*/, control.controlLocator.first().isEnabled()];
|
|
388
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
372
389
|
}
|
|
373
390
|
});
|
|
374
391
|
});
|
|
@@ -387,19 +404,14 @@ var Actions = /** @class */ (function (_super) {
|
|
|
387
404
|
*/
|
|
388
405
|
Actions.prototype.isDisplayed = function (control) {
|
|
389
406
|
return __awaiter(this, void 0, void 0, function () {
|
|
407
|
+
var isVisible;
|
|
390
408
|
return __generator(this, function (_a) {
|
|
391
409
|
switch (_a.label) {
|
|
392
|
-
case 0: return [4 /*yield*/, control.controlLocator.first().isVisible()
|
|
393
|
-
if (value) {
|
|
394
|
-
(0, logs_core_1.consoleLog)("'" + control.controlDescription + "' is displayed");
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
(0, logs_core_1.consoleLog)("'" + control.controlDescription + "' is not displayed");
|
|
398
|
-
}
|
|
399
|
-
})];
|
|
410
|
+
case 0: return [4 /*yield*/, control.controlLocator.first().isVisible()];
|
|
400
411
|
case 1:
|
|
401
|
-
_a.sent();
|
|
402
|
-
|
|
412
|
+
isVisible = _a.sent();
|
|
413
|
+
(0, logs_core_1.consoleLog)("'".concat(control.controlDescription, "' is ").concat(isVisible ? 'displayed' : 'not displayed'));
|
|
414
|
+
return [2 /*return*/, isVisible];
|
|
403
415
|
}
|
|
404
416
|
});
|
|
405
417
|
});
|
|
@@ -421,12 +433,11 @@ var Actions = /** @class */ (function (_super) {
|
|
|
421
433
|
switch (_a.label) {
|
|
422
434
|
case 0: return [4 /*yield*/, control.controlLocator.first().innerText().then(function (value) {
|
|
423
435
|
(0, logs_core_1.consoleLog)("Value is read from '" + control.controlDescription + "' is: '" + value + "'");
|
|
436
|
+
return value;
|
|
424
437
|
}, function (error) {
|
|
425
438
|
(0, logs_core_1.errorLog)("Unable to read the text from '" + control.controlDescription + "' due to reason: " + error);
|
|
426
439
|
})];
|
|
427
|
-
case 1:
|
|
428
|
-
_a.sent();
|
|
429
|
-
return [2 /*return*/, control.controlLocator.first().innerText()];
|
|
440
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
430
441
|
}
|
|
431
442
|
});
|
|
432
443
|
});
|
|
@@ -448,13 +459,11 @@ var Actions = /** @class */ (function (_super) {
|
|
|
448
459
|
switch (_a.label) {
|
|
449
460
|
case 0: return [4 /*yield*/, control.controlLocator.first().inputValue().then(function (value) {
|
|
450
461
|
(0, logs_core_1.consoleLog)("Value is read from textbox '" + control.controlDescription + "' is: '" + value + "'");
|
|
462
|
+
return value;
|
|
451
463
|
}, function (error) {
|
|
452
464
|
(0, logs_core_1.errorLog)("Unable to read the value from '" + control.controlDescription + "' due to reason: " + error);
|
|
453
465
|
})];
|
|
454
|
-
case 1:
|
|
455
|
-
_a.sent();
|
|
456
|
-
return [4 /*yield*/, control.controlLocator.first().inputValue()];
|
|
457
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
466
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
458
467
|
}
|
|
459
468
|
});
|
|
460
469
|
});
|
|
@@ -476,13 +485,11 @@ var Actions = /** @class */ (function (_super) {
|
|
|
476
485
|
switch (_a.label) {
|
|
477
486
|
case 0: return [4 /*yield*/, control.controlLocator.first().inputValue().then(function (value) {
|
|
478
487
|
(0, logs_core_1.consoleLog)("Value is read from '" + control.controlDescription + "' is: '" + value + "'");
|
|
488
|
+
return value;
|
|
479
489
|
}, function (error) {
|
|
480
490
|
(0, logs_core_1.errorLog)("Unable to read the value '" + control.controlDescription + "' due to reason: " + error);
|
|
481
491
|
})];
|
|
482
|
-
case 1:
|
|
483
|
-
_a.sent();
|
|
484
|
-
return [4 /*yield*/, control.controlLocator.first().inputValue()];
|
|
485
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
492
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
486
493
|
}
|
|
487
494
|
});
|
|
488
495
|
});
|
|
@@ -509,10 +516,7 @@ var Actions = /** @class */ (function (_super) {
|
|
|
509
516
|
}, function (reason) {
|
|
510
517
|
(0, logs_core_1.errorLog)("Unable to read attribute value from '" + control.controlDescription + "' reason: '" + reason + "'");
|
|
511
518
|
})];
|
|
512
|
-
case 1:
|
|
513
|
-
_a.sent();
|
|
514
|
-
return [4 /*yield*/, control.controlLocator.first().getAttribute(attributeName)];
|
|
515
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
519
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
516
520
|
}
|
|
517
521
|
});
|
|
518
522
|
});
|
|
@@ -580,6 +584,9 @@ var Actions = /** @class */ (function (_super) {
|
|
|
580
584
|
return [4 /*yield*/, dialog.accept().then(function () {
|
|
581
585
|
(0, logs_core_1.logAction)('Alert is accepted');
|
|
582
586
|
return true;
|
|
587
|
+
}, function (error) {
|
|
588
|
+
(0, logs_core_1.errorLog)("Unable to accept alert: " + error);
|
|
589
|
+
throw error;
|
|
583
590
|
})];
|
|
584
591
|
case 1:
|
|
585
592
|
_a.sent();
|
|
@@ -587,6 +594,9 @@ var Actions = /** @class */ (function (_super) {
|
|
|
587
594
|
case 2: return [4 /*yield*/, dialog.dismiss().then(function () {
|
|
588
595
|
(0, logs_core_1.logAction)('Alert is dismissed');
|
|
589
596
|
return false;
|
|
597
|
+
}, function (error) {
|
|
598
|
+
(0, logs_core_1.errorLog)("Unable to dismiss alert: " + error);
|
|
599
|
+
throw error;
|
|
590
600
|
})];
|
|
591
601
|
case 3:
|
|
592
602
|
_a.sent();
|
|
@@ -689,15 +699,16 @@ var Actions = /** @class */ (function (_super) {
|
|
|
689
699
|
*
|
|
690
700
|
* waitTillPageURLContains("https://www.google.com/");
|
|
691
701
|
*/
|
|
692
|
-
Actions.prototype.waitTillPageURLContains = function (
|
|
693
|
-
return __awaiter(this,
|
|
702
|
+
Actions.prototype.waitTillPageURLContains = function (url_1) {
|
|
703
|
+
return __awaiter(this, arguments, void 0, function (url, timeoutInSeconds) {
|
|
694
704
|
var error_1;
|
|
705
|
+
if (timeoutInSeconds === void 0) { timeoutInSeconds = 30; }
|
|
695
706
|
return __generator(this, function (_a) {
|
|
696
707
|
switch (_a.label) {
|
|
697
708
|
case 0:
|
|
698
709
|
_a.trys.push([0, 2, , 3]);
|
|
699
710
|
return [4 /*yield*/, this.page.waitForURL(url, {
|
|
700
|
-
timeout:
|
|
711
|
+
timeout: timeoutInSeconds * 1000,
|
|
701
712
|
waitUntil: "load"
|
|
702
713
|
})];
|
|
703
714
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -720,9 +731,10 @@ var Actions = /** @class */ (function (_super) {
|
|
|
720
731
|
*
|
|
721
732
|
* waitTillElementIsPresent(usernameTxtbx);
|
|
722
733
|
*/
|
|
723
|
-
Actions.prototype.waitTillElementIsPresent = function (
|
|
724
|
-
return __awaiter(this,
|
|
734
|
+
Actions.prototype.waitTillElementIsPresent = function (control_1) {
|
|
735
|
+
return __awaiter(this, arguments, void 0, function (control, timeoutInSeconds) {
|
|
725
736
|
var error_2;
|
|
737
|
+
if (timeoutInSeconds === void 0) { timeoutInSeconds = 30; }
|
|
726
738
|
return __generator(this, function (_a) {
|
|
727
739
|
switch (_a.label) {
|
|
728
740
|
case 0: return [4 /*yield*/, this.page.waitForLoadState("domcontentloaded")];
|
|
@@ -733,7 +745,7 @@ var Actions = /** @class */ (function (_super) {
|
|
|
733
745
|
_a.trys.push([2, 4, , 5]);
|
|
734
746
|
return [4 /*yield*/, control.controlLocator.waitFor({
|
|
735
747
|
state: "visible",
|
|
736
|
-
timeout:
|
|
748
|
+
timeout: timeoutInSeconds * 1000,
|
|
737
749
|
})];
|
|
738
750
|
case 3:
|
|
739
751
|
_a.sent();
|
|
@@ -757,9 +769,10 @@ var Actions = /** @class */ (function (_super) {
|
|
|
757
769
|
*
|
|
758
770
|
* waitTillElementIsAttached(usernameTxtbx);
|
|
759
771
|
*/
|
|
760
|
-
Actions.prototype.waitTillElementIsAttached = function (
|
|
761
|
-
return __awaiter(this,
|
|
772
|
+
Actions.prototype.waitTillElementIsAttached = function (control_1) {
|
|
773
|
+
return __awaiter(this, arguments, void 0, function (control, timeoutInSeconds) {
|
|
762
774
|
var error_3;
|
|
775
|
+
if (timeoutInSeconds === void 0) { timeoutInSeconds = 30; }
|
|
763
776
|
return __generator(this, function (_a) {
|
|
764
777
|
switch (_a.label) {
|
|
765
778
|
case 0: return [4 /*yield*/, this.page.waitForLoadState("domcontentloaded")];
|
|
@@ -770,7 +783,7 @@ var Actions = /** @class */ (function (_super) {
|
|
|
770
783
|
_a.trys.push([2, 4, , 5]);
|
|
771
784
|
return [4 /*yield*/, control.controlLocator.waitFor({
|
|
772
785
|
state: "attached",
|
|
773
|
-
timeout:
|
|
786
|
+
timeout: timeoutInSeconds * 1000,
|
|
774
787
|
})];
|
|
775
788
|
case 3:
|
|
776
789
|
_a.sent();
|
|
@@ -794,16 +807,17 @@ var Actions = /** @class */ (function (_super) {
|
|
|
794
807
|
*
|
|
795
808
|
* waitTillElementIsNotPresent(usernameTxtbx);
|
|
796
809
|
*/
|
|
797
|
-
Actions.prototype.waitTillElementIsNotPresent = function (
|
|
798
|
-
return __awaiter(this,
|
|
810
|
+
Actions.prototype.waitTillElementIsNotPresent = function (control_1) {
|
|
811
|
+
return __awaiter(this, arguments, void 0, function (control, timeoutInSeconds) {
|
|
799
812
|
var error_4;
|
|
813
|
+
if (timeoutInSeconds === void 0) { timeoutInSeconds = 30; }
|
|
800
814
|
return __generator(this, function (_a) {
|
|
801
815
|
switch (_a.label) {
|
|
802
816
|
case 0:
|
|
803
817
|
_a.trys.push([0, 2, , 3]);
|
|
804
818
|
return [4 /*yield*/, control.controlLocator.waitFor({
|
|
805
819
|
state: "hidden",
|
|
806
|
-
timeout:
|
|
820
|
+
timeout: timeoutInSeconds * 1000,
|
|
807
821
|
})];
|
|
808
822
|
case 1:
|
|
809
823
|
_a.sent();
|
|
@@ -831,7 +845,22 @@ var Actions = /** @class */ (function (_super) {
|
|
|
831
845
|
return __generator(this, function (_a) {
|
|
832
846
|
switch (_a.label) {
|
|
833
847
|
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, timeInSeconds * 1000); })];
|
|
834
|
-
case 1:
|
|
848
|
+
case 1:
|
|
849
|
+
_a.sent();
|
|
850
|
+
return [2 /*return*/];
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
};
|
|
855
|
+
Actions.prototype.waitForPageTimeout = function () {
|
|
856
|
+
return __awaiter(this, arguments, void 0, function (timeoutInSeconds) {
|
|
857
|
+
if (timeoutInSeconds === void 0) { timeoutInSeconds = 5; }
|
|
858
|
+
return __generator(this, function (_a) {
|
|
859
|
+
switch (_a.label) {
|
|
860
|
+
case 0: return [4 /*yield*/, this.page.waitForTimeout(timeoutInSeconds * 1000)];
|
|
861
|
+
case 1:
|
|
862
|
+
_a.sent();
|
|
863
|
+
return [2 /*return*/];
|
|
835
864
|
}
|
|
836
865
|
});
|
|
837
866
|
});
|
|
@@ -266,9 +266,9 @@ var Assertion = /** @class */ (function (_super) {
|
|
|
266
266
|
return __generator(this, function (_a) {
|
|
267
267
|
switch (_a.label) {
|
|
268
268
|
case 0: return [4 /*yield*/, this.getText(control).then(function (value) {
|
|
269
|
-
var verificationResult = value.trim() === expectedText.trim() ? "PASSED" : "Failed";
|
|
269
|
+
var verificationResult = (value === null || value === void 0 ? void 0 : value.trim()) === expectedText.trim() ? "PASSED" : "Failed";
|
|
270
270
|
(0, logs_core_1.logVerification)("VERIFICATION: '".concat(verificationResult, "'. Expected: '").concat(expectedText, "' Actual: '").concat(value, "'"));
|
|
271
|
-
(0, test_1.expect)(value.trim()).toBe(expectedText.trim());
|
|
271
|
+
(0, test_1.expect)(value === null || value === void 0 ? void 0 : value.trim()).toBe(expectedText.trim());
|
|
272
272
|
})];
|
|
273
273
|
case 1:
|
|
274
274
|
_a.sent();
|
|
@@ -294,9 +294,9 @@ var Assertion = /** @class */ (function (_super) {
|
|
|
294
294
|
return __generator(this, function (_a) {
|
|
295
295
|
switch (_a.label) {
|
|
296
296
|
case 0: return [4 /*yield*/, this.getText(control).then(function (value) {
|
|
297
|
-
var verificationResult = value.trim().includes(expectedText.trim()) ? "PASSED" : "Failed";
|
|
298
|
-
(0, logs_core_1.logVerification)("VERIFICATION: ".concat(verificationResult, ". Expected: '").concat(expectedText.trim(), "' is present in Actual: '").concat(value.trim(), "'"));
|
|
299
|
-
(0, test_1.expect)(value.trim()).toContain(expectedText.trim());
|
|
297
|
+
var verificationResult = (value === null || value === void 0 ? void 0 : value.trim().includes(expectedText.trim())) ? "PASSED" : "Failed";
|
|
298
|
+
(0, logs_core_1.logVerification)("VERIFICATION: ".concat(verificationResult, ". Expected: '").concat(expectedText.trim(), "' is present in Actual: '").concat(value === null || value === void 0 ? void 0 : value.trim(), "'"));
|
|
299
|
+
(0, test_1.expect)(value === null || value === void 0 ? void 0 : value.trim()).toContain(expectedText.trim());
|
|
300
300
|
})];
|
|
301
301
|
case 1:
|
|
302
302
|
_a.sent();
|
|
@@ -322,9 +322,9 @@ var Assertion = /** @class */ (function (_super) {
|
|
|
322
322
|
return __generator(this, function (_a) {
|
|
323
323
|
switch (_a.label) {
|
|
324
324
|
case 0: return [4 /*yield*/, this.getText(control).then(function (value) {
|
|
325
|
-
var verificationResult = value.trim().includes(expectedText) ? "PASSED" : "Failed";
|
|
325
|
+
var verificationResult = (value === null || value === void 0 ? void 0 : value.trim().includes(expectedText)) ? "PASSED" : "Failed";
|
|
326
326
|
(0, logs_core_1.logVerification)("VERIFICATION: ".concat(verificationResult, ". Expected: '").concat(expectedText, "' is present in Actual: '").concat(value, "' "));
|
|
327
|
-
(0, test_1.expect)(false).toBe(value.trim().includes(expectedText.trim()));
|
|
327
|
+
(0, test_1.expect)(false).toBe(value === null || value === void 0 ? void 0 : value.trim().includes(expectedText.trim()));
|
|
328
328
|
})];
|
|
329
329
|
case 1:
|
|
330
330
|
_a.sent();
|
|
@@ -59,7 +59,7 @@ var BasePage = /** @class */ (function () {
|
|
|
59
59
|
switch (_a.label) {
|
|
60
60
|
case 0: return [4 /*yield*/, this.page.goto(url, {
|
|
61
61
|
waitUntil: "load",
|
|
62
|
-
timeout:
|
|
62
|
+
timeout: 30000
|
|
63
63
|
}).then(function () {
|
|
64
64
|
(0, logs_core_1.logAction)("Navigated to URL: " + url);
|
|
65
65
|
})];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright-ts-automationframework",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@playwright/test": "^1.47.2",
|
|
23
|
-
"@types/node": "^20.16.
|
|
23
|
+
"@types/node": "^20.16.10",
|
|
24
24
|
"log4js": "^6.9.1",
|
|
25
25
|
"nodemailer": "^6.9.15",
|
|
26
26
|
"npm": "^10.8.3",
|