froth-webdriverio-framework 6.0.17 → 6.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.
|
@@ -40,11 +40,9 @@ const commonconfig = {
|
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
beforeSession: async function (config, capabilities, specs) {
|
|
44
44
|
try {
|
|
45
45
|
let syntaxFailed = false;
|
|
46
|
-
console.log("DEBUG: bstack:options →", capabilities['bstack:options']);
|
|
47
|
-
delete capabilities['bstack:options'].browserstackLocal; // ensure false
|
|
48
46
|
|
|
49
47
|
console.log('==== BEFORE SESSION HOOK ====');
|
|
50
48
|
// Perform any setup or pre-test actions here
|
|
@@ -80,32 +78,18 @@ const commonconfig = {
|
|
|
80
78
|
// set the capability like media and app and bs local
|
|
81
79
|
if (process.env.PLATFORM === 'browserstack') {
|
|
82
80
|
/// console.log("capabilities:", capabilities);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// const isLocalEnabled = process.env.BROWSERSTACK_LOCAL === "true";
|
|
86
|
-
// console.log("isLocalEnabled:", isLocalEnabled);
|
|
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
|
-
// }
|
|
93
|
-
|
|
81
|
+
capabilities.browserstackLocal = process.env.BROWSERSTACK_LOCAL;
|
|
94
82
|
// capabilities.accessKey = Buffer.from(capabilities.accessKey, 'base64').toString('utf-8');
|
|
95
83
|
if (capabilities.platformName === 'android' || capabilities.platformName === 'ios') {
|
|
96
|
-
capabilities
|
|
97
|
-
|
|
98
|
-
const appValue = capabilities['appium:app'];
|
|
99
|
-
console.log("App Value=====>", appValue);
|
|
100
|
-
|
|
101
|
-
if (appValue === undefined || appValue === null || appValue === '') {
|
|
84
|
+
capabilities.app = process.env.BROWSERSTACK_APP_PATH;
|
|
85
|
+
if (capabilities.app === undefined || capabilities.app === null || capabilities.app === '') {
|
|
102
86
|
console.error("🚨 Error: BROWSERSTACK_APP_PATH is not defined or empty.");
|
|
103
87
|
resultdetails.excution_status = 'FAILED';
|
|
104
88
|
resultdetails.comments.push("BROWSERSTACK_APP_PATH is not defined or empty.");
|
|
105
89
|
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails);
|
|
106
90
|
process.exit(1); // Stop execution if app path is not set
|
|
107
91
|
} else {
|
|
108
|
-
console.log("App Path:", capabilities
|
|
92
|
+
console.log("App Path:", capabilities.app);
|
|
109
93
|
console.log("Browserstack Local:", capabilities.browserstackLocal);
|
|
110
94
|
}
|
|
111
95
|
}
|
|
@@ -122,10 +106,6 @@ const commonconfig = {
|
|
|
122
106
|
console.error("Error parsing MEDIA_FILES:", error);
|
|
123
107
|
}
|
|
124
108
|
|
|
125
|
-
// Normalized structure to support future SauceLabs
|
|
126
|
-
// if (!capabilities['bstack:options']) {
|
|
127
|
-
// capabilities['bstack:options'] = {};
|
|
128
|
-
// }
|
|
129
109
|
console.log(`Running tests on after app,bslocal,mediafiles: ${JSON.stringify(capabilities)}`);
|
|
130
110
|
}
|
|
131
111
|
|
|
@@ -345,7 +325,7 @@ const commonconfig = {
|
|
|
345
325
|
|
|
346
326
|
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
|
|
347
327
|
|
|
348
|
-
|
|
328
|
+
|
|
349
329
|
// Perform any cleanup or post-test actions here
|
|
350
330
|
BUFFER.clear();
|
|
351
331
|
},
|
|
@@ -4,7 +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
|
+
process.env.BROWSERSTACK_APP_PATH="bs://30fdf3a163d0bad126f64a3d5713e9ab0086a41e"
|
|
8
8
|
// Select platform at runtime
|
|
9
9
|
const PLATFORM = process.env.PLATFORM || 'browserstack';
|
|
10
10
|
console.log('====>PLATFORM:', PLATFORM);
|
|
@@ -20,14 +20,12 @@ 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 capabilities;
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
-
|
|
26
|
+
capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
|
|
27
27
|
// Merge chrome-specific options if applicable
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
|
|
31
29
|
} catch (e) {
|
|
32
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`;
|
|
33
31
|
console.error(errorMsg);
|
|
@@ -51,16 +49,20 @@ try {
|
|
|
51
49
|
}
|
|
52
50
|
process.exit(1);
|
|
53
51
|
}
|
|
52
|
+
console.log('====>capabilities:', capabilities);
|
|
54
53
|
|
|
55
|
-
console.log('====>capabilities:', rawCaps);
|
|
56
54
|
const SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
|
|
57
55
|
console.log('====>SUITE_FILE:', SUITE_FILE);
|
|
58
56
|
|
|
59
57
|
if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
|
|
60
58
|
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
|
+
|
|
61
60
|
console.error(errorMsg);
|
|
62
61
|
resultdetails.comments.push(errorMsg);
|
|
63
62
|
resultdetails.excution_status = 'FAIL';
|
|
63
|
+
|
|
64
|
+
// Fire API call in background (non-blocking)
|
|
65
|
+
|
|
64
66
|
try {
|
|
65
67
|
exeDetails.updateExecuitonDetails(
|
|
66
68
|
process.env.ORGANISATION_DOMAIN_URL,
|
|
@@ -70,6 +72,7 @@ if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
|
|
|
70
72
|
);
|
|
71
73
|
setTimeout(() => {
|
|
72
74
|
console.log("30 seconds passed.");
|
|
75
|
+
// You can call your API or exit the process here
|
|
73
76
|
}, 30000);
|
|
74
77
|
console.log('Execution details updated successfully.');
|
|
75
78
|
} catch (err) {
|
|
@@ -78,88 +81,23 @@ if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
|
|
|
78
81
|
process.exit(1);
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
function setupPrerequisites(
|
|
82
|
-
console.log("
|
|
84
|
+
function setupPrerequisites() {
|
|
85
|
+
console.log("inside this fuction first ");
|
|
83
86
|
if (PLATFORM === 'browserstack') {
|
|
84
|
-
process.env.BROWSERSTACK_USERNAME =
|
|
85
|
-
|
|
86
|
-
process.env.BROWSERSTACK_ACCESS_KEY =
|
|
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';
|
|
87
|
+
process.env.BROWSERSTACK_USERNAME = capabilities.userName;
|
|
88
|
+
capabilities.accessKey = Buffer.from(capabilities.accessKey, 'base64').toString('utf-8');
|
|
89
|
+
process.env.BROWSERSTACK_ACCESS_KEY = capabilities.accessKey
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
console.log('capabilities.platformName:', capabilities.platformName ?? 'web');
|
|
92
|
+
process.env.BS_SESSION_TYPE = capabilities.platformName === 'android' || capabilities.platformName === 'ios' ? 'app-automate' : 'automate';
|
|
93
|
+
capabilities.buildName = process.env.FROTH_TESTOPS_BUILD_NAME;
|
|
94
94
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
setupPrerequisites(
|
|
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
|
-
buildIdentifier: raw.buildIdentifier,
|
|
125
|
-
// appiumVersion: "2.0",
|
|
126
|
-
projectName: process.env.BS_PROJECT_NAME || "Automation",
|
|
127
|
-
buildName: process.env.FROTH_TESTOPS_BUILD_NAME || "Mobile Build",
|
|
128
|
-
local: false
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
if (isWeb) {
|
|
133
|
-
|
|
134
|
-
// --------------------------
|
|
135
|
-
// 2. WEB – Browser Automate
|
|
136
|
-
// --------------------------
|
|
137
|
-
|
|
138
|
-
return {
|
|
139
|
-
browserName: raw.browserName,
|
|
140
|
-
browserVersion: raw.browserVersion || "latest",
|
|
141
|
-
"bstack:options": {
|
|
142
|
-
os: raw.os || "Windows",
|
|
143
|
-
osVersion: raw.osVersion || "11",
|
|
144
|
-
userName: raw.userName,
|
|
145
|
-
accessKey: Buffer.from(raw.accessKey, "base64").toString("utf8"),
|
|
146
|
-
debug: raw.debug !== false,
|
|
147
|
-
networkLogs: raw.networkLogs !== false,
|
|
148
|
-
// sessionType: "automate",
|
|
149
|
-
projectName: process.env.BS_PROJECT_NAME || "Automation",
|
|
150
|
-
buildName: process.env.FROTH_TESTOPS_BUILD_NAME || "Web Build",
|
|
151
|
-
local: false
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
throw new Error("❌ YAML does not look like web or mobile capability");
|
|
157
|
-
}
|
|
158
|
-
const finalCaps =
|
|
159
|
-
PLATFORM === "browserstack" ? normalizeCapabilities(rawCaps) : rawCaps;
|
|
99
|
+
const specificConfig = setupPrerequisites();
|
|
160
100
|
|
|
161
|
-
console.log("==== FINAL CAPS SENT TO BROWSERSTACK ====");
|
|
162
|
-
console.log(JSON.stringify(finalCaps, null, 2));
|
|
163
101
|
|
|
164
102
|
exports.config = deepmerge(commonconfig,
|
|
165
103
|
|
|
@@ -169,13 +107,7 @@ exports.config = deepmerge(commonconfig,
|
|
|
169
107
|
// debug: true,
|
|
170
108
|
// execArgv: ['--inspect-brk'],
|
|
171
109
|
services: PLATFORM === 'browserstack'
|
|
172
|
-
? [
|
|
173
|
-
['browserstack', {
|
|
174
|
-
browserstackLocal: false, // Prevent starting Local binary
|
|
175
|
-
opts: { forcelocal: false } // Ensure no fallback Local is triggered
|
|
176
|
-
// forcedStop: true // Kill any accidental extra process
|
|
177
|
-
}]
|
|
178
|
-
]
|
|
110
|
+
? ['browserstack']
|
|
179
111
|
: PLATFORM === 'saucelabs'
|
|
180
112
|
? ['sauce']
|
|
181
113
|
: [],
|
|
@@ -184,7 +116,7 @@ exports.config = deepmerge(commonconfig,
|
|
|
184
116
|
specs: require(SUITE_FILE).tests,
|
|
185
117
|
|
|
186
118
|
maxInstances: 1,
|
|
187
|
-
capabilities: [
|
|
119
|
+
capabilities: [capabilities],
|
|
188
120
|
|
|
189
121
|
logLevel: 'info',
|
|
190
122
|
coloredLogs: true,
|