froth-webdriverio-framework 4.0.46 → 4.0.49
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/froth_configs/commonconfig.js +49 -10
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ console.log('===== common config===== ');
|
|
|
16
16
|
const resultdetails = {
|
|
17
17
|
comments: [],
|
|
18
18
|
excution_status: null, // Pass/Fail
|
|
19
|
-
excution_time:
|
|
19
|
+
excution_time: null, // Execution time in milliseconds
|
|
20
20
|
};
|
|
21
21
|
// Description: This file contains the common configuration for the webdriverio framework.
|
|
22
22
|
const commonconfig = {
|
|
@@ -267,15 +267,23 @@ const commonconfig = {
|
|
|
267
267
|
console.log("====> Total Duration in after session based on summing up the test execution times:" + duration_tests);
|
|
268
268
|
|
|
269
269
|
resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
|
|
270
|
+
const frothDuration = BUFFER.getItem("FROTH_TOTAL_DURATION");
|
|
271
|
+
|
|
272
|
+
if(await isInvalidDuration(frothDuration)){
|
|
273
|
+
console.log("inside froth duration");
|
|
274
|
+
if (await isInvalidDuration(duration_tests)) {
|
|
275
|
+
console.log("inside froth duration_tests");
|
|
270
276
|
|
|
271
|
-
if(await isValidDuration(BUFFER.getItem("FROTH_TOTAL_DURATION")))
|
|
272
|
-
if(await isValidDuration(duration_tests))
|
|
273
277
|
resultdetails.excution_time = await convertTimetoHHMMSS(totalDuration);
|
|
274
|
-
else
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
278
|
+
} else {
|
|
279
|
+
console.log("inside froth totalDuration");
|
|
280
|
+
resultdetails.excution_time = await millisecondsToTime(duration_tests);
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
console.log("inside froth duration else");
|
|
284
|
+
resultdetails.excution_time = await secondsToTime(frothDuration);
|
|
285
|
+
}
|
|
286
|
+
|
|
279
287
|
console.log("====> Total Duration calculation:" +resultdetails.excution_time);
|
|
280
288
|
|
|
281
289
|
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
|
|
@@ -300,11 +308,19 @@ const commonconfig = {
|
|
|
300
308
|
}
|
|
301
309
|
|
|
302
310
|
};
|
|
303
|
-
async function
|
|
311
|
+
async function isInvalidDuration(val) {
|
|
304
312
|
console.log("val in isValidDuration:" + val);
|
|
305
313
|
// Check if the value is null, 0, or undefined
|
|
306
|
-
let isValid
|
|
314
|
+
let isValid;
|
|
315
|
+
if (typeof val === 'string') {
|
|
316
|
+
val = val.trim().toLowerCase();
|
|
317
|
+
isValid = val === "null" || val === "0" || val === "undefined";
|
|
318
|
+
|
|
319
|
+
}else
|
|
320
|
+
isValid = val === null || val === 0 || val === undefined;
|
|
321
|
+
|
|
307
322
|
console.log("isValid in isValidDuration:" + isValid);
|
|
323
|
+
|
|
308
324
|
return isValid;
|
|
309
325
|
}
|
|
310
326
|
async function secondsToTime(secs) {
|
|
@@ -320,6 +336,29 @@ async function secondsToTime(secs) {
|
|
|
320
336
|
console.log("Time:" + hours + ':' + minutes + ':' + seconds);
|
|
321
337
|
return hours + ':' + minutes + ':' + seconds;
|
|
322
338
|
}
|
|
339
|
+
async function millisecondsToTime(ms) {
|
|
340
|
+
console.log("ms in millisecondsToTime: " + ms);
|
|
341
|
+
|
|
342
|
+
// Ensure input is a number
|
|
343
|
+
ms = Number(ms);
|
|
344
|
+
if (isNaN(ms)) {
|
|
345
|
+
return '00:00:00';
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
let totalSeconds = Math.floor(ms / 1000);
|
|
349
|
+
let hours = Math.floor(totalSeconds / 3600);
|
|
350
|
+
let minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
351
|
+
let seconds = totalSeconds % 60;
|
|
352
|
+
|
|
353
|
+
// Pad with leading zeros
|
|
354
|
+
hours = hours < 10 ? '0' + hours : hours;
|
|
355
|
+
minutes = minutes < 10 ? '0' + minutes : minutes;
|
|
356
|
+
seconds = seconds < 10 ? '0' + seconds : seconds;
|
|
357
|
+
|
|
358
|
+
const timeStr = `${hours}:${minutes}:${seconds}`;
|
|
359
|
+
console.log("Formatted time:", timeStr);
|
|
360
|
+
return timeStr;
|
|
361
|
+
}
|
|
323
362
|
|
|
324
363
|
async function convertTimetoHHMMSS(time) {
|
|
325
364
|
const seconds = Math.floor((time / 1000) % 60);
|