froth-webdriverio-framework 2.0.37 → 2.0.39
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/apicall.js +46 -31
- package/config/android.conf.js +5 -1
- package/config/ios.conf.js +1 -0
- package/package.json +1 -1
package/commonMethods/apicall.js
CHANGED
|
@@ -1,37 +1,52 @@
|
|
|
1
1
|
|
|
2
|
-
async function callapi(method,api_url, queryParams, payloaddetails,authentication,headers,attachments) {
|
|
2
|
+
async function callapi(method, api_url, queryParams, payloaddetails, authentication, headers, attachments) {
|
|
3
3
|
let response;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
if (queryParams && Object.keys(queryParams).length > 0) {
|
|
5
|
+
const queryString = new URLSearchParams(queryParams).toString();
|
|
6
|
+
api_url += `?${queryString}`;
|
|
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
|
+
// Prepare fetch options
|
|
17
|
+
const options = {
|
|
18
|
+
method: method,
|
|
19
|
+
headers: await formheaders(authentication, headers)
|
|
20
|
+
};
|
|
21
|
+
console.log("options:", JSON.stringify(options, null, 2));
|
|
22
|
+
// Only add the body if the method is not GET or HEAD
|
|
23
|
+
if (method !== 'GET' && method !== 'HEAD') {
|
|
24
|
+
options.body = formData;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
// Send the request
|
|
28
|
+
response = await fetch(api_url, options);
|
|
29
|
+
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('Error during API call in call api menthod:', error);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// Function to form headers
|
|
39
|
+
async function formheaders(authentication, headers = {}) {
|
|
40
|
+
// Add authentication headers based on the type
|
|
41
|
+
if (authentication && authentication.auth_type) {
|
|
42
|
+
if (authentication.auth_type === 'Bearer') {
|
|
43
|
+
headers.Authorization = `Bearer ${authentication.token}`;
|
|
44
|
+
} else if (authentication.auth_type === 'Basic') {
|
|
45
|
+
headers.Authorization = `Basic ${btoa(`${authentication.username}:${authentication.password}`)}`;
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
return headers;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = { callapi };
|
package/config/android.conf.js
CHANGED
|
@@ -27,7 +27,11 @@ const androidConfig = deepmerge.all([commonmobileconfig, {
|
|
|
27
27
|
platformName: 'android',
|
|
28
28
|
interactiveDebugging: true,
|
|
29
29
|
buildName: process.env.BROWSERSTACK_BUILD_NAME || 'Android_Build',
|
|
30
|
-
|
|
30
|
+
enableCameraImageInjection : "true",
|
|
31
|
+
deviceOrientation:
|
|
32
|
+
(process.env.DEVICENAME || 'Samsung Galaxy S23 Ultra').toLowerCase().includes('tab')
|
|
33
|
+
? 'landscape'
|
|
34
|
+
: 'portrait',
|
|
31
35
|
}
|
|
32
36
|
}],
|
|
33
37
|
before: function (capabilities, specs) {
|
package/config/ios.conf.js
CHANGED