@auxcode/auxta 1.3.134 → 1.3.135
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.
|
@@ -19,7 +19,7 @@ const status_of_step_1 = require("../../auxta/enums/status-of.step");
|
|
|
19
19
|
const config_1 = require("../../auxta/configs/config");
|
|
20
20
|
function describePageFailure(page, error) {
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
var _a, _b;
|
|
22
|
+
var _a, _b, _c;
|
|
23
23
|
const reason = String((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error).split('\n')[0];
|
|
24
24
|
let url = '';
|
|
25
25
|
let text = '';
|
|
@@ -30,7 +30,8 @@ function describePageFailure(page, error) {
|
|
|
30
30
|
catch (e) {
|
|
31
31
|
text = `(page text unavailable: ${String((_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : e).split('\n')[0]})`;
|
|
32
32
|
}
|
|
33
|
-
const
|
|
33
|
+
const failedRequests = ((_c = page.__auxtaFailedRequests) !== null && _c !== void 0 ? _c : []).slice(-10).join(', ') || 'none';
|
|
34
|
+
const details = `reason: ${reason} | url: ${url} | page text: ${text} | failed requests: ${failedRequests}`;
|
|
34
35
|
console.log(`${new Date().toISOString()} Failure details -- ${details}`);
|
|
35
36
|
return details;
|
|
36
37
|
});
|
|
@@ -42,6 +43,16 @@ class ExtendDefaultPage {
|
|
|
42
43
|
extend_page_functions(page_1) {
|
|
43
44
|
return __awaiter(this, arguments, void 0, function* (page, time = this.defaultTimeout) {
|
|
44
45
|
this.defaultTimeout = config_1.config.timeout;
|
|
46
|
+
if (!page.__auxtaFailedRequests) {
|
|
47
|
+
page.__auxtaFailedRequests = [];
|
|
48
|
+
page.on('requestfailed', (request) => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
const entry = `${new Date().toISOString()} ${(_b = (_a = request.failure()) === null || _a === void 0 ? void 0 : _a.errorText) !== null && _b !== void 0 ? _b : 'unknown error'} ${request.url()}`;
|
|
51
|
+
page.__auxtaFailedRequests.push(entry);
|
|
52
|
+
if (page.__auxtaFailedRequests.length > 50)
|
|
53
|
+
page.__auxtaFailedRequests.shift();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
45
56
|
const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
|
|
46
57
|
page.goto = function goto(url, options) {
|
|
47
58
|
log_service_1.default.push('Then', log_service_1.default.tag, `I go to the '${url}' page`, status_of_step_1.StatusOfStep.PASSED);
|
|
@@ -171,6 +171,24 @@ class Puppeteer {
|
|
|
171
171
|
yield AuxTA_1.default.extend_page_functions(this.defaultPage);
|
|
172
172
|
yield this.defaultPage.goto(config_1.config.baseURL, { waitUntil: 'networkidle0' });
|
|
173
173
|
yield this.defaultPage.waitForNetworkIdle();
|
|
174
|
+
yield this.reloadIfBlank(this.defaultPage);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
reloadIfBlank(page_1) {
|
|
178
|
+
return __awaiter(this, arguments, void 0, function* (page, retries = 2, renderTimeout = 10000) {
|
|
179
|
+
var _a;
|
|
180
|
+
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
181
|
+
const rendered = yield page.waitForFunction(() => !!document.body && (document.body.innerText.trim().length > 0 || !!document.querySelector('button, input, a[href]')), { timeout: renderTimeout, polling: 500 }).then(() => true, () => false);
|
|
182
|
+
if (rendered)
|
|
183
|
+
return;
|
|
184
|
+
const failedRequests = ((_a = page.__auxtaFailedRequests) !== null && _a !== void 0 ? _a : []).slice(-10).join(', ') || 'none';
|
|
185
|
+
const message = `The page ${page.url()} stayed blank after loading, reloading it (attempt ${attempt} of ${retries}, failed requests: ${failedRequests})`;
|
|
186
|
+
console.log(`${new Date().toISOString()} ${message}`);
|
|
187
|
+
log_service_1.default.push('When', log_service_1.default.tag, message, status_of_step_1.StatusOfStep.LOG);
|
|
188
|
+
page.__auxtaFailedRequests = [];
|
|
189
|
+
yield page.reload({ waitUntil: 'networkidle0' });
|
|
190
|
+
yield page.waitForNetworkIdle();
|
|
191
|
+
}
|
|
174
192
|
});
|
|
175
193
|
}
|
|
176
194
|
close() {
|