froth-webdriverio-framework 3.0.49 → 3.0.51

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.
@@ -11,9 +11,9 @@ async function callapi(method, api_url, queryParams, payloaddetails, authenticat
11
11
 
12
12
  if (payloaddetails && Object.keys(payloaddetails).length > 0) {
13
13
  console.log("Payload Details:", JSON.stringify(payloaddetails));
14
- formData= await jsonToFormData(payloaddetails);
14
+ formData = await jsonToFormData(payloaddetails);
15
15
  console.log("FormData:", JSON.stringify(formData));
16
- // Object.entries(payloaddetails).forEach(([key, value]) => formData.append(key, value));
16
+ // Object.entries(payloaddetails).forEach(([key, value]) => formData.append(key, value));
17
17
  }
18
18
 
19
19
  try {
@@ -39,22 +39,22 @@ async function callapi(method, api_url, queryParams, payloaddetails, authenticat
39
39
  }
40
40
  async function jsonToFormData(json) {
41
41
  const formData = new FormData();
42
-
42
+
43
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
- }
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);
49
52
  }
50
- } else {
51
- formData.append(parentKey, data);
52
- }
53
53
  }
54
-
54
+
55
55
  appendFormData(json);
56
56
  return formData;
57
- }
57
+ }
58
58
 
59
59
  // Function to form headers
60
60
  async function formheaders(authentication, headers) {
@@ -76,48 +76,61 @@ async function formheaders(authentication, headers) {
76
76
  return headers;
77
77
 
78
78
  }
79
- async function validate(attribute, actionname, buffer, value, datatype) {
80
- let valueToVerify;
79
+ async function validate(attribute_name, attribute, actionname, buffer, buffername_value, datatype) {
81
80
 
82
81
  try {
83
- let assertionStatus = false; // Initialize status
84
82
 
85
83
  if (actionname.toLowerCase() == "verify") {
86
-
87
- //if buffer is true, get the value from buffer
88
- buffer ? valueToVerify = BUFFER.getItem(value) : valueToVerify = value;
89
-
90
- if (datatype.toLowerCase() == "integer") {
91
- valueToVerify = Number(valueToVerify);
92
- } else if (datatype.toLowerCase() == "boolean") {
93
- valueToVerify = Boolean(valueToVerify);
94
- }
95
- expect(attribute).toBe(valueToVerify, `Expected value: ${valueToVerify}, but got: ${attribute}`);
96
- assertionStatus = true; // If assertion passes, set status to true
97
- console.log("Verification succeeded.");
98
- let annotationMessage = `Verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
99
- await amendToBrowserstack(annotationMessage, "info");
100
-
84
+ await validateAttributeData(attribute_name,attribute,buffer, buffername_value, datatype);
101
85
  } else if (actionname.toLowerCase() == "setbuffer") {
102
- BUFFER.setItem(value, attribute);
86
+ BUFFER.setItem(buffername_value, attribute);
103
87
  } else if (actionname.toLowerCase() == "getbuffer") {
104
- return BUFFER.getItem(value);
88
+ return BUFFER.getItem(buffername_value);
105
89
  }
106
90
  } catch (e) {
107
- console.error('Error in validate:', e);
108
- console.log(`Validation failed. Expected text: ${valueToVerify}.`);
109
- let annotationMessage = `Verification failed. Expected text: ${valueToVerify}.`;
110
- await amendToBrowserstack(annotationMessage, "error");
91
+ console.error('Error in validate method:', e);
111
92
  }
112
93
  }
113
94
 
95
+ async function validateAttributeData(attribute_name,attribute,buffer, buffername_value, datatype) {
96
+ let assertionStatus = false; // Initialize status
97
+ let valueToVerify;
98
+
99
+ try {
100
+ //if buffer is true, get the value from buffer
101
+ buffer ? valueToVerify = BUFFER.getItem(buffername_value) : valueToVerify = buffername_value;
102
+
103
+ if (datatype.toLowerCase() == "integer") {
104
+ valueToVerify = Number(valueToVerify);
105
+ } else if (datatype.toLowerCase() == "boolean") {
106
+ valueToVerify = Boolean(valueToVerify);
107
+ }
108
+
109
+ expect(attribute).toBe(valueToVerify, `${attribute_name} --> Expected value: ${valueToVerify}, but got: ${attribute}`);
110
+ assertionStatus = true; // If assertion passes, set status to true
111
+
112
+ console.log("verification succeeded.");
113
+ let annotationMessage = `${attribute_name} verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
114
+
115
+ if (process.env.BROWSERSTACK)
116
+ await amendToBrowserstack(annotationMessage, "info");
117
+
118
+ } catch (e) {
119
+ console.error('Error in validateAttributeData:', e);
120
+ console.log(`${attribute_name} verification failed. Expected text: ${valueToVerify}.`);
121
+ let annotationMessage = `${attribute_name} verification failed. Expected text: ${valueToVerify}.`;
122
+
123
+ if (process.env.BROWSERSTACK)
124
+ await amendToBrowserstack(annotationMessage, "error");
125
+ }
126
+ }
114
127
  async function amendToBrowserstack(annotationMessage, level) {
115
128
  try {
116
- await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
117
-
129
+ await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
130
+
118
131
  } catch (error) {
119
- console.error('Error occurred while verifying text:', error);
120
- throw error;
132
+ console.error('Error occurred while annoting to BS :', error);
133
+ throw error;
121
134
  }
122
- }
135
+ }
123
136
  module.exports = { callapi, validate };
@@ -1,28 +1,77 @@
1
1
  const deepmerge = require('deepmerge')
2
- process.env.BROWSERSTACK = false;
2
+ process.env.BROWSERSTACK = true;
3
3
  const commonmobileconfig = require('./common.mobile.conf');
4
4
 
5
5
  const apiconfig = deepmerge.all([commonmobileconfig, {
6
6
 
7
- // ====================
8
- // Capabilities
9
- // ====================
10
- capabilities: [{
11
- maxInstances: 5,
12
- browserName: 'chrome',
13
- acceptInsecureCerts: true,
14
- 'goog:chromeOptions': {
15
- args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage'],
7
+
8
+ services: [
9
+ ['browserstack', {
10
+
11
+ browserstackLocal: process.env.BROWSERSTACK_LOCAL || false,
12
+ opts: {
13
+ forcelocal: false,
14
+ // localIdentifier: "webdriverio-appium"
15
+ },
16
+
17
+ }]
18
+ ],
19
+ // ====================
20
+ // Capabilities
21
+ // ====================
22
+ capabilities: [
23
+ {
24
+ 'bstack:options': {
25
+ projectName: process.env.PROJECTNAME || "roboticodigital",
26
+
27
+ browserName: 'chrome', // Choose the browser you want to test
28
+ browserVersion: 'latest', // Specify the browser version
29
+ os: 'Windows', // Specify the operating system
30
+ os_version: 'latest', // Specify the operating system version
31
+ interactiveDebugging: true,
32
+ buildName: process.env.BROWSERSTACK_BUILD_NAME || 'WEB_Build',
33
+ networkLogs: "true",
34
+ debug: "true",
35
+ }
36
+ },
37
+ // Add more capabilities for other browsers or devices as needed
38
+ ],
39
+
40
+ // ====================
41
+ // Test Configurations
42
+ // ====================
43
+ // logLevel: 'info', // Set the log level
44
+ // bail: 0, // Set to 1 to stop the test suite after the first test failure
45
+ // baseUrl: '', // Specify the base URL of your application
46
+ // waitforTimeout: 90000, // Set the timeout for all waitFor* commands
47
+ // connectionRetryTimeout: 90000, // Set the timeout in milliseconds for test retries
48
+ // connectionRetryCount: 2, // Set the number of times to retry the entire spec file
49
+
50
+ // ====================
51
+ // Framework
52
+ // ====================
53
+ // framework: 'mocha', // Use the Mocha framework
54
+ // reporters: ['spec'
55
+
56
+ // ], // Use the spec reporter
57
+
58
+ // ====================
59
+ // Hooks
60
+ // ====================
61
+ before: function (capabilities, specs) {
62
+ browser.maximizeWindow()
63
+ process.env.BS_SESSION_TYPE = "automate";
16
64
  },
17
- }],
18
- runner: 'local',
19
65
 
20
- before: function (capabilities, specs) {
21
- // browser.maximizeWindow()
22
- //process.env.BS_SESSION_TYPE = "app-automate";
23
- },
24
66
 
25
67
 
68
+ // // ====================
69
+ // // Mocha Options
70
+ // // ====================
71
+ // mochaOpts: {
72
+ // ui: 'bdd', // Set the test interface to BDD
73
+ // timeout: 90000, // Set the timeout for test cases in milliseconds
74
+ // },
26
75
  }]);
27
76
 
28
77
  module.exports = apiconfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "3.0.49",
3
+ "version": "3.0.51",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",