froth-webdriverio-framework 3.0.89 → 3.0.90

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.
Files changed (31) hide show
  1. package/{api → froth_api_calls}/browsersatckSessionInfo.js +8 -4
  2. package/{api → froth_api_calls}/getexecutionDetails.js +15 -12
  3. package/{api → froth_api_calls}/getsuiteDetails.js +9 -9
  4. package/{api → froth_api_calls}/readTestdata.js +1 -1
  5. package/{commonMethods → froth_common_actions}/Utils.js +21 -9
  6. package/{commonMethods → froth_common_actions}/alert.js +3 -3
  7. package/{commonMethods → froth_common_actions}/apicall.js +17 -5
  8. package/{commonMethods → froth_common_actions}/click.js +24 -1
  9. package/{commonMethods → froth_common_actions}/jwt.js +3 -3
  10. package/{commonMethods → froth_common_actions}/scroll.js +23 -1
  11. package/froth_common_actions/swipe.js +193 -0
  12. package/{config → froth_configs}/commonconfig.js +41 -31
  13. package/{config → froth_configs}/setallDatailinBuffer.js +8 -5
  14. package/froth_configs/wdio.common.conf.js +66 -0
  15. package/package.json +5 -6
  16. package/.github/workflows/main.yml +0 -23
  17. package/commonMethods/swipe.js +0 -59
  18. package/config/android.conf.js +0 -49
  19. package/config/api.conf.bs.js +0 -76
  20. package/config/api.conf.js +0 -77
  21. package/config/common.mobile.conf.js +0 -45
  22. package/config/injectimage.js +0 -4
  23. package/config/ios.conf.js +0 -47
  24. package/config/web.conf.bs.js +0 -76
  25. package/config/web.conf.js +0 -70
  26. /package/{api → froth_api_calls}/aesEncryption.js +0 -0
  27. /package/{api → froth_api_calls}/loginapi.js +0 -0
  28. /package/{commonMethods → froth_common_actions}/assert.js +0 -0
  29. /package/{commonMethods → froth_common_actions}/dropDown.js +0 -0
  30. /package/{commonMethods → froth_common_actions}/random.js +0 -0
  31. /package/{commonMethods → froth_common_actions}/storeToBuffer.js +0 -0
@@ -5,12 +5,13 @@ async function getBSBuildDetails(sessiontype, bs_username, bs_pwd) {
5
5
  console.log("sessiontype:" + sessiontype)
6
6
  const username = bs_username;
7
7
  const accessKey = bs_pwd;
8
+ console.log("accessKey:" + accessKey)
8
9
  const basicAuth = btoa(`${username}:${accessKey}`);
9
10
 
10
11
  let hashed_id = null;
11
12
 
12
13
  // const sessionid= BUFFER.getItem("SESSION_ID");
13
-
14
+ console.log("Browsersatck build name :" + process.env.BROWSERSTACK_BUILD_NAME)
14
15
  const url = `https://api.browserstack.com/${sessiontype}/builds.json?name=${process.env.BROWSERSTACK_BUILD_NAME}`;
15
16
 
16
17
  console.log("url:" + url)
@@ -35,6 +36,7 @@ async function getBSBuildDetails(sessiontype, bs_username, bs_pwd) {
35
36
  } else {
36
37
  const errorText = await response.text();
37
38
  console.error(`Data fetch failed response in getBSBuildDetails:${response.status}`);
39
+ // console.error(`Data fetch failed response in getBSBuildDetails:${errorText}`);
38
40
  // throw new Error(`HTTP error! status: ${response.status}`);
39
41
  }
40
42
 
@@ -52,7 +54,9 @@ async function getBSSessionDetails(sessiontype, bs_username, bs_pwd) {
52
54
  try {
53
55
  // const sessionId = sessionIdd;
54
56
  const username = bs_username;
55
- const accessKey = Buffer.from(bs_pwd, 'base64').toString('utf-8');
57
+ // const accessKey = Buffer.from(bs_pwd, 'base64').toString('utf-8');
58
+ const accessKey = bs_pwd;
59
+
56
60
  const basicAuth = btoa(`${username}:${accessKey}`);
57
61
 
58
62
  const hash_id = await getBSBuildDetails(sessiontype, bs_username, accessKey)
@@ -77,7 +81,7 @@ async function getBSSessionDetails(sessiontype, bs_username, bs_pwd) {
77
81
  const duration = data[0].automation_session.duration;
78
82
  BUFFER.setItem("REPORT_URL", publicUrl)
79
83
  BUFFER.setItem("FROTH_TOTAL_DURATION", duration)
80
-
84
+ console.log("public url:" + publicUrl)
81
85
  //return jsondata;
82
86
  } else if (response.status === 401) { //
83
87
  console.log("Unauthorized, token expired")
@@ -102,7 +106,7 @@ async function amend2Browserstack(annotationMessage, level) {
102
106
  try {
103
107
 
104
108
  console.log("Annotation message inside amend2Browserstack:" + annotationMessage)
105
- if (process.env.BROWSERSTACK)
109
+ if (process.env.PLATFORM === 'browserstack')
106
110
  await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
107
111
 
108
112
  } catch (error) {
@@ -1,5 +1,5 @@
1
1
 
2
- const getLoginToken = require("../api/loginapi.js")
2
+ const getLoginToken = require("./loginapi.js")
3
3
  // Function to get data from the API using the Bearer token
4
4
 
5
5
  async function getExecuitonDetails(frothUrl, token, id) {
@@ -21,12 +21,15 @@ async function getExecuitonDetails(frothUrl, token, id) {
21
21
  if (response.ok) {
22
22
  const data = await response.json();
23
23
  // console.log(data)
24
- jsondata.automation_suite_id = data.automation_suite_id;
25
- jsondata.test_cycle_id = data.test_cycle_id;
26
- if (data.testcycle_type === "Android" || data.testcycle_type === "Ios") {
27
- jsondata.device_name = data.device_name
28
- jsondata.version = data.version
29
- }
24
+ jsondata.automation_suite_id = data.automation_suite_details.id;
25
+ jsondata.test_cycle_id = data.test_cycle_details.id;
26
+ jsondata.app_url = data.app_details ? data.app_details.app_url : null;
27
+ jsondata.browser_stack_local = data.capability_details ? data.capability_details.browser_stack_local: null;
28
+ jsondata.mediaurls =data.media_details ? data.media_details.map(media => media.media_url):null;
29
+
30
+ console.log("media urls :" + jsondata.mediaurls );
31
+
32
+
30
33
  // console.log("json data :" + JSON.stringify(jsondata));
31
34
 
32
35
  return jsondata;
@@ -53,7 +56,7 @@ async function getExecuitonDetails(frothUrl, token, id) {
53
56
 
54
57
  }
55
58
 
56
- async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id,script_platform) {
59
+ async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id, script_platform) {
57
60
  let id;
58
61
  const url = `${frothUrl}/api/execution-script-mapping/?execution_id=${execution_id}&automation_script_id=${script_id}&platform=${script_platform}`;
59
62
 
@@ -151,12 +154,12 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
151
154
 
152
155
  }
153
156
 
154
- async function updateScriptExecutionStatus(frothUrl, token, scriptid,script_platform, status) {
157
+ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_platform, status) {
155
158
 
156
159
  if (scriptid != 0) {
157
160
  try {
158
- console.log("script platform is "+script_platform)
159
- const id = await getExecuitonScriptDetails(frothUrl, token, BUFFER.getItem("FROTH_EXECUTION_ID"), scriptid,script_platform)
161
+ console.log("script platform is " + script_platform)
162
+ const id = await getExecuitonScriptDetails(frothUrl, token, BUFFER.getItem("FROTH_EXECUTION_ID"), scriptid, script_platform)
160
163
  console.log("ID is :" + id)
161
164
  const url = `${frothUrl}/api/script-status-percentage/${id}/`;
162
165
  const formData = new FormData();
@@ -182,7 +185,7 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid,script_plat
182
185
  // Call login function to obtain a new token
183
186
  const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
184
187
  // Retry the request with the new token
185
- return updateScriptExecutionStatus(frothUrl, newToken, scriptid,script_platform, status);
188
+ return updateScriptExecutionStatus(frothUrl, newToken, scriptid, script_platform, status);
186
189
  } else {
187
190
  const errorText = await response.text();
188
191
  console.error(`error in updating the status into DB ${response.status}`);
@@ -1,5 +1,5 @@
1
1
 
2
- const getLoginToken=require('./loginapi')
2
+ const getLoginToken = require('./loginapi')
3
3
  // Function to get data from the API using the Bearer token
4
4
  async function getSuiteDetails(frothUrl, token, id) {
5
5
  let jsondata = {};
@@ -18,24 +18,24 @@ async function getSuiteDetails(frothUrl, token, id) {
18
18
  });
19
19
  if (response.ok) {
20
20
  const data = await response.json();
21
- // console.log(data)
21
+ // console.log(data)
22
22
  jsondata.automation_suite_id = data.id == null ? 0 : data.id;
23
23
  jsondata.automation_suite_name = data.automation_suite_name == null ? "" : data.automation_suite_name;
24
24
  jsondata.test_data_id = data.test_data_id == null ? 0 : data.test_data_id;
25
25
  jsondata.browser_stack_urls = data.browser_stack_urls == null ? "" : data.browser_stack_urls;
26
- jsondata.script_details=data.script_details == null ? [] : data.script_details;
27
- // console.log("automation_script_id:" + JSON.stringify(jsondata.automation_script_id))
26
+ jsondata.script_details = data.script_details == null ? [] : data.script_details;
27
+ // console.log("automation_script_id:" + JSON.stringify(jsondata.automation_script_id))
28
28
  const automationScripts = jsondata.script_details.reduce((obj, item) => {
29
29
  obj[item.script_Id] = item.script_Id;
30
30
  BUFFER.setItem(item.scriptName, item.scriptId);
31
- BUFFER.setItem(item.scriptName+"_PLATFORM", item.platform);
31
+ BUFFER.setItem(item.scriptName + "_PLATFORM", item.platform);
32
32
 
33
- return obj;
33
+ return obj;
34
34
  }, {});
35
35
  jsondata.test_sequence = data.test_sequence;
36
- // console.log("automation_script_ details:" + JSON.stringify(BUFFER))
36
+ // console.log("automation_script_ details:" + JSON.stringify(BUFFER))
37
37
 
38
- // console.log("json data :" + JSON.stringify(jsondata));
38
+ // console.log("json data :" + JSON.stringify(jsondata));
39
39
 
40
40
  return jsondata;
41
41
 
@@ -48,7 +48,7 @@ async function getSuiteDetails(frothUrl, token, id) {
48
48
  else {
49
49
  const errorText = await response.text();
50
50
  console.error(`Data fetch failed response in getSuiteDetails: ${response.status}`);
51
- // throw new Error(`HTTP error! status: ${response.status}`);
51
+ // throw new Error(`HTTP error! status: ${response.status}`);
52
52
  }
53
53
 
54
54
 
@@ -1,5 +1,5 @@
1
1
 
2
- const getLoginToken = require('../api/loginapi.js');
2
+ const getLoginToken = require('./loginapi.js');
3
3
 
4
4
 
5
5
  // Function to get data from the API using the Bearer token
@@ -7,14 +7,17 @@ let scrollToLeft = null;
7
7
  let scrollToRight = null;
8
8
  let scrollDownToView = null;
9
9
  let scrollRightToView = null;
10
+ let scrollUpUntilVisible = null;
10
11
 
11
12
  let swipeRight = null;
12
13
  let swipeLeft = null;
13
14
  let swipeUp = null;
14
15
  let swipeDown = null;
15
-
16
+ let swipetoFit = null;
17
+ let swipeWithCoordinates = null;
16
18
 
17
19
  let clickIfVisible = null;
20
+ let doubleClick = null;
18
21
 
19
22
  let assertText = null;
20
23
  let randomtext = null;
@@ -35,15 +38,15 @@ let api = null;
35
38
 
36
39
  let selectDropDownValue = null;
37
40
 
38
- let acceptalert = null;
39
- let dismissalert = null;
41
+ let acceptAlert = null;
42
+ let dismissAlert = null;
40
43
 
41
44
  let generateJWT=null;
42
45
 
43
- if (process.env.LOCATION == 'local') {
46
+ if (process.env.LOCATION ==null || process.env.LOCATION == 'local') {
44
47
  basepath = ".";
45
48
  } else {
46
- basepath = "froth-webdriverio-framework/commonMethods";
49
+ basepath = "froth-webdriverio-framework/froth_common_actions";
47
50
  }
48
51
 
49
52
  scrollToEnd = require(basepath + "/scroll").scrollToEnd;
@@ -53,14 +56,19 @@ scrollToRight = require(basepath + '/scroll').scrollToRight;
53
56
  scrollDownToView = require(basepath + '/scroll').scrollDownToView;
54
57
  scrollRightToView = require(basepath + '/scroll').scrollRightToView;
55
58
  scrollIntoView = require(basepath + '/scroll').scrollIntoView;
59
+ scrollUpUntilVisible = require(basepath + '/scroll').scrollupUntilVisible;
60
+
56
61
 
57
62
  swipeDown = require(basepath + '/swipe').swipedown;
58
63
  swipeLeft = require(basepath + '/swipe').swipeleft;
59
64
  swipeRight = require(basepath + '/swipe').swiperight;
60
65
  swipeUp = require(basepath + '/swipe').swipeup;
66
+ swipetoFit= require(basepath + '/swipe').swipetofit;
67
+ swipeWithCoordinates = require(basepath + '/swipe').swipewithcoordinates;
61
68
 
62
69
  clickIfVisible = require(basepath + "/click").clickIfVisible;
63
70
  clickByIdWithExecute = require(basepath + "/click").clickByIdWithExecute;
71
+ doubleClick= require(basepath + "/click").doubleclick;
64
72
 
65
73
  assertText = require(basepath + '/assert').assertText;
66
74
  assertAttributeValue = require(basepath + '/assert').assertAttributeValue;
@@ -82,8 +90,8 @@ validate = require(basepath + '/apicall').validate;
82
90
 
83
91
  selectDropDownValue = require(basepath + '/dropDown').select4mDropDownValue;
84
92
 
85
- acceptalert = require(basepath + '/alert.js').acceptAlert;
86
- dismissalert = require(basepath + '/alert.js').dismissAlert;
93
+ acceptAlert = require(basepath + '/alert.js').acceptalert;
94
+ dismissAlert = require(basepath + '/alert.js').dismissalert;
87
95
 
88
96
  generateJWT = require(basepath + '/jwt').generateJWTToken;
89
97
 
@@ -97,6 +105,7 @@ module.exports = {
97
105
  scrollRightToView,
98
106
  clickIfVisible,
99
107
  clickByIdWithExecute,
108
+ doubleClick,
100
109
  assertText,
101
110
  assertAttributeValue,
102
111
  randomtext,
@@ -110,14 +119,17 @@ module.exports = {
110
119
  storevalue,
111
120
  storeattributevalue,
112
121
  scrollIntoView,
122
+ scrollUpUntilVisible,
113
123
  api,
114
124
  validate,
115
125
  selectDropDownValue,
116
- acceptalert,
117
- dismissalert,
126
+ acceptAlert,
127
+ dismissAlert,
118
128
  swipeLeft,
119
129
  swipeRight,
120
130
  swipeDown,
121
131
  swipeUp,
132
+ swipetoFit,
133
+ swipeWithCoordinates,
122
134
  generateJWT
123
135
  };
@@ -1,4 +1,4 @@
1
- async function acceptAlert() {
1
+ async function acceptalert() {
2
2
 
3
3
  try {
4
4
  await browser.waitUntil(async () => {
@@ -14,7 +14,7 @@ async function acceptAlert() {
14
14
 
15
15
  }
16
16
 
17
- async function dismissAlert() {
17
+ async function dismissalert() {
18
18
  try {
19
19
  await browser.waitUntil(async () => {
20
20
  return await browser.isAlertOpen();
@@ -31,4 +31,4 @@ async function dismissAlert() {
31
31
 
32
32
  }
33
33
 
34
- module.exports = { acceptAlert, dismissAlert };
34
+ module.exports = { acceptalert, dismissalert };
@@ -1,4 +1,4 @@
1
- const amendToBrowserstack = require("../api/browsersatckSessionInfo").amend2Browserstack;
1
+ const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
2
2
 
3
3
  async function callapi(method, api_url, queryParams, payloaddetails, authentication, headers, attachments) {
4
4
  let response;
@@ -88,8 +88,14 @@ async function validate(attribute_name, attribute, actionname, buffer, buffernam
88
88
  await validateAttributeData(attribute_name, attribute, buffer, buffername_value, datatype);
89
89
  } else if (actionname.toLowerCase() == "setbuffer") {
90
90
  BUFFER.setItem(buffername_value, attribute);
91
+ let annotationMessage = `The vlaue has been stored in the buffer : ${buffername_value}.`;
92
+ await amendToBrowserstack(annotationMessage, "info");
93
+
91
94
  } else if (actionname.toLowerCase() == "getbuffer") {
95
+ let annotationMessage = `The vlaue has been retrived from the buffer : ${buffername_value}.`;
96
+ await amendToBrowserstack(annotationMessage, "info");
92
97
  return BUFFER.getItem(buffername_value);
98
+
93
99
  }
94
100
  // } catch (e) {
95
101
  // console.error('Error in validate method:', e);
@@ -109,19 +115,25 @@ async function validateAttributeData(attribute_name, attribute, buffer, bufferna
109
115
  valueToVerify = Number(valueToVerify);
110
116
  } else if (datatype.toLowerCase() == "boolean") {
111
117
  valueToVerify = Boolean(valueToVerify);
118
+ }else if (datatype.toLowerCase() == "float") {
119
+ valueToVerify = parseFloat(valueToVerify);
120
+ }else if (datatype.toLowerCase() == "double") {
121
+ valueToVerify = parseFloat(valueToVerify);
122
+ }else if (datatype.toLowerCase() == "string") {
123
+ valueToVerify = valueToVerify.toString();
112
124
  }
113
125
 
114
126
  expect(attribute).toBe(valueToVerify, `${attribute_name} --> Expected value: ${valueToVerify}, but got: ${attribute}`);
115
127
  assertionStatus = true; // If assertion passes, set status to true
116
128
 
117
- console.log("verification succeeded.");
118
- let annotationMessage = `${attribute_name} - verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
129
+ console.log(`Attribute name : ${attribute_name} verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`);
130
+ let annotationMessage = `Attribute name : ${attribute_name} - verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
119
131
  await amendToBrowserstack(annotationMessage, "info");
120
132
 
121
133
  } catch (e) {
122
134
  console.error('Error in validateAttributeData:', e);
123
- console.log(`${attribute_name} verification failed. Expected text: ${valueToVerify}.`);
124
- let annotationMessage = `${attribute_name} - verification failed. Expected text: ${valueToVerify}.`;
135
+ console.log(`Attribute name : ${attribute_name} verification failed. Expected text: ${valueToVerify}. error: ${e.message}`);
136
+ let annotationMessage = `Attribute name : ${attribute_name} - verification failed. Expected text: ${valueToVerify}. error: ${e.message}`;
125
137
  await amendToBrowserstack(annotationMessage, "error");
126
138
 
127
139
  throw e;
@@ -20,6 +20,29 @@ async function clickIfVisible(elementSelector) {
20
20
  }
21
21
  }
22
22
 
23
+ async function doubleclick(elementSelector) {
24
+ try {
25
+ let isDisplayed;
26
+ // Wait for the element to be visible
27
+ await driver.waitUntil(async () => {
28
+ console.log("Waiting for element to be visible");
29
+ const element = await $(elementSelector);
30
+ isDisplayed = await element.isDisplayed();
31
+ console.log("Element is displayed:", isDisplayed);
32
+ if (isDisplayed) {
33
+ // Get the actual text from the element
34
+ const element = await $(elementSelector);
35
+ await element.doubleClick();
36
+ console.log("Element is double clicked successfully.");
37
+ return;
38
+ }
39
+ }, { timeout: 30000 });
40
+ } catch (error) {
41
+ console.error("Element not found or not visible within 30 seconds");
42
+ }
43
+ }
44
+
45
+
23
46
 
24
47
  async function clickByIdWithExecute(elementid) {
25
48
  try {
@@ -31,4 +54,4 @@ async function clickByIdWithExecute(elementid) {
31
54
  }
32
55
  }
33
56
 
34
- module.exports = { clickIfVisible, clickByIdWithExecute };
57
+ module.exports = { clickIfVisible, clickByIdWithExecute ,doubleclick};
@@ -54,11 +54,11 @@ function main() {
54
54
  iat: currentTimestamp, // Issued at
55
55
  exp: currentTimestamp + 200, // Expiry time: 30 seconds from issuance
56
56
  user_agent: {
57
- id: "janga.reddy@ytlcomms.my"
57
+ id: "janga.reddy@ytl.com"
58
58
  }
59
59
  };
60
60
 
61
61
  console.log('JWT signed token:', generateJWTToken(payload));
62
62
  }
63
- //main()
64
- module.exports = { generateJWTToken}
63
+ main()
64
+ //module.exports = { generateJWTToken}
@@ -79,4 +79,26 @@ async function scrollIntoView(element){
79
79
  console.error(error.message);
80
80
  }
81
81
  }
82
- module.exports = { scrollToEnd, scrollToLeft, scrollToBeginning, scrollRightToView, scrollDownToView, scrollToRight ,scrollIntoView};
82
+
83
+ async function scrollupUntilVisible(selector) {
84
+ const element = await $(selector);
85
+
86
+ while (!(await element.isDisplayed())) {
87
+ await driver.performActions([
88
+ {
89
+ type: 'pointer',
90
+ id: 'finger1',
91
+ parameters: { pointerType: 'touch' },
92
+ actions: [
93
+ { type: 'pointerMove', duration: 0, x: 200, y: 800 },
94
+ { type: 'pointerDown', button: 0 },
95
+ { type: 'pause', duration: 100 },
96
+ { type: 'pointerMove', duration: 500, x: 200, y: 200 },
97
+ { type: 'pointerUp', button: 0 }
98
+ ]
99
+ }
100
+ ]);
101
+ await browser.pause(500);
102
+ }
103
+ }
104
+ module.exports = { scrollToEnd, scrollToLeft, scrollToBeginning, scrollRightToView, scrollDownToView, scrollToRight ,scrollIntoView,scrollupUntilVisible};
@@ -0,0 +1,193 @@
1
+ async function swipeleft(selector, xoffset, speedinsec) {
2
+ try {
3
+ console.log('Swiping left');
4
+
5
+ if (xoffset == null) {
6
+ driver.swipeLeft(selector, speedinsec);
7
+ } else {
8
+ driver.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 right');
19
+
20
+ if (xoffset == null) {
21
+ driver.swipeRight(selector, speedinsec);
22
+ } else {
23
+ driver.swipeRight(selector, xoffset, speedinsec);
24
+ }
25
+ } catch (error) {
26
+ console.error(error.message);
27
+ }
28
+
29
+ }
30
+
31
+ async function swipeup(selector, yoffset, speedinsec) {
32
+ try {
33
+ console.log('Swiping up');
34
+
35
+ if (yoffset == null) {
36
+ driver.swipeUp(selector, speedinsec);
37
+ } else {
38
+ driver.swipeUp(selector, yoffset, speedinsec);
39
+ }
40
+ } catch (error) {
41
+ console.error(error.message);
42
+ }
43
+ }
44
+
45
+ async function swipedown(selector, yoffset, speedinsec) {
46
+ try {
47
+ console.log('Swiping down');
48
+
49
+ if (yoffset == null) {
50
+ driver.swipeDown(selector, speedinsec);
51
+ } else {
52
+ driver.swipeDown(selector, yoffset, speedinsec);
53
+ }
54
+ } catch (error) {
55
+ console.error(error.message);
56
+ }
57
+ }
58
+
59
+ async function swipewithcoordinates(StartX, StartY, EndX, EndY) {
60
+
61
+ await driver.performActions([
62
+ {
63
+ type: "pointer",
64
+ id: "finger1",
65
+ parameters: { pointerType: "touch" },
66
+ actions: [
67
+ { type: "pointerMove", duration: 0, x: StartX, y: StartY },
68
+ { type: "pointerDown", button: 0 },
69
+ { type: "pause", duration: 300 },
70
+ { type: "pointerMove", duration: 1000, x: EndX, y: EndY },
71
+ { type: "pointerUp", button: 0 }
72
+ ],
73
+ }
74
+ ]);
75
+ }
76
+ async function swipetofit() {
77
+ // Get screen size dynamically
78
+ const screenSize = await driver.getWindowRect();
79
+ const screenWidth = screenSize.width;
80
+ const screenHeight = screenSize.height;
81
+
82
+ console.log(`Screen Size: Width=${screenWidth}, Height=${screenHeight}`);
83
+
84
+ // Define approximate positions for corners
85
+ const topRightStartX = screenWidth * 0.88; // Top-right corner
86
+ const topRightStartY = screenHeight * 0.44;
87
+
88
+ const topRightEndX = screenWidth * 0.96; // Expand to the right
89
+ const topRightEndY = screenHeight * 0.39; // Move upwards slightly
90
+
91
+ const bottomLeftStartX = screenWidth * 0.12; // Bottom-left corner
92
+ const bottomLeftStartY = screenHeight * 0.69;
93
+
94
+ const bottomLeftEndX = screenWidth * 0.014; // Expand to the left
95
+ const bottomLeftEndY = screenHeight * 0.73; // Move down slightly
96
+
97
+ console.log(`Resizing top-right from (${topRightStartX}, ${topRightStartY}) to (${topRightEndX}, ${topRightEndY})`);
98
+ console.log(`Resizing bottom-left from (${bottomLeftStartX}, ${bottomLeftStartY}) to (${bottomLeftEndX}, ${bottomLeftEndY})`);
99
+
100
+ // Resize from top-right corner
101
+ await driver.performActions([
102
+ {
103
+ type: "pointer",
104
+ id: "finger1",
105
+ parameters: { pointerType: "touch" },
106
+ actions: [
107
+ { type: "pointerMove", duration: 0, x: topRightStartX, y: topRightStartY },
108
+ { type: "pointerDown", button: 0 },
109
+ { type: "pause", duration: 300 },
110
+ { type: "pointerMove", duration: 1000, x: topRightEndX, y: topRightEndY },
111
+ { type: "pointerUp", button: 0 }
112
+ ],
113
+ }
114
+ ]);
115
+
116
+ // Resize from bottom-left corner
117
+ await driver.performActions([
118
+ {
119
+ type: "pointer",
120
+ id: "finger2",
121
+ parameters: { pointerType: "touch" },
122
+ actions: [
123
+ { type: "pointerMove", duration: 0, x: bottomLeftStartX, y: bottomLeftStartY },
124
+ { type: "pointerDown", button: 0 },
125
+ { type: "pause", duration: 300 },
126
+ { type: "pointerMove", duration: 1000, x: bottomLeftEndX, y: bottomLeftEndY },
127
+ { type: "pointerUp", button: 0 }
128
+ ],
129
+ }
130
+ ]);
131
+
132
+ console.log("✅ Crop overlay resized from two corners successfully!");
133
+ }
134
+
135
+ async function swipetofit(TopRStartXpct, TopRStartYpct, TopREndXpct, TopREndYpct, BottomLStartXpct, BottomLStartYpct, BottomLEndXpct, BottomLEndYpct) {
136
+ // Get screen size dynamically
137
+ const screenSize = await driver.getWindowRect();
138
+ const screenWidth = screenSize.width;
139
+ const screenHeight = screenSize.height;
140
+
141
+ console.log(`Screen Size: Width=${screenWidth}, Height=${screenHeight}`);
142
+
143
+ // Define approximate positions for corners
144
+ const topRightStartX = screenWidth * (TopRStartXpct/100); // Top-right corner
145
+ const topRightStartY = screenHeight * (TopRStartYpct/100);
146
+
147
+ const topRightEndX = screenWidth * (TopREndXpct/100); // Expand to the right
148
+ const topRightEndY = screenHeight * (TopREndYpct/100); // Move upwards slightly
149
+
150
+ const bottomLeftStartX = screenWidth * (BottomLStartXpct/100); // Bottom-left corner
151
+ const bottomLeftStartY = screenHeight * (BottomLStartYpct/100);
152
+
153
+ const bottomLeftEndX = screenWidth * (BottomLEndXpct/100); // Expand to the left
154
+ const bottomLeftEndY = screenHeight * (BottomLEndYpct/100); // Move down slightly
155
+
156
+ console.log(`Resizing top-right from (${topRightStartX}, ${topRightStartY}) to (${topRightEndX}, ${topRightEndY})`);
157
+ console.log(`Resizing bottom-left from (${bottomLeftStartX}, ${bottomLeftStartY}) to (${bottomLeftEndX}, ${bottomLeftEndY})`);
158
+
159
+ // Resize from top-right corner
160
+ await driver.performActions([
161
+ {
162
+ type: "pointer",
163
+ id: "finger1",
164
+ parameters: { pointerType: "touch" },
165
+ actions: [
166
+ { type: "pointerMove", duration: 0, x: topRightStartX, y: topRightStartY },
167
+ { type: "pointerDown", button: 0 },
168
+ { type: "pause", duration: 300 },
169
+ { type: "pointerMove", duration: 1000, x: topRightEndX, y: topRightEndY },
170
+ { type: "pointerUp", button: 0 }
171
+ ],
172
+ }
173
+ ]);
174
+
175
+ // Resize from bottom-left corner
176
+ await driver.performActions([
177
+ {
178
+ type: "pointer",
179
+ id: "finger2",
180
+ parameters: { pointerType: "touch" },
181
+ actions: [
182
+ { type: "pointerMove", duration: 0, x: bottomLeftStartX, y: bottomLeftStartY },
183
+ { type: "pointerDown", button: 0 },
184
+ { type: "pause", duration: 300 },
185
+ { type: "pointerMove", duration: 1000, x: bottomLeftEndX, y: bottomLeftEndY },
186
+ { type: "pointerUp", button: 0 }
187
+ ],
188
+ }
189
+ ]);
190
+
191
+ console.log("✅ Crop overlay resized from two corners successfully!");
192
+ }
193
+ module.exports = { swipeleft, swipedown, swiperight, swipeup, swipetofit ,swipewithcoordinates};