froth-webdriverio-framework 6.0.6 → 6.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.
|
@@ -8,7 +8,6 @@ const exeDetails = require("../froth_api_calls/getexecutionDetails")
|
|
|
8
8
|
const getBSSessionDetails = require("../froth_api_calls/browsersatckSessionInfo").getBSSessionDetails;
|
|
9
9
|
const { fail } = require("assert");
|
|
10
10
|
const { error } = require('console');
|
|
11
|
-
const browserstack = require("browserstack-local");
|
|
12
11
|
//const isBrowserStackEnabled = process.env.BROWSERSTACK;
|
|
13
12
|
let starttime;
|
|
14
13
|
let endtime;
|
|
@@ -19,7 +18,6 @@ const resultdetails = {
|
|
|
19
18
|
excution_status: null, // Pass/Fail
|
|
20
19
|
excution_time: null, // Execution time in milliseconds
|
|
21
20
|
};
|
|
22
|
-
let bsLocal;
|
|
23
21
|
// Description: This file contains the common configuration for the webdriverio framework.
|
|
24
22
|
const commonconfig = {
|
|
25
23
|
|
|
@@ -84,42 +82,22 @@ const commonconfig = {
|
|
|
84
82
|
console.log("====> BROWSERSTACK_LOCAL : " + process.env.BROWSERSTACK_LOCAL);
|
|
85
83
|
console.log("Local enabled? →", capabilities['bstack:options']?.local);
|
|
86
84
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// };
|
|
96
|
-
|
|
97
|
-
// await new Promise((resolve, reject) => {
|
|
98
|
-
// bsLocal.start(localArgs, function (error) {
|
|
99
|
-
// if (error) return reject(error);
|
|
100
|
-
// console.log("====> BrowserStack Local started successfully.");
|
|
101
|
-
// resolve();
|
|
102
|
-
// });
|
|
103
|
-
// });
|
|
104
|
-
|
|
105
|
-
// // Add Local settings into capabilities dynamically
|
|
106
|
-
// capabilities['browserstack.local'] = true;
|
|
107
|
-
// capabilities['browserstack.localIdentifier'] = localArgs.localIdentifier || 'ExecuteLocal';
|
|
108
|
-
// }
|
|
109
|
-
// else {
|
|
110
|
-
// console.log("====> BROWSERSTACK_LOCAL not set. Skipping BrowserStack Local startup." + process.env.BROWSERSTACK_LOCAL);
|
|
111
|
-
// // Make sure no stale values from config remain
|
|
112
|
-
// delete capabilities['browserstack.local'];
|
|
113
|
-
// delete capabilities['browserstack.localIdentifier'];
|
|
114
|
-
// }
|
|
85
|
+
const isLocalEnabled = process.env.BROWSERSTACK_LOCAL === "true";
|
|
86
|
+
|
|
87
|
+
if (isLocalEnabled) {
|
|
88
|
+
console.log("====> Starting BrowserStack Local...");
|
|
89
|
+
if (!capabilities['bstack:options']) capabilities['bstack:options'] = {};
|
|
90
|
+
capabilities['bstack:options'].browserstackLocal = true;
|
|
91
|
+
console.log("✔ BrowserStack Local enabled dynamically");
|
|
92
|
+
}
|
|
115
93
|
|
|
116
94
|
// capabilities.accessKey = Buffer.from(capabilities.accessKey, 'base64').toString('utf-8');
|
|
117
95
|
if (capabilities.platformName === 'android' || capabilities.platformName === 'ios') {
|
|
118
96
|
capabilities['appium:app'] = process.env.BROWSERSTACK_APP_PATH;
|
|
119
|
-
|
|
120
97
|
// capabilities.app = process.env.BROWSERSTACK_APP_PATH;
|
|
121
98
|
const appValue = capabilities['appium:app'];
|
|
122
|
-
console.log("App Value
|
|
99
|
+
console.log("App Value=====>", appValue);
|
|
100
|
+
|
|
123
101
|
if (appValue === undefined || appValue === null || appValue === '') {
|
|
124
102
|
console.error("🚨 Error: BROWSERSTACK_APP_PATH is not defined or empty.");
|
|
125
103
|
resultdetails.excution_status = 'FAILED';
|
|
@@ -20,11 +20,13 @@ const resultdetails = {
|
|
|
20
20
|
// Load YAML file
|
|
21
21
|
//const capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
|
|
22
22
|
|
|
23
|
-
let
|
|
23
|
+
let rawCaps;
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
-
|
|
26
|
+
rawCaps = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
|
|
27
27
|
// Merge chrome-specific options if applicable
|
|
28
|
+
console.log("==== RAW YAML ====", rawCaps);
|
|
29
|
+
|
|
28
30
|
|
|
29
31
|
} catch (e) {
|
|
30
32
|
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`;
|
|
@@ -49,20 +51,16 @@ try {
|
|
|
49
51
|
}
|
|
50
52
|
process.exit(1);
|
|
51
53
|
}
|
|
52
|
-
console.log('====>capabilities:', capabilities);
|
|
53
54
|
|
|
55
|
+
console.log('====>capabilities:', rawCaps);
|
|
54
56
|
const SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
|
|
55
57
|
console.log('====>SUITE_FILE:', SUITE_FILE);
|
|
56
58
|
|
|
57
59
|
if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
|
|
58
60
|
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`;
|
|
59
|
-
|
|
60
61
|
console.error(errorMsg);
|
|
61
62
|
resultdetails.comments.push(errorMsg);
|
|
62
63
|
resultdetails.excution_status = 'FAIL';
|
|
63
|
-
|
|
64
|
-
// Fire API call in background (non-blocking)
|
|
65
|
-
|
|
66
64
|
try {
|
|
67
65
|
exeDetails.updateExecuitonDetails(
|
|
68
66
|
process.env.ORGANISATION_DOMAIN_URL,
|
|
@@ -72,7 +70,6 @@ if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
|
|
|
72
70
|
);
|
|
73
71
|
setTimeout(() => {
|
|
74
72
|
console.log("30 seconds passed.");
|
|
75
|
-
// You can call your API or exit the process here
|
|
76
73
|
}, 30000);
|
|
77
74
|
console.log('Execution details updated successfully.');
|
|
78
75
|
} catch (err) {
|
|
@@ -81,86 +78,88 @@ if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
|
|
|
81
78
|
process.exit(1);
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
function setupPrerequisites() {
|
|
85
|
-
console.log("
|
|
81
|
+
function setupPrerequisites(rawCaps) {
|
|
82
|
+
console.log("==== Running setupPrerequisites() ====");
|
|
86
83
|
if (PLATFORM === 'browserstack') {
|
|
87
|
-
process.env.BROWSERSTACK_USERNAME =
|
|
88
|
-
|
|
89
|
-
process.env.BROWSERSTACK_ACCESS_KEY =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (isMobile) {
|
|
99
|
-
process.env.BS_SESSION_TYPE = "app-automate";
|
|
100
|
-
} else {
|
|
101
|
-
process.env.BS_SESSION_TYPE = "automate";
|
|
102
|
-
}
|
|
103
|
-
// process.env.BS_SESSION_TYPE = capabilities.platformName === 'android' || capabilities.platformName === 'ios' ? 'app-automate' : 'automate';
|
|
104
|
-
capabilities.buildName = process.env.FROTH_TESTOPS_BUILD_NAME;
|
|
84
|
+
process.env.BROWSERSTACK_USERNAME = rawCaps.userName;
|
|
85
|
+
rawCaps.accessKey = Buffer.from(rawCaps.accessKey, 'base64').toString('utf-8');
|
|
86
|
+
process.env.BROWSERSTACK_ACCESS_KEY = rawCaps.accessKey
|
|
87
|
+
|
|
88
|
+
console.log('capabilities.platformName:', rawCaps.platformName ?? 'web');
|
|
89
|
+
const isMobile = rawCaps.platformName === "android" || rawCaps.platformName === "ios";
|
|
90
|
+
process.env.BS_SESSION_TYPE = isMobile ? 'app-automate' : 'automate';
|
|
91
|
+
|
|
92
|
+
rawCaps.buildName = process.env.FROTH_TESTOPS_BUILD_NAME;
|
|
93
|
+
console.log("SessionType=====>:", process.env.BS_SESSION_TYPE);
|
|
105
94
|
|
|
106
95
|
}
|
|
107
96
|
|
|
108
97
|
}
|
|
109
98
|
|
|
110
|
-
setupPrerequisites();
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
99
|
+
setupPrerequisites(rawCaps);
|
|
100
|
+
// ---------------------------------------------
|
|
101
|
+
// NORMALIZER — WEB + MOBILE (AUTODETECTION)
|
|
102
|
+
// ---------------------------------------------
|
|
103
|
+
function normalizeCapabilities(raw) {
|
|
104
|
+
const isMobile =
|
|
105
|
+
raw.platformName === "android" || raw.platformName === "ios";
|
|
106
|
+
const isWeb = !!raw.browserName;
|
|
107
|
+
|
|
108
|
+
// --------------------------
|
|
109
|
+
// 1. MOBILE – App Automate
|
|
110
|
+
// --------------------------
|
|
111
|
+
if (isMobile) {
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
platformName: raw.platformName,
|
|
115
|
+
"appium:platformVersion": raw.platformVersion,
|
|
116
|
+
"appium:deviceName": raw.deviceName,
|
|
117
|
+
"appium:deviceOrientation": raw.deviceOrientation,
|
|
118
|
+
"bstack:options": {
|
|
119
|
+
userName: raw.userName,
|
|
120
|
+
accessKey: Buffer.from(raw.accessKey, "base64").toString("utf8"),
|
|
121
|
+
debug: raw.debug,
|
|
122
|
+
networkLogs: raw.networkLogs,
|
|
123
|
+
interactiveDebugging: raw.interactiveDebugging,
|
|
124
|
+
// appProfiling: raw.appProfiling,
|
|
125
|
+
buildIdentifier: raw.buildIdentifier,
|
|
126
|
+
sessionType: "app",
|
|
127
|
+
appiumVersion: "2.0",
|
|
128
|
+
projectName: process.env.BS_PROJECT_NAME || "Automation",
|
|
129
|
+
buildName: process.env.FROTH_TESTOPS_BUILD_NAME || "Mobile Build",
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (isWeb) {
|
|
134
|
+
|
|
135
|
+
// --------------------------
|
|
136
|
+
// 2. WEB – Browser Automate
|
|
137
|
+
// --------------------------
|
|
137
138
|
|
|
138
|
-
// ----------------------------------
|
|
139
|
-
// BrowserStack APP-Automate (Mobile)
|
|
140
|
-
// ----------------------------------
|
|
141
139
|
return {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// userName: rawCaps.userName,
|
|
155
|
-
// accessKey: process.env.BROWSERSTACK_ACCESS_KEY
|
|
140
|
+
browserName: raw.browserName,
|
|
141
|
+
browserVersion: raw.browserVersion || "latest",
|
|
142
|
+
"bstack:options": {
|
|
143
|
+
os: raw.os || "Windows",
|
|
144
|
+
osVersion: raw.osVersion || "11",
|
|
145
|
+
userName: raw.userName,
|
|
146
|
+
accessKey: Buffer.from(raw.accessKey, "base64").toString("utf8"),
|
|
147
|
+
debug: raw.debug !== false,
|
|
148
|
+
networkLogs: raw.networkLogs !== false,
|
|
149
|
+
sessionType: "automate",
|
|
150
|
+
projectName: process.env.BS_PROJECT_NAME || "Automation",
|
|
151
|
+
buildName: process.env.FROTH_TESTOPS_BUILD_NAME || "Web Build",
|
|
156
152
|
}
|
|
157
153
|
};
|
|
158
154
|
}
|
|
159
|
-
return rawCaps;
|
|
160
155
|
|
|
156
|
+
throw new Error("❌ YAML does not look like web or mobile capability");
|
|
161
157
|
}
|
|
162
|
-
const
|
|
163
|
-
|
|
158
|
+
const finalCaps =
|
|
159
|
+
PLATFORM === "browserstack" ? normalizeCapabilities(rawCaps) : rawCaps;
|
|
160
|
+
|
|
161
|
+
console.log("==== FINAL CAPS SENT TO BROWSERSTACK ====");
|
|
162
|
+
console.log(JSON.stringify(finalCaps, null, 2));
|
|
164
163
|
|
|
165
164
|
exports.config = deepmerge(commonconfig,
|
|
166
165
|
|
|
@@ -170,7 +169,7 @@ exports.config = deepmerge(commonconfig,
|
|
|
170
169
|
// debug: true,
|
|
171
170
|
// execArgv: ['--inspect-brk'],
|
|
172
171
|
services: PLATFORM === 'browserstack'
|
|
173
|
-
? ['browserstack', { browserstackLocal: false }]
|
|
172
|
+
? [['browserstack', { browserstackLocal: false }]]
|
|
174
173
|
: PLATFORM === 'saucelabs'
|
|
175
174
|
? ['sauce']
|
|
176
175
|
: [],
|
|
@@ -179,7 +178,7 @@ exports.config = deepmerge(commonconfig,
|
|
|
179
178
|
specs: require(SUITE_FILE).tests,
|
|
180
179
|
|
|
181
180
|
maxInstances: 1,
|
|
182
|
-
capabilities: [
|
|
181
|
+
capabilities: [finalCaps],
|
|
183
182
|
|
|
184
183
|
logLevel: 'info',
|
|
185
184
|
coloredLogs: true,
|