@auxcode/auxta 1.3.117 → 1.3.119
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.
|
@@ -20,6 +20,7 @@ const status_of_step_1 = __importDefault(require("../enums/status-of.step"));
|
|
|
20
20
|
const RETRY_NUMBERS = 10;
|
|
21
21
|
function captureScreenshot() {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
log_service_1.default.push('When', log_service_1.default.tag, `captureScreenshot started`, status_of_step_1.default.PASSED);
|
|
23
24
|
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
24
25
|
if (!pages.length)
|
|
25
26
|
return undefined;
|
|
@@ -30,10 +31,12 @@ function captureScreenshot() {
|
|
|
30
31
|
while (count <= RETRY_NUMBERS) {
|
|
31
32
|
try {
|
|
32
33
|
const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
|
|
34
|
+
log_service_1.default.push('When', log_service_1.default.tag, `Just before retry ${count}. Pages: ${pages.length}`, status_of_step_1.default.PASSED);
|
|
33
35
|
const screenshotBuffer = yield lastPage.screenshot({
|
|
34
36
|
captureBeyondViewport: false,
|
|
35
37
|
encoding: 'binary'
|
|
36
38
|
});
|
|
39
|
+
log_service_1.default.push('When', log_service_1.default.tag, `Successfull try ${count}`, status_of_step_1.default.PASSED);
|
|
37
40
|
if (Buffer.isBuffer(screenshotBuffer))
|
|
38
41
|
return screenshotBuffer;
|
|
39
42
|
}
|
|
@@ -48,6 +51,7 @@ function captureScreenshot() {
|
|
|
48
51
|
}
|
|
49
52
|
else {
|
|
50
53
|
let count = 0;
|
|
54
|
+
log_service_1.default.push('When', log_service_1.default.tag, `Failed try ${count}`, status_of_step_1.default.FAILED);
|
|
51
55
|
while (count <= RETRY_NUMBERS) {
|
|
52
56
|
try {
|
|
53
57
|
const screenshotBuffer = yield page.screenshot({
|
|
@@ -69,14 +73,17 @@ function captureScreenshot() {
|
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
}
|
|
76
|
+
log_service_1.default.push('When', log_service_1.default.tag, `captureScreenshot ended`, status_of_step_1.default.PASSED);
|
|
72
77
|
return undefined;
|
|
73
78
|
});
|
|
74
79
|
}
|
|
75
80
|
function captureScreenshotPage(page) {
|
|
76
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
log_service_1.default.push('When', log_service_1.default.tag, `captureScreenshotPage started`, status_of_step_1.default.PASSED);
|
|
77
83
|
let count = 0;
|
|
78
84
|
while (count <= RETRY_NUMBERS) {
|
|
79
85
|
try {
|
|
86
|
+
log_service_1.default.push('When', log_service_1.default.tag, `Just before retry ${count}`, status_of_step_1.default.PASSED);
|
|
80
87
|
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
81
88
|
log_service_1.default.push('When', log_service_1.default.tag, `Before the screenshot the number of pages are ${pages.length}`, status_of_step_1.default.PASSED);
|
|
82
89
|
const screenshotBuffer = yield page.screenshot({
|
|
@@ -84,10 +91,12 @@ function captureScreenshotPage(page) {
|
|
|
84
91
|
captureBeyondViewport: false,
|
|
85
92
|
encoding: 'binary'
|
|
86
93
|
});
|
|
94
|
+
log_service_1.default.push('When', log_service_1.default.tag, `Successfull try ${count}`, status_of_step_1.default.PASSED);
|
|
87
95
|
if (Buffer.isBuffer(screenshotBuffer))
|
|
88
96
|
return screenshotBuffer;
|
|
89
97
|
}
|
|
90
98
|
catch (e) {
|
|
99
|
+
log_service_1.default.push('When', log_service_1.default.tag, `Failed try ${count}`, status_of_step_1.default.FAILED);
|
|
91
100
|
if (count == RETRY_NUMBERS) {
|
|
92
101
|
log_service_1.default.push('When', log_service_1.default.tag, e.toString(), status_of_step_1.default.FAILED);
|
|
93
102
|
return undefined;
|
|
@@ -95,6 +104,7 @@ function captureScreenshotPage(page) {
|
|
|
95
104
|
}
|
|
96
105
|
count++;
|
|
97
106
|
}
|
|
107
|
+
log_service_1.default.push('When', log_service_1.default.tag, `captureScreenshotPage ended`, status_of_step_1.default.PASSED);
|
|
98
108
|
return undefined;
|
|
99
109
|
});
|
|
100
110
|
}
|
|
@@ -172,7 +172,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
172
172
|
const url = page.url();
|
|
173
173
|
let message = `I am on the ${selector} page`;
|
|
174
174
|
if (!url.includes(selector)) {
|
|
175
|
-
log_service_1.default.push('And', log_service_1.default.tag, message
|
|
175
|
+
log_service_1.default.push('And', log_service_1.default.tag, `${message}. URL: ${url}`, status_of_step_1.StatusOfStep.FAILED);
|
|
176
176
|
throw new Error(message);
|
|
177
177
|
}
|
|
178
178
|
log_service_1.default.push('And', log_service_1.default.tag, message, status_of_step_1.StatusOfStep.PASSED);
|