appium-uiautomator2-driver 3.10.0 → 4.0.0

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 (72) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/build/lib/commands/actions.d.ts +13 -7
  3. package/build/lib/commands/actions.d.ts.map +1 -1
  4. package/build/lib/commands/actions.js +24 -10
  5. package/build/lib/commands/actions.js.map +1 -1
  6. package/build/lib/commands/alert.d.ts +8 -4
  7. package/build/lib/commands/alert.d.ts.map +1 -1
  8. package/build/lib/commands/alert.js +10 -6
  9. package/build/lib/commands/alert.js.map +1 -1
  10. package/build/lib/commands/app-management.d.ts +10 -6
  11. package/build/lib/commands/app-management.d.ts.map +1 -1
  12. package/build/lib/commands/app-management.js +13 -10
  13. package/build/lib/commands/app-management.js.map +1 -1
  14. package/build/lib/commands/clipboard.d.ts +0 -12
  15. package/build/lib/commands/clipboard.d.ts.map +1 -1
  16. package/build/lib/commands/clipboard.js +0 -18
  17. package/build/lib/commands/clipboard.js.map +1 -1
  18. package/build/lib/commands/element.d.ts +3 -2
  19. package/build/lib/commands/element.d.ts.map +1 -1
  20. package/build/lib/commands/element.js +3 -4
  21. package/build/lib/commands/element.js.map +1 -1
  22. package/build/lib/commands/gestures.d.ts +130 -22
  23. package/build/lib/commands/gestures.d.ts.map +1 -1
  24. package/build/lib/commands/gestures.js +130 -33
  25. package/build/lib/commands/gestures.js.map +1 -1
  26. package/build/lib/commands/keyboard.d.ts +11 -4
  27. package/build/lib/commands/keyboard.d.ts.map +1 -1
  28. package/build/lib/commands/keyboard.js +13 -7
  29. package/build/lib/commands/keyboard.js.map +1 -1
  30. package/build/lib/commands/navigation.d.ts +5 -2
  31. package/build/lib/commands/navigation.d.ts.map +1 -1
  32. package/build/lib/commands/navigation.js +5 -3
  33. package/build/lib/commands/navigation.js.map +1 -1
  34. package/build/lib/commands/screenshot.d.ts +4 -2
  35. package/build/lib/commands/screenshot.d.ts.map +1 -1
  36. package/build/lib/commands/screenshot.js +4 -3
  37. package/build/lib/commands/screenshot.js.map +1 -1
  38. package/build/lib/commands/types.d.ts +0 -387
  39. package/build/lib/commands/types.d.ts.map +1 -1
  40. package/build/lib/driver.d.ts +540 -8
  41. package/build/lib/driver.d.ts.map +1 -1
  42. package/build/lib/driver.js +2 -7
  43. package/build/lib/driver.js.map +1 -1
  44. package/build/lib/execute-method-map.d.ts +540 -0
  45. package/build/lib/execute-method-map.d.ts.map +1 -0
  46. package/build/lib/execute-method-map.js +257 -0
  47. package/build/lib/execute-method-map.js.map +1 -0
  48. package/build/tsconfig.tsbuildinfo +1 -1
  49. package/lib/commands/actions.js +32 -10
  50. package/lib/commands/alert.js +10 -6
  51. package/lib/commands/app-management.js +14 -11
  52. package/lib/commands/clipboard.js +0 -18
  53. package/lib/commands/element.js +3 -4
  54. package/lib/commands/gestures.js +184 -38
  55. package/lib/commands/keyboard.js +13 -8
  56. package/lib/commands/navigation.js +5 -3
  57. package/lib/commands/screenshot.js +4 -3
  58. package/lib/commands/types.ts +0 -406
  59. package/lib/driver.ts +2 -16
  60. package/lib/execute-method-map.ts +269 -0
  61. package/npm-shrinkwrap.json +34 -41
  62. package/package.json +2 -2
  63. package/build/lib/commands/app-strings.d.ts +0 -12
  64. package/build/lib/commands/app-strings.d.ts.map +0 -1
  65. package/build/lib/commands/app-strings.js +0 -19
  66. package/build/lib/commands/app-strings.js.map +0 -1
  67. package/build/lib/commands/execute.d.ts +0 -15
  68. package/build/lib/commands/execute.d.ts.map +0 -1
  69. package/build/lib/commands/execute.js +0 -83
  70. package/build/lib/commands/execute.js.map +0 -1
  71. package/lib/commands/app-strings.js +0 -16
  72. package/lib/commands/execute.js +0 -93
@@ -1,55 +1,5 @@
1
1
  import {Rect, StringRecord} from '@appium/types';
2
2
 
3
- /**
4
- * Represents options for pressing a key on an Android device.
5
- */
6
- export interface PressKeyOptions {
7
- /**
8
- * A valid Android key code. See https://developer.android.com/reference/android/view/KeyEvent
9
- * for the list of available key codes.
10
- */
11
- keycode: number;
12
- /**
13
- * An integer in which each bit set to 1 represents a pressed meta key. See
14
- * https://developer.android.com/reference/android/view/KeyEvent for more details.
15
- */
16
- metastate?: number;
17
- /**
18
- * Flags for the particular key event. See
19
- * https://developer.android.com/reference/android/view/KeyEvent for more details.
20
- */
21
- flags?: string;
22
- /**
23
- * Whether to emulate long key press. Defaults to `false`.
24
- */
25
- isLongPress: boolean;
26
- }
27
-
28
- export interface AcceptAlertOptions {
29
- /**
30
- * The name of the button to click in order to accept the alert. If the name is not provided
31
- * then the script will try to detect the button automatically.
32
- */
33
- buttonLabel?: string;
34
- }
35
-
36
- export interface DismissAlertOptions {
37
- /**
38
- * The name of the button to click in order to dismiss the alert. If the name is not provided
39
- * then the script will try to detect the button automatically.
40
- */
41
- buttonLabel?: string;
42
- }
43
-
44
- export interface GetAppStringsOptions {
45
- /**
46
- * The language abbreviation to fetch app strings mapping for. If no
47
- * language is provided then strings for the default language on the device under test
48
- * would be returned. Examples: en, fr
49
- */
50
- language?: string;
51
- }
52
-
53
3
  export type BatteryState = -1 | 1 | 2 | 3 | 4 | 5;
54
4
 
55
5
  export interface BatteryInfo {
@@ -70,43 +20,10 @@ export interface BatteryInfo {
70
20
  state: BatteryState;
71
21
  }
72
22
 
73
- export interface ReplaceValueOptions {
74
- /**
75
- * The id of the element whose content will be replaced.
76
- */
77
- elementId: string;
78
- /**
79
- * The actual text to set.
80
- */
81
- text: string;
82
- }
83
-
84
23
  export type MapKey<T, K extends keyof T, N extends string> = Pick<T, Exclude<keyof T, K>> & {
85
24
  [P in N]: T[K];
86
25
  };
87
26
 
88
- export interface DeepLinkOpts {
89
- /**
90
- * The name of URL to start.
91
- */
92
- url: string;
93
- /**
94
- * The name of the package to start the URI with.
95
- */
96
- package?: string;
97
- /**
98
- * If `false` then adb won't wait for the started activity to return the control.
99
- * @defaultValue true
100
- */
101
- waitForLaunch?: boolean;
102
- }
103
-
104
- export interface TypingOptions {
105
- /**
106
- * The text to type. Can be a string, number or boolean.
107
- */
108
- text: string | number | boolean;
109
- }
110
27
  export interface InstallOptions {
111
28
  /**
112
29
  * Set to true in order to allow test packages installation.
@@ -138,301 +55,6 @@ export interface InstallOptions {
138
55
  partialInstall?: boolean;
139
56
  }
140
57
 
141
- export interface InstallMultipleApksOptions {
142
- /**
143
- * The list of APKs to install. Each APK should be a path to a apk
144
- * or downloadable URL as HTTP/HTTPS.
145
- */
146
- apks: string[];
147
- /**
148
- * The installation options.
149
- */
150
- options?: InstallOptions;
151
- }
152
- export interface BackgroundAppOptions {
153
- /**
154
- * The amount of seconds to wait between putting the app to background and restoring it.
155
- * Any negative value means to not restore the app after putting it to background.
156
- * @defaultValue -1
157
- */
158
- seconds?: number;
159
- }
160
-
161
- export interface ClickOptions {
162
- /**
163
- * The id of the element to be clicked. If the element is missing then both click offset coordinates must be provided. If both the element id and offset are provided then the coordinates are parsed as relative offsets from the top left corner of the element.
164
- */
165
- elementId?: string;
166
- /**
167
- * The x coordinate to click on.
168
- */
169
- x?: number;
170
- /**
171
- * The y coordinate to click on.
172
- */
173
- y?: number;
174
- }
175
-
176
- export interface LongClickOptions {
177
- /**
178
- * The id of the element to be clicked.
179
- * If the element is missing then both click offset coordinates must be provided.
180
- * If both the element id and offset are provided then the coordinates
181
- * are parsed as relative offsets from the top left corner of the element.
182
- */
183
- elementId?: string;
184
- /**
185
- * The x coordinate to click on.
186
- */
187
- x?: number;
188
- /**
189
- * The y coordinate to click on.
190
- */
191
- y?: number;
192
- /**
193
- * Click duration in milliseconds. The value must not be negative.
194
- * Default is 500.
195
- */
196
- duration?: number;
197
- }
198
-
199
- export type DoubleClickOptions = ClickOptions;
200
-
201
- export interface DragOptions {
202
- /**
203
- * The id of the element to be dragged.
204
- * If the element id is missing then the start coordinates must be provided.
205
- * If both the element id and the start coordinates are provided then these
206
- * coordinates are considered as offsets from the top left element corner.
207
- */
208
- elementId?: string;
209
- /**
210
- * The x coordinate where the dragging starts
211
- */
212
- startX?: number;
213
- /**
214
- * The y coordinate where the dragging starts
215
- */
216
- startY?: number;
217
- /**
218
- * The x coordinate where the dragging ends
219
- */
220
- endX?: number;
221
- /**
222
- * The y coordinate where the dragging ends
223
- */
224
- endY?: number;
225
- /**
226
- * The speed at which to perform this gesture in pixels per second.
227
- * The value must not be negative.
228
- * Default is 2500 * displayDensity.
229
- */
230
- speed?: number;
231
- }
232
-
233
- export interface FlingOptions {
234
- /**
235
- * The id of the element to be flinged.
236
- * If the element id is missing then fling bounding area must be provided.
237
- * If both the element id and the fling bounding area are provided then this
238
- * area is effectively ignored.
239
- */
240
- elementId?: string;
241
- /**
242
- * The left coordinate of the fling bounding area.
243
- */
244
- left?: number;
245
- /**
246
- * The top coordinate of the fling bounding area.
247
- */
248
- top?: number;
249
- /**
250
- * The width of the fling bounding area.
251
- */
252
- width?: number;
253
- /**
254
- * The height of the fling bounding area.
255
- */
256
- height?: number;
257
- /**
258
- * Direction of the fling.
259
- * Acceptable values are: `up`, `down`, `left` and `right` (case insensitive).
260
- */
261
- direction: string;
262
- /**
263
- * The speed at which to perform this gesture in pixels per second.
264
- * The value must be greater than the minimum fling velocity for the given view (50 by default).
265
- * Default is 7500 * displayDensity.
266
- */
267
- speed?: number;
268
- }
269
-
270
- export interface PinchOptions {
271
- /**
272
- * The id of the element to be pinched.
273
- * If the element id is missing then pinch bounding area must be provided.
274
- * If both the element id and the pinch bounding area are provided then the
275
- * area is effectively ignored.
276
- */
277
- elementId?: string;
278
- /**
279
- * The left coordinate of the pinch bounding area.
280
- */
281
- left?: number;
282
- /**
283
- * The top coordinate of the pinch bounding area.
284
- */
285
- top?: number;
286
- /**
287
- * The width of the pinch bounding area.
288
- */
289
- width?: number;
290
- /**
291
- * The height of the pinch bounding area.
292
- */
293
- height?: number;
294
- /**
295
- * The size of the pinch as a percentage of the pinch area size.
296
- * Valid values must be float numbers in range 0..1, where 1.0 is 100%
297
- */
298
- percent: number;
299
- /**
300
- * The speed at which to perform this gesture in pixels per second.
301
- * The value must not be negative.
302
- * Default is 2500 * displayDensity.
303
- */
304
- speed?: number;
305
- }
306
-
307
- export interface SwipeOptions {
308
- /**
309
- * The id of the element to be swiped.
310
- * If the element id is missing then swipe bounding area must be provided.
311
- * If both the element id and the swipe bounding area are provided then the
312
- * area is effectively ignored.
313
- */
314
- elementId?: string;
315
- /**
316
- * The left coordinate of the swipe bounding area.
317
- */
318
- left?: number;
319
- /**
320
- * The top coordinate of the swipe bounding area.
321
- */
322
- top?: number;
323
- /**
324
- * The width of the swipe bounding area.
325
- */
326
- width?: number;
327
- /**
328
- * The height of the swipe bounding area.
329
- */
330
- height?: number;
331
- /**
332
- * Direction of the swipe.
333
- * Acceptable values are: `up`, `down`, `left` and `right` (case insensitive).
334
- */
335
- direction: string;
336
- /**
337
- * The size of the swipe as a percentage of the swipe area size.
338
- * Valid values must be float numbers in range 0..1, where 1.0 is 100%.
339
- */
340
- percent: number;
341
- /**
342
- * The speed at which to perform this gesture in pixels per second.
343
- * The value must not be negative.
344
- * Default is 5000 * displayDensity.
345
- */
346
- speed?: number;
347
- }
348
- export interface ScrollGestureOptions {
349
- /**
350
- * The id of the element to be scrolled.
351
- * If the element id is missing then scroll bounding area must be provided.
352
- * If both the element id and the scroll bounding area are provided then this
353
- * area is effectively ignored.
354
- */
355
- elementId?: string;
356
- /**
357
- * The left coordinate of the scroll bounding area.
358
- */
359
- left?: number;
360
- /**
361
- * The top coordinate of the scroll bounding area.
362
- */
363
- top?: number;
364
- /**
365
- * The width of the scroll bounding area.
366
- */
367
- width?: number;
368
- /**
369
- * The height of the scroll bounding area.
370
- */
371
- height?: number;
372
- /**
373
- * Direction of the scroll.
374
- * Acceptable values are: `up`, `down`, `left` and `right` (case insensitive).
375
- */
376
- direction: string;
377
- /**
378
- * The size of the scroll as a percentage of the scrolling area size.
379
- * Valid values must be float numbers greater than zero, where 1.0 is 100%.
380
- */
381
- percent: number;
382
- /**
383
- * The speed at which to perform this gesture in pixels per second.
384
- * The value must not be negative.
385
- * Default is 5000 * displayDensity.
386
- */
387
- speed?: number;
388
- }
389
-
390
- export interface ScrollElementToElementOpts {
391
- /**
392
- * The identifier of the scrollable element, which is going to be scrolled.
393
- * It is required this element is a valid scrollable container and it was located
394
- * by `-android uiautomator` strategy.
395
- */
396
- elementId: string;
397
- /**
398
- * The identifier of the item, which belongs to the scrollable element above,
399
- * and which should become visible after the scrolling operation is finished.
400
- * It is required this element was located by `-android uiautomator` strategy.
401
- */
402
- elementToId: string;
403
- }
404
-
405
- export interface ScrollOptions {
406
- /**
407
- * The identifier of an element. It is required this element is a valid scrollable container
408
- * and it was located by `-android uiautomator` strategy.
409
- * If this property is not provided then the first currently available scrollable view
410
- * is selected for the interaction.
411
- */
412
- elementId?: string;
413
- /**
414
- * The following strategies are supported:
415
- * - `accessibility id` (UiSelector().description)
416
- * - `class name` (UiSelector().className)
417
- * - `-android uiautomator` (UiSelector)
418
- */
419
- strategy: string;
420
- /**
421
- * The corresponding lookup value for the given strategy.
422
- */
423
- selector: string;
424
- /**
425
- * The maximum number of swipes to perform on the target scrollable view in order to reach
426
- * the destination element. In case this value is unset then it would be retrieved from the
427
- * scrollable element itself (via `getMaxSearchSwipes()` property).
428
- */
429
- maxSwipes?: number;
430
- /**
431
- * @deprecated
432
- */
433
- element?: string;
434
- }
435
-
436
58
  export type RelativeRect = Pick<Rect, 'width' | 'height'> & {left: Rect['x']; top: Rect['y']};
437
59
 
438
60
  export interface Screenshot {
@@ -454,35 +76,7 @@ export interface Screenshot {
454
76
  payload: string;
455
77
  }
456
78
 
457
- export interface ScreenshotsOpts {
458
- /**
459
- * Android display identifier to take a screenshot for.
460
- * If not provided then screenshots of all displays are going to be returned.
461
- * If no matches were found then an error is thrown.
462
- */
463
- displayId?: number | string;
464
- }
465
-
466
79
  export interface ActionResult {
467
80
  repeats: number;
468
81
  stepResults: StringRecord[][];
469
82
  }
470
-
471
- export interface ActionArgs {
472
- name: string;
473
- }
474
-
475
- export interface SetClipboardOpts {
476
- /**
477
- * Base64-encoded clipboard payload
478
- */
479
- content: string;
480
- /**
481
- * Only a single content type is supported, which is 'plaintext'
482
- */
483
- contentType?: 'plaintext';
484
- /**
485
- * Optinal label to identify the current clipboard payload
486
- */
487
- label?: string;
488
- }
package/lib/driver.ts CHANGED
@@ -55,17 +55,12 @@ import {
55
55
  mobileInstallMultipleApks,
56
56
  mobileBackgroundApp,
57
57
  } from './commands/app-management';
58
- import {
59
- mobileGetAppStrings,
60
- } from './commands/app-strings';
61
58
  import {
62
59
  mobileGetBatteryInfo,
63
60
  } from './commands/battery';
64
61
  import {
65
62
  getClipboard,
66
- mobileGetClipboard,
67
63
  setClipboard,
68
- mobileSetClipboard,
69
64
  } from './commands/clipboard';
70
65
  import {
71
66
  active,
@@ -85,10 +80,6 @@ import {
85
80
  clear,
86
81
  mobileReplaceElementValue,
87
82
  } from './commands/element';
88
- import {
89
- executeMobile,
90
- mobileCommandsMapping,
91
- } from './commands/execute';
92
83
  import {
93
84
  doFindElementOrEls,
94
85
  } from './commands/find';
@@ -141,6 +132,7 @@ import {
141
132
  getWindowSize,
142
133
  mobileViewPortRect,
143
134
  } from './commands/viewport';
135
+ import { executeMethodMap } from './execute-method-map';
144
136
 
145
137
  // The range of ports we can use on the system for communicating to the
146
138
  // UiAutomator2 HTTP server on the device
@@ -269,6 +261,7 @@ class AndroidUiautomator2Driver
269
261
  >
270
262
  {
271
263
  static newMethodMap = newMethodMap;
264
+ static executeMethodMap = executeMethodMap;
272
265
 
273
266
  uiautomator2: UiAutomator2Server;
274
267
 
@@ -1018,8 +1011,6 @@ class AndroidUiautomator2Driver
1018
1011
  mobileInstallMultipleApks = mobileInstallMultipleApks;
1019
1012
  mobileBackgroundApp = mobileBackgroundApp;
1020
1013
 
1021
- mobileGetAppStrings = mobileGetAppStrings;
1022
-
1023
1014
  mobileGetBatteryInfo = mobileGetBatteryInfo;
1024
1015
 
1025
1016
  active = active;
@@ -1039,9 +1030,6 @@ class AndroidUiautomator2Driver
1039
1030
  clear = clear;
1040
1031
  mobileReplaceElementValue = mobileReplaceElementValue;
1041
1032
 
1042
- executeMobile = executeMobile;
1043
- mobileCommandsMapping = mobileCommandsMapping;
1044
-
1045
1033
  doFindElementOrEls = doFindElementOrEls;
1046
1034
 
1047
1035
  mobileClickGesture = mobileClickGesture;
@@ -1071,9 +1059,7 @@ class AndroidUiautomator2Driver
1071
1059
  mobileGetDeviceInfo = mobileGetDeviceInfo;
1072
1060
 
1073
1061
  getClipboard = getClipboard;
1074
- mobileGetClipboard = mobileGetClipboard;
1075
1062
  setClipboard = setClipboard;
1076
- mobileSetClipboard = mobileSetClipboard;
1077
1063
 
1078
1064
  setUrl = setUrl;
1079
1065
  mobileDeepLink = mobileDeepLink;