froth-webdriverio-framework 0.1.57 → 0.1.59
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/api/browsersatckSessionInfo.js +18 -6
- package/config/commonconfig.js +14 -10
- package/package.json +1 -1
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
|
|
2
|
-
async function getBSSessionDetails(
|
|
3
|
-
|
|
2
|
+
async function getBSSessionDetails(sessiontype,bs_username,bs_pwd) {
|
|
3
|
+
// const sessionId = sessionIdd;
|
|
4
4
|
const username = bs_username;
|
|
5
5
|
const accessKey = bs_pwd;
|
|
6
6
|
|
|
7
7
|
const basicAuth = btoa(`${username}:${accessKey}`);
|
|
8
|
-
const url = `https://api.browserstack.com/${sessiontype}/sessions/${sessionId}.json`;
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
try {
|
|
12
|
-
|
|
11
|
+
const sessionId = browser.sessionId;
|
|
12
|
+
console.log(`Session ID: ${sessionId}`);
|
|
13
|
+
|
|
14
|
+
// const sessionInfo = await browser.execute(() => {
|
|
15
|
+
// return window._browserstack_executor({
|
|
16
|
+
// action: 'getSessionDetails'
|
|
17
|
+
// });
|
|
18
|
+
// });
|
|
19
|
+
|
|
20
|
+
// console.log('BrowserStack session info:', sessionInfo);
|
|
21
|
+
|
|
22
|
+
const url = `https://api.browserstack.com/${sessiontype}/sessions/${sessionId}.json`;
|
|
23
|
+
|
|
13
24
|
const response = await fetch(url, {
|
|
14
25
|
method: 'GET',
|
|
15
26
|
headers: {
|
|
@@ -19,7 +30,7 @@ async function getBSSessionDetails(sessionIdd,sessiontype,bs_username,bs_pwd) {
|
|
|
19
30
|
|
|
20
31
|
if (response.ok) {
|
|
21
32
|
const data = await response.json();
|
|
22
|
-
|
|
33
|
+
console.log('Session Info:', data);
|
|
23
34
|
// const details = JSON.parse(data);
|
|
24
35
|
|
|
25
36
|
// Accessing the public_url property
|
|
@@ -27,7 +38,8 @@ async function getBSSessionDetails(sessionIdd,sessiontype,bs_username,bs_pwd) {
|
|
|
27
38
|
|
|
28
39
|
console.log("public url : " + publicUrl);
|
|
29
40
|
// return jsondata;
|
|
30
|
-
} else if (response.status === 401) { //
|
|
41
|
+
} else if (response.status === 401) { //
|
|
42
|
+
console.log("Unauthorized, token expired")
|
|
31
43
|
// Call login function to obtain a new token
|
|
32
44
|
// const newToken = await getLoginToken(localStorage.getItem("SERVICE_USER"), localStorage.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
33
45
|
// Retry the request with the new token
|
package/config/commonconfig.js
CHANGED
|
@@ -4,20 +4,22 @@ const getLoginToken = require("../api/loginapi");
|
|
|
4
4
|
const getSuiteDetails = require("../api/getsuiteDetails");
|
|
5
5
|
const { LocalStorage } = require('node-localstorage');
|
|
6
6
|
global.localStorage = new LocalStorage('./storage');
|
|
7
|
-
|
|
7
|
+
const getBSSessionDetails = require("../api/browsersatckSessionInfo")
|
|
8
8
|
// Description: This file contains the common configuration for the webdriverio framework.
|
|
9
9
|
const commonconfig = {
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
onPrepare: async function (capabilities, specs) {
|
|
13
|
-
localStorage.setItem("TOTAL_DURATION",0);
|
|
13
|
+
localStorage.setItem("TOTAL_DURATION", 0);
|
|
14
14
|
// This code runs before the test suite starts
|
|
15
15
|
// console.log("organisation url" + process.env.organisation_url);
|
|
16
16
|
// console.log("test data id" + process.env.testdata_id);
|
|
17
|
-
localStorage.setItem("EXECUTION_ID", process.env.EXECUTION_ID)
|
|
18
|
-
localStorage.setItem("organisation_url", process.env.organisation_url)
|
|
19
|
-
localStorage.setItem("SERVICE_USER", "subhra.subudhi@roboticodigital.com")
|
|
20
|
-
localStorage.setItem("SERVICE_PASSWORD", "V2VsY29tZUAxMjM=")
|
|
17
|
+
localStorage.setItem("EXECUTION_ID", process.env.EXECUTION_ID);
|
|
18
|
+
localStorage.setItem("organisation_url", process.env.organisation_url);
|
|
19
|
+
localStorage.setItem("SERVICE_USER", "subhra.subudhi@roboticodigital.com");
|
|
20
|
+
localStorage.setItem("SERVICE_PASSWORD", "V2VsY29tZUAxMjM=");
|
|
21
|
+
localStorage.setItem("BROWSERSTACK_USERNAME", process.env.BROWSERSTACK_USERNAME);
|
|
22
|
+
localStorage.setItem("BROWSERSTACK_ACCESS_KEY", process.env.BROWSERSTACK_ACCESS_KEY);
|
|
21
23
|
|
|
22
24
|
const getToken = await getLoginToken(localStorage.getItem("organisation_url"), localStorage.getItem("SERVICE_USER"), localStorage.getItem("SERVICE_PASSWORD"));
|
|
23
25
|
process.env.LOGIN_TOKEN = getToken;
|
|
@@ -26,9 +28,8 @@ const commonconfig = {
|
|
|
26
28
|
const getExeDetails = await exeDetails.getExecuitonDetails(localStorage.getItem("organisation_url"), getToken, localStorage.getItem("EXECUTION_ID"));
|
|
27
29
|
if (getExeDetails.automation_suite_id != null) {
|
|
28
30
|
const getSuiteDetail = await getSuiteDetails(localStorage.getItem("organisation_url"), getToken, getExeDetails.automation_suite_id);
|
|
29
|
-
if (getSuiteDetail.test_data_id != null)
|
|
30
|
-
|
|
31
|
-
const jsonobject = await getDataById(localStorage.getItem("organisation_url"),getToken, getSuiteDetail.test_data_id);
|
|
31
|
+
if (getSuiteDetail.test_data_id != null) {
|
|
32
|
+
const jsonobject = await getDataById(localStorage.getItem("organisation_url"), getToken, getSuiteDetail.test_data_id);
|
|
32
33
|
if (jsonobject == null) {
|
|
33
34
|
console.log("Test data is not available");
|
|
34
35
|
}
|
|
@@ -56,6 +57,9 @@ const commonconfig = {
|
|
|
56
57
|
console.log("Running suite:", suite.title);
|
|
57
58
|
console.log("Reading test data from the API");
|
|
58
59
|
|
|
60
|
+
getBSSessionDetails("app-automate", localStorage.getItem("BROWSERSTACK_USERNAME"),
|
|
61
|
+
localStorage.getItem("BROWSERSTACK_ACCESS_KEY"));
|
|
62
|
+
|
|
59
63
|
} catch (e) {
|
|
60
64
|
console.log("Error in beforeSuite:", e);
|
|
61
65
|
}
|
|
@@ -90,7 +94,7 @@ const commonconfig = {
|
|
|
90
94
|
*/
|
|
91
95
|
afterTest: function (test, context, { error, result, duration, passed, retries }) {
|
|
92
96
|
console.log(`Test '${test.title}' finished.`);
|
|
93
|
-
localStorage.setItem("TOTAL_DURATION",Number(localStorage.getItem("TOTAL_DURATION"))+duration)
|
|
97
|
+
localStorage.setItem("TOTAL_DURATION", Number(localStorage.getItem("TOTAL_DURATION")) + duration)
|
|
94
98
|
console.log(`Duration: ${duration}ms`);
|
|
95
99
|
console.log(`Passed: ${passed}`);
|
|
96
100
|
if (passed)
|