froth-webdriverio-framework 7.0.37 → 7.0.39

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.
@@ -47,18 +47,18 @@ async function getExecuitonDetails(frothUrl, token, id) {
47
47
  headers: DEFAULT_HEADERS(token)
48
48
  });
49
49
 
50
- const data = await handleResponse(response, 'getExecuitonDetails');
51
- if (!data) return null;
50
+ // const data = await handleResponse(response, 'getExecuitonDetails');
51
+ // if (!data) return null;
52
52
 
53
- // let data = await handleResponse(response, 'getExecuitonDetails');
54
- // // let responseData = await response.json()
53
+ let data = await handleResponse(response, 'getExecuitonDetails');
54
+ // let responseData = await response.json()
55
55
 
56
- // data = await aes.decrpytData(data.data)
57
- // // console.log("after decrypting",data)
56
+ data = await aes.decrpytData(data.data)
57
+ // console.log("after decrypting",data)
58
58
 
59
- // data = JSON.parse(data)
60
- // // console.log("json parsing",data)
61
- // if (!data) return null;
59
+ data = JSON.parse(data)
60
+ // console.log("json parsing",data)
61
+ if (!data) return null;
62
62
 
63
63
  const jsondata = {
64
64
  automation_suite_id: data?.automation_suite_details?.id ?? null,
@@ -29,24 +29,24 @@ async function getSuiteDetails(frothUrl, token, suiteId) {
29
29
  }
30
30
  });
31
31
 
32
- const data = await handleResponse(response, 'getExecuitonDetails');
33
- if (!data) return null;
34
-
35
- // let resData = await handleResponse(response, 'getSuiteDetails');
36
- // if (!resData || !resData.data) return jsonData;
37
-
38
- // // Decrypt the data
39
- // let decryptedData = await aes.decrpytData(resData.data);
40
- // if (!decryptedData) return jsonData;
41
-
42
- // // Parse JSON
43
- //let data;
44
- // try {
45
- // data = JSON.parse(decryptedData);
46
- // } catch (parseError) {
47
- // console.error('Failed to parse decrypted data:', parseError);
48
- // return jsonData;
49
- // }
32
+ // const data = await handleResponse(response, 'getExecuitonDetails');
33
+ // if (!data) return null;
34
+
35
+ let resData = await handleResponse(response, 'getSuiteDetails');
36
+ if (!resData || !resData.data) return jsonData;
37
+
38
+ // Decrypt the data
39
+ let decryptedData = await aes.decrpytData(resData.data);
40
+ if (!decryptedData) return jsonData;
41
+
42
+ // Parse JSON
43
+ let data;
44
+ try {
45
+ data = JSON.parse(decryptedData);
46
+ } catch (parseError) {
47
+ console.error('Failed to parse decrypted data:', parseError);
48
+ return jsonData;
49
+ }
50
50
 
51
51
  // Map data to default structure
52
52
  jsonData = {
@@ -110,6 +110,28 @@ const commonHooks = {
110
110
  }
111
111
  },
112
112
 
113
+ /* ========== ON WORKER ERROR (SESSION / DRIVER FAILURES) ========== */
114
+ onWorkerError: async function (cid, error, specs, retries) {
115
+ console.error('==== ON WORKER ERROR HOOK ====');
116
+ console.error(`Worker ID : ${cid}`);
117
+ console.error(`Specs : ${specs?.join(', ')}`);
118
+ console.error(`Retries : ${retries}`);
119
+ console.error(`Error : ${error?.message}`);
120
+ console.error(error?.stack);
121
+
122
+ // Prevent duplicate updates
123
+ if (executionUpdated) return;
124
+
125
+ const userMessage = await normalizeWdioError(error);
126
+
127
+ resultdetails.excution_status = 'FAILED';
128
+ resultdetails.comments.push(userMessage);
129
+
130
+ await safeUpdateExecution();
131
+ },
132
+ /* ========== ON ERROR ========== */
133
+
134
+
113
135
  /* ========== BEFORE SESSION ========== */
114
136
 
115
137
  beforeSession: async function (config, capabilities, specs) {
@@ -270,7 +292,9 @@ const commonHooks = {
270
292
  const endTime = Date.now();
271
293
  const totalTime = endTime - suiteStartTime; // Full WDIO+CI elapsed time
272
294
  resultdetails.excution_time = await msToTime(totalTime);
295
+
273
296
  console.log("Exit code after session===>" + exitCode)
297
+ exitCode = exitCode ?? 0;
274
298
  resultdetails.excution_status = exitCode === 0 ? 'PASSED' : 'FAILED';
275
299
 
276
300
  console.log('Comments being sent:', resultdetails.comments);
@@ -282,7 +306,6 @@ const commonHooks = {
282
306
 
283
307
  },
284
308
 
285
- /* ========== ON ERROR ========== */
286
309
 
287
310
  onError: async function (error) {
288
311
  console.error('==== ON ERROR HOOK ====');
@@ -305,6 +328,11 @@ const commonHooks = {
305
328
  onComplete: async (exitCode, _, __, results) => {
306
329
  console.log('==== ON COMPLETE ====');
307
330
  console.log(`Total: ${results.total || 0}, Passed: ${results.passed || 0}, Failed: ${results.failed || 0}`);
331
+ exitCode = exitCode ?? 0;
332
+ resultdetails.excution_status = exitCode === 0 ? 'PASSED' : 'FAILED';
333
+ resultdetails.comments.push(`WDIO Error: ${error.message}`);
334
+
335
+ await safeUpdateExecution();
308
336
 
309
337
 
310
338
  return exitCode;
@@ -313,5 +341,27 @@ const commonHooks = {
313
341
 
314
342
 
315
343
  };
344
+ async function normalizeWdioError(error) {
345
+ const msg = error?.message || String(error);
346
+
347
+ if (msg.includes('driver.version')) {
348
+ return 'Browser driver could not be initialized. Please verify browser compatibility and driver version.';
349
+ }
350
+
351
+ if (msg.toLowerCase().includes('opera')) {
352
+ return 'Opera browser is unstable on BrowserStack. Please switch to Chrome or Edge.';
353
+ }
354
+
355
+ if (msg.includes('session not created')) {
356
+ return 'Automation session could not be created. Please check browser capabilities.';
357
+ }
358
+
359
+ if (msg.includes('timeout')) {
360
+ return 'Session timed out while initializing the browser.';
361
+ }
362
+
363
+ return `Automation framework error: ${msg}`;
364
+ }
365
+
316
366
 
317
367
  module.exports = commonHooks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "7.0.37",
3
+ "version": "7.0.39",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",