froth-webdriverio-framework 5.0.6 → 5.0.8
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_api_calls/browsersatckSessionInfo.js +15 -6
- package/froth_common_actions/Utils.js +4 -1
- package/froth_common_actions/captureNavigationTime.js +3 -2
- package/froth_common_actions/logData.js +77 -0
- package/froth_configs/commonconfig.js +1 -1
- package/froth_configs/setallDatailinBuffer.js +1 -1
- package/package.json +1 -1
- package/config/commonconfig.js +0 -0
|
@@ -106,7 +106,7 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
106
106
|
try {
|
|
107
107
|
|
|
108
108
|
console.log("Annotation message inside amend2Browserstack:" + annotationMessage)
|
|
109
|
-
if (process.env.PLATFORM === 'browserstack')
|
|
109
|
+
if (process.env.PLATFORM === 'browserstack')
|
|
110
110
|
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
111
111
|
|
|
112
112
|
} catch (error) {
|
|
@@ -115,13 +115,22 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
//Execute the main function
|
|
119
118
|
|
|
120
|
-
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
// Execute the main function
|
|
122
|
+
|
|
123
|
+
// Main function to execute the API call
|
|
121
124
|
// async function main() {
|
|
122
125
|
// try {
|
|
123
|
-
//
|
|
124
|
-
//
|
|
126
|
+
// /// BUFFER.setItem("EXECUTION_SESSIONID","297666e2fd4195de98d7da3b359669072ff41a2a");
|
|
127
|
+
// const login=0.30;
|
|
128
|
+
// const landing=0.30;
|
|
129
|
+
// const home=0.30;
|
|
130
|
+
// const payment=0.30;
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
// await amend2Browserstack("\n Page load time for login page:"+login+"\n Page load time for landing page:"+landing+"\n Page load time for home page:"+home+"\n Page load time for payment page:"+payment, "info");
|
|
125
134
|
// } catch (error) {
|
|
126
135
|
// console.error('Error in main function:', error);
|
|
127
136
|
// }
|
|
@@ -131,6 +140,6 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
131
140
|
module.exports = {
|
|
132
141
|
getBSSessionDetails,
|
|
133
142
|
getBSBuildDetails,
|
|
134
|
-
amend2Browserstack
|
|
143
|
+
amend2Browserstack,
|
|
135
144
|
};
|
|
136
145
|
|
|
@@ -53,6 +53,7 @@ let switchToWindowByIndex = null;
|
|
|
53
53
|
|
|
54
54
|
let captureLoadNavigation = null;
|
|
55
55
|
let amendBrowserStackLog = null;
|
|
56
|
+
let logJsonDataToTable = null;
|
|
56
57
|
|
|
57
58
|
if (process.env.LOCATION == null || process.env.LOCATION == 'local') {
|
|
58
59
|
basepath = ".";
|
|
@@ -112,6 +113,7 @@ generateJWT = require(basepath + '/jwt').generateJWTToken;
|
|
|
112
113
|
captureLoadNavigation= require(basepath + '/captureNavigationTime').captureLoadNavigationTime;
|
|
113
114
|
|
|
114
115
|
amendBrowserStackLog= require(basepath + '/../froth_api_calls/browsersatckSessionInfo').amend2Browserstack;
|
|
116
|
+
logJsonDataToTable= require(basepath + '/logData').logJsonData2Table;
|
|
115
117
|
//export the variabels
|
|
116
118
|
module.exports = {
|
|
117
119
|
scrollToEnd,
|
|
@@ -155,5 +157,6 @@ module.exports = {
|
|
|
155
157
|
switchToWindowByTitle,
|
|
156
158
|
switchToWindowByIndex,
|
|
157
159
|
captureLoadNavigation,
|
|
158
|
-
amendBrowserStackLog
|
|
160
|
+
amendBrowserStackLog,
|
|
161
|
+
logJsonDataToTable
|
|
159
162
|
};
|
|
@@ -37,9 +37,10 @@ async function captureLoadNavigationTime(pageName = '') {
|
|
|
37
37
|
.trim(); // remove leading/trailing spaces
|
|
38
38
|
|
|
39
39
|
pageLoadTime = perfEntries.loadEventEnd; // Already relative to startTime
|
|
40
|
-
|
|
40
|
+
pageLoadTime = (pageLoadTime / 1000).toFixed(2); // Convert ms to seconds, keep 2 decimals
|
|
41
|
+
await amendToBrowserstack(`⏱ Page Load Time for ${title}: ${pageLoadTime} seconds`, "info");
|
|
41
42
|
|
|
42
|
-
console.log(`⏱ Page Load Time for ${title}: ${pageLoadTime}
|
|
43
|
+
console.log(`⏱ Page Load Time for ${title}: ${pageLoadTime} seconds`);
|
|
43
44
|
} catch (error) {
|
|
44
45
|
console.error('Error capturing navigation timing:', error);
|
|
45
46
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
2
|
+
|
|
3
|
+
async function logJsonData2Table(jsonData) {
|
|
4
|
+
try {
|
|
5
|
+
console.log("Logging JSON data to table format in BrowserStack:");
|
|
6
|
+
console.log(JSON.stringify(jsonData, null, 2));
|
|
7
|
+
|
|
8
|
+
if (!Array.isArray(jsonData) || jsonData.length === 0) {
|
|
9
|
+
await amendToBrowserstack("No data to log", "info");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// --- Extract keys dynamically (columns) ---
|
|
14
|
+
const keys = Object.keys(jsonData[0]);
|
|
15
|
+
|
|
16
|
+
// --- Calculate max width for each column ---
|
|
17
|
+
const colWidths = {};
|
|
18
|
+
keys.forEach(key => {
|
|
19
|
+
colWidths[key] = Math.max(
|
|
20
|
+
key.length,
|
|
21
|
+
...jsonData.map(row => String(row[key] ?? "").length)
|
|
22
|
+
) + 2;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// --- Build line separator ---
|
|
26
|
+
const line = "-".repeat(
|
|
27
|
+
keys.reduce((sum, key) => sum + colWidths[key], 0) + keys.length + 1
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// --- Build header ---
|
|
31
|
+
let table = line + "\n";
|
|
32
|
+
table += "|" + keys.map(key => ` ${key.padEnd(colWidths[key])}`).join("|") + "|\n";
|
|
33
|
+
table += line + "\n";
|
|
34
|
+
|
|
35
|
+
// --- Build rows ---
|
|
36
|
+
jsonData.forEach(row => {
|
|
37
|
+
table += "|" + keys.map(key => ` ${String(row[key] ?? "").padEnd(colWidths[key])}`).join("|") + "|\n";
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
table += line;
|
|
41
|
+
console.log(table);
|
|
42
|
+
// --- Send to BrowserStack ---
|
|
43
|
+
await amendToBrowserstack(table, "info");
|
|
44
|
+
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error occurred while logging JSON data to table:', error);
|
|
47
|
+
// let annotationMessage = `Error occurred while logging JSON data to table: ${error.message}.`;
|
|
48
|
+
// await amendToBrowserstack(annotationMessage, "error");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
module.exports = {
|
|
52
|
+
logJsonData2Table
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// // Main function to execute the API call
|
|
56
|
+
// async function main() {
|
|
57
|
+
// try {
|
|
58
|
+
// /// BUFFER.setItem("EXECUTION_SESSIONID","297666e2fd4195de98d7da3b359669072ff41a2a");
|
|
59
|
+
// const pageTimes = [
|
|
60
|
+
// { name: "Homepage", time: 120 },
|
|
61
|
+
// { name: "Service Account Page", time: 250 },
|
|
62
|
+
// { name: "Search Results", time: 180 }
|
|
63
|
+
// ];
|
|
64
|
+
|
|
65
|
+
// await logJsonData2Table(pageTimes, "info");
|
|
66
|
+
// const data = [
|
|
67
|
+
// { id: 1, score: 95.5, passed: true },
|
|
68
|
+
// { id: 2, score: 67.2, passed: false },
|
|
69
|
+
// { id: 3, score: null, passed: "N/A" }
|
|
70
|
+
// ];
|
|
71
|
+
// await logJsonData2Table(data, "info");
|
|
72
|
+
// } catch (error) {
|
|
73
|
+
// console.error('Error in main function:', error);
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
|
|
77
|
+
// main();
|
|
@@ -139,7 +139,7 @@ const commonconfig = {
|
|
|
139
139
|
|
|
140
140
|
// const resultdetails = {};
|
|
141
141
|
await exeDetails.update_CICDRUNID_ReportUrl(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
142
|
-
BUFFER.setItem("UPDATE_EXECUTION", 'FALSE')
|
|
142
|
+
BUFFER.setItem("UPDATE_EXECUTION", 'FALSE') //i need to recall
|
|
143
143
|
|
|
144
144
|
} catch (e) {
|
|
145
145
|
console.log("Error in beforeSuite:", e);
|
|
@@ -39,7 +39,7 @@ async function setEnvVariables() {
|
|
|
39
39
|
generateBuildNumber();
|
|
40
40
|
BUFFER.setItem("FROTH_TOTAL_DURATION", 0);
|
|
41
41
|
BUFFER.setItem("FROTH_EXECUTION_ID", process.env.EXECUTION_ID || 1);
|
|
42
|
-
|
|
42
|
+
// BUFFER.setItem("FROTH_INTEGRATION_ID", process.env.INTEGRATION_ID || 1);
|
|
43
43
|
BUFFER.setItem("ORGANISATION_DOMAIN_URL", process.env.ORGANISATION_DOMAIN_URL || "https://devapi.frothtestops.com");
|
|
44
44
|
BUFFER.setItem("FROTH_LOGIN_TOKEN", process.env.API_TOKEN)
|
|
45
45
|
console.log("api token in set evn variable :" + BUFFER.getItem("FROTH_LOGIN_TOKEN"))
|
package/package.json
CHANGED
package/config/commonconfig.js
DELETED
|
File without changes
|