froth-webdriverio-framework 2.0.32 → 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.
@@ -23,6 +23,9 @@ let storevalue = null;
23
23
  let storeattributevalue = null;
24
24
  let assertAttributeValue = null;
25
25
  let basepath = null;
26
+ let scrollIntoView = null;
27
+ let api=null;
28
+
26
29
  if (process.env.LOCATION == 'local') {
27
30
  basepath = ".";
28
31
  } else {
@@ -35,6 +38,7 @@ scrollToLeft = require(basepath + '/scroll').scrollToLeft;
35
38
  scrollToRight = require(basepath + '/scroll').scrollToRight;
36
39
  scrollDownToView = require(basepath + '/scroll').scrollDownToView;
37
40
  scrollRightToView = require(basepath + '/scroll').scrollRightToView;
41
+ scrollIntoView = require(basepath + '/scroll').scrollIntoView;
38
42
 
39
43
  clickIfVisible = require(basepath + "/clickIfVisible");
40
44
 
@@ -53,33 +57,9 @@ storetext = require(basepath + '/storeToBuffer').STORETEXT;
53
57
  storevalue = require(basepath + '/storeToBuffer').STOREVALUE;
54
58
  storeattributevalue = require(basepath + '/storeToBuffer').STOREATTRIBUTEVALUE;
55
59
 
56
- // } else {
57
- // scrollToEnd = require('froth-webdriverio-framework/commonMethods/scroll').scrollToEnd;
58
- // scrollDownToView = require('froth-webdriverio-framework/commonMethods/scroll').scrollDownToView;
59
- // scrollToBeginning = require('froth-webdriverio-framework/commonMethods/scroll').scrollToBeginning;
60
- // scrollToLeft = require('froth-webdriverio-framework/commonMethods/scroll').scrollToLeft;
61
- // scrollToRight = require('froth-webdriverio-framework/commonMethods/scroll').scrollToRight;
62
- // scrollRightToView = require('froth-webdriverio-framework/commonMethods/scroll').scrollRightToView;
63
-
64
-
65
- // clickIfVisible = require('froth-webdriverio-framework/commonMethods/clickIfVisible');
60
+ api = require(basepath + '/apicall').callapi;
66
61
 
67
- // assertText = require('froth-webdriverio-framework/commonMethods/assert').assertText;
68
- // assertAttributeValue = require('froth-webdriverio-framework/commonMethods/assert').assertAttributeValue;
69
62
 
70
- // randomtext = require('froth-webdriverio-framework/commonMethods/random').RANDOMTEXT;
71
- // randomnumber = require('froth-webdriverio-framework/commonMethods/random').RNDNUMBER;
72
- // randomfloat = require('froth-webdriverio-framework/commonMethods/random').RNDFLOAT;
73
- // randomint = require('froth-webdriverio-framework/commonMethods/random').RNDINT;
74
- // randomalphanum = require('froth-webdriverio-framework/commonMethods/random').RNDALPHANUM;
75
- // randomdecimal = require('froth-webdriverio-framework/commonMethods/random').RNDDECIMAL;
76
- // randomregex = require('froth-webdriverio-framework/commonMethods/random').RNDREGEX;
77
-
78
- // storetext = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STORETEXT;
79
- // storevalue = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STOREVALUE;
80
- // storeattributevalue = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STOREATTRIBUTEVALUE;
81
-
82
- // }
83
63
  //export the variabels
84
64
  module.exports = {
85
65
  scrollToEnd,
@@ -100,6 +80,7 @@ module.exports = {
100
80
  randomregex,
101
81
  storetext,
102
82
  storevalue,
103
- storeattributevalue
104
-
83
+ storeattributevalue,
84
+ scrollIntoView,
85
+ api
105
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 };
@@ -1,6 +1,6 @@
1
1
  // Function to verify text in Android app
2
2
 
3
- async function assertText(driver, elementSelector, expectedText) {
3
+ async function assertText(elementSelector, expectedText) {
4
4
 
5
5
 
6
6
  console.log("inside the assert text function" + elementSelector)
@@ -31,7 +31,7 @@ async function assertText(driver, elementSelector, expectedText) {
31
31
 
32
32
  }
33
33
 
34
- async function assertAttributeValue(driver, elementSelector, attributeName, expectedText) {
34
+ async function assertAttributeValue(elementSelector, attributeName, expectedText) {
35
35
 
36
36
 
37
37
  console.log("inside the assertAttributeValue function" + elementSelector)
@@ -66,4 +66,17 @@ async function scrollToRight(steps) {
66
66
  console.error(error.message);
67
67
  }
68
68
  }
69
- module.exports = { scrollToEnd, scrollToLeft, scrollToBeginning, scrollRightToView, scrollDownToView, scrollToRight };
69
+
70
+ async function scrollIntoView(element){
71
+ try{
72
+ const elem = await $(element);
73
+ // scroll to specific element
74
+ await elem.scrollIntoView();
75
+ // center element within the viewport
76
+ await elem.scrollIntoView({ block: 'center', inline: 'center' });
77
+
78
+ }catch(error){
79
+ console.error(error.message);
80
+ }
81
+ }
82
+ module.exports = { scrollToEnd, scrollToLeft, scrollToBeginning, scrollRightToView, scrollDownToView, scrollToRight ,scrollIntoView};
@@ -0,0 +1,29 @@
1
+ async function swipeleft(selector,xoffset,speedinsec) {
2
+ try {
3
+ console.log('Swiping left');
4
+
5
+ if(xoffset == null){
6
+ browser.swipeLeft(selector,speedinsec);
7
+ }else{
8
+ browser.swipeLeft(selector,xoffset,speedinsec);
9
+ }
10
+ } catch (error) {
11
+ console.error(error.message);
12
+ }
13
+
14
+ }
15
+
16
+ async function swiperight(selector,xoffset,speedinsec) {
17
+ try {
18
+ console.log('Swiping left');
19
+
20
+ if(xoffset == null){
21
+ browser.swipeRight(selector,speedinsec);
22
+ }else{
23
+ browser.swipeRight(selector,xoffset,speedinsec);
24
+ }
25
+ } catch (error) {
26
+ console.error(error.message);
27
+ }
28
+
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "2.0.32",
3
+ "version": "2.0.34",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",