froth-webdriverio-framework 2.0.33 → 2.0.34
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 +5 -27
- package/commonMethods/apicall.js +37 -0
- package/package.json +1 -1
package/commonMethods/Utils.js
CHANGED
|
@@ -24,6 +24,8 @@ let storeattributevalue = null;
|
|
|
24
24
|
let assertAttributeValue = null;
|
|
25
25
|
let basepath = null;
|
|
26
26
|
let scrollIntoView = null;
|
|
27
|
+
let api=null;
|
|
28
|
+
|
|
27
29
|
if (process.env.LOCATION == 'local') {
|
|
28
30
|
basepath = ".";
|
|
29
31
|
} else {
|
|
@@ -55,33 +57,9 @@ storetext = require(basepath + '/storeToBuffer').STORETEXT;
|
|
|
55
57
|
storevalue = require(basepath + '/storeToBuffer').STOREVALUE;
|
|
56
58
|
storeattributevalue = require(basepath + '/storeToBuffer').STOREATTRIBUTEVALUE;
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
// scrollToEnd = require('froth-webdriverio-framework/commonMethods/scroll').scrollToEnd;
|
|
60
|
-
// scrollDownToView = require('froth-webdriverio-framework/commonMethods/scroll').scrollDownToView;
|
|
61
|
-
// scrollToBeginning = require('froth-webdriverio-framework/commonMethods/scroll').scrollToBeginning;
|
|
62
|
-
// scrollToLeft = require('froth-webdriverio-framework/commonMethods/scroll').scrollToLeft;
|
|
63
|
-
// scrollToRight = require('froth-webdriverio-framework/commonMethods/scroll').scrollToRight;
|
|
64
|
-
// scrollRightToView = require('froth-webdriverio-framework/commonMethods/scroll').scrollRightToView;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// clickIfVisible = require('froth-webdriverio-framework/commonMethods/clickIfVisible');
|
|
60
|
+
api = require(basepath + '/apicall').callapi;
|
|
68
61
|
|
|
69
|
-
// assertText = require('froth-webdriverio-framework/commonMethods/assert').assertText;
|
|
70
|
-
// assertAttributeValue = require('froth-webdriverio-framework/commonMethods/assert').assertAttributeValue;
|
|
71
62
|
|
|
72
|
-
// randomtext = require('froth-webdriverio-framework/commonMethods/random').RANDOMTEXT;
|
|
73
|
-
// randomnumber = require('froth-webdriverio-framework/commonMethods/random').RNDNUMBER;
|
|
74
|
-
// randomfloat = require('froth-webdriverio-framework/commonMethods/random').RNDFLOAT;
|
|
75
|
-
// randomint = require('froth-webdriverio-framework/commonMethods/random').RNDINT;
|
|
76
|
-
// randomalphanum = require('froth-webdriverio-framework/commonMethods/random').RNDALPHANUM;
|
|
77
|
-
// randomdecimal = require('froth-webdriverio-framework/commonMethods/random').RNDDECIMAL;
|
|
78
|
-
// randomregex = require('froth-webdriverio-framework/commonMethods/random').RNDREGEX;
|
|
79
|
-
|
|
80
|
-
// storetext = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STORETEXT;
|
|
81
|
-
// storevalue = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STOREVALUE;
|
|
82
|
-
// storeattributevalue = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STOREATTRIBUTEVALUE;
|
|
83
|
-
|
|
84
|
-
// }
|
|
85
63
|
//export the variabels
|
|
86
64
|
module.exports = {
|
|
87
65
|
scrollToEnd,
|
|
@@ -103,6 +81,6 @@ module.exports = {
|
|
|
103
81
|
storetext,
|
|
104
82
|
storevalue,
|
|
105
83
|
storeattributevalue,
|
|
106
|
-
scrollIntoView
|
|
107
|
-
|
|
84
|
+
scrollIntoView,
|
|
85
|
+
api
|
|
108
86
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
async function callapi(method,api_url, queryParams, payloaddetails,authentication,headers) {
|
|
3
|
+
let response;
|
|
4
|
+
if (queryParams && Object.keys(queryParams).length > 0) {
|
|
5
|
+
const queryParams = new URLSearchParams(queryParams).toString();
|
|
6
|
+
api_url += `?${queryParams}`;
|
|
7
|
+
}
|
|
8
|
+
console.log("URL: " + api_url);
|
|
9
|
+
const formData = new FormData();
|
|
10
|
+
|
|
11
|
+
if (payloaddetails && Object.keys(payloaddetails).length > 0) {
|
|
12
|
+
Object.entries(payloaddetails).forEach(([key, value]) => formData.append(key, value));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
// Send the request with axios and form-data
|
|
17
|
+
response = await fetch(api_url, {
|
|
18
|
+
method: method,
|
|
19
|
+
headers: await formheaders(authentication,headers),
|
|
20
|
+
body: formData // Optional: handle large payloads
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error('Error during API call:', error.response ? error.response.data : error.message);
|
|
25
|
+
}
|
|
26
|
+
return response;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// Function to form headers
|
|
31
|
+
async function formheaders(authentication,headers) {
|
|
32
|
+
if (authentication !== "") {
|
|
33
|
+
headers.Authorization = `Bearer ${authentication}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = { callapi };
|