froth-webdriverio-framework 3.0.80 → 3.0.82
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.
- package/commonMethods/Utils.js +3 -0
- package/commonMethods/swipe.js +103 -26
- package/package.json +1 -1
package/commonMethods/Utils.js
CHANGED
|
@@ -13,6 +13,7 @@ let swipeLeft = null;
|
|
|
13
13
|
let swipeUp = null;
|
|
14
14
|
let swipeDown = null;
|
|
15
15
|
let swipetoFit = null;
|
|
16
|
+
let swipeWithCoordinates = null;
|
|
16
17
|
|
|
17
18
|
let clickIfVisible = null;
|
|
18
19
|
|
|
@@ -59,6 +60,7 @@ swipeLeft = require(basepath + '/swipe').swipeleft;
|
|
|
59
60
|
swipeRight = require(basepath + '/swipe').swiperight;
|
|
60
61
|
swipeUp = require(basepath + '/swipe').swipeup;
|
|
61
62
|
swipetoFit= require(basepath + '/swipe').swipetofit;
|
|
63
|
+
swipeWithCoordinates = require(basepath + '/swipe').swipewithcoordinates;
|
|
62
64
|
|
|
63
65
|
clickIfVisible = require(basepath + "/click").clickIfVisible;
|
|
64
66
|
clickByIdWithExecute = require(basepath + "/click").clickByIdWithExecute;
|
|
@@ -121,5 +123,6 @@ module.exports = {
|
|
|
121
123
|
swipeDown,
|
|
122
124
|
swipeUp,
|
|
123
125
|
swipetoFit,
|
|
126
|
+
swipeWithCoordinates,
|
|
124
127
|
generateJWT
|
|
125
128
|
};
|
package/commonMethods/swipe.js
CHANGED
|
@@ -56,31 +56,108 @@ async function swipedown(selector, yoffset, speedinsec) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
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
|
+
}
|
|
60
76
|
async function swipetofit() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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!");
|
|
85
133
|
}
|
|
86
|
-
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
// async function swipetofit() {
|
|
138
|
+
// try {
|
|
139
|
+
// const { width, height } = await driver.getWindowRect();
|
|
140
|
+
|
|
141
|
+
// console.log('width and height:', width, height);
|
|
142
|
+
// // ⬅ Swipe from right to left (Full Swipe)
|
|
143
|
+
|
|
144
|
+
// await driver.touchAction([
|
|
145
|
+
// { action: 'press', x: width - 10, y: height / 2 }, // Start near the right edge
|
|
146
|
+
// { action: 'wait', ms: 500 }, // Hold to stabilize
|
|
147
|
+
// { action: 'moveTo', x: 10, y: height / 2 }, // Move to the left edge
|
|
148
|
+
// { action: 'release' }
|
|
149
|
+
// ]);
|
|
150
|
+
// // ⬅ Swipe from Left to Right (Full Swipe)
|
|
151
|
+
|
|
152
|
+
// await driver.touchAction([
|
|
153
|
+
// { action: 'press', x: 10, y: height / 2 }, // Start near the left edge
|
|
154
|
+
// { action: 'wait', ms: 500 },
|
|
155
|
+
// { action: 'moveTo', x: width - 10, y: height / 2 }, // Move to the right edge
|
|
156
|
+
// { action: 'release' }
|
|
157
|
+
// ]);
|
|
158
|
+
|
|
159
|
+
// } catch (error) {
|
|
160
|
+
// console.error(error.message);
|
|
161
|
+
// }
|
|
162
|
+
// }
|
|
163
|
+
module.exports = { swipeleft, swipedown, swiperight, swipeup, swipetofit ,swipewithcoordinates};
|