@auxcode/auxta 1.3.66 → 1.3.68
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.
|
@@ -16,24 +16,31 @@ exports.captureScreenshotPage = exports.captureScreenshot = void 0;
|
|
|
16
16
|
const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
|
|
17
17
|
const log_service_1 = __importDefault(require("../services/log.service"));
|
|
18
18
|
const status_of_step_1 = __importDefault(require("../enums/status-of.step"));
|
|
19
|
+
const RETRY_NUMBERS = 10;
|
|
19
20
|
function captureScreenshot() {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
let count = 0;
|
|
23
|
+
while (count <= RETRY_NUMBERS) {
|
|
24
|
+
try {
|
|
25
|
+
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
26
|
+
if (!pages.length)
|
|
27
|
+
return undefined;
|
|
28
|
+
const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
|
|
29
|
+
const screenshotBuffer = yield lastPage.screenshot({
|
|
30
|
+
fullPage: true,
|
|
31
|
+
captureBeyondViewport: false,
|
|
32
|
+
encoding: 'binary'
|
|
33
|
+
});
|
|
34
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
35
|
+
return screenshotBuffer;
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
if (count == RETRY_NUMBERS) {
|
|
39
|
+
log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
count++;
|
|
43
|
+
}
|
|
37
44
|
}
|
|
38
45
|
return undefined;
|
|
39
46
|
});
|
|
@@ -41,19 +48,26 @@ function captureScreenshot() {
|
|
|
41
48
|
exports.captureScreenshot = captureScreenshot;
|
|
42
49
|
function captureScreenshotPage(page) {
|
|
43
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
let count = 0;
|
|
52
|
+
while (count <= RETRY_NUMBERS) {
|
|
53
|
+
try {
|
|
54
|
+
const screenshotBuffer = yield page.screenshot({
|
|
55
|
+
fullPage: true,
|
|
56
|
+
captureBeyondViewport: false,
|
|
57
|
+
encoding: 'binary'
|
|
58
|
+
});
|
|
59
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
60
|
+
return screenshotBuffer;
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
if (count == RETRY_NUMBERS) {
|
|
64
|
+
log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
count++;
|
|
68
|
+
}
|
|
56
69
|
}
|
|
70
|
+
return undefined;
|
|
57
71
|
});
|
|
58
72
|
}
|
|
59
73
|
exports.captureScreenshotPage = captureScreenshotPage;
|
|
@@ -37,58 +37,57 @@ class EmailHelper {
|
|
|
37
37
|
if (!messagesIds || messagesIds.length === 0) {
|
|
38
38
|
throw new Error('No messagesIds found.');
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
let count = 0;
|
|
40
|
+
log_service_1.default.push('Then', `Entering main for`, AuxTA_1.StepStatus.PASSED);
|
|
42
41
|
for (const messageId of messagesIds) {
|
|
43
42
|
if (messageId.id) {
|
|
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
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.modify({
|
|
69
|
-
userId: "me",
|
|
70
|
-
id: gmailResponse.data.id,
|
|
71
|
-
requestBody: {
|
|
72
|
-
'addLabelIds': [],
|
|
73
|
-
'removeLabelIds': ['UNREAD']
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
log_service_1.default.push('Then', `I got modify email`, AuxTA_1.StepStatus.PASSED);
|
|
77
|
-
if (link) {
|
|
78
|
-
const html_link = yield this.getUrl(message_body);
|
|
79
|
-
log_service_1.default.push('Then', `I get html lik`, AuxTA_1.StepStatus.PASSED);
|
|
80
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.delete({
|
|
43
|
+
let gmailResponse;
|
|
44
|
+
try {
|
|
45
|
+
gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
46
|
+
userId: "me",
|
|
47
|
+
id: messageId.id.toString(),
|
|
48
|
+
format: 'FULL'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (gmailResponse) {
|
|
55
|
+
log_service_1.default.push('Then', `I check payload && id && threadId`, AuxTA_1.StepStatus.PASSED);
|
|
56
|
+
if (gmailResponse.data.payload && gmailResponse.data.id && gmailResponse.data.threadId) {
|
|
57
|
+
const message_sender = this.getHeader('from', gmailResponse);
|
|
58
|
+
log_service_1.default.push('Then', `I got message_sender`, AuxTA_1.StepStatus.PASSED);
|
|
59
|
+
const message_subject = this.getHeader('subject', gmailResponse);
|
|
60
|
+
log_service_1.default.push('Then', `I got message_body`, AuxTA_1.StepStatus.PASSED);
|
|
61
|
+
const message_body = this.getBody(subject, gmailResponse);
|
|
62
|
+
log_service_1.default.push('Then', `I got message_body`, AuxTA_1.StepStatus.PASSED);
|
|
63
|
+
if (message_sender.toLocaleLowerCase().includes(from_email) && message_sender.toLocaleLowerCase().includes(from_name.toLocaleLowerCase()) &&
|
|
64
|
+
message_subject.toLocaleLowerCase().includes(subject.toLocaleLowerCase()) && message_body.toLocaleLowerCase().includes(body.toLocaleLowerCase())) {
|
|
65
|
+
log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
66
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.modify({
|
|
81
67
|
userId: "me",
|
|
82
68
|
id: gmailResponse.data.id,
|
|
69
|
+
requestBody: {
|
|
70
|
+
'addLabelIds': [],
|
|
71
|
+
'removeLabelIds': ['UNREAD']
|
|
72
|
+
}
|
|
83
73
|
});
|
|
84
|
-
log_service_1.default.push('Then', `I
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
log_service_1.default.push('Then', `I got modify email`, AuxTA_1.StepStatus.PASSED);
|
|
75
|
+
if (link) {
|
|
76
|
+
const html_link = yield this.getUrl(message_body);
|
|
77
|
+
log_service_1.default.push('Then', `I get html lik`, AuxTA_1.StepStatus.PASSED);
|
|
78
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.delete({
|
|
79
|
+
userId: "me",
|
|
80
|
+
id: gmailResponse.data.id,
|
|
81
|
+
});
|
|
82
|
+
log_service_1.default.push('Then', `I deleted email`, AuxTA_1.StepStatus.PASSED);
|
|
83
|
+
return {
|
|
84
|
+
id: gmailResponse.data.id,
|
|
85
|
+
threadId: gmailResponse.data.threadId,
|
|
86
|
+
link: html_link
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
|
|
90
90
|
}
|
|
91
|
-
return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
}
|
|
@@ -42,7 +42,6 @@ class Puppeteer {
|
|
|
42
42
|
this.browser = yield puppeteer.default.launch({
|
|
43
43
|
slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
|
|
44
44
|
executablePath: puppeteer.default.executablePath(),
|
|
45
|
-
protocolTimeout: 50000,
|
|
46
45
|
args,
|
|
47
46
|
env,
|
|
48
47
|
ignoreDefaultArgs: ["--enable-automation"],
|