froth-webdriverio-framework 7.0.59 → 7.0.61
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.
- package/froth_configs/commonhook.js +36 -40
- package/package.json +1 -1
|
@@ -158,46 +158,7 @@ const commonHooks = {
|
|
|
158
158
|
}
|
|
159
159
|
/** 2️⃣ BrowserStack capability normalization */
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
const bsOpts = capabilities['bstack:options'] || {};
|
|
163
|
-
|
|
164
|
-
console.log('✅ BS_USERNAME set from capabilities:', process.env.BROWSERSTACK_USERNAME);
|
|
165
|
-
|
|
166
|
-
if (process.env.BS_SESSION_TYPE === 'app-automate') {
|
|
167
|
-
const appPath = process.env.BROWSERSTACK_APP_PATH;
|
|
168
|
-
if (!appPath) {
|
|
169
|
-
await failExecution('BROWSERSTACK_APP_PATH is missing');
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
bsOpts.app = appPath;
|
|
173
|
-
capabilities['appium:app'] = appPath;
|
|
174
|
-
console.log('✅ App & media set in before session');
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
/** Media upload */
|
|
178
|
-
|
|
179
|
-
if (process.env.MEDIA_FILES) {
|
|
180
|
-
try {
|
|
181
|
-
console.log("env details for media -->" + process.env.MEDIA_FILES)
|
|
182
|
-
const media = JSON.parse(process.env.MEDIA_FILES).join(',');
|
|
183
|
-
process.env.BS_UPLOAD_MEDIA= media;
|
|
184
|
-
console.log("after comma separted "+ process.env.BS_UPLOAD_MEDIA)
|
|
185
|
-
// console.log('Total items:', media.length);
|
|
186
|
-
if (process.env.BS_UPLOAD_MEDIA) {
|
|
187
|
-
bsOpts.uploadMedia = process.env.BS_UPLOAD_MEDIA
|
|
188
|
-
.split(',')
|
|
189
|
-
.map(x => x.trim())
|
|
190
|
-
|
|
191
|
-
console.log('Final capabilities:', JSON.stringify(capabilities, null, 2));
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
} catch (error) {
|
|
195
|
-
console.warn('⚠️ MEDIA_FILES is not valid JSON', error.message);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
capabilities['bstack:options'] = bsOpts;
|
|
199
|
-
|
|
200
|
-
}
|
|
161
|
+
capabilities = getBrowserStackCapabilities(capabilities);
|
|
201
162
|
console.log('final cinfig dteials :' + JSON.stringify(capabilities))
|
|
202
163
|
|
|
203
164
|
// console.log("config details " + JSON.stringify(config))
|
|
@@ -373,6 +334,41 @@ async function normalizeWdioError(error) {
|
|
|
373
334
|
|
|
374
335
|
return `Automation framework error: ${msg}`;
|
|
375
336
|
}
|
|
337
|
+
async function getBrowserStackCapabilities(baseCaps) {
|
|
338
|
+
if (
|
|
339
|
+
process.env.PLATFORM !== 'browserstack' &&
|
|
340
|
+
process.env.PLATFORM !== 'browserstacklocal'
|
|
341
|
+
) {
|
|
342
|
+
return baseCaps;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Ensure we work with array
|
|
346
|
+
const capsArray = Array.isArray(baseCaps) ? baseCaps : [baseCaps];
|
|
376
347
|
|
|
348
|
+
const updatedCaps = capsArray.map((capabilities) => {
|
|
349
|
+
const bsOpts = capabilities['bstack:options'] || {};
|
|
350
|
+
|
|
351
|
+
// Optional: debug
|
|
352
|
+
bsOpts.debug = process.env.BS_DEBUG === 'true';
|
|
353
|
+
|
|
354
|
+
// Handle uploadMedia
|
|
355
|
+
if (process.env.MEDIA_FILES) {
|
|
356
|
+
try {
|
|
357
|
+
const media = JSON.parse(process.env.MEDIA_FILES).map(x => x.trim());
|
|
358
|
+
if (media.length) {
|
|
359
|
+
bsOpts.uploadMedia = media;
|
|
360
|
+
}
|
|
361
|
+
} catch (e) {
|
|
362
|
+
console.warn('Invalid MEDIA_FILES JSON:', process.env.MEDIA_FILES);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
capabilities['bstack:options'] = bsOpts;
|
|
367
|
+
return capabilities;
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// Return same type as input: array or single object
|
|
371
|
+
return Array.isArray(baseCaps) ? updatedCaps : updatedCaps[0];
|
|
372
|
+
}
|
|
377
373
|
|
|
378
374
|
module.exports = commonHooks;
|