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