froth-webdriverio-framework 2.0.45 → 2.0.47
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 +5 -2
- 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
|
// ====================
|
|
@@ -11,6 +11,9 @@ const apiconfig = deepmerge.all([commonmobileconfig, {
|
|
|
11
11
|
maxInstances: 5,
|
|
12
12
|
browserName: 'chrome',
|
|
13
13
|
acceptInsecureCerts: true,
|
|
14
|
+
'goog:chromeOptions': {
|
|
15
|
+
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage'],
|
|
16
|
+
},
|
|
14
17
|
}],
|
|
15
18
|
runner: 'local',
|
|
16
19
|
|
|
@@ -18,7 +21,7 @@ const apiconfig = deepmerge.all([commonmobileconfig, {
|
|
|
18
21
|
// browser.maximizeWindow()
|
|
19
22
|
//process.env.BS_SESSION_TYPE = "app-automate";
|
|
20
23
|
},
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
|
|
23
26
|
}]);
|
|
24
27
|
|