playwright-ts-automationframework 1.1.68 → 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.
- package/lib/core/actions.core.d.ts +13 -1
- package/lib/core/actions.core.js +433 -735
- package/lib/core/assertion.core.d.ts +1 -1
- package/lib/core/assertion.core.js +466 -775
- package/lib/core/basePage.core.js +19 -66
- package/lib/core/configuration.core.js +44 -67
- package/lib/core/global.setup.js +7 -55
- package/lib/core/global.tearDown.js +4 -51
- package/lib/core/logs.core.js +12 -12
- package/lib/core/sendEmail.js +38 -93
- package/lib/core/webControl.core.js +5 -4
- package/lib/src/core/actions.core.d.ts +349 -0
- package/lib/src/core/actions.core.js +1056 -0
- package/lib/src/core/assertion.core.d.ts +269 -0
- package/lib/src/core/assertion.core.js +1045 -0
- package/lib/src/core/basePage.core.d.ts +17 -0
- package/lib/src/core/basePage.core.js +86 -0
- package/lib/src/core/configuration.core.d.ts +22 -0
- package/lib/src/core/configuration.core.js +84 -0
- package/lib/src/core/global.setup.d.ts +3 -0
- package/lib/src/core/global.setup.js +60 -0
- package/lib/src/core/global.tearDown.d.ts +3 -0
- package/lib/src/core/global.tearDown.js +56 -0
- package/lib/src/core/logs.core.d.ts +5 -0
- package/lib/src/core/logs.core.js +54 -0
- package/lib/src/core/sendEmail.d.ts +7 -0
- package/lib/src/core/sendEmail.js +102 -0
- package/lib/src/core/webControl.core.d.ts +10 -0
- package/lib/src/core/webControl.core.js +15 -0
- package/lib/src/index.d.ts +8 -0
- package/lib/src/index.js +23 -0
- package/package.json +6 -6
package/lib/core/actions.core.js
CHANGED
|
@@ -1,67 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
28
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.Actions = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
4
|
+
const basePage_core_1 = require("./basePage.core");
|
|
5
|
+
const logs_core_1 = require("./logs.core");
|
|
57
6
|
/**
|
|
58
7
|
* All wrapper methods over playwright actions methods with logger.
|
|
59
8
|
* @author Ketan Pardeshi
|
|
60
9
|
* */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return _super.call(this, page) || this;
|
|
10
|
+
class Actions extends basePage_core_1.BasePage {
|
|
11
|
+
constructor(page) {
|
|
12
|
+
super(page);
|
|
65
13
|
}
|
|
66
14
|
/**
|
|
67
15
|
* Click on an element.
|
|
@@ -74,25 +22,14 @@ var Actions = /** @class */ (function (_super) {
|
|
|
74
22
|
*
|
|
75
23
|
* click(loginBtn);
|
|
76
24
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
(0, logs_core_1.logAction)("Clicked on '" + control.controlDescription + "'");
|
|
84
|
-
}, function (error) {
|
|
85
|
-
(0, logs_core_1.logError)("\u274C Unable to click on '".concat(control.controlDescription, "'"));
|
|
86
|
-
(0, logs_core_1.logConsole)("Error: '".concat(error, "'"));
|
|
87
|
-
throw error;
|
|
88
|
-
})];
|
|
89
|
-
case 1:
|
|
90
|
-
_a.sent();
|
|
91
|
-
return [2 /*return*/];
|
|
92
|
-
}
|
|
93
|
-
});
|
|
25
|
+
async click(control, isforceful = false) {
|
|
26
|
+
await control.controlLocator.first().click({ force: isforceful }).then(() => {
|
|
27
|
+
(0, logs_core_1.logAction)("Clicked on '" + control.controlDescription + "'");
|
|
28
|
+
}, (error) => {
|
|
29
|
+
(0, logs_core_1.logError)(`❌ Unable to click on '${control.controlDescription}' due to reason: '${error}'`);
|
|
30
|
+
throw error;
|
|
94
31
|
});
|
|
95
|
-
}
|
|
32
|
+
}
|
|
96
33
|
/**
|
|
97
34
|
* Mouse hover on an element.
|
|
98
35
|
*
|
|
@@ -104,23 +41,13 @@ var Actions = /** @class */ (function (_super) {
|
|
|
104
41
|
*
|
|
105
42
|
* mouseHover(loginBtn);
|
|
106
43
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(0, logs_core_1.logAction)("Mouse hover to '" + control.controlDescription + "'");
|
|
113
|
-
}, function (error) {
|
|
114
|
-
(0, logs_core_1.logError)("\u274C Unable to mouse hover on '".concat(control.controlDescription, "'"));
|
|
115
|
-
(0, logs_core_1.logConsole)("Error: '".concat(error, "'"));
|
|
116
|
-
})];
|
|
117
|
-
case 1:
|
|
118
|
-
_a.sent();
|
|
119
|
-
return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
44
|
+
async mouseHover(control) {
|
|
45
|
+
await control.controlLocator.first().hover().then(() => {
|
|
46
|
+
(0, logs_core_1.logAction)("Mouse hover to '" + control.controlDescription + "'");
|
|
47
|
+
}, (error) => {
|
|
48
|
+
(0, logs_core_1.logError)(`❌ Unable to mouse hover on '${control.controlDescription}' due to reason: '${error}'`);
|
|
122
49
|
});
|
|
123
|
-
}
|
|
50
|
+
}
|
|
124
51
|
/**
|
|
125
52
|
* Focus on element and press keyboard button.
|
|
126
53
|
*
|
|
@@ -133,21 +60,16 @@ var Actions = /** @class */ (function (_super) {
|
|
|
133
60
|
*
|
|
134
61
|
* focusAndPressSpace(loginBtn, "Enter");
|
|
135
62
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return [2 /*return*/];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
};
|
|
63
|
+
async focusAndPressKeyboardEvent(control, action) {
|
|
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
|
+
}
|
|
71
|
+
await this.pressKeyboardEvent(control, action);
|
|
72
|
+
}
|
|
151
73
|
/**
|
|
152
74
|
* Enter value in textbox control.
|
|
153
75
|
*
|
|
@@ -159,50 +81,32 @@ var Actions = /** @class */ (function (_super) {
|
|
|
159
81
|
*
|
|
160
82
|
* type(usernameTxtbx);
|
|
161
83
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}, function (error) {
|
|
174
|
-
(0, logs_core_1.logError)("\u274C Unable to enter text in '".concat(control.controlDescription, "' textbox due to reason: ").concat(error));
|
|
175
|
-
throw error;
|
|
176
|
-
})];
|
|
177
|
-
case 1:
|
|
178
|
-
_a.sent();
|
|
179
|
-
return [2 /*return*/];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
84
|
+
async type(control, textTobeEntered) {
|
|
85
|
+
await control.controlLocator.first().fill(textTobeEntered).then(() => {
|
|
86
|
+
if (control.controlDescription.trim().toLowerCase().endsWith('textbox')) {
|
|
87
|
+
(0, logs_core_1.logAction)(`Entered '${textTobeEntered}' in '${control.controlDescription}'`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
(0, logs_core_1.logAction)(`Entered '${textTobeEntered}' in '${control.controlDescription}' textbox`);
|
|
91
|
+
}
|
|
92
|
+
}, (error) => {
|
|
93
|
+
(0, logs_core_1.logError)(`❌ Unable to enter text in '${control.controlDescription}' textbox due to reason: '${error}'`);
|
|
94
|
+
throw error;
|
|
182
95
|
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}, function (error) {
|
|
196
|
-
(0, logs_core_1.logError)("\u274C Unable to enter text in '".concat(control.controlDescription, "' textbox due to reason: ").concat(error));
|
|
197
|
-
throw error;
|
|
198
|
-
})];
|
|
199
|
-
case 1:
|
|
200
|
-
_a.sent();
|
|
201
|
-
return [2 /*return*/];
|
|
202
|
-
}
|
|
203
|
-
});
|
|
96
|
+
}
|
|
97
|
+
async typePassword(control, textTobeEntered) {
|
|
98
|
+
await control.controlLocator.first().fill(textTobeEntered).then(() => {
|
|
99
|
+
if (control.controlDescription.trim().toLowerCase().endsWith('textbox')) {
|
|
100
|
+
(0, logs_core_1.logAction)(`Entered '********' in '${control.controlDescription}'`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
(0, logs_core_1.logAction)(`Entered '********' in '${control.controlDescription}' textbox`);
|
|
104
|
+
}
|
|
105
|
+
}, (error) => {
|
|
106
|
+
(0, logs_core_1.logError)(`❌ Unable to enter text in '${control.controlDescription}' textbox due to reason: '${error}'`);
|
|
107
|
+
throw error;
|
|
204
108
|
});
|
|
205
|
-
}
|
|
109
|
+
}
|
|
206
110
|
/**
|
|
207
111
|
* Press Keyboard event.
|
|
208
112
|
*
|
|
@@ -215,20 +119,13 @@ var Actions = /** @class */ (function (_super) {
|
|
|
215
119
|
*
|
|
216
120
|
* pressKeyboardEvent(loginBtn, "Enter");
|
|
217
121
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
(0, logs_core_1.logAction)("Press Key '".concat(key.toUpperCase(), "' on '").concat(control.controlDescription, "'"));
|
|
224
|
-
})];
|
|
225
|
-
case 1:
|
|
226
|
-
_a.sent();
|
|
227
|
-
return [2 /*return*/];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
122
|
+
async pressKeyboardEvent(control, key) {
|
|
123
|
+
await control.controlLocator.first().press(key).then(() => {
|
|
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}'`);
|
|
230
127
|
});
|
|
231
|
-
}
|
|
128
|
+
}
|
|
232
129
|
/**
|
|
233
130
|
* Select dropdown element by value.
|
|
234
131
|
*
|
|
@@ -241,24 +138,14 @@ var Actions = /** @class */ (function (_super) {
|
|
|
241
138
|
*
|
|
242
139
|
* selectFromDropdownByValue(cityDrpdwn, "Sydney");
|
|
243
140
|
*/
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}, function (error) {
|
|
251
|
-
(0, logs_core_1.logError)("\u274C Unable to select '".concat(optionTobeSelcted, "' from '").concat(control.controlDescription, "'"));
|
|
252
|
-
(0, logs_core_1.logConsole)("Error: '".concat(error, "'"));
|
|
253
|
-
throw error;
|
|
254
|
-
})];
|
|
255
|
-
case 1:
|
|
256
|
-
_a.sent();
|
|
257
|
-
return [2 /*return*/];
|
|
258
|
-
}
|
|
259
|
-
});
|
|
141
|
+
async selectFromDropdownByValue(control, optionTobeSelcted) {
|
|
142
|
+
await control.controlLocator.first().selectOption({ value: optionTobeSelcted }).then(() => {
|
|
143
|
+
(0, logs_core_1.logAction)("Selected '" + optionTobeSelcted + "' from '" + control.controlDescription + "'");
|
|
144
|
+
}, (error) => {
|
|
145
|
+
(0, logs_core_1.logError)(`❌ Unable to select '${optionTobeSelcted}' from '${control.controlDescription}' due to reason: '${error}'`);
|
|
146
|
+
throw error;
|
|
260
147
|
});
|
|
261
|
-
}
|
|
148
|
+
}
|
|
262
149
|
/**
|
|
263
150
|
* Select dropdown element by text.
|
|
264
151
|
*
|
|
@@ -271,51 +158,35 @@ var Actions = /** @class */ (function (_super) {
|
|
|
271
158
|
*
|
|
272
159
|
* selectDropDownByText(cityDrpdwn, "Sydney");
|
|
273
160
|
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}, function (error) {
|
|
281
|
-
(0, logs_core_1.logError)("\u274C Unable to select '".concat(optionTobeSelcted, "' from '").concat(control.controlDescription, "'"));
|
|
282
|
-
(0, logs_core_1.logConsole)("Error: '".concat(error, "'"));
|
|
283
|
-
throw error;
|
|
284
|
-
})];
|
|
285
|
-
case 1:
|
|
286
|
-
_a.sent();
|
|
287
|
-
return [2 /*return*/];
|
|
288
|
-
}
|
|
289
|
-
});
|
|
161
|
+
async selectFromDropdownByText(control, optionTobeSelcted) {
|
|
162
|
+
await control.controlLocator.first().selectOption({ label: optionTobeSelcted }).then(() => {
|
|
163
|
+
(0, logs_core_1.logAction)(`Selected '${optionTobeSelcted}' from '${control.controlDescription}'`);
|
|
164
|
+
}, (error) => {
|
|
165
|
+
(0, logs_core_1.logError)(`❌ Unable to select '${optionTobeSelcted}' from '${control.controlDescription}' due to reason: '${error}'`);
|
|
166
|
+
throw error;
|
|
290
167
|
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
})];
|
|
312
|
-
case 2:
|
|
313
|
-
_a.sent();
|
|
314
|
-
return [2 /*return*/];
|
|
315
|
-
}
|
|
316
|
-
});
|
|
168
|
+
}
|
|
169
|
+
async selectFromDropdownByPartialText(control, partialText) {
|
|
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
|
+
}
|
|
178
|
+
const matchingOption = options.find(option => option.includes(partialText));
|
|
179
|
+
if (!matchingOption) {
|
|
180
|
+
(0, logs_core_1.logError)(`❌ No option found containing '${partialText}' in '${control.controlDescription}'`);
|
|
181
|
+
throw new Error(`No matching option found for '${partialText}'`);
|
|
182
|
+
}
|
|
183
|
+
await control.controlLocator.first().selectOption({ label: matchingOption }).then(() => {
|
|
184
|
+
(0, logs_core_1.logAction)(`Selected '${matchingOption}' from '${control.controlDescription}'`);
|
|
185
|
+
}, (error) => {
|
|
186
|
+
(0, logs_core_1.logError)(`❌ Unable to select '${matchingOption}' from '${control.controlDescription}' due to reason: '${error}'`);
|
|
187
|
+
throw error;
|
|
317
188
|
});
|
|
318
|
-
}
|
|
189
|
+
}
|
|
319
190
|
/**
|
|
320
191
|
* Select dropdown element by index.
|
|
321
192
|
*
|
|
@@ -328,24 +199,14 @@ var Actions = /** @class */ (function (_super) {
|
|
|
328
199
|
*
|
|
329
200
|
* selectFromDropdownByIndex(cityDrpdwn, 1);
|
|
330
201
|
*/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}, function (error) {
|
|
338
|
-
(0, logs_core_1.logError)("\u274C Unable to select '".concat(index, "' option from '").concat(control.controlDescription, "'"));
|
|
339
|
-
(0, logs_core_1.logConsole)("Error: '".concat(error, "'"));
|
|
340
|
-
throw error;
|
|
341
|
-
})];
|
|
342
|
-
case 1:
|
|
343
|
-
_a.sent();
|
|
344
|
-
return [2 /*return*/];
|
|
345
|
-
}
|
|
346
|
-
});
|
|
202
|
+
async selectFromDropdownByIndex(control, index) {
|
|
203
|
+
await control.controlLocator.first().selectOption({ index: index }).then(() => {
|
|
204
|
+
(0, logs_core_1.logAction)("Selected '" + index + "' option from '" + control.controlDescription + "'");
|
|
205
|
+
}, (error) => {
|
|
206
|
+
(0, logs_core_1.logError)(`❌ Unable to select '${index}' option from '${control.controlDescription}' due to reason: '${error}'`);
|
|
207
|
+
throw error;
|
|
347
208
|
});
|
|
348
|
-
}
|
|
209
|
+
}
|
|
349
210
|
/**
|
|
350
211
|
* Select checkbox element.
|
|
351
212
|
*
|
|
@@ -358,39 +219,23 @@ var Actions = /** @class */ (function (_super) {
|
|
|
358
219
|
*
|
|
359
220
|
* selectCheckbox(isMinorChkbx, true);
|
|
360
221
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
if (expectedCheckboxValue
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
return [3 /*break*/, 6];
|
|
379
|
-
case 4: return [4 /*yield*/, control.controlLocator.first().uncheck()];
|
|
380
|
-
case 5:
|
|
381
|
-
_a.sent();
|
|
382
|
-
(0, logs_core_1.logAction)("Set checkbox value of '" + control.controlDescription + "' as unchecked");
|
|
383
|
-
_a.label = 6;
|
|
384
|
-
case 6: return [3 /*break*/, 8];
|
|
385
|
-
case 7:
|
|
386
|
-
error_1 = _a.sent();
|
|
387
|
-
(0, logs_core_1.logError)("\u274C Unable to set checkbox value of '".concat(control.controlDescription, "' as ").concat(expectedCheckboxValue ? "checked" : "unchecked"));
|
|
388
|
-
throw error_1;
|
|
389
|
-
case 8: return [2 /*return*/];
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
};
|
|
222
|
+
async selectCheckbox(control, expectedCheckboxValue = true) {
|
|
223
|
+
await this.waitTillElementIsPresent(control);
|
|
224
|
+
try {
|
|
225
|
+
if (expectedCheckboxValue) {
|
|
226
|
+
await control.controlLocator.first().check();
|
|
227
|
+
(0, logs_core_1.logAction)("Set checkbox value of '" + control.controlDescription + "' as checked");
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
await control.controlLocator.first().uncheck();
|
|
231
|
+
(0, logs_core_1.logAction)("Set checkbox value of '" + control.controlDescription + "' as unchecked");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
(0, logs_core_1.logError)(`❌ Unable to set checkbox value of '${control.controlDescription}' as ${expectedCheckboxValue ? "checked" : "unchecked"} due to reason: '${error}'`);
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
394
239
|
/**
|
|
395
240
|
* Info to get weather checkbox/Radio element is selected or not.
|
|
396
241
|
* Returns true if element is selected else false
|
|
@@ -403,23 +248,20 @@ var Actions = /** @class */ (function (_super) {
|
|
|
403
248
|
*
|
|
404
249
|
* let checkboxValue = isSelected(isMinorChkbx);
|
|
405
250
|
*/
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
};
|
|
251
|
+
async isSelected(control) {
|
|
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
|
+
}
|
|
264
|
+
}
|
|
423
265
|
/**
|
|
424
266
|
* Info to get wheather element is enabled or not.
|
|
425
267
|
* Returns true if element is enabled else false
|
|
@@ -432,22 +274,20 @@ var Actions = /** @class */ (function (_super) {
|
|
|
432
274
|
*
|
|
433
275
|
* let enabledValue = isEnabled(loginBtn);
|
|
434
276
|
*/
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
});
|
|
450
|
-
};
|
|
277
|
+
async isEnabled(control) {
|
|
278
|
+
try {
|
|
279
|
+
const value = await control.controlLocator.first().isEnabled();
|
|
280
|
+
if (value)
|
|
281
|
+
(0, logs_core_1.logConsole)(`${control.controlDescription} is enabled`);
|
|
282
|
+
else
|
|
283
|
+
(0, logs_core_1.logConsole)(`${control.controlDescription} is NOT enabled`);
|
|
284
|
+
return value;
|
|
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
|
+
}
|
|
290
|
+
}
|
|
451
291
|
/**
|
|
452
292
|
* Info to get wheather element is displayed or not.
|
|
453
293
|
* Returns true if element is displayed else false
|
|
@@ -460,23 +300,20 @@ var Actions = /** @class */ (function (_super) {
|
|
|
460
300
|
*
|
|
461
301
|
* let displayedValue = isDisplayed(loginBtn);
|
|
462
302
|
*/
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
});
|
|
478
|
-
});
|
|
479
|
-
};
|
|
303
|
+
async isDisplayed(control) {
|
|
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
|
+
}
|
|
316
|
+
}
|
|
480
317
|
/**
|
|
481
318
|
* Read text of an element
|
|
482
319
|
*
|
|
@@ -488,27 +325,17 @@ var Actions = /** @class */ (function (_super) {
|
|
|
488
325
|
*
|
|
489
326
|
* let errorMessage = getText(errorMsg);
|
|
490
327
|
*/
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
return [2 /*return*/, text];
|
|
503
|
-
case 2:
|
|
504
|
-
error_2 = _a.sent();
|
|
505
|
-
(0, logs_core_1.logError)("\u274C Unable to read the text from '".concat(control.controlDescription, "' due to reason: ").concat(error_2));
|
|
506
|
-
return [2 /*return*/, '']; // Return an empty string or handle it as needed
|
|
507
|
-
case 3: return [2 /*return*/];
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
};
|
|
328
|
+
async getText(control) {
|
|
329
|
+
try {
|
|
330
|
+
const text = await control.controlLocator.first().innerText();
|
|
331
|
+
(0, logs_core_1.logConsole)(`Value read from '${control.controlDescription}' is: '${text}'`);
|
|
332
|
+
return text;
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
(0, logs_core_1.logError)(`❌ Unable to read the text from '${control.controlDescription}' due to reason: '${error}'`);
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
512
339
|
/**
|
|
513
340
|
* Read textbox value of an element
|
|
514
341
|
*
|
|
@@ -520,27 +347,39 @@ var Actions = /** @class */ (function (_super) {
|
|
|
520
347
|
*
|
|
521
348
|
* let textboxValue = getTextboxValue(usernameTxtbx);
|
|
522
349
|
*/
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
350
|
+
async getTextboxValue(control) {
|
|
351
|
+
try {
|
|
352
|
+
const value = await control.controlLocator.first().inputValue();
|
|
353
|
+
(0, logs_core_1.logConsole)(`Value read from textbox '${control.controlDescription}' is: '${value}'`);
|
|
354
|
+
return value;
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
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;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
544
383
|
/**
|
|
545
384
|
* Read selected dropdown item.
|
|
546
385
|
*
|
|
@@ -552,27 +391,17 @@ var Actions = /** @class */ (function (_super) {
|
|
|
552
391
|
*
|
|
553
392
|
* let selectedItem = getSelectedItemFromDropdown(cityDrpdwn);
|
|
554
393
|
*/
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
return [2 /*return*/, value];
|
|
567
|
-
case 2:
|
|
568
|
-
error_4 = _a.sent();
|
|
569
|
-
(0, logs_core_1.logError)("\u274C Unable to read the value from '".concat(control.controlDescription, "' due to reason: ").concat(error_4));
|
|
570
|
-
return [2 /*return*/, '']; // Return an empty string or handle it as needed
|
|
571
|
-
case 3: return [2 /*return*/];
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
});
|
|
575
|
-
};
|
|
394
|
+
async getSelectedItemFromDropdown(control) {
|
|
395
|
+
try {
|
|
396
|
+
const value = await control.controlLocator.first().inputValue();
|
|
397
|
+
(0, logs_core_1.logConsole)(`Value read from '${control.controlDescription}' is: '${value}'`);
|
|
398
|
+
return value;
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
(0, logs_core_1.logError)(`❌ Unable to read the value from '${control.controlDescription}' due to reason: '${error}'`);
|
|
402
|
+
throw error;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
576
405
|
/**
|
|
577
406
|
* Read attribute value of element.
|
|
578
407
|
*
|
|
@@ -585,27 +414,17 @@ var Actions = /** @class */ (function (_super) {
|
|
|
585
414
|
*
|
|
586
415
|
* let attributeValue = getAttributeValue(usernameTxtbx, "title");
|
|
587
416
|
*/
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
return [2 /*return*/, value];
|
|
600
|
-
case 2:
|
|
601
|
-
error_5 = _a.sent();
|
|
602
|
-
(0, logs_core_1.logError)("\u274C Unable to read attribute value from '".concat(control.controlDescription, "' - Reason: ").concat(error_5));
|
|
603
|
-
return [2 /*return*/, ''];
|
|
604
|
-
case 3: return [2 /*return*/];
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
});
|
|
608
|
-
};
|
|
417
|
+
async getAttributeValue(control, attributeName) {
|
|
418
|
+
try {
|
|
419
|
+
let value = await control.controlLocator.first().getAttribute(attributeName);
|
|
420
|
+
(0, logs_core_1.logConsole)(`Attribute value for '${control.controlDescription}' - Attribute Name: '${attributeName}', Value: '${value}'`);
|
|
421
|
+
return value;
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
(0, logs_core_1.logError)(`❌ Unable to read attribute value from '${control.controlDescription}' due to reason: '${error}'`);
|
|
425
|
+
throw error;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
609
428
|
/**
|
|
610
429
|
* Scroll to an element.
|
|
611
430
|
*
|
|
@@ -617,18 +436,14 @@ var Actions = /** @class */ (function (_super) {
|
|
|
617
436
|
*
|
|
618
437
|
* scrollToControl(loginBtn);
|
|
619
438
|
*/
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
});
|
|
631
|
-
};
|
|
439
|
+
async scrollToControl(control) {
|
|
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
|
+
}
|
|
446
|
+
}
|
|
632
447
|
/**
|
|
633
448
|
* Navigate back on browser.
|
|
634
449
|
*
|
|
@@ -636,18 +451,15 @@ var Actions = /** @class */ (function (_super) {
|
|
|
636
451
|
*
|
|
637
452
|
* navigateBack();
|
|
638
453
|
*/
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
};
|
|
454
|
+
async navigateBack() {
|
|
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
|
+
}
|
|
462
|
+
}
|
|
651
463
|
/**
|
|
652
464
|
* Handle web Alert by accepting or dismissing it
|
|
653
465
|
*
|
|
@@ -657,43 +469,28 @@ var Actions = /** @class */ (function (_super) {
|
|
|
657
469
|
*
|
|
658
470
|
* handleAlert("Accept");
|
|
659
471
|
*/
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
(0, logs_core_1.logAction)('Alert is dismissed');
|
|
681
|
-
return false;
|
|
682
|
-
}, function (error) {
|
|
683
|
-
(0, logs_core_1.logError)("\u274C Unable to dismiss alert: ".concat(error));
|
|
684
|
-
throw error;
|
|
685
|
-
})];
|
|
686
|
-
case 3:
|
|
687
|
-
_a.sent();
|
|
688
|
-
_a.label = 4;
|
|
689
|
-
case 4: return [2 /*return*/];
|
|
690
|
-
}
|
|
691
|
-
});
|
|
692
|
-
}); });
|
|
693
|
-
return [2 /*return*/];
|
|
694
|
-
});
|
|
472
|
+
async handleAlert(action) {
|
|
473
|
+
this.page.on("dialog", async (dialog) => {
|
|
474
|
+
if (action.toLowerCase() === 'accept') {
|
|
475
|
+
await dialog.accept().then(() => {
|
|
476
|
+
(0, logs_core_1.logAction)('Alert is accepted');
|
|
477
|
+
return true;
|
|
478
|
+
}, (error) => {
|
|
479
|
+
(0, logs_core_1.logError)(`❌ Unable to accept alert due to reason: '${error}'`);
|
|
480
|
+
throw error;
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
await dialog.dismiss().then(() => {
|
|
485
|
+
(0, logs_core_1.logAction)('Alert is dismissed');
|
|
486
|
+
return false;
|
|
487
|
+
}, (error) => {
|
|
488
|
+
(0, logs_core_1.logError)(`❌ Unable to dismiss alert due to reason: '${error}'`);
|
|
489
|
+
throw error;
|
|
490
|
+
});
|
|
491
|
+
}
|
|
695
492
|
});
|
|
696
|
-
}
|
|
493
|
+
}
|
|
697
494
|
/**
|
|
698
495
|
* Read the web alert message
|
|
699
496
|
*
|
|
@@ -701,20 +498,20 @@ var Actions = /** @class */ (function (_super) {
|
|
|
701
498
|
*
|
|
702
499
|
* let alertMsg = getAlertDialogMessage();
|
|
703
500
|
*/
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
});
|
|
501
|
+
async getAlertDialogMessage() {
|
|
502
|
+
this.page.on('dialog', async (dialog) => {
|
|
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
|
+
}
|
|
716
512
|
});
|
|
717
|
-
|
|
513
|
+
return this.page.on('dialog', dialog => dialog.message());
|
|
514
|
+
}
|
|
718
515
|
/**
|
|
719
516
|
* Return all elements for given search criteria.
|
|
720
517
|
*
|
|
@@ -726,54 +523,36 @@ var Actions = /** @class */ (function (_super) {
|
|
|
726
523
|
*
|
|
727
524
|
* findAll(dateColumn);
|
|
728
525
|
*/
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
return
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
});
|
|
760
|
-
};
|
|
761
|
-
Actions.prototype.getAllTextContents = function (control) {
|
|
762
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
763
|
-
var allElements;
|
|
764
|
-
return __generator(this, function (_a) {
|
|
765
|
-
switch (_a.label) {
|
|
766
|
-
case 0: return [4 /*yield*/, this.waitTillElementIsPresent(control)];
|
|
767
|
-
case 1:
|
|
768
|
-
_a.sent();
|
|
769
|
-
return [4 /*yield*/, control.controlLocator.allTextContents()];
|
|
770
|
-
case 2:
|
|
771
|
-
allElements = _a.sent();
|
|
772
|
-
return [2 /*return*/, allElements];
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
});
|
|
776
|
-
};
|
|
526
|
+
async findAll(control) {
|
|
527
|
+
await this.waitTillElementIsPresent(control);
|
|
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
|
+
}
|
|
535
|
+
}
|
|
536
|
+
async getAllInnerText(control) {
|
|
537
|
+
await this.waitTillElementIsPresent(control);
|
|
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
|
+
}
|
|
545
|
+
}
|
|
546
|
+
async getAllTextContents(control) {
|
|
547
|
+
await this.waitTillElementIsPresent(control);
|
|
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
|
+
}
|
|
555
|
+
}
|
|
777
556
|
/**
|
|
778
557
|
* Read the web URL
|
|
779
558
|
*
|
|
@@ -781,13 +560,15 @@ var Actions = /** @class */ (function (_super) {
|
|
|
781
560
|
*
|
|
782
561
|
* let url = getURL();
|
|
783
562
|
*/
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
return
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
563
|
+
async getURL() {
|
|
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
|
+
}
|
|
571
|
+
}
|
|
791
572
|
/**
|
|
792
573
|
* Read the title of web Page
|
|
793
574
|
*
|
|
@@ -795,18 +576,17 @@ var Actions = /** @class */ (function (_super) {
|
|
|
795
576
|
*
|
|
796
577
|
* let title = getTitle();
|
|
797
578
|
*/
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
};
|
|
579
|
+
async getTitle() {
|
|
580
|
+
try {
|
|
581
|
+
const value = await this.page.title();
|
|
582
|
+
(0, logs_core_1.logAction)("Title of the webpage is: '" + value + "'");
|
|
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
|
+
}
|
|
589
|
+
}
|
|
810
590
|
/**
|
|
811
591
|
* Wait till URL contains value
|
|
812
592
|
*
|
|
@@ -816,27 +596,18 @@ var Actions = /** @class */ (function (_super) {
|
|
|
816
596
|
*
|
|
817
597
|
* waitTillPageURLContains("https://www.google.com/");
|
|
818
598
|
*/
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
832
|
-
case 2:
|
|
833
|
-
error_6 = _a.sent();
|
|
834
|
-
return [3 /*break*/, 3];
|
|
835
|
-
case 3: return [2 /*return*/];
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
});
|
|
839
|
-
};
|
|
599
|
+
async waitTillPageURLContains(url, timeoutInSeconds = 60) {
|
|
600
|
+
try {
|
|
601
|
+
return await this.page.waitForURL(url, {
|
|
602
|
+
timeout: timeoutInSeconds * 1000,
|
|
603
|
+
waitUntil: "load"
|
|
604
|
+
});
|
|
605
|
+
}
|
|
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
|
+
}
|
|
610
|
+
}
|
|
840
611
|
/**
|
|
841
612
|
* Wait till element is present
|
|
842
613
|
*
|
|
@@ -848,33 +619,19 @@ var Actions = /** @class */ (function (_super) {
|
|
|
848
619
|
*
|
|
849
620
|
* waitTillElementIsPresent(usernameTxtbx);
|
|
850
621
|
*/
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
state: "visible",
|
|
865
|
-
timeout: timeoutInSeconds * 1000,
|
|
866
|
-
})];
|
|
867
|
-
case 3:
|
|
868
|
-
_a.sent();
|
|
869
|
-
return [3 /*break*/, 5];
|
|
870
|
-
case 4:
|
|
871
|
-
error_7 = _a.sent();
|
|
872
|
-
return [3 /*break*/, 5];
|
|
873
|
-
case 5: return [2 /*return*/];
|
|
874
|
-
}
|
|
875
|
-
});
|
|
876
|
-
});
|
|
877
|
-
};
|
|
622
|
+
async waitTillElementIsPresent(control, timeoutInSeconds = 60) {
|
|
623
|
+
try {
|
|
624
|
+
await this.page.waitForLoadState("domcontentloaded");
|
|
625
|
+
await control.controlLocator.first().waitFor({
|
|
626
|
+
state: "visible",
|
|
627
|
+
timeout: timeoutInSeconds * 1000,
|
|
628
|
+
});
|
|
629
|
+
}
|
|
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
|
+
}
|
|
634
|
+
}
|
|
878
635
|
/**
|
|
879
636
|
* Wait till element is attached to the dom
|
|
880
637
|
*
|
|
@@ -886,33 +643,19 @@ var Actions = /** @class */ (function (_super) {
|
|
|
886
643
|
*
|
|
887
644
|
* waitTillElementIsAttached(usernameTxtbx);
|
|
888
645
|
*/
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
state: "attached",
|
|
903
|
-
timeout: timeoutInSeconds * 1000,
|
|
904
|
-
})];
|
|
905
|
-
case 3:
|
|
906
|
-
_a.sent();
|
|
907
|
-
return [3 /*break*/, 5];
|
|
908
|
-
case 4:
|
|
909
|
-
error_8 = _a.sent();
|
|
910
|
-
return [3 /*break*/, 5];
|
|
911
|
-
case 5: return [2 /*return*/];
|
|
912
|
-
}
|
|
913
|
-
});
|
|
914
|
-
});
|
|
915
|
-
};
|
|
646
|
+
async waitTillElementIsAttached(control, timeoutInSeconds = 60) {
|
|
647
|
+
try {
|
|
648
|
+
await this.page.waitForLoadState("domcontentloaded");
|
|
649
|
+
await control.controlLocator.first().waitFor({
|
|
650
|
+
state: "attached",
|
|
651
|
+
timeout: timeoutInSeconds * 1000,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
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
|
+
}
|
|
658
|
+
}
|
|
916
659
|
/**
|
|
917
660
|
* Wait till element is not displayed
|
|
918
661
|
*
|
|
@@ -924,29 +667,18 @@ var Actions = /** @class */ (function (_super) {
|
|
|
924
667
|
*
|
|
925
668
|
* waitTillElementIsNotPresent(usernameTxtbx);
|
|
926
669
|
*/
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
case 1:
|
|
940
|
-
_a.sent();
|
|
941
|
-
return [3 /*break*/, 3];
|
|
942
|
-
case 2:
|
|
943
|
-
error_9 = _a.sent();
|
|
944
|
-
return [3 /*break*/, 3];
|
|
945
|
-
case 3: return [2 /*return*/];
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
});
|
|
949
|
-
};
|
|
670
|
+
async waitTillElementIsNotPresent(control, timeoutInSeconds = 60) {
|
|
671
|
+
try {
|
|
672
|
+
await control.controlLocator.waitFor({
|
|
673
|
+
state: "hidden",
|
|
674
|
+
timeout: timeoutInSeconds * 1000,
|
|
675
|
+
});
|
|
676
|
+
}
|
|
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
|
+
}
|
|
681
|
+
}
|
|
950
682
|
/**
|
|
951
683
|
* Wait for execution to stop for given time
|
|
952
684
|
*
|
|
@@ -956,101 +688,67 @@ var Actions = /** @class */ (function (_super) {
|
|
|
956
688
|
*
|
|
957
689
|
* sleep(10);
|
|
958
690
|
*/
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
}
|
|
1008
|
-
});
|
|
1009
|
-
});
|
|
1010
|
-
};
|
|
1011
|
-
Actions.prototype.waitForNetworkIdle = function () {
|
|
1012
|
-
return __awaiter(this, arguments, void 0, function (timeInSeconds) {
|
|
1013
|
-
if (timeInSeconds === void 0) { timeInSeconds = 30; }
|
|
1014
|
-
return __generator(this, function (_a) {
|
|
1015
|
-
switch (_a.label) {
|
|
1016
|
-
case 0: return [4 /*yield*/, this.page.waitForLoadState("networkidle", { timeout: timeInSeconds * 1000 })];
|
|
1017
|
-
case 1:
|
|
1018
|
-
_a.sent();
|
|
1019
|
-
return [2 /*return*/];
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
});
|
|
1023
|
-
};
|
|
1024
|
-
Actions.prototype.refreshWebPage = function () {
|
|
1025
|
-
return __awaiter(this, arguments, void 0, function (timeInSeconds) {
|
|
1026
|
-
if (timeInSeconds === void 0) { timeInSeconds = 30; }
|
|
1027
|
-
return __generator(this, function (_a) {
|
|
1028
|
-
switch (_a.label) {
|
|
1029
|
-
case 0: return [4 /*yield*/, this.page.reload({ waitUntil: "load", timeout: timeInSeconds * 1000 })];
|
|
1030
|
-
case 1:
|
|
1031
|
-
_a.sent();
|
|
1032
|
-
return [2 /*return*/];
|
|
1033
|
-
}
|
|
1034
|
-
});
|
|
1035
|
-
});
|
|
1036
|
-
};
|
|
691
|
+
async sleep(timeInSeconds = 5) {
|
|
692
|
+
await new Promise(resolve => setTimeout(resolve, timeInSeconds * 1000));
|
|
693
|
+
}
|
|
694
|
+
async waitForPageTimeout(timeoutInSeconds = 5) {
|
|
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
|
+
}
|
|
702
|
+
}
|
|
703
|
+
async waitForPageLoad(timeInSeconds = 30) {
|
|
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
|
+
}
|
|
711
|
+
}
|
|
712
|
+
async waitForPageDOMcontentLoaded(timeInSeconds = 30) {
|
|
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
|
+
}
|
|
720
|
+
}
|
|
721
|
+
async waitForNetworkIdle(timeInSeconds = 30) {
|
|
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
|
+
}
|
|
729
|
+
}
|
|
730
|
+
async refreshWebPage(timeInSeconds = 30) {
|
|
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
|
+
}
|
|
738
|
+
}
|
|
1037
739
|
/**
|
|
1038
740
|
* Close the browser instance
|
|
1039
741
|
*
|
|
1040
742
|
* closeBrowser();
|
|
1041
743
|
*/
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
});
|
|
1053
|
-
};
|
|
1054
|
-
return Actions;
|
|
1055
|
-
}(basePage_core_1.BasePage));
|
|
744
|
+
async closeBrowser() {
|
|
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
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
1056
754
|
exports.Actions = Actions;
|