froth-webdriverio-framework 7.0.17 → 7.0.19

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 (35) hide show
  1. package/froth_common_actions_back/Utils.js +167 -0
  2. package/froth_common_actions_back/alert.js +49 -0
  3. package/froth_common_actions_back/apicall.js +179 -0
  4. package/froth_common_actions_back/assert.js +85 -0
  5. package/froth_common_actions_back/captureNavigationTime.js +53 -0
  6. package/froth_common_actions_back/click.js +57 -0
  7. package/froth_common_actions_back/dropDown.js +34 -0
  8. package/froth_common_actions_back/emailParsing.js +161 -0
  9. package/froth_common_actions_back/jwt.js +64 -0
  10. package/froth_common_actions_back/logData.js +73 -0
  11. package/froth_common_actions_back/random.js +230 -0
  12. package/froth_common_actions_back/scroll.js +104 -0
  13. package/froth_common_actions_back/storeToBuffer.js +45 -0
  14. package/froth_common_actions_back/swicthWindowTab.js +36 -0
  15. package/froth_common_actions_back/swipe.js +219 -0
  16. package/froth_configs/commonhook.js +1 -1
  17. package/froth_configs_back/commonconfig.js +409 -0
  18. package/froth_configs_back/setallDatailinBuffer.js +100 -0
  19. package/froth_configs_back/wdio.common.conf.js +53 -0
  20. package/froth_configs_back/wdio.common.conf_back.js +138 -0
  21. package/package.json +36 -22
  22. package/browserstack.err +0 -1
  23. package/buffer_storage/FROTHE_SUITE_DETAILS +0 -1
  24. package/buffer_storage/FROTH_EXECUTION_ID +0 -1
  25. package/buffer_storage/FROTH_LOGIN_TOKEN +0 -1
  26. package/buffer_storage/FROTH_TOTAL_DURATION +0 -1
  27. package/buffer_storage/ORGANISATION_DOMAIN_URL +0 -1
  28. package/froth_configs/commonhook copy.js +0 -38
  29. package/froth_configs/commonhook_with_old_code.js +0 -425
  30. package/froth_configs/wdio.common.conf copy.js +0 -57
  31. package/local.log +0 -8
  32. package/log/key-metrics.json +0 -4853
  33. package/log/sdk-cli-debug.log +0 -122
  34. package/log/sdk-cli.log +0 -16974
  35. package/log/sdk-debug-utility.log +0 -0
@@ -1,425 +0,0 @@
1
- const setAllDetails = require('./setallDatailinBuffer');
2
- const exeDetails = require('../froth_api_calls/getexecutionDetails');
3
- const { getBSSessionDetails } = require('../froth_api_calls/browsersatckSessionInfo');
4
- let globalErrorHandled = false;
5
- let suiteStartTime;
6
- let totalTestDuration = 0;
7
- const url = require('url');
8
- const fs = require('fs');
9
- const path = require('path');
10
-
11
- const resultdetails = {
12
- comments: [],
13
- excution_status: null,
14
- excution_time: null
15
- };
16
-
17
- /* ----------------- GLOBAL ERROR HANDLERS ----------------- */
18
- let globalErrorRegistered = false;
19
- function registerGlobalErrorHandlers() {
20
- if (globalErrorRegistered) return;
21
- globalErrorRegistered = true;
22
-
23
- process.on('uncaughtException', async (err) => {
24
- console.error('🔥 Uncaught Exception:', err);
25
- resultdetails.excution_status = 'FAILED';
26
- resultdetails.comments.push(`Uncaught Exception: ${err.message}`);
27
- await safeUpdateExecution();
28
- process.exit(1);
29
- });
30
-
31
- process.on('unhandledRejection', async (reason) => {
32
- console.error('🔥 Unhandled Rejection:', reason);
33
- resultdetails.excution_status = 'FAILED';
34
- resultdetails.comments.push(`Unhandled Rejection: ${reason?.message || reason}`);
35
- await safeUpdateExecution();
36
- process.exit(1);
37
- });
38
- }
39
-
40
- async function safeUpdateExecution() {
41
- try {
42
- await exeDetails.updateExecuitonDetails(
43
- BUFFER.getItem('ORGANISATION_DOMAIN_URL'),
44
- BUFFER.getItem('FROTH_LOGIN_TOKEN'),
45
- BUFFER.getItem('FROTH_EXECUTION_ID'),
46
- resultdetails
47
- );
48
- } catch (e) {
49
- console.error('❌ Failed to update execution details:', e.message);
50
- }
51
- }
52
-
53
- /* ----------------- HELPER FUNCTIONS ----------------- */
54
- function msToTime(ms) {
55
- const sec = Math.floor(ms / 1000);
56
- return new Date(sec * 1000).toISOString().substr(11, 8);
57
- }
58
-
59
- async function failExecution(reason) {
60
- resultdetails.excution_status = 'FAILED';
61
- resultdetails.comments.push(reason);
62
- await safeUpdateExecution();
63
- process.exit(1);
64
- }
65
- /* ------------------ COMMON CONFIG ------------------ */
66
-
67
- const commonHooks = {
68
-
69
- /* ========== ON PREPARE ========== */
70
- onPrepare: async () => {
71
- registerGlobalErrorHandlers();
72
-
73
- console.log('==== ON PREPARE HOOK ====');
74
- await setAllDetails.setEnvVariables();
75
- await setAllDetails.setExecutionDetails();
76
- await setAllDetails.setSuiteDetails();
77
- await setAllDetails.setTestDataDetails();
78
-
79
- console.log('✅ All Env Varibale set');
80
- },
81
-
82
- /* ========== BEFORE SESSION ========== */
83
-
84
- beforeSession: async function (config, capabilities, specs) {
85
- console.log('==== BEFORE SESSION ====');
86
- try {
87
- /** 1️⃣ Validate test syntax */
88
- let syntaxFailed = false;
89
-
90
- for (const fileUrl of specs) {
91
- const filePath = url.fileURLToPath(fileUrl);
92
- try {
93
- new Function(fs.readFileSync(filePath, 'utf8'));
94
- } catch (err) {
95
- const msg = `❌ Syntax error in ${path.basename(filePath)}: ${err.message}`;
96
- console.error(msg);
97
- resultdetails.comments.push(msg);
98
- syntaxFailed = true;
99
- }
100
- }
101
-
102
- if (syntaxFailed) {
103
- await failExecution('Syntax validation failed');
104
- }
105
- /** 2️⃣ BrowserStack capability normalization */
106
-
107
- if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
108
- const bsOpts = capabilities['bstack:options'] || {};
109
- if (process.env.BS_SESSION_TYPE === 'app-automate') {
110
- const appPath = process.env.BROWSERSTACK_APP_PATH;
111
- if (!appPath) {
112
- await failExecution('BROWSERSTACK_APP_PATH is missing');
113
- }
114
-
115
- bsOpts.app = appPath;
116
- capabilities['appium:app'] = appPath;
117
- console.log('✅ App & media set in before session');
118
-
119
- }
120
- /** Media upload */
121
- if (process.env.MEDIA_FILES) {
122
- try {
123
- bsOpts['browserstack.uploadMedia'] = JSON.parse(process.env.MEDIA_FILES);
124
- } catch {
125
- console.warn('⚠️ MEDIA_FILES is not valid JSON');
126
- }
127
- }
128
- capabilities['bstack:options'] = bsOpts;
129
-
130
- }
131
- console.log('final cinfig dteials :' + JSON.stringify(capabilities))
132
-
133
- console.log("config details " + JSON.stringify(config))
134
-
135
-
136
- } catch (error) {
137
- console.error('🚨 Error in beforeSession:', error);
138
- console.error('🚨 Error in beforeSession:', error.message);
139
- }
140
- },
141
- /**
142
- * Gets executed before the suite starts (in Mocha/Jasmine only).
143
- * @param {object} suite suite details
144
- */
145
- beforeSuite: async function (suite) {
146
- try {
147
- console.log('==== BEFORE SUITE HOOK ====');
148
- console.log(`====> Test suite has been started ' ${suite.title}' `,);
149
-
150
- starttime = new Date().getTime();
151
-
152
- if (process.env.PLATFORM === 'browserstack')
153
- await getBSSessionDetails(process.env.BS_SESSION_TYPE, process.env.BROWSERSTACK_USERNAME, process.env.BROWSERSTACK_ACCESS_KEY);
154
-
155
-
156
- // const resultdetails = {};
157
- await exeDetails.update_CICDRUNID_ReportUrl(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"))
158
- BUFFER.setItem("UPDATE_EXECUTION", 'FALSE') //i need to recall
159
-
160
- } catch (e) {
161
- console.log("Error in beforeSuite:", e);
162
- }
163
- },
164
-
165
- before: async function (capabilities, specs) {
166
- if (process.env.BS_SESSION_TYPE === 'automate') {
167
- console.log('==== BEFORE HOOK ====')
168
- await browser.maximizeWindow()
169
- }
170
- else {
171
- console.log('==== BEFORE HOOK FOR MOBILE ====');
172
- }
173
-
174
- },
175
-
176
- /**
177
- * Function to be executed before a test (in Mocha/Jasmine only)
178
- * @param {object} test test object
179
- * @param {object} context scope object the test was executed with
180
- */
181
- beforeTest: async function (test, context) {
182
-
183
- console.log('==== BEFORE TEST HOOK ====');
184
- console.log(`====> Test Started '${test.title}'`);
185
-
186
- },
187
-
188
-
189
- /**
190
- * Function to be executed after a test (in Mocha/Jasmine only)
191
- * @param {object} test test object
192
- * @param {object} context scope object the test was executed with
193
- * @param {Error} result.error error object in case the test fails, otherwise `undefined`
194
- * @param {*} result.result return object of test function
195
- * @param {number} result.duration duration of test
196
- * @param {boolean} result.passed true if test has passed, otherwise false
197
- * @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }`
198
- */
199
- afterTest: async function (test, _, { error, duration, passed }) {
200
- console.log('==== AFTER TEST HOOK ====');
201
- console.log(`====> Test name finished '${test.title}'`);
202
-
203
- const fileName = path.basename(test.file);
204
- console.log('====> Test File Name:', fileName);
205
- // BUFFER.setItem("FROTH_TOTAL_DURATION", Number(BUFFER.getItem("FROTH_TOTAL_DURATION")) + duration)
206
- console.log(`====> Total Duration for this test: ${duration}ms`);
207
- totalTestDuration += duration;
208
- console.log(`====> Total Duration for all tests: ${totalTestDuration}ms`);
209
- console.log(`====> Status of test: ${passed}`);
210
-
211
- let scriptresult = "NOT RUN";
212
- // Default assumption: test passed (unless soft assertion failed)
213
- let finalPassed = passed;
214
-
215
- if (passed) {
216
- scriptresult = "PASSED"
217
- resultdetails.comments.push(`${test.title} - passed`);
218
- console.log(`====> resultdetails comments: ${resultdetails.comments}`);
219
- }
220
- else if (!finalPassed || error) {
221
- scriptresult = "FAILED"
222
- console.log(`====> Failed or error while executing the test: ${error ? error.message : "Test failed"}`);
223
- if (!resultdetails.comments.some(comment => typeof comment === 'string' && comment.includes(test.title)))
224
- resultdetails.comments.push(`${test.title} - failed: ${error ? error.message : "Test failed"}`);
225
-
226
- }
227
-
228
- let scriptDetails = BUFFER.getItem("FROTHE_SUITE_DETAILS");
229
- if (typeof scriptDetails === "string") {
230
- scriptDetails = JSON.parse(scriptDetails);
231
- }
232
- const jwtScript = scriptDetails.find(s => s.scriptName === fileName.replace(".js", ""));
233
- console.log("jwtScript:", jwtScript);
234
-
235
- await exeDetails.updateScriptExecutionStatus(
236
- BUFFER.getItem("ORGANISATION_DOMAIN_URL"),
237
- BUFFER.getItem("FROTH_LOGIN_TOKEN"),
238
- jwtScript.scriptId,
239
- jwtScript.platform.toLowerCase(),
240
- scriptresult)
241
-
242
-
243
- },
244
- /**
245
- * Hook that gets executed after the suite has ended (in Mocha/Jasmine only).
246
- * @param {object} suite suite details
247
- */
248
- afterSuite: async function (suite) {
249
- console.log('==== AFTER SUITE HOOK ====');
250
- console.log(`====> Test suite has completed '${suite.title}'`);
251
- },
252
- /**
253
- * Gets executed after all tests are done. You still have access to all global variables from
254
- * the test.
255
- * @param {number} result 0 - test pass, 1 - test fail
256
- * @param {Array.<Object>} capabilities list of capabilities details
257
- * @param {Array.<String>} specs List of spec file paths that ran
258
- */
259
- after: async function (result, config, capabilities, specs) {
260
- console.log('==== AFTER HOOK ====');
261
- console.log('====> All tests are completed.' + result);
262
- BUFFER.setItem("RESULT_DATA", result);
263
- console.log("====> Result data :" + BUFFER.getItem("RESULT_DATA"))
264
- resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
265
- console.log("====> Total Duration taken for the suite:" + BUFFER.getItem("FROTH_TOTAL_DURATION"));
266
- console.log("====> Execution Status from results" + resultdetails.excution_status);
267
- // Capture WebDriver session errors
268
-
269
- if (result !== 0) {
270
- if (resultdetails.comments.length === 0) {
271
- resultdetails.comments.push("❌ WebDriver session failed or timed out.");
272
- }
273
- resultdetails.comments.push(`Execution failed with exit code: ${result}`);
274
-
275
- process.on('uncaughtException', (err) => {
276
- console.error("Uncaught Exception:", err);
277
- resultdetails.comments.push(`Execution failed : ${err}`);
278
- });
279
-
280
- }
281
-
282
- },
283
-
284
- onError: async function (error) {
285
- console.error('==== ON ERROR HOOK ====');
286
- console.error('====> Error occurred:', error.message);
287
- if (error.message.includes('Automate testing time expired')) {
288
- console.log('❌ Global error: Session timed out on BrowserStack.');
289
- resultdetails.excution_status = 'FAILED';
290
- resultdetails.comments.push(`Global error: Session timed out on BrowserStack.Please check ths session: ${result}`);
291
-
292
- await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
293
- process.exit(1); // Stop execution if session timed out
294
- }
295
- },
296
- afterSession: async function (config, capabilities, specs) {
297
- console.log('==== AFTER SESSION HOOK ====');
298
- console.log('====> This is the aftersession hook');
299
- // console.log("Capabilities:", capabilities);
300
- console.log("Specs:", specs);
301
- //console.log("Config:", config);
302
-
303
- process.on('uncaughtException', (err) => {
304
- console.error("Uncaught Exception:", err);
305
- resultdetails.comments.push(`Execution failed with exit code: ${err}`);
306
- });
307
-
308
- // Capture unhandled promise rejections
309
- process.on('unhandledRejection', (reason, promise) => {
310
- console.error("Unhandled Promise Rejection:", reason);
311
- resultdetails.comments.push(`Execution failed with exit code: ${reason}`);
312
- });
313
-
314
- endtime = new Date().getTime();
315
- let totalDuration = endtime - starttime;
316
- console.log("====> Total Duration taken for :" + BUFFER.getItem("FROTH_TOTAL_DURATION"));
317
- console.log("====> Total Duration in after session based on start time and end time:" + totalDuration);
318
- console.log("====> Total Duration in after session based on summing up the test execution times:" + totalTestDuration);
319
-
320
- resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
321
- const frothDuration = BUFFER.getItem("FROTH_TOTAL_DURATION");
322
-
323
- if (await isInvalidDuration(frothDuration)) {
324
- // console.log("inside froth duration");
325
- if (await isInvalidDuration(totalTestDuration)) {
326
- console.log("inside froth totalTestDuration");
327
- resultdetails.excution_time = await millisecondsToTime(totalDuration);
328
- } else {
329
- console.log("inside froth totalTestDuration comparision");
330
- if (totalDuration > totalTestDuration)
331
- resultdetails.excution_time = await millisecondsToTime(totalDuration);
332
- else
333
- resultdetails.excution_time = await millisecondsToTime(totalTestDuration);
334
- }
335
- } else {
336
- console.log("inside froth duration else");
337
- resultdetails.excution_time = await secondsToTime(frothDuration);
338
- }
339
-
340
- console.log("====> Total Duration calculation:" + resultdetails.excution_time);
341
-
342
- await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
343
-
344
- // Perform any cleanup or post-test actions here
345
- BUFFER.clear();
346
- },
347
-
348
- onComplete: async function (exitCode, config, capabilities, results) {
349
- console.log('==== ON COMPLETE HOOK ====');
350
- console.log('====> Results:', results);
351
- console.log('==== Test Results Summary ======');
352
- console.log('Total Tests:', results.total);
353
- console.log('Passed:', results.passed);
354
- console.log('Failed:', results.failed);
355
- console.log('Exit Code:', exitCode);
356
-
357
- console.log('==== ALL TESTS ARE COMPLETED ====');
358
- return exitCode;
359
- }
360
-
361
- };
362
- async function isInvalidDuration(val) {
363
- console.log("val in isValidDuration:" + val);
364
- // Check if the value is null, 0, or undefined
365
- let isValid;
366
- if (typeof val === 'string') {
367
- val = val.trim().toLowerCase();
368
- isValid = val === "null" || val === "0" || val === "undefined";
369
-
370
- } else
371
- isValid = val === null || val === 0 || val === undefined;
372
-
373
- console.log("isValid in isValidDuration:" + isValid);
374
-
375
- return isValid;
376
- }
377
- async function secondsToTime(secs) {
378
- console.log("secs in secondsToTime :" + secs);
379
- let hours = Math.floor(secs / 3600);
380
- let minutes = Math.floor((secs % 3600) / 60);
381
- let seconds = secs % 60;
382
-
383
- // Adding leading zeros if the value is less than 10
384
- if (hours < 10) hours = '0' + hours;
385
- if (minutes < 10) minutes = '0' + minutes;
386
- if (seconds < 10) seconds = '0' + seconds;
387
- console.log("Time:" + hours + ':' + minutes + ':' + seconds);
388
- return hours + ':' + minutes + ':' + seconds;
389
- }
390
- async function millisecondsToTime(ms) {
391
- console.log("ms in millisecondsToTime: " + ms);
392
-
393
- // Ensure input is a number
394
- ms = Number(ms);
395
- if (isNaN(ms)) {
396
- return '00:00:00';
397
- }
398
-
399
- let totalSeconds = Math.floor(ms / 1000);
400
- let hours = Math.floor(totalSeconds / 3600);
401
- let minutes = Math.floor((totalSeconds % 3600) / 60);
402
- let seconds = totalSeconds % 60;
403
-
404
- // Pad with leading zeros
405
- hours = hours < 10 ? '0' + hours : hours;
406
- minutes = minutes < 10 ? '0' + minutes : minutes;
407
- seconds = seconds < 10 ? '0' + seconds : seconds;
408
-
409
- const timeStr = `${hours}:${minutes}:${seconds}`;
410
- console.log("Formatted time:", timeStr);
411
- return timeStr;
412
- }
413
-
414
- async function convertTimetoHHMMSS(time) {
415
- const seconds = Math.floor((time / 1000) % 60);
416
- const minutes = Math.floor((time / (1000 * 60)) % 60);
417
- const hours = Math.floor((time / (1000 * 60 * 60)) % 24);
418
- const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
419
-
420
- console.log("Time:" + hours + ':' + minutes + ':' + seconds);
421
-
422
- return formattedTime;
423
- }
424
-
425
- module.exports = commonHooks;
@@ -1,57 +0,0 @@
1
- const path = require('path');
2
-
3
- const SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
4
- console.log('====>SUITE_FILE:', SUITE_FILE);
5
- exports.config = {
6
- user: process.env.BROWSERSTACK_USERNAME || 'naveen_OSt3Pw',
7
- key: process.env.BROWSERSTACK_ACCESS_KEY || 'B9Rx28MTKFzRJ2QEVK1c',
8
- services: [
9
- [
10
- 'browserstack',
11
- {
12
- buildIdentifier: '${BUILD_NUMBER}',
13
- browserstackLocal: true,
14
- opts: { forcelocal: true, localIdentifier: "webdriverio-appium-app-browserstack-android-repo" },
15
- app: process.env.BROWSERSTACK_APP_PATH || 'bs://30fdf3a163d0bad126f64a3d5713e9ab0086a41e'
16
- }
17
- ]
18
- ],
19
-
20
- capabilities: [{
21
- 'bstack:options': {
22
- projectName: "BrowserStack Samples",
23
- buildName: 'browserstack build',
24
- sessionName: 'BStack local webdriverio-appium',
25
- deviceName: 'Samsung Galaxy S22 Ultra',
26
- osVersion: "12.0",
27
- debug: true,
28
- networkLogs: true,
29
- source: 'webdriverio:appium-sample-sdk:v1.0',
30
- interactiveDebugging: true,
31
- 'appium:autoWebview': false
32
- }
33
- }],
34
-
35
- updateJob: false,
36
- // specs: [
37
- // '/Users/subhrasubudhi/WORKSPACES/WEBDRIVERIO/SAMPLE_BS_LOCAL_PROJECT/android/examples/run-local-test/specs/local_test.js'
38
- // ],
39
-
40
- specs: require(SUITE_FILE).tests,
41
-
42
- exclude: [],
43
-
44
- logLevel: 'info',
45
- coloredLogs: true,
46
- screenshotPath: './errorShots/',
47
- baseUrl: '',
48
- waitforTimeout: 10000,
49
- connectionRetryTimeout: 90000,
50
- connectionRetryCount: 3,
51
-
52
- framework: 'mocha',
53
- mochaOpts: {
54
- ui: 'bdd',
55
- timeout: 20000
56
- }
57
- };
package/local.log DELETED
@@ -1,8 +0,0 @@
1
-
2
-
3
- Sat Dec 13 2025 23:44:27:601 GMT+0800 (+08) -- [WARNING] Skipping initialisation of configuration console because: port already in use by another Binary
4
- Sat Dec 13 2025 23:44:29:503 GMT+0800 (+08) -- [SUCCESS] You can now access your local server(s) in our remote browser
5
-
6
- Sat Dec 13 2025 23:44:30:228 GMT+0800 (+08) -- Press Ctrl-C to exit
7
-
8
-