froth-webdriverio-framework 3.0.44 → 3.0.46

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.
@@ -6,22 +6,25 @@ async function callapi(method, api_url, queryParams, payloaddetails, authenticat
6
6
  api_url += `?${queryString}`;
7
7
  }
8
8
  console.log("URL: " + api_url);
9
- const formData = new FormData();
9
+ let formData = new FormData();
10
10
  console.log("Payload Details: before if loop", JSON.stringify(payloaddetails));
11
11
 
12
12
  if (payloaddetails && Object.keys(payloaddetails).length > 0) {
13
13
  console.log("Payload Details:", JSON.stringify(payloaddetails));
14
- Object.entries(payloaddetails).forEach(([key, value]) => formData.append(key, value));
14
+ formData= await jsonToFormData(payloaddetails);
15
+ console.log("FormData:", JSON.stringify(formData));
16
+ // Object.entries(payloaddetails).forEach(([key, value]) => formData.append(key, value));
15
17
  }
16
18
 
17
19
  try {
18
20
  // Prepare fetch options
19
- const options = {
21
+ let options = {
20
22
  method: method,
21
23
  headers: await formheaders(authentication, headers)
22
24
  };
23
25
  // Only add the body if the method is not GET or HEAD
24
26
  if (method !== 'GET' && method !== 'HEAD') {
27
+ console.log("inside if loop if its POST or PUT");
25
28
  options.body = formData;
26
29
  }
27
30
  console.log("options:", JSON.stringify(options, null, 2));
@@ -34,7 +37,24 @@ async function callapi(method, api_url, queryParams, payloaddetails, authenticat
34
37
  }
35
38
  return response;
36
39
  }
37
-
40
+ async function jsonToFormData(json) {
41
+ const formData = new FormData();
42
+
43
+ function appendFormData(data, parentKey = '') {
44
+ if (data && typeof data === 'object' && !Array.isArray(data)) {
45
+ for (const key in data) {
46
+ if (data.hasOwnProperty(key)) {
47
+ appendFormData(data[key], parentKey ? `${parentKey}[${key}]` : key);
48
+ }
49
+ }
50
+ } else {
51
+ formData.append(parentKey, data);
52
+ }
53
+ }
54
+
55
+ appendFormData(json);
56
+ return formData;
57
+ }
38
58
 
39
59
  // Function to form headers
40
60
  async function formheaders(authentication, headers) {
@@ -57,8 +77,9 @@ async function formheaders(authentication, headers) {
57
77
 
58
78
  }
59
79
  async function validate(attribute, actionname, buffer, value, datatype) {
80
+ let valueToVerify;
81
+
60
82
  try {
61
- let valueToVerify;
62
83
  let assertionStatus = false; // Initialize status
63
84
 
64
85
  if (actionname.toLowerCase() == "verify") {
@@ -91,4 +112,13 @@ async function validate(attribute, actionname, buffer, value, datatype) {
91
112
  }
92
113
  }
93
114
 
115
+ async function amendToBrowserstack(annotationMessage, level) {
116
+ try {
117
+ await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
118
+
119
+ } catch (error) {
120
+ console.error('Error occurred while verifying text:', error);
121
+ throw error;
122
+ }
123
+ }
94
124
  module.exports = { callapi, validate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "3.0.44",
3
+ "version": "3.0.46",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",