Skip to content

Commit dc8eff4

Browse files
authored
Merge pull request #83 from Shahnawaz-Sk/master
changes for logging session URL
2 parents e832241 + d40e247 commit dc8eff4

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wdio-lambdatest-service",
3-
"version": "2.1.3",
3+
"version": "3.0.0",
44
"description": "A WebdriverIO service that manages tunnel and job metadata for LambdaTest.",
55
"author": "LambdaTest <[email protected]>",
66
"contributors": [

src/constants.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ declare module 'constants' {
1515

1616
export const TUNNEL_STOP_FAILED: string;
1717
export const TUNNEL_START_FAILED: string;
18+
export const appSessionURL: string;
19+
export const webSessionURL: string;
1820
}
1921

src/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ module.exports = {
55
baseUrlApp: "https://mobile-api.lambdatest.com/mobile-automation/api/",
66
TUNNEL_STOP_FAILED: "LambdaTest Tunnel failed to stop within 60 seconds!",
77
TUNNEL_START_FAILED :"LambdaTest Tunnel failed to start within 60 seconds!",
8-
TUNNEL_STOP_TIMEOUT:60000
8+
TUNNEL_STOP_TIMEOUT:60000,
9+
appSessionURL: "https://appautomation.lambdatest.com/test?testID",
10+
webSessionURL: "https://automation.lambdatest.com/test?testID"
911
};

src/service.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ export default class LambdaRestService implements Services.ServiceInstance {
6161
setSessionName(suiteTitle: string, test: Frameworks.Test): Promise<void>;
6262
_setSessionName(sessionName: string): Promise<void>;
6363
_executeCommand(cmd: string): Promise<void>;
64+
getSessionURL(sessionId: string, product: string): string;
6465
}

src/service.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logger from '@wdio/logger'
22

33
import { getParentSuiteName, updateSessionById } from './util.js'
4+
import { appSessionURL, webSessionURL } from './constants.js';
45

56
const log = logger('@wdio/lambdatest-service')
67

@@ -241,11 +242,25 @@ export default class LambdaRestService {
241242

242243
if (!this._browser.isMultiremote) {
243244
log.info(`Update job with sessionId ${this._browser.sessionId}, ${status}`);
245+
246+
// Print session URL for single remote browser
247+
if(process.env.LOG_SESSION_URL === "true") {
248+
const sessionURL = this.getSessionURL(this._browser.sessionId, this._config.product);
249+
log.info(`Session URL: ${sessionURL}`);
250+
}
251+
244252
return this._update({ sessionId: this._browser.sessionId, failures: result });
245253
}
246254

247255
return Promise.all(Object.keys(this._capabilities).map(browserName => {
248256
log.info(`Update multiremote job for browser '${browserName}' and sessionId ${this._browser[browserName].sessionId}, ${status}`);
257+
258+
// Print session URL for each remote browser
259+
if(process.env.LOG_SESSION_URL === "true") {
260+
const sessionURL = this.getSessionURL(this._browser[browserName].sessionId, this._config.product);
261+
log.info(`Session URL for ${browserName}: ${sessionURL}`);
262+
}
263+
249264
return this._update({ sessionId: this._browser[browserName].sessionId, failures: failures, calledOnReload: false, browserName: browserName });
250265
}));
251266
}
@@ -260,11 +275,24 @@ export default class LambdaRestService {
260275
if (!this._browser.isMultiremote) {
261276
log.info(`Update (reloaded) job with sessionId ${oldSessionId}, ${status}`);
262277

278+
// Print session URL for single remote browser
279+
if(process.env.LOG_SESSION_URL === "true") {
280+
const sessionURL = this.getSessionURL(this._browser.sessionId, this._config.product);
281+
log.info(`Session URL: ${sessionURL}`);
282+
}
283+
263284
await this._update({ sessionId: oldSessionId, fullTitle: this._currentTestTitle, status: status, calledOnReload: true });
264285

265286
} else {
266287
const browserName = this._browser.instances.filter(browserName => this._browser[browserName].sessionId === newSessionId)[0];
267288
log.info(`Update (reloaded) multiremote job for browser '${browserName}' and sessionId ${oldSessionId}, ${status}`);
289+
290+
// Print session URL for each remote browser
291+
if(process.env.LOG_SESSION_URL === "true") {
292+
const sessionURL = this.getSessionURL(this._browser[browserName].sessionId, this._config.product);
293+
log.info(`Session URL for ${browserName}: ${sessionURL}`);
294+
}
295+
268296
await this._update({ sessionId : oldSessionId, failures:this._failures, calledOnReload: true, browserName: browserName });
269297
}
270298

@@ -393,4 +421,11 @@ export default class LambdaRestService {
393421
}
394422
return await this._browser.execute(cmd);
395423
}
424+
425+
getSessionURL(sessionId, product) {
426+
if (product === 'appAutomation') {
427+
return `${appSessionURL}=${sessionId}`;
428+
}
429+
return `${webSessionURL}=${sessionId}`;
430+
}
396431
}

0 commit comments

Comments
 (0)