froth-webdriverio-framework 1.0.63 → 1.0.64
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.
|
@@ -1,65 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
async function getBSBuildDetails(sessiontype,bs_username,bs_pwd) {
|
|
2
|
+
async function getBSBuildDetails(sessiontype, bs_username, bs_pwd) {
|
|
3
3
|
// const sessionId = sessionIdd;
|
|
4
|
-
const username = bs_username;
|
|
5
|
-
const accessKey = bs_pwd;
|
|
6
|
-
|
|
7
|
-
const basicAuth = btoa(`${username}:${accessKey}`);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const sessionid= BUFFER.getItem("SESSION_ID");
|
|
12
|
-
|
|
13
|
-
const url = `https://api.browserstack.com/${sessiontype}/sessions/${sessionid}.json`;
|
|
14
|
-
|
|
15
|
-
const response = await fetch(url, {
|
|
16
|
-
method: 'GET',
|
|
17
|
-
headers: {
|
|
18
|
-
'Authorization': `Basic ${basicAuth}`
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (response.ok) {
|
|
23
|
-
const data = await response.json();
|
|
24
|
-
|
|
25
|
-
// Accessing the public_url property
|
|
26
|
-
const publicUrl = data.automation_session.public_url;
|
|
27
|
-
const duration=data.automation_session.duration;
|
|
28
|
-
BUFFER.setItem("REPORT_URL",publicUrl)
|
|
29
|
-
BUFFER.setItem("TOTAL_DURATION",duration)
|
|
30
|
-
|
|
31
|
-
//return jsondata;
|
|
32
|
-
} else if (response.status === 401) { //
|
|
33
|
-
console.log("Unauthorized, token expired")
|
|
34
|
-
|
|
35
|
-
} else {
|
|
36
|
-
const errorText = await response.text();
|
|
37
|
-
console.error(`Data fetch failed response:${response.status}`);
|
|
38
|
-
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error('Error fetching data:', error);
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function getBSSessionDetails(sessiontype,bs_username,bs_pwd) {
|
|
52
|
-
// const sessionId = sessionIdd;
|
|
53
4
|
const username = bs_username;
|
|
54
5
|
const accessKey = bs_pwd;
|
|
55
6
|
|
|
56
7
|
const basicAuth = btoa(`${username}:${accessKey}`);
|
|
57
8
|
|
|
58
|
-
|
|
9
|
+
let hashed_id = null;
|
|
59
10
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const url = `https://api.browserstack.com/${sessiontype}/
|
|
11
|
+
// const sessionid= BUFFER.getItem("SESSION_ID");
|
|
12
|
+
|
|
13
|
+
const url = `https://api.browserstack.com/${sessiontype}/builds.json?name=${process.env.BROWSERSTACK_BUILD_NAME}`;
|
|
63
14
|
|
|
64
15
|
const response = await fetch(url, {
|
|
65
16
|
method: 'GET',
|
|
@@ -70,21 +21,69 @@ async function getBSSessionDetails(sessiontype,bs_username,bs_pwd) {
|
|
|
70
21
|
|
|
71
22
|
if (response.ok) {
|
|
72
23
|
const data = await response.json();
|
|
73
|
-
|
|
24
|
+
|
|
25
|
+
// Accessing the public_url property
|
|
26
|
+
hashed_id = data.automation_build.hashed_id;
|
|
27
|
+
|
|
28
|
+
//return jsondata;
|
|
29
|
+
} else if (response.status === 401) { //
|
|
30
|
+
console.log("Unauthorized, token expired")
|
|
31
|
+
|
|
32
|
+
} else {
|
|
33
|
+
const errorText = await response.text();
|
|
34
|
+
console.error(`Data fetch failed response:${response.status}`);
|
|
35
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('Error fetching data:', error);
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function getBSSessionDetails(sessiontype, bs_username, bs_pwd) {
|
|
49
|
+
// const sessionId = sessionIdd;
|
|
50
|
+
const username = bs_username;
|
|
51
|
+
const accessKey = bs_pwd;
|
|
52
|
+
const basicAuth = btoa(`${username}:${accessKey}`);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
|
|
57
|
+
const hash_id=await getBSBuildDetails(sessiontype, bs_username, bs_pwd)
|
|
58
|
+
// const sessionid = BUFFER.getItem("SESSION_ID");
|
|
59
|
+
|
|
60
|
+
// const url = `https://api.browserstack.com/${sessiontype}/sessions/${sessionid}.json`;
|
|
61
|
+
const url = `https://api.browserstack.com/${sessiontype}/builds/${hash_id}/sessions.json`;
|
|
62
|
+
|
|
63
|
+
const response = await fetch(url, {
|
|
64
|
+
method: 'GET',
|
|
65
|
+
headers: {
|
|
66
|
+
'Authorization': `Basic ${basicAuth}`
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (response.ok) {
|
|
71
|
+
const data = await response.json();
|
|
72
|
+
|
|
74
73
|
// Accessing the public_url property
|
|
75
74
|
const publicUrl = data.automation_session.public_url;
|
|
76
|
-
const duration=data.automation_session.duration;
|
|
77
|
-
BUFFER.setItem("REPORT_URL",publicUrl)
|
|
78
|
-
BUFFER.setItem("TOTAL_DURATION",duration)
|
|
75
|
+
const duration = data.automation_session.duration;
|
|
76
|
+
BUFFER.setItem("REPORT_URL", publicUrl)
|
|
77
|
+
BUFFER.setItem("TOTAL_DURATION", duration)
|
|
79
78
|
|
|
80
79
|
//return jsondata;
|
|
81
80
|
} else if (response.status === 401) { //
|
|
82
81
|
console.log("Unauthorized, token expired")
|
|
83
|
-
|
|
82
|
+
|
|
84
83
|
} else {
|
|
85
84
|
const errorText = await response.text();
|
|
86
85
|
console.error(`Data fetch failed response:${response.status}`);
|
|
87
|
-
|
|
86
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
|
|
@@ -62,7 +62,7 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
62
62
|
console.log("resultdetails" + JSON.stringify(resultdetails))
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
if (resultdetails != null) {
|
|
65
|
+
if (resultdetails.excution_status != null) {
|
|
66
66
|
formData.append('excution_status', resultdetails.excution_status);
|
|
67
67
|
}
|
|
68
68
|
if (resultdetails.excution_time != null) {
|
|
@@ -91,7 +91,7 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
91
91
|
return updateExecuitonDetails(frothUrl, newToken, id, resultdetails);
|
|
92
92
|
} else {
|
|
93
93
|
const errorText = await response.text();
|
|
94
|
-
console.error(`
|
|
94
|
+
console.error(`error in updating the status into DB ${response.status}`);
|
|
95
95
|
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
96
96
|
}
|
|
97
97
|
|
package/config/commonconfig.js
CHANGED
|
@@ -30,10 +30,9 @@ const commonconfig = {
|
|
|
30
30
|
beforeSuite: async function (suite) {
|
|
31
31
|
try {
|
|
32
32
|
console.log("Running suite:", suite.title);
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// const sessionId = browser.sessionId;
|
|
34
|
+
// BUFFER.setItem("SESSION_ID", sessionId)
|
|
35
35
|
await getBSSessionDetails(process.env.BS_SESSION_TYPE, process.env.BROWSERSTACK_USERNAME, Buffer.from(process.env.BROWSERSTACK_ACCESS_KEY, 'base64').toString('utf-8'));
|
|
36
|
-
// console.log("ALL JSON DATA IN BUFFER:" + JSON.stringify(BUFFER));
|
|
37
36
|
const resultdetails = {};
|
|
38
37
|
exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), BUFFER.getItem("EXECUTION_ID"), resultdetails)
|
|
39
38
|
|
|
@@ -71,7 +70,7 @@ const commonconfig = {
|
|
|
71
70
|
*/
|
|
72
71
|
afterTest: function (test, context, { error, result, duration, passed, retries }) {
|
|
73
72
|
console.log(`Test '${test.title}' finished.`);
|
|
74
|
-
|
|
73
|
+
// BUFFER.setItem("TOTAL_DURATION", Number(BUFFER.getItem("TOTAL_DURATION")) + duration)
|
|
75
74
|
console.log(`Duration: ${duration}ms`);
|
|
76
75
|
console.log(`Passed: ${passed}`);
|
|
77
76
|
if (passed)
|
|
@@ -97,13 +96,11 @@ const commonconfig = {
|
|
|
97
96
|
*/
|
|
98
97
|
after: async function (result, capabilities, specs) {
|
|
99
98
|
console.log('All tests are done.');
|
|
100
|
-
//const resultdata = result === 0 ? 'Pass' : 'Fail';
|
|
101
|
-
//console.log(`Result: ${resultdata}`);
|
|
102
|
-
// const resultdata = result === 0 ? 'PASSED' : 'FAILED'
|
|
103
99
|
BUFFER.setItem("RESULT_DATA", result);
|
|
104
100
|
const resultdetails = {}
|
|
105
101
|
resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") === 0 ? 'PASSED' : 'FAILED'
|
|
106
102
|
console.log("Total Duration:" + BUFFER.getItem("TOTAL_DURATION"));
|
|
103
|
+
console.log("Results" + resultdetails.excution_status);
|
|
107
104
|
resultdetails.excution_time = await secondsToTime(BUFFER.getItem("TOTAL_DURATION"))
|
|
108
105
|
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), BUFFER.getItem("EXECUTION_ID"), resultdetails)
|
|
109
106
|
|