froth-webdriverio-framework 2.0.46 → 2.0.48
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/commonMethods/Utils.js +3 -0
- package/commonMethods/apicall.js +39 -8
- package/config/api.conf.js +4 -4
- package/config/commonconfig.js +16 -6
- package/package.json +1 -1
package/commonMethods/Utils.js
CHANGED
|
@@ -63,6 +63,8 @@ storevalue = require(basepath + '/storeToBuffer').STOREVALUE;
|
|
|
63
63
|
storeattributevalue = require(basepath + '/storeToBuffer').STOREATTRIBUTEVALUE;
|
|
64
64
|
|
|
65
65
|
api = require(basepath + '/apicall').callapi;
|
|
66
|
+
validate = require(basepath + '/apicall').validate;
|
|
67
|
+
|
|
66
68
|
selectDropDownValue = require(basepath + '/dropDown').selectDropDownValue;
|
|
67
69
|
|
|
68
70
|
|
|
@@ -90,5 +92,6 @@ module.exports = {
|
|
|
90
92
|
storeattributevalue,
|
|
91
93
|
scrollIntoView,
|
|
92
94
|
api,
|
|
95
|
+
validate,
|
|
93
96
|
selectDropDownValue
|
|
94
97
|
};
|
package/commonMethods/apicall.js
CHANGED
|
@@ -36,17 +36,48 @@ async function callapi(method, api_url, queryParams, payloaddetails, authenticat
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
// Function to form headers
|
|
39
|
-
async function formheaders(authentication, headers
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (authentication.auth_type
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
async function formheaders(authentication, headers) {
|
|
40
|
+
try {
|
|
41
|
+
// Add authentication headers based on the type
|
|
42
|
+
if (authentication && authentication.auth_type) {
|
|
43
|
+
if (authentication.auth_type?.toLowerCase() === 'bearer') {
|
|
44
|
+
console.log('Bearer token:', authentication.token);
|
|
45
|
+
headers.Authorization = `Bearer ` + authentication.token;
|
|
46
|
+
} else if (authentication.auth_type?.toLowerCase() === 'basic') {
|
|
47
|
+
headers.Authorization = `Basic ` + btoa(authentication.username + `:` + authentication.password);
|
|
48
|
+
}
|
|
46
49
|
}
|
|
50
|
+
console.log('Headers:', headers);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
|
|
53
|
+
console.error('Error in formheaders:', e);
|
|
47
54
|
}
|
|
48
55
|
return headers;
|
|
49
56
|
|
|
50
57
|
}
|
|
58
|
+
async function validate(attribute, actionname, buffer, value, datatype) {
|
|
59
|
+
try {
|
|
60
|
+
if (actionname.toLowerCase() == "verify") {
|
|
61
|
+
|
|
62
|
+
if (datatype.toLowerCase() == "integer") {
|
|
63
|
+
if (buffer)
|
|
64
|
+
expect(attribute).toBe(Number(BUFFER.getItem(value)));
|
|
65
|
+
else
|
|
66
|
+
expect(attribute).toBe(Number(value));
|
|
67
|
+
} else if (datatype.toLowerCase() == "string") {
|
|
68
|
+
if (buffer)
|
|
69
|
+
expect(attribute).toBe(BUFFER.getItem(value));
|
|
70
|
+
else
|
|
71
|
+
expect(attribute).toBe(value);
|
|
72
|
+
}
|
|
73
|
+
} else if (actionname.toLowerCase() == "setbuffer") {
|
|
74
|
+
BUFFER.setItem(value, attribute);
|
|
75
|
+
} else if (actionname.toLowerCase() == "getbuffer") {
|
|
76
|
+
return BUFFER.getItem(value);
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {
|
|
79
|
+
console.error(' Error in validate:', e);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
51
82
|
|
|
52
|
-
module.exports = { callapi };
|
|
83
|
+
module.exports = { callapi, validate };
|
package/config/api.conf.js
CHANGED
|
@@ -3,7 +3,7 @@ const commonmobileconfig = require('./common.mobile.conf');
|
|
|
3
3
|
process.env.BROWSERSTACK = false;
|
|
4
4
|
|
|
5
5
|
const apiconfig = deepmerge.all([commonmobileconfig, {
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
// ====================
|
|
8
8
|
// Capabilities
|
|
9
9
|
// ====================
|
|
@@ -12,8 +12,8 @@ const apiconfig = deepmerge.all([commonmobileconfig, {
|
|
|
12
12
|
browserName: 'chrome',
|
|
13
13
|
acceptInsecureCerts: true,
|
|
14
14
|
'goog:chromeOptions': {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage'],
|
|
16
|
+
},
|
|
17
17
|
}],
|
|
18
18
|
runner: 'local',
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ const apiconfig = deepmerge.all([commonmobileconfig, {
|
|
|
21
21
|
// browser.maximizeWindow()
|
|
22
22
|
//process.env.BS_SESSION_TYPE = "app-automate";
|
|
23
23
|
},
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
|
|
26
26
|
}]);
|
|
27
27
|
|
package/config/commonconfig.js
CHANGED
|
@@ -3,7 +3,8 @@ const { LocalStorage } = require('node-localstorage');
|
|
|
3
3
|
global.BUFFER = new LocalStorage('./storage');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const exeDetails = require("../api/getexecutionDetails")
|
|
6
|
-
const getBSSessionDetails = require("../api/browsersatckSessionInfo")
|
|
6
|
+
const getBSSessionDetails = require("../api/browsersatckSessionInfo");
|
|
7
|
+
const { time } = require("console");
|
|
7
8
|
const isBrowserStackEnabled = process.env.BROWSERSTACK;
|
|
8
9
|
let starttime;
|
|
9
10
|
let endtime;
|
|
@@ -14,7 +15,7 @@ const commonconfig = {
|
|
|
14
15
|
|
|
15
16
|
onPrepare: async function (capabilities, specs) {
|
|
16
17
|
// This code runs before the test suite starts
|
|
17
|
-
|
|
18
|
+
starttime = new Date().getTime();
|
|
18
19
|
await setAllDetails.setEnvVariables();
|
|
19
20
|
await setAllDetails.setLoginToken();
|
|
20
21
|
await setAllDetails.setExecutionDetails();
|
|
@@ -33,7 +34,6 @@ const commonconfig = {
|
|
|
33
34
|
beforeSuite: async function (suite) {
|
|
34
35
|
try {
|
|
35
36
|
console.log("Running suite:", suite.title);
|
|
36
|
-
starttime = new Date().getTime();
|
|
37
37
|
// const sessionId = browser.sessionId;
|
|
38
38
|
// BUFFER.setItem("SESSION_ID", sessionId)
|
|
39
39
|
if (isBrowserStackEnabled) {
|
|
@@ -128,7 +128,7 @@ const commonconfig = {
|
|
|
128
128
|
afterSession: async function (config, capabilities, specs) {
|
|
129
129
|
console.log('This is the aftersession hook');
|
|
130
130
|
// Perform any cleanup or post-test actions here
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
endtime = new Date().getTime();
|
|
133
133
|
let totalDuration = endtime - starttime;
|
|
134
134
|
console.log("Total Duration:" + totalDuration);
|
|
@@ -137,8 +137,8 @@ const commonconfig = {
|
|
|
137
137
|
|
|
138
138
|
const resultdetails = {}
|
|
139
139
|
resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
|
|
140
|
-
console.log("Total Duration:" + BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 ? totalDuration:BUFFER.getItem("FROTH_TOTAL_DURATION"));
|
|
141
|
-
resultdetails.excution_time =
|
|
140
|
+
console.log("Total Duration:" + BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 ? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION")));
|
|
141
|
+
resultdetails.excution_time = BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 ? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION"))
|
|
142
142
|
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
|
|
143
143
|
BUFFER.clear();
|
|
144
144
|
// Perform any cleanup or post-test actions here
|
|
@@ -159,4 +159,14 @@ async function secondsToTime(secs) {
|
|
|
159
159
|
return hours + ':' + minutes + ':' + seconds;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
async function convertTimetoHHMMSS(time) {
|
|
163
|
+
const seconds = Math.floor((time / 1000) % 60);
|
|
164
|
+
const minutes = Math.floor((time / (1000 * 60)) % 60);
|
|
165
|
+
const hours = Math.floor((time / (1000 * 60 * 60)) % 24);
|
|
166
|
+
const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
|
167
|
+
|
|
168
|
+
console.log("Time:" + hours + ':' + minutes + ':' + seconds);
|
|
169
|
+
return formattedTime;
|
|
170
|
+
}
|
|
171
|
+
|
|
162
172
|
module.exports = commonconfig;
|