froth-webdriverio-framework 5.0.7 → 5.0.9

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.
Files changed (51) hide show
  1. package/allure-report/app.js +2 -0
  2. package/allure-report/data/attachments/5a44d93eb6bbc152.json +3 -0
  3. package/allure-report/data/attachments/8b4b70d43c5ef509.json +1 -0
  4. package/allure-report/data/attachments/f8f260f9d290c8dc.json +3 -0
  5. package/allure-report/data/behaviors.csv +2 -0
  6. package/allure-report/data/behaviors.json +1 -0
  7. package/allure-report/data/categories.csv +2 -0
  8. package/allure-report/data/categories.json +1 -0
  9. package/allure-report/data/packages.json +1 -0
  10. package/allure-report/data/suites.csv +2 -0
  11. package/allure-report/data/suites.json +1 -0
  12. package/allure-report/data/test-cases/eae527eca53ea9fc.json +1 -0
  13. package/allure-report/data/timeline.json +1 -0
  14. package/allure-report/export/influxDbData.txt +14 -0
  15. package/allure-report/export/mail.html +10 -0
  16. package/allure-report/export/prometheusData.txt +14 -0
  17. package/allure-report/favicon.ico +0 -0
  18. package/allure-report/history/categories-trend.json +1 -0
  19. package/allure-report/history/duration-trend.json +1 -0
  20. package/allure-report/history/history-trend.json +1 -0
  21. package/allure-report/history/history.json +1 -0
  22. package/allure-report/history/retry-trend.json +1 -0
  23. package/allure-report/index.html +34 -0
  24. package/allure-report/plugin/behaviors/index.js +276 -0
  25. package/allure-report/plugin/packages/index.js +160 -0
  26. package/allure-report/plugin/screen-diff/index.js +200 -0
  27. package/allure-report/plugin/screen-diff/styles.css +30 -0
  28. package/allure-report/styles.css +5 -0
  29. package/allure-report/widgets/behaviors.json +1 -0
  30. package/allure-report/widgets/categories-trend.json +1 -0
  31. package/allure-report/widgets/categories.json +1 -0
  32. package/allure-report/widgets/duration-trend.json +1 -0
  33. package/allure-report/widgets/duration.json +1 -0
  34. package/allure-report/widgets/environment.json +1 -0
  35. package/allure-report/widgets/executors.json +1 -0
  36. package/allure-report/widgets/history-trend.json +1 -0
  37. package/allure-report/widgets/launch.json +1 -0
  38. package/allure-report/widgets/retry-trend.json +1 -0
  39. package/allure-report/widgets/severity.json +1 -0
  40. package/allure-report/widgets/status-chart.json +1 -0
  41. package/allure-report/widgets/suites.json +1 -0
  42. package/allure-report/widgets/summary.json +1 -0
  43. package/froth_api_calls/browsersatckSessionInfo.js +6 -3
  44. package/froth_api_calls/getexecutionDetails.js +5 -2
  45. package/froth_common_actions/Utils.js +4 -1
  46. package/froth_common_actions/logData.js +73 -0
  47. package/froth_configs/commonconfig.js +53 -4
  48. package/froth_configs/setallDatailinBuffer.js +1 -1
  49. package/froth_configs/wdio.common.conf.js +26 -11
  50. package/package.json +5 -2
  51. package/config/commonconfig.js +0 -0
@@ -0,0 +1 @@
1
+ {"total":1,"items":[]}
@@ -0,0 +1 @@
1
+ [{"data":{"Test defects":1}}]
@@ -0,0 +1 @@
1
+ {"total":1,"items":[{"uid":"bdbf199525818fae7a8651db9eafe741","name":"Test defects","statistic":{"failed":0,"broken":1,"skipped":0,"passed":0,"unknown":0,"total":1}}]}
@@ -0,0 +1 @@
1
+ [{"data":{"duration":104296}}]
@@ -0,0 +1 @@
1
+ [{"uid":"eae527eca53ea9fc","name":"tests login testops","time":{"start":1760354649871,"stop":1760354754167,"duration":104296},"status":"broken","severity":"normal"}]
@@ -0,0 +1 @@
1
+ []
@@ -0,0 +1 @@
1
+ []
@@ -0,0 +1 @@
1
+ [{"data":{"failed":0,"broken":1,"skipped":0,"passed":0,"unknown":0,"total":1}}]
@@ -0,0 +1 @@
1
+ []
@@ -0,0 +1 @@
1
+ [{"data":{"run":1,"retry":0}}]
@@ -0,0 +1 @@
1
+ [{"uid":"eae527eca53ea9fc","name":"tests login testops","time":{"start":1760354649871,"stop":1760354754167,"duration":104296},"status":"broken","severity":"normal"}]
@@ -0,0 +1 @@
1
+ [{"uid":"eae527eca53ea9fc","name":"tests login testops","time":{"start":1760354649871,"stop":1760354754167,"duration":104296},"status":"broken","severity":"normal"}]
@@ -0,0 +1 @@
1
+ {"total":1,"items":[{"uid":"ad6e8c27e8a1b970e8e4080890e75484","name":"login testops","statistic":{"failed":0,"broken":1,"skipped":0,"passed":0,"unknown":0,"total":1}}]}
@@ -0,0 +1 @@
1
+ {"reportName":"Allure Report","testRuns":[],"statistic":{"failed":0,"broken":1,"skipped":0,"passed":0,"unknown":0,"total":1},"time":{"start":1760354649871,"stop":1760354754167,"duration":104296,"minDuration":104296,"maxDuration":104296,"sumDuration":104296}}
@@ -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,6 +115,9 @@ async function amend2Browserstack(annotationMessage, level) {
115
115
  }
116
116
  }
117
117
 
118
+
119
+
120
+
118
121
  // Execute the main function
119
122
 
120
123
  // Main function to execute the API call
@@ -125,7 +128,7 @@ async function amend2Browserstack(annotationMessage, level) {
125
128
  // const landing=0.30;
126
129
  // const home=0.30;
127
130
  // const payment=0.30;
128
-
131
+
129
132
 
130
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");
131
134
  // } catch (error) {
@@ -137,6 +140,6 @@ async function amend2Browserstack(annotationMessage, level) {
137
140
  module.exports = {
138
141
  getBSSessionDetails,
139
142
  getBSBuildDetails,
140
- amend2Browserstack
143
+ amend2Browserstack,
141
144
  };
142
145
 
@@ -34,7 +34,7 @@ async function getExecuitonDetails(frothUrl, token, id) {
34
34
 
35
35
  return jsondata;
36
36
  } else if (response.status === 401) { // Unauthorized, token expired
37
-
37
+
38
38
  console.error("Unauthorized, token expired" + response.status);
39
39
 
40
40
  } else {
@@ -107,7 +107,10 @@ async function update_CICDRUNID_ReportUrl(frothUrl, token, id) {
107
107
 
108
108
  // formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
109
109
  formData.append('updated_through_bot', true)
110
- formData.append('run_id', process.env.CICD_RUN_ID)
110
+ if (process.env.CICD_RUN_ID === null)
111
+ console.log("CICD_RUN_ID is null")
112
+ else
113
+ formData.append('run_id', process.env.CICD_RUN_ID)
111
114
 
112
115
 
113
116
  if (BUFFER.getItem("REPORT_URL") === null)
@@ -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
  };
@@ -0,0 +1,73 @@
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 = "[{ name: 'Homepage', time: 120 },{ name: 'Service Account Page', time: 250 },{ name: 'Search Results', time: 180 }]";
60
+
61
+ // await logJsonData2Table(pageTimes, "info");
62
+ // // const data = [
63
+ // // { id: 1, score: 95.5, passed: true },
64
+ // // { id: 2, score: 67.2, passed: false },
65
+ // // { id: 3, score: null, passed: "N/A" }
66
+ // // ];
67
+ // // await logJsonData2Table(data, "info");
68
+ // } catch (error) {
69
+ // console.error('Error in main function:', error);
70
+ // }
71
+ // }
72
+
73
+ // main();
@@ -5,9 +5,11 @@ const { LocalStorage } = require('node-localstorage');
5
5
  global.BUFFER = new LocalStorage('./storage');
6
6
  const setAllDetails = require("./setallDatailinBuffer")
7
7
  const exeDetails = require("../froth_api_calls/getexecutionDetails")
8
- const getBSSessionDetails = require("../froth_api_calls/browsersatckSessionInfo").getBSSessionDetails;
8
+ //const getBSSessionDetails = require("../froth_api_calls/browsersatckSessionInfo").getBSSessionDetails;
9
9
  const { fail } = require("assert");
10
10
  const { error } = require('console');
11
+ const HTMLReportGenerator = require('wdio-json-html-reporter').HTMLReportGenerator;
12
+
11
13
  //const isBrowserStackEnabled = process.env.BROWSERSTACK;
12
14
  let starttime;
13
15
  let endtime;
@@ -31,7 +33,6 @@ const commonconfig = {
31
33
  await setAllDetails.setSuiteDetails();
32
34
  await setAllDetails.setTestDataDetails();
33
35
  console.log("on prepare:", JSON.stringify(capabilities))
34
-
35
36
  // console.log("ALL JSON DATA in env variable :" + JSON.stringify(process.env));
36
37
  } catch (e) {
37
38
  console.log("====> Error in onPrepare:", e);
@@ -135,11 +136,18 @@ const commonconfig = {
135
136
 
136
137
  if (process.env.PLATFORM === 'browserstack')
137
138
  await getBSSessionDetails(process.env.BS_SESSION_TYPE, process.env.BROWSERSTACK_USERNAME, process.env.BROWSERSTACK_ACCESS_KEY);
139
+ else
140
+ {
141
+ console.log("Local execution - no BrowserStack session details to fetch.");
142
+ // BUFFER.setItem("SESSION_ID", "local-session");
143
+ BUFFER.setItem("REPORT_URL", `./reports/${process.env.EXECUTION_ID}/test-report.html`);
144
+ //BUFFER.setItem("FROTH_TOTAL_DURATION", 0);
138
145
 
146
+ }
139
147
 
140
148
  // const resultdetails = {};
141
149
  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')
150
+ BUFFER.setItem("UPDATE_EXECUTION", 'FALSE') //i need to recall
143
151
 
144
152
  } catch (e) {
145
153
  console.log("Error in beforeSuite:", e);
@@ -339,7 +347,48 @@ const commonconfig = {
339
347
  console.log('Exit Code:', exitCode);
340
348
 
341
349
  console.log('==== ALL TESTS ARE COMPLETED ====');
342
- return exitCode;
350
+
351
+ const outputFilePath = `./reports/${process.env.EXECUTION_ID}/test-report.html`;
352
+ const jsonFolder = `./reports/${process.env.EXECUTION_ID}/`; // Directory where JSON reports are saved
353
+ // Find latest JSON file (if multiple exist)
354
+ // const jsonFiles = fs
355
+ // .readdirSync(jsonFolder)
356
+ // .filter(file => file.endsWith('.json'))
357
+ // .map(file => ({
358
+ // name: file,
359
+ // time: fs.statSync(path.join(jsonFolder, file)).mtime.getTime(),
360
+ // }))
361
+ // .sort((a, b) => b.time - a.time);
362
+
363
+ // if (jsonFiles.length === 0) {
364
+ // console.warn('⚠️ No JSON file found, HTML not generated.');
365
+ // return;
366
+ // }
367
+
368
+ // const latestJson = path.join(jsonFolder, jsonFiles[0].name);
369
+ //console.log(`🧩 Using JSON report: ${latestJson}`);
370
+
371
+ // const reportGenerator = new HTMLReportGenerator(outputFilePath, jsonFolder);
372
+
373
+ // Call your method (you can rename "generate" to whatever method your class exposes)
374
+ // reportGenerator.generate({
375
+ // jsonFile: latestJson,
376
+ // reportPath: jsonFolder,
377
+ // reportName: `Execution Report - ${process.env.EXECUTION_ID}`,
378
+ // outputFile: outputFilePath,
379
+ // });
380
+
381
+
382
+ console.log(`✅ HTML report generated: ${outputFilePath}`);
383
+ // If you want to include historical data, specify the history JSON file path here.
384
+ const historyFile = `./reports/${process.env.EXECUTION_ID}/history.json`; // Optional
385
+
386
+ // Optionally, generate aggregated history data before generating the HTML report.
387
+ // JSONReporter.generateAggregateHistory({ reportPaths: jsonFolder, historyPath: historyFile });
388
+
389
+ const reportGenerator = new HTMLReportGenerator(outputFilePath, historyFile);
390
+ await reportGenerator.convertJSONFolderToHTML(jsonFolder);
391
+ // return exitCode;
343
392
  }
344
393
 
345
394
  };
@@ -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
- BUFFER.setItem("FROTH_INTEGRATION_ID", process.env.INTEGRATION_ID || 1);
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"))
@@ -4,13 +4,14 @@ const yaml = require('js-yaml');
4
4
  const path = require('path');
5
5
  const commonconfig = require('./commonconfig');
6
6
  console.log('=====wdios common config===== ');
7
+ const { JSONReporter, HTMLReportGenerator } = require('wdio-json-html-reporter');
7
8
 
8
9
  // Select platform at runtime
9
10
  const PLATFORM = process.env.PLATFORM || 'browserstack';
10
11
  console.log('====>PLATFORM:', PLATFORM);
11
12
 
12
13
  const configFile = process.env.YML_NAME;
13
-
14
+ const timestamp = new Date().toISOString().replace(/[-:.TZ]/g, '').slice(0, 14); // e.g., 20251014_121532
14
15
  const resultdetails = {
15
16
  comments: [],
16
17
  excution_status: null, // Pass/Fail
@@ -25,7 +26,7 @@ let capabilities;
25
26
  try {
26
27
  capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
27
28
  // Merge chrome-specific options if applicable
28
-
29
+
29
30
  } catch (e) {
30
31
  const errorMsg = `The capability file does not exist in the currently configured repository at path: ${path.resolve(process.cwd(), configFile)}: ${e.message},Please update the Capability by editing the file`;
31
32
  console.error(errorMsg);
@@ -92,27 +93,37 @@ function setupPrerequisites() {
92
93
  process.env.BS_SESSION_TYPE = capabilities.platformName === 'android' || capabilities.platformName === 'ios' ? 'app-automate' : 'automate';
93
94
  capabilities.buildName = process.env.FROTH_TESTOPS_BUILD_NAME;
94
95
 
96
+ } else {
97
+ console.log("inside this fuction for local setup ");
98
+ console.log('capabilities.platformName:', capabilities.platformName ?? 'web');
99
+ capabilities.buildName = process.env.FROTH_TESTOPS_BUILD_NAME;
100
+
95
101
  }
96
102
 
97
103
  }
98
104
 
99
105
  const specificConfig = setupPrerequisites();
100
106
 
107
+ // Create per-execution report folder
108
+ const reportDir = path.resolve(process.cwd(), `./reports/${process.env.EXECUTION_ID}`);
109
+ if (!fs.existsSync(reportDir)) {
110
+ fs.mkdirSync(reportDir, { recursive: true });
111
+ }
101
112
 
102
113
  exports.config = deepmerge(commonconfig,
103
114
 
104
115
  {
105
- user: process.env.BROWSERSTACK_USERNAME,
106
- key: process.env.BROWSERSTACK_ACCESS_KEY,
116
+ // user: process.env.BROWSERSTACK_USERNAME,
117
+ // key: process.env.BROWSERSTACK_ACCESS_KEY,
107
118
  // debug: true,
108
119
  // execArgv: ['--inspect-brk'],
109
- services: PLATFORM === 'browserstack'
110
- ? ['browserstack']
111
- : PLATFORM === 'saucelabs'
112
- ? ['sauce']
113
- : [],
120
+ // services: PLATFORM === 'browserstack'
121
+ // ? ['browserstack']
122
+ // : PLATFORM === 'saucelabs'
123
+ // ? ['sauce']
124
+ // : [''],
114
125
 
115
- //runner: 'local',
126
+ runner: 'local',
116
127
  specs: require(SUITE_FILE).tests,
117
128
 
118
129
  maxInstances: 1,
@@ -128,11 +139,15 @@ exports.config = deepmerge(commonconfig,
128
139
  connectionRetryCount: 3,
129
140
 
130
141
  framework: 'mocha',
131
- reporters: ['spec'],
142
+ reporters: ['spec',
143
+ [JSONReporter, { outputDir: reportDir,outputFile: `./reports/${process.env.EXECUTION_ID}/test-results-${timestamp}.json`, screenshotOption: 'OnFailure' }],
144
+ ],
145
+
132
146
  maxInstances: 10,
133
147
  updateJob: false,
134
148
  mochaOpts: {
135
149
  ui: 'bdd',
136
150
  timeout: 300000
137
151
  }
152
+
138
153
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "5.0.7",
3
+ "version": "5.0.9",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",
@@ -25,6 +25,8 @@
25
25
  "appium"
26
26
  ],
27
27
  "dependencies": {
28
+ "@wdio/allure-reporter": "^9.20.0",
29
+ "allure-commandline": "^2.34.1",
28
30
  "@wdio/appium-service": "^9.0.9",
29
31
  "@wdio/browserstack-service": "^9.0.9",
30
32
  "@wdio/cli": "^9.0.9",
@@ -48,6 +50,7 @@
48
50
  "node-localstorage": "^3.0.5",
49
51
  "randexp": "^0.5.3",
50
52
  "ts-node": "^10.9.2",
51
- "typescript": "^5.4.5"
53
+ "typescript": "^5.4.5",
54
+ "wdio-json-html-reporter": "^1.5.14"
52
55
  }
53
56
  }
File without changes