froth-webdriverio-framework 6.0.30 → 6.0.31

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.
@@ -0,0 +1 @@
1
+ [object Object]
@@ -1,4 +1,4 @@
1
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
1
+ // process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
2
2
 
3
3
  const Imap = require('imap');
4
4
  const { simpleParser } = require('mailparser');
@@ -1,11 +1,34 @@
1
1
  const path = require('path');
2
-
3
2
  const SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
4
- console.log('====>SUITE_FILE:', SUITE_FILE);
3
+ console.log('====>SUITE_FILE IN BASE CONFIG:', SUITE_FILE);
4
+ const setAllDetails = require("./setallDatailinBuffer.js")
5
+ //we have to set here the browserstack environment variables before the config export
6
+ process.env.BROWSERSTACK_USERNAME='naveen_OSt3Pw'
7
+ process.env.BROWSERSTACK_ACCESS_KEY= 'B9Rx28MTKFzRJ2QEVK1c'
8
+ console.log('====BROWSERSTACK_APP_PATH before baseconfig ', process.env.BROWSERSTACK_APP_PATH);
9
+ console.log('====BROWSERSTACK_USERNAME before baseconfig ', process.env.BROWSERSTACK_USERNAME);
10
+ console.log('====BROWSERSTACK_ACCESS_KEY before baseconfig ', process.env.BROWSERSTACK_ACCESS_KEY);
5
11
 
6
12
  exports.config = {
7
- user: process.env.BROWSERSTACK_USERNAME || 'naveen_OSt3Pw',
8
- key: process.env.BROWSERSTACK_ACCESS_KEY || Buffer.from('QjlSeDI4TVRLRnpSSjJRRVZLMWM=', 'base64').toString('utf-8'),
13
+ onPrepare: async function (config, capabilities) {
14
+ try {
15
+
16
+ console.log('==== ON PREPARE HOOK ====');
17
+ // This code runs before the test suite starts
18
+ await setAllDetails.setEnvVariables();
19
+ await setAllDetails.setExecutionDetails();
20
+ await setAllDetails.setSuiteDetails();
21
+ await setAllDetails.setTestDataDetails();
22
+ console.log("on prepare:", JSON.stringify(capabilities))
23
+ console.log("BS USERNAME:", process.env.BROWSERSTACK_USERNAME)
24
+ console.log("BS ACCESS KEY:", process.env.BROWSERSTACK_ACCESS_KEY)
25
+ // console.log("ALL JSON DATA in env variable :" + JSON.stringify(process.env));
26
+ } catch (e) {
27
+ console.log("====> Error in onPrepare:", e);
28
+
29
+ }
30
+ },
31
+
9
32
 
10
33
  updateJob: false,
11
34
  specs: require(SUITE_FILE).tests,
@@ -19,13 +42,7 @@ exports.config = {
19
42
  connectionRetryTimeout: 120000,
20
43
  connectionRetryCount: 3,
21
44
  hostname: 'hub.browserstack.com',
22
- services: [['browserstack']],
23
-
24
- // before: function () {
25
- // var chai = require('chai');
26
- // global.expect = chai.expect;
27
- // chai.Should();
28
- // },
45
+ // services: [['browserstack']],
29
46
  framework: 'mocha',
30
47
  mochaOpts: {
31
48
  ui: 'bdd',
@@ -40,7 +40,7 @@ const commonconfig = {
40
40
  },
41
41
 
42
42
 
43
- beforeSession: async function (config, capabilities, specs) {
43
+ beforeSession: async function (config, capabilities, specs) {
44
44
  try {
45
45
  let syntaxFailed = false;
46
46
 
@@ -76,38 +76,38 @@ const commonconfig = {
76
76
  process.exit(1);
77
77
  }
78
78
  // set the capability like media and app and bs local
79
- // if (process.env.PLATFORM === 'browserstack') {
80
- // /// console.log("capabilities:", capabilities);
81
- // capabilities.browserstackLocal = process.env.BROWSERSTACK_LOCAL;
82
- // // capabilities.accessKey = Buffer.from(capabilities.accessKey, 'base64').toString('utf-8');
83
- // if (capabilities.platformName === 'android' || capabilities.platformName === 'ios') {
84
- // capabilities.app = process.env.BROWSERSTACK_APP_PATH;
85
- // if (capabilities.app === undefined || capabilities.app === null || capabilities.app === '') {
86
- // console.error("🚨 Error: BROWSERSTACK_APP_PATH is not defined or empty.");
87
- // resultdetails.excution_status = 'FAILED';
88
- // resultdetails.comments.push("BROWSERSTACK_APP_PATH is not defined or empty.");
89
- // await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails);
90
- // process.exit(1); // Stop execution if app path is not set
91
- // } else {
92
- // console.log("App Path:", capabilities.app);
93
- // console.log("Browserstack Local:", capabilities.browserstackLocal);
94
- // }
95
- // }
96
-
97
- // try {
98
- // let mediaFiles = process.env.MEDIA_FILES ? JSON.parse(process.env.MEDIA_FILES) : [];
99
- // console.log("Size of Media Files:", Array.isArray(mediaFiles) ? mediaFiles.length : "Invalid data");
100
-
101
- // if (Array.isArray(mediaFiles) && mediaFiles.length > 0) {
102
- // console.log("Media Files:", JSON.parse(process.env.MEDIA_FILES));
103
- // capabilities['browserstack.uploadMedia'] = JSON.parse(process.env.MEDIA_FILES);
104
- // }
105
- // } catch (error) {
106
- // console.error("Error parsing MEDIA_FILES:", error);
107
- // }
108
-
109
- // console.log(`Running tests on after app,bslocal,mediafiles: ${JSON.stringify(capabilities)}`);
110
- // }
79
+ if (process.env.PLATFORM === 'browserstack') {
80
+ /// console.log("capabilities:", capabilities);
81
+ capabilities.browserstackLocal = process.env.BROWSERSTACK_LOCAL;
82
+ // capabilities.accessKey = Buffer.from(capabilities.accessKey, 'base64').toString('utf-8');
83
+ if (capabilities.platformName === 'android' || capabilities.platformName === 'ios') {
84
+ capabilities.app = process.env.BROWSERSTACK_APP_PATH;
85
+ if (capabilities.app === undefined || capabilities.app === null || capabilities.app === '') {
86
+ console.error("🚨 Error: BROWSERSTACK_APP_PATH is not defined or empty.");
87
+ resultdetails.excution_status = 'FAILED';
88
+ resultdetails.comments.push("BROWSERSTACK_APP_PATH is not defined or empty.");
89
+ await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails);
90
+ process.exit(1); // Stop execution if app path is not set
91
+ } else {
92
+ console.log("App Path:", capabilities.app);
93
+ console.log("Browserstack Local:", capabilities.browserstackLocal);
94
+ }
95
+ }
96
+
97
+ try {
98
+ let mediaFiles = process.env.MEDIA_FILES ? JSON.parse(process.env.MEDIA_FILES) : [];
99
+ console.log("Size of Media Files:", Array.isArray(mediaFiles) ? mediaFiles.length : "Invalid data");
100
+
101
+ if (Array.isArray(mediaFiles) && mediaFiles.length > 0) {
102
+ console.log("Media Files:", JSON.parse(process.env.MEDIA_FILES));
103
+ capabilities['browserstack.uploadMedia'] = JSON.parse(process.env.MEDIA_FILES);
104
+ }
105
+ } catch (error) {
106
+ console.error("Error parsing MEDIA_FILES:", error);
107
+ }
108
+
109
+ console.log(`Running tests on after app,bslocal,mediafiles: ${JSON.stringify(capabilities)}`);
110
+ }
111
111
 
112
112
  } catch (error) {
113
113
  console.error('🚨 Error in beforeSession:', error);
@@ -325,7 +325,6 @@ const commonconfig = {
325
325
 
326
326
  await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
327
327
 
328
-
329
328
  // Perform any cleanup or post-test actions here
330
329
  BUFFER.clear();
331
330
  },
@@ -407,4 +406,4 @@ async function convertTimetoHHMMSS(time) {
407
406
  return formattedTime;
408
407
  }
409
408
 
410
- module.exports = commonconfig;
409
+ module.exports = commonconfig;
@@ -6,13 +6,13 @@ const getDataById = require("../froth_api_calls/readTestdata");
6
6
 
7
7
  async function generateBuildNumber() {
8
8
  try {
9
- const now = new Date();
10
- const timestamp = formatDate(now); // Format date as needed
9
+ const now = await new Date();
10
+ const timestamp = await formatDate(now); // Format date as needed
11
11
 
12
12
  // Construct the build number with timestamp and counter
13
13
  const buildNumber = `${timestamp}`;
14
14
  process.env.BUILD_NUMBER = buildNumber;
15
-
15
+ console.log("Generated Build Number:", buildNumber);
16
16
  // Increment the counter for the next build
17
17
  } catch (error) {
18
18
  console.log("error in generateBuildNumber")
@@ -21,29 +21,28 @@ async function generateBuildNumber() {
21
21
  }
22
22
 
23
23
  async function formatDate(date) {
24
- const year = date.getFullYear();
25
- const month = padZero(date.getMonth() + 1); // Month is zero-indexed
26
- const day = padZero(date.getDate());
27
- const hours = padZero(date.getHours());
28
- const minutes = padZero(date.getMinutes());
29
- const seconds = padZero(date.getSeconds());
24
+ const year = await date.getFullYear();
25
+ const month = await padZero(date.getMonth() + 1); // Month is zero-indexed
26
+ const day = await padZero(date.getDate());
27
+ const hours = await padZero(date.getHours());
28
+ const minutes = await padZero(date.getMinutes());
29
+ const seconds =await padZero(date.getSeconds());
30
30
 
31
31
  return `${year}${month}${day}_${hours}${minutes}${seconds}`;
32
32
  }
33
33
 
34
34
  async function padZero(num) {
35
- return num.toString().padStart(2, '0');
35
+ return await num.toString().padStart(2, '0');
36
36
  }
37
37
 
38
38
  async function setEnvVariables() {
39
- generateBuildNumber();
40
- BUFFER.setItem("FROTH_TOTAL_DURATION", 0);
41
- BUFFER.setItem("FROTH_EXECUTION_ID", process.env.EXECUTION_ID || 1);
42
- // BUFFER.setItem("FROTH_INTEGRATION_ID", process.env.INTEGRATION_ID || 1);
43
- BUFFER.setItem("ORGANISATION_DOMAIN_URL", process.env.ORGANISATION_DOMAIN_URL || "https://devapi.frothtestops.com");
44
- BUFFER.setItem("FROTH_LOGIN_TOKEN", process.env.API_TOKEN)
45
- console.log("api token in set evn variable :" + BUFFER.getItem("FROTH_LOGIN_TOKEN"))
46
- console.log("CICD_RUN_ID in set evn variable :" + process.env.CICD_RUN_ID)
39
+ await generateBuildNumber();
40
+ await BUFFER.setItem("FROTH_TOTAL_DURATION", 0);
41
+ await BUFFER.setItem("FROTH_EXECUTION_ID", process.env.EXECUTION_ID || 1);
42
+ await BUFFER.setItem("ORGANISATION_DOMAIN_URL", process.env.ORGANISATION_DOMAIN_URL || "https://devapi.frothtestops.com");
43
+ await BUFFER.setItem("FROTH_LOGIN_TOKEN", process.env.API_TOKEN)
44
+ console.log("api token in set evn variable :" + BUFFER.getItem("FROTH_LOGIN_TOKEN"))
45
+ console.log("CICD_RUN_ID in set evn variable :" + process.env.CICD_RUN_ID)
47
46
  }
48
47
 
49
48
  async function setLoginToken() {
@@ -4,6 +4,7 @@ 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
+
7
8
  // Select platform at runtime
8
9
  const PLATFORM = process.env.PLATFORM || 'browserstack';
9
10
  console.log('====>PLATFORM:', PLATFORM);
@@ -24,7 +25,7 @@ let capabilities;
24
25
  try {
25
26
  capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
26
27
  // Merge chrome-specific options if applicable
27
-
28
+
28
29
  } catch (e) {
29
30
  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`;
30
31
  console.error(errorMsg);
@@ -101,56 +102,22 @@ const specificConfig = setupPrerequisites();
101
102
  exports.config = deepmerge(commonconfig,
102
103
 
103
104
  {
104
- user: process.env.BROWSERSTACK_USERNAME||'naveen_OSt3Pw',
105
- key: process.env.BROWSERSTACK_ACCESS_KEY||'B9Rx28MTKFzRJ2QEVK1c',
105
+ user: process.env.BROWSERSTACK_USERNAME,
106
+ key: process.env.BROWSERSTACK_ACCESS_KEY,
106
107
  // debug: true,
107
- // services: PLATFORM === 'browserstack'
108
- // ? ['browserstack']
109
- // : PLATFORM === 'saucelabs'
110
- // ? ['sauce']
111
- // : [],
112
-
113
- services: [
114
- [
115
- 'browserstack',
116
- {
117
- buildIdentifier: '${BUILD_NUMBER}',
118
- browserstackLocal: false,
119
- opts: { forcelocal: false, localIdentifier: "webdriverio-appium-app-browserstack-android-repo" },
120
- app: 'bs://0bfd506ea937c227cf29d0d5ef55f2520a8f7a29' || '/Users/subhrasubudhi/WORKSPACES/WEBDRIVERIO/SAMPLE_BS_LOCAL_PROJECT/android/examples/LocalSample.apk'
121
- }
122
- ]
123
- ],
108
+ // execArgv: ['--inspect-brk'],
109
+ services: PLATFORM === 'browserstack'
110
+ ? ['browserstack']
111
+ : PLATFORM === 'saucelabs'
112
+ ? ['sauce']
113
+ : [],
124
114
 
125
115
  //runner: 'local',
126
116
  specs: require(SUITE_FILE).tests,
127
117
 
128
118
  maxInstances: 1,
129
- // capabilities: [capabilities],
130
- // capabilities: [{
131
- // // capabilities for local Appium web tests on an Android Emulator
132
- // platformName: 'Android',
133
- // browserName: 'Chrome',
134
- // 'appium:app': 'bs://30fdf3a163d0bad126f64a3d5713e9ab0086a41e',
135
- // 'appium:deviceName': 'Samsung Galaxy S22 Ultra',
136
- // 'appium:platformVersion': '12.0',
137
- // 'appium:automationName': 'UiAutomator2'
138
- // }],
139
-
140
- capabilities: [{
141
- 'bstack:options': {
142
- projectName: "BrowserStack Samples",
143
- buildName: 'browserstack build',
144
- sessionName: 'BStack local webdriverio-appium',
145
- deviceName: 'Samsung Galaxy S22 Ultra',
146
- osVersion: "12.0",
147
- debug: true,
148
- networkLogs: true,
149
- source: 'webdriverio:appium-sample-sdk:v1.0',
150
- interactiveDebugging: true,
151
- 'appium:autoWebview': false
152
- }
153
- }],
119
+ capabilities: [capabilities],
120
+
154
121
  logLevel: 'info',
155
122
  coloredLogs: true,
156
123
  screenshotPath: './errorShots/',
@@ -0,0 +1,171 @@
1
+ const deepmerge = require('deepmerge')
2
+ const fs = require('fs');
3
+ const yaml = require('js-yaml');
4
+ const path = require('path');
5
+ const commonconfig = require('./commonconfig');
6
+ console.log('=====wdios common config===== ');
7
+ // Select platform at runtime
8
+ const PLATFORM = process.env.PLATFORM || 'browserstack';
9
+ console.log('====>PLATFORM:', PLATFORM);
10
+
11
+ const configFile = process.env.YML_NAME;
12
+
13
+ const resultdetails = {
14
+ comments: [],
15
+ excution_status: null, // Pass/Fail
16
+ excution_time: null, // Execution time in milliseconds
17
+ };
18
+
19
+ // Load YAML file
20
+ //const capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
21
+
22
+ let capabilities;
23
+
24
+ try {
25
+ capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
26
+ // Merge chrome-specific options if applicable
27
+
28
+ } catch (e) {
29
+ 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`;
30
+ console.error(errorMsg);
31
+ resultdetails.comments.push(errorMsg);
32
+ resultdetails.excution_status = 'FAIL';
33
+
34
+ try {
35
+ exeDetails.updateExecuitonDetails(
36
+ process.env.ORGANISATION_DOMAIN_URL,
37
+ process.env.API_TOKEN,
38
+ process.env.EXECUTION_ID,
39
+ resultdetails
40
+ );
41
+ setTimeout(() => {
42
+ console.log("30 seconds passed.");
43
+ // You can call your API or exit the process here
44
+ }, 30000);
45
+ console.log('Execution details updated successfully.');
46
+ } catch (err) {
47
+ console.error('Failed to update execution details:', err.message);
48
+ }
49
+ process.exit(1);
50
+ }
51
+ console.log('====>capabilities:', capabilities);
52
+
53
+ const SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
54
+ console.log('====>SUITE_FILE:', SUITE_FILE);
55
+
56
+ if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
57
+ let errorMsg = `The suite file does not exist in the currently configured repository at path: ${SUITE_FILE}. Please update the SUITE by editing the file`;
58
+
59
+ console.error(errorMsg);
60
+ resultdetails.comments.push(errorMsg);
61
+ resultdetails.excution_status = 'FAIL';
62
+
63
+ // Fire API call in background (non-blocking)
64
+
65
+ try {
66
+ exeDetails.updateExecuitonDetails(
67
+ process.env.ORGANISATION_DOMAIN_URL,
68
+ process.env.API_TOKEN,
69
+ process.env.EXECUTION_ID,
70
+ resultdetails
71
+ );
72
+ setTimeout(() => {
73
+ console.log("30 seconds passed.");
74
+ // You can call your API or exit the process here
75
+ }, 30000);
76
+ console.log('Execution details updated successfully.');
77
+ } catch (err) {
78
+ console.error('Failed to update execution details:', err.message);
79
+ }
80
+ process.exit(1);
81
+ }
82
+
83
+ function setupPrerequisites() {
84
+ console.log("inside this fuction first ");
85
+ if (PLATFORM === 'browserstack') {
86
+ process.env.BROWSERSTACK_USERNAME = capabilities.userName;
87
+ capabilities.accessKey = Buffer.from(capabilities.accessKey, 'base64').toString('utf-8');
88
+ process.env.BROWSERSTACK_ACCESS_KEY = capabilities.accessKey
89
+
90
+ console.log('capabilities.platformName:', capabilities.platformName ?? 'web');
91
+ process.env.BS_SESSION_TYPE = capabilities.platformName === 'android' || capabilities.platformName === 'ios' ? 'app-automate' : 'automate';
92
+ capabilities.buildName = process.env.FROTH_TESTOPS_BUILD_NAME;
93
+
94
+ }
95
+
96
+ }
97
+
98
+ const specificConfig = setupPrerequisites();
99
+
100
+
101
+ exports.config = deepmerge(commonconfig,
102
+
103
+ {
104
+ user: process.env.BROWSERSTACK_USERNAME||'naveen_OSt3Pw',
105
+ key: process.env.BROWSERSTACK_ACCESS_KEY||'B9Rx28MTKFzRJ2QEVK1c',
106
+ // debug: true,
107
+ // services: PLATFORM === 'browserstack'
108
+ // ? ['browserstack']
109
+ // : PLATFORM === 'saucelabs'
110
+ // ? ['sauce']
111
+ // : [],
112
+
113
+ services: [
114
+ [
115
+ 'browserstack',
116
+ {
117
+ buildIdentifier: '${BUILD_NUMBER}',
118
+ browserstackLocal: false,
119
+ opts: { forcelocal: false, localIdentifier: "webdriverio-appium-app-browserstack-android-repo" },
120
+ app: 'bs://0bfd506ea937c227cf29d0d5ef55f2520a8f7a29' || '/Users/subhrasubudhi/WORKSPACES/WEBDRIVERIO/SAMPLE_BS_LOCAL_PROJECT/android/examples/LocalSample.apk'
121
+ }
122
+ ]
123
+ ],
124
+
125
+ //runner: 'local',
126
+ specs: require(SUITE_FILE).tests,
127
+
128
+ maxInstances: 1,
129
+ // capabilities: [capabilities],
130
+ // capabilities: [{
131
+ // // capabilities for local Appium web tests on an Android Emulator
132
+ // platformName: 'Android',
133
+ // browserName: 'Chrome',
134
+ // 'appium:app': 'bs://30fdf3a163d0bad126f64a3d5713e9ab0086a41e',
135
+ // 'appium:deviceName': 'Samsung Galaxy S22 Ultra',
136
+ // 'appium:platformVersion': '12.0',
137
+ // 'appium:automationName': 'UiAutomator2'
138
+ // }],
139
+
140
+ capabilities: [{
141
+ 'bstack:options': {
142
+ projectName: "BrowserStack Samples",
143
+ buildName: 'browserstack build',
144
+ sessionName: 'BStack local webdriverio-appium',
145
+ deviceName: 'Samsung Galaxy S22 Ultra',
146
+ osVersion: "12.0",
147
+ debug: true,
148
+ networkLogs: true,
149
+ source: 'webdriverio:appium-sample-sdk:v1.0',
150
+ interactiveDebugging: true,
151
+ 'appium:autoWebview': false
152
+ }
153
+ }],
154
+ logLevel: 'info',
155
+ coloredLogs: true,
156
+ screenshotPath: './errorShots/',
157
+ bail: 0,
158
+ //baseUrl: 'https://example.com',
159
+ waitforTimeout: 90000,
160
+ connectionRetryTimeout: 90000,
161
+ connectionRetryCount: 3,
162
+
163
+ framework: 'mocha',
164
+ reporters: ['spec'],
165
+ maxInstances: 10,
166
+ updateJob: false,
167
+ mochaOpts: {
168
+ ui: 'bdd',
169
+ timeout: 300000
170
+ }
171
+ });
package/local.log CHANGED
@@ -1,8 +1 @@
1
1
 
2
-
3
- Mon Dec 08 2025 10:44:50:843 GMT+0800 (+08) -- Starting configuration console on http://localhost:45454
4
- Mon Dec 08 2025 10:44:53:559 GMT+0800 (+08) -- [SUCCESS] You can now access your local server(s) in our remote browser
5
-
6
- Mon Dec 08 2025 10:44:53:666 GMT+0800 (+08) -- Press Ctrl-C to exit
7
-
8
-