appium-uiautomator2-driver 6.7.5 → 6.7.7
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/CHANGELOG.md +12 -0
- package/build/lib/commands/actions.d.ts +26 -29
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +19 -27
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +14 -22
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +8 -19
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +7 -10
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +4 -14
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/battery.d.ts +4 -5
- package/build/lib/commands/battery.d.ts.map +1 -1
- package/build/lib/commands/battery.js +4 -9
- package/build/lib/commands/battery.js.map +1 -1
- package/build/lib/commands/clipboard.d.ts +9 -13
- package/build/lib/commands/clipboard.d.ts.map +1 -1
- package/build/lib/commands/clipboard.js +7 -14
- package/build/lib/commands/clipboard.js.map +1 -1
- package/build/lib/commands/element.d.ts +64 -69
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +64 -84
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/find.d.ts +13 -9
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +4 -16
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/gestures.d.ts +87 -189
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js +77 -204
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +30 -41
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +22 -37
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/misc.d.ts +19 -35
- package/build/lib/commands/misc.d.ts.map +1 -1
- package/build/lib/commands/misc.js +15 -30
- package/build/lib/commands/misc.js.map +1 -1
- package/build/lib/commands/navigation.d.ts +11 -16
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js +9 -17
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/viewport.d.ts +23 -22
- package/build/lib/commands/viewport.d.ts.map +1 -1
- package/build/lib/commands/viewport.js +17 -24
- package/build/lib/commands/viewport.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/commands/actions.ts +95 -0
- package/lib/commands/alert.ts +46 -0
- package/lib/commands/app-management.ts +25 -0
- package/lib/commands/battery.ts +19 -0
- package/lib/commands/clipboard.ts +29 -0
- package/lib/commands/element.ts +180 -0
- package/lib/commands/find.ts +48 -0
- package/lib/commands/gestures.ts +297 -0
- package/lib/commands/keyboard.ts +102 -0
- package/lib/commands/misc.ts +67 -0
- package/lib/commands/navigation.ts +32 -0
- package/lib/commands/viewport.ts +78 -0
- package/npm-shrinkwrap.json +16 -46
- package/package.json +1 -1
- package/lib/commands/actions.js +0 -107
- package/lib/commands/alert.js +0 -63
- package/lib/commands/app-management.js +0 -32
- package/lib/commands/battery.js +0 -23
- package/lib/commands/clipboard.js +0 -37
- package/lib/commands/element.js +0 -261
- package/lib/commands/find.js +0 -47
- package/lib/commands/gestures.js +0 -446
- package/lib/commands/keyboard.js +0 -108
- package/lib/commands/misc.js +0 -109
- package/lib/commands/navigation.js +0 -33
- package/lib/commands/viewport.js +0 -100
package/lib/commands/gestures.js
DELETED
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import {util} from 'appium/support';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import {errors} from 'appium/driver';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Performs a simple click/tap gesture
|
|
7
|
-
*
|
|
8
|
-
* @this {AndroidUiautomator2Driver}
|
|
9
|
-
* @param {string} [elementId] The id of the element to be clicked.
|
|
10
|
-
* If the element is missing then both click offset coordinates must be provided.
|
|
11
|
-
* If both the element id and offset are provided then the coordinates are parsed
|
|
12
|
-
* as relative offsets from the top left corner of the element.
|
|
13
|
-
* @param {number} [x] The x coordinate to click on.
|
|
14
|
-
* @param {number} [y] The y coordinate to click on.
|
|
15
|
-
* @returns {Promise<void>}
|
|
16
|
-
* @throws {Error} if provided options are not valid
|
|
17
|
-
*/
|
|
18
|
-
export async function mobileClickGesture(elementId, x, y) {
|
|
19
|
-
await this.uiautomator2.jwproxy.command(
|
|
20
|
-
'/appium/gestures/click',
|
|
21
|
-
'POST',
|
|
22
|
-
{
|
|
23
|
-
origin: toOrigin(elementId),
|
|
24
|
-
offset: toPoint(x, y),
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Performs a click that lasts for the given duration
|
|
31
|
-
*
|
|
32
|
-
* @this {AndroidUiautomator2Driver}
|
|
33
|
-
* @param {string} [elementId] The id of the element to be clicked.
|
|
34
|
-
* If the element is missing then both click offset coordinates must be provided.
|
|
35
|
-
* If both the element id and offset are provided then the coordinates are parsed
|
|
36
|
-
* as relative offsets from the top left corner of the element.
|
|
37
|
-
* @param {number} [x] The x coordinate to click on.
|
|
38
|
-
* @param {number} [y] The y coordinate to click on.
|
|
39
|
-
* @param {number} [duration] Click duration in milliseconds. The value must not be negative.
|
|
40
|
-
* Default is 500.
|
|
41
|
-
* @returns {Promise<void>}
|
|
42
|
-
* @throws {Error} if provided options are not valid
|
|
43
|
-
*/
|
|
44
|
-
export async function mobileLongClickGesture(elementId, x, y, duration) {
|
|
45
|
-
await this.uiautomator2.jwproxy.command(
|
|
46
|
-
'/appium/gestures/long_click',
|
|
47
|
-
'POST',
|
|
48
|
-
{
|
|
49
|
-
origin: toOrigin(elementId),
|
|
50
|
-
offset: toPoint(x, y),
|
|
51
|
-
duration,
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Performs a click that lasts for the given duration
|
|
58
|
-
* @this {AndroidUiautomator2Driver}
|
|
59
|
-
* @param {string} [elementId] The id of the element to be clicked.
|
|
60
|
-
* If the element is missing then both click offset coordinates must be provided.
|
|
61
|
-
* If both the element id and offset are provided then the coordinates are parsed
|
|
62
|
-
* as relative offsets from the top left corner of the element.
|
|
63
|
-
* @param {number} [x] The x coordinate to click on.
|
|
64
|
-
* @param {number} [y] The y coordinate to click on.
|
|
65
|
-
* @returns {Promise<void>}
|
|
66
|
-
* @throws {Error} if provided options are not valid
|
|
67
|
-
*/
|
|
68
|
-
export async function mobileDoubleClickGesture(elementId, x, y) {
|
|
69
|
-
await this.uiautomator2.jwproxy.command(
|
|
70
|
-
'/appium/gestures/double_click',
|
|
71
|
-
'POST',
|
|
72
|
-
{
|
|
73
|
-
origin: toOrigin(elementId),
|
|
74
|
-
offset: toPoint(x, y),
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Drags this object to the specified location.
|
|
81
|
-
* @this {AndroidUiautomator2Driver}
|
|
82
|
-
* @param {string} [elementId] The id of the element to be dragged.
|
|
83
|
-
* If the element id is missing then the start coordinates must be provided.
|
|
84
|
-
* If both the element id and the start coordinates are provided then these
|
|
85
|
-
* coordinates are considered as offsets from the top left element corner.
|
|
86
|
-
* @param {number} [startX] The x coordinate where the dragging starts
|
|
87
|
-
* @param {number} [startY] The y coordinate where the dragging starts
|
|
88
|
-
* @param {number} [endX] The x coordinate where the dragging ends
|
|
89
|
-
* @param {number} [endY] The y coordinate where the dragging ends
|
|
90
|
-
* @param {number} [speed] The speed at which to perform this gesture in pixels per second.
|
|
91
|
-
* The value must not be negative.
|
|
92
|
-
* Default is 2500 * displayDensity.
|
|
93
|
-
* @returns {Promise<void>}
|
|
94
|
-
* @throws {Error} if provided options are not valid
|
|
95
|
-
*/
|
|
96
|
-
export async function mobileDragGesture(
|
|
97
|
-
elementId,
|
|
98
|
-
startX,
|
|
99
|
-
startY,
|
|
100
|
-
endX,
|
|
101
|
-
endY,
|
|
102
|
-
speed,
|
|
103
|
-
) {
|
|
104
|
-
await this.uiautomator2.jwproxy.command(
|
|
105
|
-
'/appium/gestures/drag',
|
|
106
|
-
'POST',
|
|
107
|
-
{
|
|
108
|
-
origin: toOrigin(elementId),
|
|
109
|
-
start: toPoint(startX, startY),
|
|
110
|
-
end: toPoint(endX, endY),
|
|
111
|
-
speed,
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Drags to the specified location.
|
|
118
|
-
*
|
|
119
|
-
* @throws {Error} if provided options are not valid
|
|
120
|
-
* @this {AndroidUiautomator2Driver}
|
|
121
|
-
* @param {string} direction Direction of the fling.
|
|
122
|
-
* Acceptable values are: `up`, `down`, `left` and `right` (case insensitive).
|
|
123
|
-
* @param {string} [elementId] The id of the element to be flinged.
|
|
124
|
-
* If the element id is missing then fling bounding area must be provided.
|
|
125
|
-
* If both the element id and the fling bounding area are provided then this
|
|
126
|
-
* area is effectively ignored.
|
|
127
|
-
* @param {number} [left] The left coordinate of the fling bounding area.
|
|
128
|
-
* @param {number} [top] The top coordinate of the fling bounding area.
|
|
129
|
-
* @param {number} [width] The width of the fling bounding area.
|
|
130
|
-
* @param {number} [height] The height of the fling bounding area.
|
|
131
|
-
* @param {number} [speed] The speed at which to perform this gesture in pixels per second.
|
|
132
|
-
* The value must be greater than the minimum fling velocity for the given view (50 by default).
|
|
133
|
-
* Default is 7500 * displayDensity.
|
|
134
|
-
* @returns {Promise<boolean>} True if the object can still scroll in the given direction.
|
|
135
|
-
*/
|
|
136
|
-
export async function mobileFlingGesture(
|
|
137
|
-
direction,
|
|
138
|
-
elementId,
|
|
139
|
-
left,
|
|
140
|
-
top,
|
|
141
|
-
width,
|
|
142
|
-
height,
|
|
143
|
-
speed,
|
|
144
|
-
) {
|
|
145
|
-
return /** @type {boolean} */ (
|
|
146
|
-
await this.uiautomator2.jwproxy.command(
|
|
147
|
-
'/appium/gestures/fling',
|
|
148
|
-
'POST',
|
|
149
|
-
{
|
|
150
|
-
origin: toOrigin(elementId),
|
|
151
|
-
area: toRect(left, top, width, height),
|
|
152
|
-
direction,
|
|
153
|
-
speed,
|
|
154
|
-
}
|
|
155
|
-
)
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Performs a pinch close gesture.
|
|
161
|
-
* @this {AndroidUiautomator2Driver}
|
|
162
|
-
* @param {number} percent The size of the pinch as a percentage of the pinch area size.
|
|
163
|
-
* Valid values must be float numbers in range 0..1, where 1.0 is 100%
|
|
164
|
-
* @param {string} [elementId] The id of the element to be pinched.
|
|
165
|
-
* If the element id is missing then pinch bounding area must be provided.
|
|
166
|
-
* If both the element id and the pinch bounding area are provided then the
|
|
167
|
-
* area is effectively ignored.
|
|
168
|
-
* @param {number} [left] The left coordinate of the pinch bounding area.
|
|
169
|
-
* @param {number} [top] The top coordinate of the pinch bounding area.
|
|
170
|
-
* @param {number} [width] The width of the pinch bounding area.
|
|
171
|
-
* @param {number} [height] The height of the pinch bounding area.
|
|
172
|
-
* @param {number} [speed] The speed at which to perform this gesture in pixels per second.
|
|
173
|
-
* The value must not be negative.
|
|
174
|
-
* Default is 2500 * displayDensity.
|
|
175
|
-
* @returns {Promise<void>}
|
|
176
|
-
* @throws {Error} if provided options are not valid
|
|
177
|
-
*/
|
|
178
|
-
export async function mobilePinchCloseGesture(
|
|
179
|
-
percent,
|
|
180
|
-
elementId,
|
|
181
|
-
left,
|
|
182
|
-
top,
|
|
183
|
-
width,
|
|
184
|
-
height,
|
|
185
|
-
speed,
|
|
186
|
-
) {
|
|
187
|
-
await this.uiautomator2.jwproxy.command(
|
|
188
|
-
'/appium/gestures/pinch_close',
|
|
189
|
-
'POST',
|
|
190
|
-
{
|
|
191
|
-
origin: toOrigin(elementId),
|
|
192
|
-
area: toRect(left, top, width, height),
|
|
193
|
-
percent,
|
|
194
|
-
speed,
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Performs a pinch open gesture.
|
|
201
|
-
* @this {AndroidUiautomator2Driver}
|
|
202
|
-
* @param {number} percent The size of the pinch as a percentage of the pinch area size.
|
|
203
|
-
* Valid values must be float numbers in range 0..1, where 1.0 is 100%
|
|
204
|
-
* @param {string} [elementId] The id of the element to be pinched.
|
|
205
|
-
* If the element id is missing then pinch bounding area must be provided.
|
|
206
|
-
* If both the element id and the pinch bounding area are provided then the
|
|
207
|
-
* area is effectively ignored.
|
|
208
|
-
* @param {number} [left] The left coordinate of the pinch bounding area.
|
|
209
|
-
* @param {number} [top] The top coordinate of the pinch bounding area.
|
|
210
|
-
* @param {number} [width] The width of the pinch bounding area.
|
|
211
|
-
* @param {number} [height] The height of the pinch bounding area.
|
|
212
|
-
* @param {number} [speed] The speed at which to perform this gesture in pixels per second.
|
|
213
|
-
* The value must not be negative.
|
|
214
|
-
* Default is 2500 * displayDensity.
|
|
215
|
-
* @returns {Promise<void>}
|
|
216
|
-
* @throws {Error} if provided options are not valid
|
|
217
|
-
*/
|
|
218
|
-
export async function mobilePinchOpenGesture(
|
|
219
|
-
percent,
|
|
220
|
-
elementId,
|
|
221
|
-
left,
|
|
222
|
-
top,
|
|
223
|
-
width,
|
|
224
|
-
height,
|
|
225
|
-
speed,
|
|
226
|
-
) {
|
|
227
|
-
await this.uiautomator2.jwproxy.command(
|
|
228
|
-
'/appium/gestures/pinch_open',
|
|
229
|
-
'POST',
|
|
230
|
-
{
|
|
231
|
-
origin: toOrigin(elementId),
|
|
232
|
-
area: toRect(left, top, width, height),
|
|
233
|
-
percent,
|
|
234
|
-
speed,
|
|
235
|
-
}
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Performs a swipe gesture.
|
|
241
|
-
* @this {AndroidUiautomator2Driver}
|
|
242
|
-
* @param {string} direction Direction of the swipe.
|
|
243
|
-
* Acceptable values are: `up`, `down`, `left` and `right` (case insensitive).
|
|
244
|
-
* @param {number} percent The size of the swipe as a percentage of the swipe area size.
|
|
245
|
-
* Valid values must be float numbers in range 0..1, where 1.0 is 100%.
|
|
246
|
-
* @param {string} [elementId] The id of the element to be swiped.
|
|
247
|
-
* If the element id is missing then swipe bounding area must be provided.
|
|
248
|
-
* If both the element id and the swipe bounding area are provided then the
|
|
249
|
-
* area is effectively ignored.
|
|
250
|
-
* @param {number} [left] The left coordinate of the swipe bounding area.
|
|
251
|
-
* @param {number} [top] The top coordinate of the swipe bounding area.
|
|
252
|
-
* @param {number} [width] The width of the swipe bounding area.
|
|
253
|
-
* @param {number} [height] The height of the swipe bounding area.
|
|
254
|
-
* @param {number} [speed] The speed at which to perform this gesture in pixels per second.
|
|
255
|
-
* The value must not be negative.
|
|
256
|
-
* Default is 5000 * displayDensity.
|
|
257
|
-
* @returns {Promise<void>}
|
|
258
|
-
* @throws {Error} if provided options are not valid
|
|
259
|
-
*/
|
|
260
|
-
export async function mobileSwipeGesture(
|
|
261
|
-
direction,
|
|
262
|
-
percent,
|
|
263
|
-
elementId,
|
|
264
|
-
left,
|
|
265
|
-
top,
|
|
266
|
-
width,
|
|
267
|
-
height,
|
|
268
|
-
speed,
|
|
269
|
-
) {
|
|
270
|
-
await this.uiautomator2.jwproxy.command(
|
|
271
|
-
'/appium/gestures/swipe',
|
|
272
|
-
'POST',
|
|
273
|
-
{
|
|
274
|
-
origin: toOrigin(elementId),
|
|
275
|
-
area: toRect(left, top, width, height),
|
|
276
|
-
direction,
|
|
277
|
-
percent,
|
|
278
|
-
speed,
|
|
279
|
-
}
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Performs a scroll gesture.
|
|
285
|
-
*
|
|
286
|
-
* @throws {Error} if provided options are not valid
|
|
287
|
-
* @this {AndroidUiautomator2Driver}
|
|
288
|
-
* @param {string} direction Direction of the scroll.
|
|
289
|
-
* Acceptable values are: `up`, `down`, `left` and `right` (case insensitive).
|
|
290
|
-
* @param {number} percent The size of the scroll as a percentage of the scrolling area size.
|
|
291
|
-
* Valid values must be float numbers greater than zero, where 1.0 is 100%.
|
|
292
|
-
* @param {string} [elementId] The id of the element to be scrolled.
|
|
293
|
-
* If the element id is missing then scroll bounding area must be provided.
|
|
294
|
-
* If both the element id and the scroll bounding area are provided then this
|
|
295
|
-
* area is effectively ignored.
|
|
296
|
-
* @param {number} [left] The left coordinate of the scroll bounding area.
|
|
297
|
-
* @param {number} [top] The top coordinate of the scroll bounding area.
|
|
298
|
-
* @param {number} [width] The width of the scroll bounding area.
|
|
299
|
-
* @param {number} [height] The height of the scroll bounding area.
|
|
300
|
-
* @param {number} [speed] The speed at which to perform this gesture in pixels per second.
|
|
301
|
-
* The value must not be negative.
|
|
302
|
-
* Default is 5000 * displayDensity.
|
|
303
|
-
* @returns {Promise<boolean>} True if the object can still scroll in the given direction.
|
|
304
|
-
*/
|
|
305
|
-
export async function mobileScrollGesture(
|
|
306
|
-
direction,
|
|
307
|
-
percent,
|
|
308
|
-
elementId,
|
|
309
|
-
left,
|
|
310
|
-
top,
|
|
311
|
-
width,
|
|
312
|
-
height,
|
|
313
|
-
speed,
|
|
314
|
-
) {
|
|
315
|
-
return /** @type {boolean} */ (
|
|
316
|
-
await this.uiautomator2.jwproxy.command(
|
|
317
|
-
'/appium/gestures/scroll',
|
|
318
|
-
'POST',
|
|
319
|
-
{
|
|
320
|
-
origin: toOrigin(elementId),
|
|
321
|
-
area: toRect(left, top, width, height),
|
|
322
|
-
direction,
|
|
323
|
-
percent,
|
|
324
|
-
speed,
|
|
325
|
-
}
|
|
326
|
-
)
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Scrolls the given scrollable element `elementId` until `elementToId`
|
|
332
|
-
* becomes visible. This function returns immediately if the `elementToId`
|
|
333
|
-
* is already visible in the view port. Otherwise it would scroll
|
|
334
|
-
* to the very beginning of the scrollable control and tries to reach the destination element
|
|
335
|
-
* by scrolling its parent to the end step by step. The scroll direction (vertical or horizontal)
|
|
336
|
-
* is detected automatically.
|
|
337
|
-
* @this {AndroidUiautomator2Driver}
|
|
338
|
-
* @param {string} elementId The identifier of the scrollable element, which is going to be scrolled.
|
|
339
|
-
* It is required this element is a valid scrollable container and it was located
|
|
340
|
-
* by `-android uiautomator` strategy.
|
|
341
|
-
* @param {string} elementToId The identifier of the item, which belongs to the scrollable element above,
|
|
342
|
-
* and which should become visible after the scrolling operation is finished.
|
|
343
|
-
* It is required this element was located by `-android uiautomator` strategy.
|
|
344
|
-
* @returns {Promise<void>}
|
|
345
|
-
* @throws {Error} if the scrolling operation cannot be performed
|
|
346
|
-
*/
|
|
347
|
-
export async function mobileScrollBackTo(elementId, elementToId) {
|
|
348
|
-
if (!elementId || !elementToId) {
|
|
349
|
-
throw new errors.InvalidArgumentError(
|
|
350
|
-
`Both elementId and elementToId arguments must be provided`
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
await this.uiautomator2.jwproxy.command(
|
|
354
|
-
`/appium/element/${util.unwrapElement(elementId)}/scroll_to/${util.unwrapElement(
|
|
355
|
-
elementToId
|
|
356
|
-
)}`,
|
|
357
|
-
'POST',
|
|
358
|
-
{}
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Scrolls the given scrollable element until the element identified
|
|
364
|
-
* by `strategy` and `selector` becomes visible. This function returns immediately if the
|
|
365
|
-
* destination element is already visible in the view port. Otherwise it would scroll
|
|
366
|
-
* to the very beginning of the scrollable control and tries to reach the destination element
|
|
367
|
-
* by scrolling its parent to the end step by step. The scroll direction (vertical or horizontal)
|
|
368
|
-
* is detected automatically.
|
|
369
|
-
*
|
|
370
|
-
* @this {AndroidUiautomator2Driver}
|
|
371
|
-
* @param {string} strategy The following strategies are supported:
|
|
372
|
-
* - `accessibility id` (UiSelector().description)
|
|
373
|
-
* - `class name` (UiSelector().className)
|
|
374
|
-
* - `-android uiautomator` (UiSelector)
|
|
375
|
-
* @param {string} selector The corresponding lookup value for the given strategy.
|
|
376
|
-
* @param {string} [elementId] The identifier of an element. It is required this element is a valid scrollable container
|
|
377
|
-
* and it was located by `-android uiautomator` strategy.
|
|
378
|
-
* If this property is not provided then the first currently available scrollable view
|
|
379
|
-
* is selected for the interaction.
|
|
380
|
-
* @param {number} [maxSwipes] The maximum number of swipes to perform on the target scrollable view in order to reach
|
|
381
|
-
* the destination element. In case this value is unset then it would be retrieved from the
|
|
382
|
-
* scrollable element itself (via `getMaxSearchSwipes()` property).
|
|
383
|
-
* @returns {Promise<void>}
|
|
384
|
-
* @throws {Error} if the scrolling operation cannot be performed
|
|
385
|
-
*/
|
|
386
|
-
export async function mobileScroll(
|
|
387
|
-
strategy,
|
|
388
|
-
selector,
|
|
389
|
-
elementId,
|
|
390
|
-
maxSwipes,
|
|
391
|
-
) {
|
|
392
|
-
if (!strategy || !selector) {
|
|
393
|
-
throw new errors.InvalidArgumentError(
|
|
394
|
-
`Both strategy and selector arguments must be provided`
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
await this.uiautomator2.jwproxy.command(
|
|
398
|
-
'/gestures/scroll_to',
|
|
399
|
-
'POST',
|
|
400
|
-
{
|
|
401
|
-
origin: toOrigin(elementId),
|
|
402
|
-
params: {strategy, selector, maxSwipes},
|
|
403
|
-
}
|
|
404
|
-
);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// #region Internal Helpers
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
*
|
|
411
|
-
* @param {import('@appium/types').Element|string} [element]
|
|
412
|
-
* @returns {import('@appium/types').Element|undefined}
|
|
413
|
-
*/
|
|
414
|
-
function toOrigin(element) {
|
|
415
|
-
return element ? util.wrapElement(util.unwrapElement(element)) : undefined;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
*
|
|
420
|
-
* @param {number} [x]
|
|
421
|
-
* @param {number} [y]
|
|
422
|
-
* @returns {Partial<import('@appium/types').Position>|undefined}
|
|
423
|
-
*/
|
|
424
|
-
function toPoint(x, y) {
|
|
425
|
-
return _.isFinite(x) && _.isFinite(y) ? {x, y} : undefined;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
*
|
|
430
|
-
* @param {number} [left]
|
|
431
|
-
* @param {number} [top]
|
|
432
|
-
* @param {number} [width]
|
|
433
|
-
* @param {number} [height]
|
|
434
|
-
* @returns {Partial<import('./types').RelativeRect>|undefined}
|
|
435
|
-
*/
|
|
436
|
-
function toRect(left, top, width, height) {
|
|
437
|
-
return [left, top, width, height].some((v) => !_.isFinite(v))
|
|
438
|
-
? undefined
|
|
439
|
-
: {left, top, width, height};
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// #endregion
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
|
|
446
|
-
*/
|
package/lib/commands/keyboard.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { errors } from 'appium/driver';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @this {AndroidUiautomator2Driver}
|
|
6
|
-
* @param {string|number} keycode
|
|
7
|
-
* @param {number} [metastate]
|
|
8
|
-
* @param {number} [flags]
|
|
9
|
-
* @returns {Promise<void>}
|
|
10
|
-
*/
|
|
11
|
-
export async function pressKeyCode(keycode, metastate, flags) {
|
|
12
|
-
await this.uiautomator2.jwproxy.command(
|
|
13
|
-
'/appium/device/press_keycode',
|
|
14
|
-
'POST',
|
|
15
|
-
{
|
|
16
|
-
keycode,
|
|
17
|
-
metastate,
|
|
18
|
-
flags,
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @this {AndroidUiautomator2Driver}
|
|
25
|
-
* @param {string|number} keycode
|
|
26
|
-
* @param {number} metastate
|
|
27
|
-
* @param {number} [flags]
|
|
28
|
-
* @returns {Promise<void>}
|
|
29
|
-
*/
|
|
30
|
-
export async function longPressKeyCode(keycode, metastate, flags) {
|
|
31
|
-
await this.uiautomator2.jwproxy.command(
|
|
32
|
-
'/appium/device/long_press_keycode',
|
|
33
|
-
'POST',
|
|
34
|
-
{
|
|
35
|
-
keycode,
|
|
36
|
-
metastate,
|
|
37
|
-
flags,
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @this {AndroidUiautomator2Driver}
|
|
44
|
-
* @param {number} keycode A valid Android key code. See https://developer.android.com/reference/android/view/KeyEvent
|
|
45
|
-
* for the list of available key codes.
|
|
46
|
-
* @param {number} [metastate] An integer in which each bit set to 1 represents a pressed meta key. See
|
|
47
|
-
* https://developer.android.com/reference/android/view/KeyEvent for more details.
|
|
48
|
-
* @param {string} [flags] Flags for the particular key event. See
|
|
49
|
-
* https://developer.android.com/reference/android/view/KeyEvent for more details.
|
|
50
|
-
* @param {boolean} [isLongPress=false] Whether to emulate long key press
|
|
51
|
-
* @returns {Promise<void>}
|
|
52
|
-
*/
|
|
53
|
-
export async function mobilePressKey(keycode, metastate, flags, isLongPress = false) {
|
|
54
|
-
await this.uiautomator2.jwproxy.command(
|
|
55
|
-
`/appium/device/${isLongPress ? 'long_' : ''}press_keycode`,
|
|
56
|
-
'POST',
|
|
57
|
-
{
|
|
58
|
-
keycode,
|
|
59
|
-
metastate,
|
|
60
|
-
flags,
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Types the given Unicode string.
|
|
67
|
-
* It is expected that the focus is already put
|
|
68
|
-
* to the destination input field before this method is called.
|
|
69
|
-
*
|
|
70
|
-
* @this {AndroidUiautomator2Driver}
|
|
71
|
-
* @param {string | number | boolean} text The text to type. Can be a string, number or boolean.
|
|
72
|
-
* @returns {Promise<boolean>} `true` if the input text has been successfully sent to adb
|
|
73
|
-
* @throws {Error} if `text` property has not been provided
|
|
74
|
-
*/
|
|
75
|
-
export async function mobileType(text) {
|
|
76
|
-
if (_.isUndefined(text)) {
|
|
77
|
-
throw new errors.InvalidArgumentError(`The 'text' argument is mandatory`);
|
|
78
|
-
}
|
|
79
|
-
return await this.settingsApp.typeUnicode(String(text));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @this {AndroidUiautomator2Driver}
|
|
84
|
-
* @param {import('appium-android-driver').SendKeysOpts} params
|
|
85
|
-
* @returns {Promise<void>}
|
|
86
|
-
*/
|
|
87
|
-
export async function doSendKeys(params) {
|
|
88
|
-
await this.uiautomator2.jwproxy.command(
|
|
89
|
-
'/keys',
|
|
90
|
-
'POST',
|
|
91
|
-
params
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @this {AndroidUiautomator2Driver}
|
|
97
|
-
* @param {string|number} keycode
|
|
98
|
-
* @param {number} [metastate]
|
|
99
|
-
* @returns {Promise<void>}
|
|
100
|
-
*/
|
|
101
|
-
export async function keyevent(keycode, metastate) {
|
|
102
|
-
this.log.debug(`Ignoring metastate ${metastate}`);
|
|
103
|
-
await this.adb.keyevent(keycode);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
|
|
108
|
-
*/
|
package/lib/commands/misc.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @this {AndroidUiautomator2Driver}
|
|
3
|
-
* @returns {Promise<string>}
|
|
4
|
-
*/
|
|
5
|
-
export async function getPageSource() {
|
|
6
|
-
return String(
|
|
7
|
-
await this.uiautomator2.jwproxy.command(
|
|
8
|
-
'/source',
|
|
9
|
-
'GET',
|
|
10
|
-
{}
|
|
11
|
-
)
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @this {AndroidUiautomator2Driver}
|
|
17
|
-
* @returns {Promise<import('@appium/types').Orientation>}
|
|
18
|
-
*/
|
|
19
|
-
export async function getOrientation() {
|
|
20
|
-
return /** @type {import('@appium/types').Orientation} */ (
|
|
21
|
-
await this.uiautomator2.jwproxy.command(
|
|
22
|
-
`/orientation`,
|
|
23
|
-
'GET',
|
|
24
|
-
{}
|
|
25
|
-
)
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @this {AndroidUiautomator2Driver}
|
|
31
|
-
* @param {import('@appium/types').Orientation} orientation
|
|
32
|
-
* @returns {Promise<void>}
|
|
33
|
-
*/
|
|
34
|
-
export async function setOrientation(orientation) {
|
|
35
|
-
orientation = /** @type {import('@appium/types').Orientation} */ (orientation.toUpperCase());
|
|
36
|
-
await this.uiautomator2.jwproxy.command(
|
|
37
|
-
`/orientation`,
|
|
38
|
-
'POST',
|
|
39
|
-
{orientation}
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @this {AndroidUiautomator2Driver}
|
|
45
|
-
* @returns {Promise<void>}
|
|
46
|
-
*/
|
|
47
|
-
export async function openNotifications() {
|
|
48
|
-
await this.uiautomator2.jwproxy.command(
|
|
49
|
-
'/appium/device/open_notifications',
|
|
50
|
-
'POST',
|
|
51
|
-
{}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Stop proxying to any Chromedriver and redirect to uiautomator2
|
|
57
|
-
* @this {AndroidUiautomator2Driver}
|
|
58
|
-
* @returns {void}
|
|
59
|
-
*/
|
|
60
|
-
export function suspendChromedriverProxy() {
|
|
61
|
-
if (!this.uiautomator2?.proxyReqRes || !this.uiautomator2?.proxyCommand) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
this.chromedriver = undefined;
|
|
66
|
-
this.proxyReqRes = this.uiautomator2.proxyReqRes.bind(
|
|
67
|
-
this.uiautomator2
|
|
68
|
-
);
|
|
69
|
-
this.proxyCommand = /** @type {typeof this.proxyCommand} */ (
|
|
70
|
-
this.uiautomator2.proxyCommand.bind(this.uiautomator2)
|
|
71
|
-
);
|
|
72
|
-
this.jwpProxyActive = true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* The list of available info entries can be found at
|
|
77
|
-
* https://github.com/appium/appium-uiautomator2-server/blob/master/app/src/main/java/io/appium/uiautomator2/handler/GetDeviceInfo.java
|
|
78
|
-
* @this {AndroidUiautomator2Driver}
|
|
79
|
-
* @returns {Promise<StringRecord>}
|
|
80
|
-
*/
|
|
81
|
-
export async function mobileGetDeviceInfo() {
|
|
82
|
-
return /** @type {StringRecord} */ (
|
|
83
|
-
await this.uiautomator2.jwproxy.command(
|
|
84
|
-
'/appium/device/info',
|
|
85
|
-
'GET'
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Resets the accessibility cache on the device.
|
|
92
|
-
* This can be useful when the accessibility service cache becomes stale
|
|
93
|
-
* and needs to be refreshed to reflect the current UI state.
|
|
94
|
-
* @this {AndroidUiautomator2Driver}
|
|
95
|
-
* @returns {Promise<void>}
|
|
96
|
-
*/
|
|
97
|
-
export async function mobileResetAccessibilityCache() {
|
|
98
|
-
await this.uiautomator2.jwproxy.command(
|
|
99
|
-
'/appium/reset_ax_cache',
|
|
100
|
-
'POST',
|
|
101
|
-
{}
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* @template [T=any]
|
|
107
|
-
* @typedef {import('@appium/types').StringRecord<T>} StringRecord
|
|
108
|
-
* @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
|
|
109
|
-
*/
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @this {AndroidUiautomator2Driver}
|
|
3
|
-
* @param {string} url
|
|
4
|
-
* @returns {Promise<void>}
|
|
5
|
-
*/
|
|
6
|
-
export async function setUrl(url) {
|
|
7
|
-
await this.adb.startUri(url, /** @type {string} */ (this.opts.appPackage));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Start URL that take users directly to specific content in the app
|
|
12
|
-
* @this {AndroidUiautomator2Driver}
|
|
13
|
-
* @param {string} url The name of URL to start.
|
|
14
|
-
* @param {string} [pkg] The name of the package to start the URI with.
|
|
15
|
-
* @param {boolean} [waitForLaunch=true] If `false` then adb won't wait for
|
|
16
|
-
* the started activity to return the control.
|
|
17
|
-
* @returns {Promise<void>}
|
|
18
|
-
*/
|
|
19
|
-
export async function mobileDeepLink(url, pkg, waitForLaunch) {
|
|
20
|
-
return await this.adb.startUri(url, pkg, {waitForLaunch});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @this {AndroidUiautomator2Driver}
|
|
25
|
-
* @returns {Promise<void>}
|
|
26
|
-
*/
|
|
27
|
-
export async function back() {
|
|
28
|
-
await this.adb.keyevent(4);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
|
|
33
|
-
*/
|