@auxcode/auxta 1.3.24-beta.5 → 1.3.24
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 +93 -93
- package/build/cjs/AuxTA.d.ts +61 -60
- package/build/cjs/AuxTA.js +152 -150
- package/build/cjs/auxta/configs/config.d.ts +54 -54
- package/build/cjs/auxta/configs/config.js +65 -65
- package/build/cjs/auxta/enums/status-of.step.d.ts +7 -7
- package/build/cjs/auxta/enums/status-of.step.js +11 -11
- package/build/cjs/auxta/helpers/response.helper.d.ts +10 -10
- package/build/cjs/auxta/helpers/response.helper.js +15 -15
- package/build/cjs/auxta/helpers/start.helper.d.ts +1 -1
- package/build/cjs/auxta/helpers/start.helper.js +26 -26
- package/build/cjs/auxta/hooks/report.hook.d.ts +14 -14
- package/build/cjs/auxta/hooks/report.hook.js +66 -66
- package/build/cjs/auxta/models/upload.model.d.ts +32 -32
- package/build/cjs/auxta/models/upload.model.js +75 -75
- package/build/cjs/auxta/services/log.service.d.ts +26 -26
- package/build/cjs/auxta/services/log.service.js +47 -47
- package/build/cjs/auxta/services/report.service.d.ts +36 -36
- package/build/cjs/auxta/services/report.service.js +164 -164
- package/build/cjs/auxta/services/runtime.service.d.ts +16 -16
- package/build/cjs/auxta/services/runtime.service.js +41 -41
- package/build/cjs/auxta/utilities/runtime.helper.d.ts +15 -15
- package/build/cjs/auxta/utilities/runtime.helper.js +19 -19
- package/build/cjs/auxta/utilities/screenshot.helper.d.ts +2 -2
- package/build/cjs/auxta/utilities/screenshot.helper.js +36 -36
- package/build/cjs/auxta/utilities/start-suite.helper.d.ts +17 -17
- package/build/cjs/auxta/utilities/start-suite.helper.js +31 -31
- package/build/cjs/macros/helpers/Aux2faAuth.d.ts +7 -7
- package/build/cjs/macros/helpers/Aux2faAuth.js +29 -29
- package/build/cjs/macros/helpers/AuxGoogleAuth.d.ts +17 -13
- package/build/cjs/macros/helpers/AuxGoogleAuth.js +104 -104
- package/build/cjs/macros/helpers/code.helper.d.ts +21 -27
- package/build/cjs/macros/helpers/code.helper.js +201 -259
- package/build/cjs/macros/helpers/emailHelper.d.ts +23 -0
- package/build/cjs/macros/helpers/emailHelper.js +167 -0
- package/build/cjs/macros/helpers/extend-default-page.d.ts +6 -6
- package/build/cjs/macros/helpers/extend-default-page.js +89 -89
- package/build/cjs/puppeteer/puppeteer.d.ts +25 -25
- package/build/cjs/puppeteer/puppeteer.js +196 -194
- package/build/esm/AuxTA.d.ts +61 -60
- package/build/esm/AuxTA.js +123 -121
- package/build/esm/auxta/configs/config.d.ts +54 -54
- package/build/esm/auxta/configs/config.js +60 -60
- package/build/esm/auxta/enums/status-of.step.d.ts +7 -7
- package/build/esm/auxta/enums/status-of.step.js +8 -8
- package/build/esm/auxta/helpers/response.helper.d.ts +10 -10
- package/build/esm/auxta/helpers/response.helper.js +11 -11
- package/build/esm/auxta/helpers/start.helper.d.ts +1 -1
- package/build/esm/auxta/helpers/start.helper.js +24 -24
- package/build/esm/auxta/hooks/report.hook.d.ts +14 -14
- package/build/esm/auxta/hooks/report.hook.js +58 -58
- package/build/esm/auxta/models/upload.model.d.ts +32 -32
- package/build/esm/auxta/models/upload.model.js +71 -71
- package/build/esm/auxta/services/log.service.d.ts +26 -26
- package/build/esm/auxta/services/log.service.js +43 -43
- package/build/esm/auxta/services/report.service.d.ts +36 -36
- package/build/esm/auxta/services/report.service.js +150 -150
- package/build/esm/auxta/services/runtime.service.d.ts +16 -16
- package/build/esm/auxta/services/runtime.service.js +37 -37
- package/build/esm/auxta/utilities/runtime.helper.d.ts +15 -15
- package/build/esm/auxta/utilities/runtime.helper.js +15 -15
- package/build/esm/auxta/utilities/screenshot.helper.d.ts +2 -2
- package/build/esm/auxta/utilities/screenshot.helper.js +29 -29
- package/build/esm/auxta/utilities/start-suite.helper.d.ts +17 -17
- package/build/esm/auxta/utilities/start-suite.helper.js +26 -26
- package/build/esm/macros/helpers/Aux2faAuth.d.ts +7 -7
- package/build/esm/macros/helpers/Aux2faAuth.js +25 -25
- package/build/esm/macros/helpers/AuxGoogleAuth.d.ts +17 -13
- package/build/esm/macros/helpers/AuxGoogleAuth.js +100 -100
- package/build/esm/macros/helpers/code.helper.d.ts +21 -27
- package/build/esm/macros/helpers/code.helper.js +194 -252
- package/build/esm/macros/helpers/emailHelper.d.ts +23 -0
- package/build/esm/macros/helpers/emailHelper.js +160 -0
- package/build/esm/macros/helpers/extend-default-page.d.ts +6 -6
- package/build/esm/macros/helpers/extend-default-page.js +82 -82
- package/build/esm/puppeteer/puppeteer.d.ts +25 -25
- package/build/esm/puppeteer/puppeteer.js +188 -186
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -32
|
@@ -1,259 +1,201 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.FunctionHelper = void 0;
|
|
16
|
-
const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
|
|
17
|
-
const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
|
|
18
|
-
const status_of_step_1 = require("../../auxta/enums/status-of.step");
|
|
19
|
-
const AuxTA_1 = require("../../AuxTA");
|
|
20
|
-
const extend_default_page_1 = require("./extend-default-page");
|
|
21
|
-
const puppeteer_2 = require("puppeteer");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
yield this.
|
|
170
|
-
yield loginPage.
|
|
171
|
-
yield
|
|
172
|
-
yield loginPage.
|
|
173
|
-
yield
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
yield
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
yield this.
|
|
195
|
-
yield loginPage.keyboard.press('Enter');
|
|
196
|
-
yield
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
204
|
-
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
205
|
-
userId: "me",
|
|
206
|
-
maxResults: 3
|
|
207
|
-
});
|
|
208
|
-
const messagesIds = res.data.messages;
|
|
209
|
-
if (!messagesIds || messagesIds.length === 0) {
|
|
210
|
-
throw new Error('No messagesIds found.');
|
|
211
|
-
}
|
|
212
|
-
let timeoutCount = 12000;
|
|
213
|
-
yield this.timeout(12000);
|
|
214
|
-
while (timeoutCount <= 60000) {
|
|
215
|
-
for (const messageId of messagesIds) {
|
|
216
|
-
if (messageId.id) {
|
|
217
|
-
const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
218
|
-
userId: "me",
|
|
219
|
-
id: messageId.id.toString(),
|
|
220
|
-
format: 'FULL'
|
|
221
|
-
});
|
|
222
|
-
if (gmailResponse.data.payload) {
|
|
223
|
-
const message_sender = this.getHeader('from', gmailResponse.data.payload.headers);
|
|
224
|
-
const message_subject = this.getHeader('subject', gmailResponse.data.payload.headers);
|
|
225
|
-
const message_body = this.getBody(from_name, from_email, subject, gmailResponse);
|
|
226
|
-
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) &&
|
|
227
|
-
message_subject.includes(subject.toLocaleLowerCase()) && message_body.includes(body.toLocaleLowerCase())) {
|
|
228
|
-
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
yield this.timeout(12000);
|
|
236
|
-
timeoutCount += 12000;
|
|
237
|
-
}
|
|
238
|
-
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.FAILED);
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
getHeader(value, headers) {
|
|
242
|
-
for (const header of headers) {
|
|
243
|
-
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
244
|
-
return header.value.toLocaleLowerCase();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
getBody(from_name, from_email, subject, gmailResponse) {
|
|
249
|
-
const body = gmailResponse.data.payload.parts[0].body.data;
|
|
250
|
-
if (body) {
|
|
251
|
-
return (0, buffer_1.atob)(body).toLocaleLowerCase();
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} body is empty`);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
exports.FunctionHelper = FunctionHelper;
|
|
259
|
-
exports.default = new FunctionHelper();
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FunctionHelper = void 0;
|
|
16
|
+
const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
|
|
17
|
+
const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
|
|
18
|
+
const status_of_step_1 = require("../../auxta/enums/status-of.step");
|
|
19
|
+
const AuxTA_1 = require("../../AuxTA");
|
|
20
|
+
const extend_default_page_1 = require("./extend-default-page");
|
|
21
|
+
const puppeteer_2 = require("puppeteer");
|
|
22
|
+
class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
23
|
+
log(keyword, name, status) {
|
|
24
|
+
log_service_1.default.push(keyword, name, status);
|
|
25
|
+
}
|
|
26
|
+
suggest(name) {
|
|
27
|
+
log_service_1.default.addSuggestion(name);
|
|
28
|
+
}
|
|
29
|
+
getEscapedText(text) {
|
|
30
|
+
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
31
|
+
return `concat('${splitedQuotes}', '')`;
|
|
32
|
+
}
|
|
33
|
+
clickByText(selector, text, dotOrText = '.', options = {}, page = puppeteer_1.default.defaultPage, time = this.defaultTimeout, log_message = true) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const message = `I clicked on the '${text}' '${selector}'`;
|
|
36
|
+
try {
|
|
37
|
+
const [linkHandlers] = yield page.$x(`//${selector}[contains(${dotOrText},"${text}")]`);
|
|
38
|
+
if (linkHandlers) {
|
|
39
|
+
yield linkHandlers.click(options);
|
|
40
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (log_message) {
|
|
45
|
+
log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
|
|
46
|
+
}
|
|
47
|
+
throw new Error(message);
|
|
48
|
+
}
|
|
49
|
+
if (log_message) {
|
|
50
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
clickByTextWithClass(class_selector, class_name, selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const message = `I click on the '${text}' '${selector}'`;
|
|
57
|
+
try {
|
|
58
|
+
const [linkHandlers] = yield page.$x(`//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[contains(${dotOrText},"${text}")]`);
|
|
59
|
+
if (linkHandlers) {
|
|
60
|
+
yield linkHandlers.click();
|
|
61
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
}
|
|
67
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
|
|
68
|
+
throw new Error(message);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
waitForSelectorWithText(selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const message = `I check for '${text}' on the current page`;
|
|
74
|
+
try {
|
|
75
|
+
yield page.waitForSelector(selector, {
|
|
76
|
+
timeout: this.defaultTimeout
|
|
77
|
+
});
|
|
78
|
+
const linkHandlers = yield page.$x(`//${selector}[contains(${dotOrText},"${text}")]`);
|
|
79
|
+
if (linkHandlers.length > 0) {
|
|
80
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
}
|
|
86
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
87
|
+
throw new Error(message);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
yield new Promise(r => setTimeout(r, timeout));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const message = `I checked for the '${selector}' element to be ${option}`;
|
|
98
|
+
try {
|
|
99
|
+
yield page.waitForSelector(selector, {
|
|
100
|
+
[option]: true,
|
|
101
|
+
timeout: time
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
if (log_message) {
|
|
106
|
+
log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
|
|
107
|
+
}
|
|
108
|
+
throw new Error(message);
|
|
109
|
+
}
|
|
110
|
+
if (log_message) {
|
|
111
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
urlContains(selector, page = puppeteer_1.default.defaultPage) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const url = page.url();
|
|
118
|
+
let message = `I am on the ${selector} page`;
|
|
119
|
+
if (!url.includes(selector)) {
|
|
120
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
121
|
+
throw new Error(message);
|
|
122
|
+
}
|
|
123
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
pressEnter(page = puppeteer_1.default.defaultPage) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
yield page.keyboard.press('Enter');
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
emulate(phone_name, page = puppeteer_1.default.defaultPage) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
const phone = puppeteer_2.KnownDevices[phone_name];
|
|
134
|
+
yield page.emulate(phone);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
restartBrowser() {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
yield puppeteer_1.default.close();
|
|
140
|
+
yield puppeteer_1.default.startBrowser();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const nav = new Promise(res => page.browser().on('targetcreated', res));
|
|
146
|
+
yield page.click(selector);
|
|
147
|
+
yield nav;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
closeLastPage(page = puppeteer_1.default.defaultPage) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const pages = yield page.browser().pages();
|
|
153
|
+
yield pages[pages.length - 1].close();
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
microsoftLogin(button, email, password) {
|
|
157
|
+
var _a;
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const email_input = 'input[type="email"]';
|
|
160
|
+
const password_input = 'input[type="password"]';
|
|
161
|
+
const next_button = 'input[value="Next"]';
|
|
162
|
+
const sign_in_button = 'input[value="Sign in"]';
|
|
163
|
+
const no_button = 'input.ext-secondary';
|
|
164
|
+
yield this.clickAndWaitForPageToBeCreated(button);
|
|
165
|
+
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
166
|
+
const loginPage = pages[pages.length - 1];
|
|
167
|
+
yield this.extend_page_functions(loginPage);
|
|
168
|
+
yield loginPage.waitForNetworkIdle();
|
|
169
|
+
yield this.waitForSelector('visible', next_button, 60000, loginPage);
|
|
170
|
+
yield loginPage.type(email_input, email, { delay: 0 });
|
|
171
|
+
yield loginPage.keyboard.press('Enter');
|
|
172
|
+
yield loginPage.waitForNetworkIdle();
|
|
173
|
+
let isWorkOrPersonalVisible = yield puppeteer_1.default.defaultPage.$('div.table');
|
|
174
|
+
if (!!isWorkOrPersonalVisible) {
|
|
175
|
+
yield (yield puppeteer_1.default.defaultPage.$$('div.table'))[0].click();
|
|
176
|
+
console.log('Then', 'I clicked Work or school account', AuxTA_1.StepStatus.PASSED);
|
|
177
|
+
yield puppeteer_1.default.defaultPage.waitForNetworkIdle();
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
yield puppeteer_1.default.defaultPage.waitForNetworkIdle();
|
|
181
|
+
}
|
|
182
|
+
yield this.waitForSelector('visible', sign_in_button, 60000, loginPage);
|
|
183
|
+
yield this.waitForSelector('visible', password_input, 6000, loginPage);
|
|
184
|
+
try {
|
|
185
|
+
(_a = (yield loginPage.$(password_input))) === null || _a === void 0 ? void 0 : _a.type(password);
|
|
186
|
+
yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.PASSED);
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.FAILED);
|
|
190
|
+
throw new Error(`I type password into the ${password_input}`);
|
|
191
|
+
}
|
|
192
|
+
yield this.timeout(3000);
|
|
193
|
+
yield loginPage.keyboard.press('Enter');
|
|
194
|
+
yield this.waitForSelector('visible', no_button, 60000, loginPage);
|
|
195
|
+
yield loginPage.keyboard.press('Enter');
|
|
196
|
+
yield loginPage.waitForNetworkIdle();
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.FunctionHelper = FunctionHelper;
|
|
201
|
+
exports.default = new FunctionHelper();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { gmail_v1 } from "googleapis";
|
|
2
|
+
export declare class EmailHelper {
|
|
3
|
+
verifyEmail(from_name: string, from_email: string, subject: string, body: string, link?: boolean): Promise<{
|
|
4
|
+
id: string;
|
|
5
|
+
threadId: string;
|
|
6
|
+
link: string;
|
|
7
|
+
} | {
|
|
8
|
+
id: string;
|
|
9
|
+
threadId: string;
|
|
10
|
+
link: undefined;
|
|
11
|
+
} | undefined>;
|
|
12
|
+
sendEmail(to: string, subject: string, body: string): Promise<void>;
|
|
13
|
+
replyEmail(id: string, threadId: string, body: string): Promise<void>;
|
|
14
|
+
private static send;
|
|
15
|
+
private getHeader;
|
|
16
|
+
private getBody;
|
|
17
|
+
private getCurrentUserEmail;
|
|
18
|
+
private getUrl;
|
|
19
|
+
}
|
|
20
|
+
export interface gmailResponse extends gmail_v1.Gmail {
|
|
21
|
+
}
|
|
22
|
+
declare const _default: EmailHelper;
|
|
23
|
+
export default _default;
|