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.
@@ -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
- 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);
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
- return response;
26
+
27
+ // Send the request
28
+ response = await fetch(api_url, options);
29
+
27
30
  }
28
-
29
-
30
- // Function to form headers
31
- async function formheaders(authentication,headers) {
32
- if (authentication !== "") {
33
- headers.Authorization = `Bearer ${authentication}`;
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
- module.exports = { callapi };
48
+ return headers;
49
+
50
+ }
51
+
52
+ module.exports = { callapi };
@@ -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) {
@@ -25,6 +25,7 @@ const iosconfig = deepmerge.all([commonmobileconfig, {
25
25
  platformName: 'iOS',
26
26
  interactiveDebugging: true,
27
27
  buildName: process.env.BROWSERSTACK_BUILD_NAME || 'IOS_Build',
28
+ enableCameraImageInjection : "true",
28
29
 
29
30
  }
30
31
  }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "2.0.37",
3
+ "version": "2.0.39",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",