appium-android-driver 7.8.3 → 8.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.
- package/CHANGELOG.md +25 -0
- package/build/lib/commands/app-management.d.ts +129 -5
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +433 -128
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/appearance.d.ts +17 -4
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js +32 -33
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/context/cache.d.ts +19 -0
- package/build/lib/commands/context/cache.d.ts.map +1 -0
- package/build/lib/commands/context/cache.js +32 -0
- package/build/lib/commands/context/cache.js.map +1 -0
- package/build/lib/commands/context/exports.d.ts +141 -0
- package/build/lib/commands/context/exports.d.ts.map +1 -0
- package/build/lib/commands/context/exports.js +351 -0
- package/build/lib/commands/context/exports.js.map +1 -0
- package/build/lib/commands/context/helpers.d.ts +98 -0
- package/build/lib/commands/context/helpers.d.ts.map +1 -0
- package/build/lib/commands/context/helpers.js +715 -0
- package/build/lib/commands/context/helpers.js.map +1 -0
- package/build/lib/commands/device/common.d.ts +23 -0
- package/build/lib/commands/device/common.d.ts.map +1 -0
- package/build/lib/commands/device/common.js +230 -0
- package/build/lib/commands/device/common.js.map +1 -0
- package/build/lib/commands/device/emulator-actions.d.ts +114 -0
- package/build/lib/commands/device/emulator-actions.d.ts.map +1 -0
- package/build/lib/commands/device/emulator-actions.js +197 -0
- package/build/lib/commands/device/emulator-actions.js.map +1 -0
- package/build/lib/commands/device/emulator-console.d.ts +7 -0
- package/build/lib/commands/device/emulator-console.d.ts.map +1 -0
- package/build/lib/commands/device/emulator-console.js +24 -0
- package/build/lib/commands/device/emulator-console.js.map +1 -0
- package/build/lib/commands/device/utils.d.ts +50 -0
- package/build/lib/commands/device/utils.d.ts.map +1 -0
- package/build/lib/commands/device/utils.js +238 -0
- package/build/lib/commands/device/utils.js.map +1 -0
- package/build/lib/commands/deviceidle.d.ts +8 -5
- package/build/lib/commands/deviceidle.d.ts.map +1 -1
- package/build/lib/commands/deviceidle.js +31 -37
- package/build/lib/commands/deviceidle.js.map +1 -1
- package/build/lib/commands/element.d.ts +99 -5
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +152 -116
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts +12 -4
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +83 -78
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +42 -5
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +230 -194
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +5 -4
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +7 -10
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/geolocation.d.ts +45 -0
- package/build/lib/commands/geolocation.d.ts.map +1 -0
- package/build/lib/commands/geolocation.js +182 -0
- package/build/lib/commands/geolocation.js.map +1 -0
- package/build/lib/commands/ime.d.ts +25 -5
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +59 -42
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/intent.d.ts +56 -5
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +135 -83
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +58 -4
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +119 -17
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/lock/exports.d.ts +301 -0
- package/build/lib/commands/lock/exports.d.ts.map +1 -0
- package/build/lib/commands/lock/exports.js +121 -0
- package/build/lib/commands/lock/exports.js.map +1 -0
- package/build/lib/commands/lock/helpers.d.ts +349 -0
- package/build/lib/commands/lock/helpers.d.ts.map +1 -0
- package/build/lib/commands/lock/helpers.js +375 -0
- package/build/lib/commands/lock/helpers.js.map +1 -0
- package/build/lib/commands/log.d.ts +59 -5
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +150 -140
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +16 -5
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +69 -58
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/memory.d.ts +9 -5
- package/build/lib/commands/memory.d.ts.map +1 -1
- package/build/lib/commands/memory.js +19 -24
- package/build/lib/commands/memory.js.map +1 -1
- package/build/lib/commands/misc.d.ts +42 -0
- package/build/lib/commands/misc.d.ts.map +1 -0
- package/build/lib/commands/misc.js +100 -0
- package/build/lib/commands/misc.js.map +1 -0
- package/build/lib/commands/network.d.ts +61 -5
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +196 -189
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +67 -27
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +105 -80
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +12 -6
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +65 -62
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +44 -5
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +131 -126
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/resources.d.ts +16 -0
- package/build/lib/commands/resources.d.ts.map +1 -0
- package/build/lib/commands/resources.js +91 -0
- package/build/lib/commands/resources.js.map +1 -0
- package/build/lib/commands/shell.d.ts +8 -5
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +29 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +34 -6
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +166 -162
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +18 -13
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +68 -64
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/time.d.ts +14 -0
- package/build/lib/commands/time.d.ts.map +1 -0
- package/build/lib/commands/time.js +39 -0
- package/build/lib/commands/time.js.map +1 -0
- package/build/lib/commands/touch.d.ts +99 -6
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +399 -280
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +110 -2
- package/build/lib/commands/types.d.ts.map +1 -1
- package/build/lib/doctor/checks.d.ts.map +1 -1
- package/build/lib/doctor/checks.js +4 -4
- package/build/lib/doctor/checks.js.map +1 -1
- package/build/lib/driver.d.ts +224 -27
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +232 -7
- package/build/lib/driver.js.map +1 -1
- package/build/lib/index.d.ts +1 -4
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +1 -13
- package/build/lib/index.js.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/method-map.d.ts +0 -23
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +0 -11
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/utils.d.ts +12 -0
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +38 -2
- package/build/lib/utils.js.map +1 -1
- package/lib/commands/app-management.js +470 -145
- package/lib/commands/appearance.js +29 -36
- package/lib/commands/context/cache.js +29 -0
- package/lib/commands/context/exports.js +379 -0
- package/lib/commands/context/helpers.js +802 -0
- package/lib/commands/device/common.js +264 -0
- package/lib/commands/device/emulator-actions.js +194 -0
- package/lib/commands/device/emulator-console.js +24 -0
- package/lib/commands/device/utils.js +285 -0
- package/lib/commands/deviceidle.js +31 -44
- package/lib/commands/element.js +149 -142
- package/lib/commands/execute.js +86 -87
- package/lib/commands/file-actions.js +249 -222
- package/lib/commands/find.ts +13 -19
- package/lib/commands/geolocation.js +179 -0
- package/lib/commands/ime.js +53 -45
- package/lib/commands/intent.js +149 -91
- package/lib/commands/keyboard.js +114 -17
- package/lib/commands/lock/exports.js +139 -0
- package/lib/commands/lock/helpers.js +379 -0
- package/lib/commands/log.js +170 -166
- package/lib/commands/media-projection.js +75 -70
- package/lib/commands/memory.js +17 -29
- package/lib/commands/misc.js +94 -0
- package/lib/commands/network.js +209 -223
- package/lib/commands/performance.js +88 -73
- package/lib/commands/permissions.js +83 -84
- package/lib/commands/recordscreen.js +171 -170
- package/lib/commands/resources.js +96 -0
- package/lib/commands/shell.js +28 -42
- package/lib/commands/streamscreen.js +207 -206
- package/lib/commands/system-bars.js +76 -77
- package/lib/commands/time.js +36 -0
- package/lib/commands/touch.js +442 -346
- package/lib/commands/types.ts +123 -2
- package/lib/doctor/checks.js +24 -16
- package/lib/driver.ts +454 -12
- package/lib/index.ts +1 -13
- package/lib/logger.js +1 -1
- package/lib/method-map.js +0 -11
- package/lib/utils.js +40 -3
- package/package.json +1 -1
- package/build/lib/commands/actions.d.ts +0 -8
- package/build/lib/commands/actions.d.ts.map +0 -1
- package/build/lib/commands/actions.js +0 -207
- package/build/lib/commands/actions.js.map +0 -1
- package/build/lib/commands/alert.d.ts +0 -8
- package/build/lib/commands/alert.d.ts.map +0 -1
- package/build/lib/commands/alert.js +0 -29
- package/build/lib/commands/alert.js.map +0 -1
- package/build/lib/commands/context.d.ts +0 -10
- package/build/lib/commands/context.d.ts.map +0 -1
- package/build/lib/commands/context.js +0 -431
- package/build/lib/commands/context.js.map +0 -1
- package/build/lib/commands/emu-console.d.ts +0 -7
- package/build/lib/commands/emu-console.d.ts.map +0 -1
- package/build/lib/commands/emu-console.js +0 -27
- package/build/lib/commands/emu-console.js.map +0 -1
- package/build/lib/commands/general.d.ts +0 -9
- package/build/lib/commands/general.d.ts.map +0 -1
- package/build/lib/commands/general.js +0 -293
- package/build/lib/commands/general.js.map +0 -1
- package/build/lib/commands/index.d.ts +0 -28
- package/build/lib/commands/index.d.ts.map +0 -1
- package/build/lib/commands/index.js +0 -57
- package/build/lib/commands/index.js.map +0 -1
- package/build/lib/commands/mixins.d.ts +0 -747
- package/build/lib/commands/mixins.d.ts.map +0 -1
- package/build/lib/commands/mixins.js +0 -19
- package/build/lib/commands/mixins.js.map +0 -1
- package/build/lib/helpers/android.d.ts +0 -163
- package/build/lib/helpers/android.d.ts.map +0 -1
- package/build/lib/helpers/android.js +0 -818
- package/build/lib/helpers/android.js.map +0 -1
- package/build/lib/helpers/index.d.ts +0 -7
- package/build/lib/helpers/index.d.ts.map +0 -1
- package/build/lib/helpers/index.js +0 -29
- package/build/lib/helpers/index.js.map +0 -1
- package/build/lib/helpers/types.d.ts +0 -122
- package/build/lib/helpers/types.d.ts.map +0 -1
- package/build/lib/helpers/types.js +0 -3
- package/build/lib/helpers/types.js.map +0 -1
- package/build/lib/helpers/unlock.d.ts +0 -32
- package/build/lib/helpers/unlock.d.ts.map +0 -1
- package/build/lib/helpers/unlock.js +0 -273
- package/build/lib/helpers/unlock.js.map +0 -1
- package/build/lib/helpers/webview.d.ts +0 -74
- package/build/lib/helpers/webview.d.ts.map +0 -1
- package/build/lib/helpers/webview.js +0 -448
- package/build/lib/helpers/webview.js.map +0 -1
- package/lib/commands/actions.js +0 -244
- package/lib/commands/alert.js +0 -34
- package/lib/commands/context.js +0 -507
- package/lib/commands/emu-console.js +0 -31
- package/lib/commands/general.js +0 -343
- package/lib/commands/index.ts +0 -54
- package/lib/commands/mixins.ts +0 -976
- package/lib/helpers/android.ts +0 -1153
- package/lib/helpers/index.ts +0 -6
- package/lib/helpers/types.ts +0 -136
- package/lib/helpers/unlock.ts +0 -329
- package/lib/helpers/webview.ts +0 -610
|
@@ -1,18 +1,227 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.truncateDecimals = exports.doPerformMultiAction = exports.performMultiAction = exports.performTouch = exports.doTouchAction = exports.doTouchDrag = exports.doSwipe = exports.touchMove = exports.touchUp = exports.touchDown = exports.touchLongClick = exports.tap = void 0;
|
|
7
8
|
const support_1 = require("@appium/support");
|
|
8
9
|
const driver_1 = require("appium/driver");
|
|
9
10
|
const asyncbox_1 = require("asyncbox");
|
|
10
11
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
11
12
|
const lodash_1 = __importDefault(require("lodash"));
|
|
12
|
-
const android_1 = __importDefault(require("../helpers/android"));
|
|
13
|
-
const mixins_1 = require("./mixins");
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* @deprecated
|
|
15
|
+
* @this {import('../driver').AndroidDriver}
|
|
16
|
+
* @param {string?} [elementId=null]
|
|
17
|
+
* @param {number?} [x=null]
|
|
18
|
+
* @param {number?} [y=null]
|
|
19
|
+
* @param {number} [count=1]
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
*/
|
|
22
|
+
async function tap(elementId = null, x = null, y = null, count = 1) {
|
|
23
|
+
throw new driver_1.errors.NotImplementedError('Not implemented');
|
|
24
|
+
}
|
|
25
|
+
exports.tap = tap;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated
|
|
28
|
+
* @this {import('../driver').AndroidDriver}
|
|
29
|
+
* @param {string} elementId
|
|
30
|
+
* @param {number} x
|
|
31
|
+
* @param {number} y
|
|
32
|
+
* @param {number} duration
|
|
33
|
+
* @returns {Promise<void>}
|
|
34
|
+
*/
|
|
35
|
+
async function touchLongClick(elementId, x, y, duration) {
|
|
36
|
+
throw new driver_1.errors.NotImplementedError('Not implemented');
|
|
37
|
+
}
|
|
38
|
+
exports.touchLongClick = touchLongClick;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated
|
|
41
|
+
* @this {import('../driver').AndroidDriver}
|
|
42
|
+
* @param {string} elementId
|
|
43
|
+
* @param {number} x
|
|
44
|
+
* @param {number} y
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
async function touchDown(elementId, x, y) {
|
|
48
|
+
throw new driver_1.errors.NotImplementedError('Not implemented');
|
|
49
|
+
}
|
|
50
|
+
exports.touchDown = touchDown;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated
|
|
53
|
+
* @this {import('../driver').AndroidDriver}
|
|
54
|
+
* @param {string} elementId
|
|
55
|
+
* @param {number} x
|
|
56
|
+
* @param {number} y
|
|
57
|
+
* @returns {Promise<void>}
|
|
58
|
+
*/
|
|
59
|
+
async function touchUp(elementId, x, y) {
|
|
60
|
+
throw new driver_1.errors.NotImplementedError('Not implemented');
|
|
61
|
+
}
|
|
62
|
+
exports.touchUp = touchUp;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated
|
|
65
|
+
* @this {import('../driver').AndroidDriver}
|
|
66
|
+
* @param {string} elementId
|
|
67
|
+
* @param {number} x
|
|
68
|
+
* @param {number} y
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
*/
|
|
71
|
+
async function touchMove(elementId, x, y) {
|
|
72
|
+
throw new driver_1.errors.NotImplementedError('Not implemented');
|
|
73
|
+
}
|
|
74
|
+
exports.touchMove = touchMove;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated
|
|
77
|
+
* @this {import('../driver').AndroidDriver}
|
|
78
|
+
* @param {import('./types').SwipeOpts} opts
|
|
79
|
+
* @returns {Promise<void>}
|
|
80
|
+
*/
|
|
81
|
+
async function doSwipe(opts) {
|
|
82
|
+
throw new driver_1.errors.NotImplementedError('Not implemented');
|
|
83
|
+
}
|
|
84
|
+
exports.doSwipe = doSwipe;
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated
|
|
87
|
+
* @this {import('../driver').AndroidDriver}
|
|
88
|
+
* @param {import('./types').TouchDragAction} opts
|
|
89
|
+
* @returns {Promise<void>}
|
|
90
|
+
*/
|
|
91
|
+
async function doTouchDrag(opts) {
|
|
92
|
+
throw new driver_1.errors.NotImplementedError('Not implemented');
|
|
93
|
+
}
|
|
94
|
+
exports.doTouchDrag = doTouchDrag;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated
|
|
97
|
+
* @this {import('../driver').AndroidDriver}
|
|
98
|
+
* @param {import('./types').TouchActionKind} action
|
|
99
|
+
* @param {import('./types').TouchActionOpts} [opts={}]
|
|
100
|
+
* @returns {Promise<void>}
|
|
101
|
+
*/
|
|
102
|
+
async function doTouchAction(action, opts = {}) {
|
|
103
|
+
const { element, x, y, count, ms, duration } = opts;
|
|
104
|
+
// parseTouch precalculates absolute element positions
|
|
105
|
+
// so there is no need to pass `element` to the affected gestures
|
|
106
|
+
switch (action) {
|
|
107
|
+
case 'tap':
|
|
108
|
+
return await this.tap('', x, y, count);
|
|
109
|
+
case 'press':
|
|
110
|
+
return await this.touchDown('', /** @type {number} */ (x), /** @type {number} */ (y));
|
|
111
|
+
case 'release':
|
|
112
|
+
return await this.touchUp(String(element),
|
|
113
|
+
/** @type {number} */ (x),
|
|
114
|
+
/** @type {number} */ (y));
|
|
115
|
+
case 'moveTo':
|
|
116
|
+
return await this.touchMove('', /** @type {number} */ (x), /** @type {number} */ (y));
|
|
117
|
+
case 'wait':
|
|
118
|
+
return await bluebird_1.default.delay(/** @type {number} */ (ms));
|
|
119
|
+
case 'longPress':
|
|
120
|
+
return await this.touchLongClick('',
|
|
121
|
+
/** @type {number} */ (x),
|
|
122
|
+
/** @type {number} */ (y), duration ?? 1000);
|
|
123
|
+
case 'cancel':
|
|
124
|
+
// TODO: clarify behavior of 'cancel' action and fix this
|
|
125
|
+
this.log.warn('Cancel action currently has no effect');
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
this.log.errorAndThrow(`unknown action ${action}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.doTouchAction = doTouchAction;
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated
|
|
134
|
+
* @this {import('../driver').AndroidDriver}
|
|
135
|
+
* @param {import('./types').TouchAction[]} gestures
|
|
136
|
+
* @returns {Promise<void>}
|
|
137
|
+
*/
|
|
138
|
+
async function performTouch(gestures) {
|
|
139
|
+
// press-wait-moveTo-release is `swipe`, so use native method
|
|
140
|
+
if (gestures.length === 4 &&
|
|
141
|
+
gestures[0].action === 'press' &&
|
|
142
|
+
gestures[1].action === 'wait' &&
|
|
143
|
+
gestures[2].action === 'moveTo' &&
|
|
144
|
+
gestures[3].action === 'release') {
|
|
145
|
+
let swipeOpts = await getSwipeOptions.bind(this)(
|
|
146
|
+
/** @type {import('./types').SwipeAction} */ (gestures));
|
|
147
|
+
return await this.doSwipe(swipeOpts);
|
|
148
|
+
}
|
|
149
|
+
let actions = /** @type {(import('./types').TouchActionKind|TouchAction)[]} */ (lodash_1.default.map(gestures, 'action'));
|
|
150
|
+
if (actions[0] === 'longPress' && actions[1] === 'moveTo' && actions[2] === 'release') {
|
|
151
|
+
// some things are special
|
|
152
|
+
return await this.doTouchDrag(/** @type {import('./types').TouchDragAction} */ (gestures));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
if (actions.length === 2) {
|
|
156
|
+
// `press` without a wait is too slow and gets interpretted as a `longPress`
|
|
157
|
+
if (lodash_1.default.head(actions) === 'press' && lodash_1.default.last(actions) === 'release') {
|
|
158
|
+
actions[0] = 'tap';
|
|
159
|
+
gestures[0].action = 'tap';
|
|
160
|
+
}
|
|
161
|
+
// the `longPress` and `tap` methods release on their own
|
|
162
|
+
if ((lodash_1.default.head(actions) === 'tap' || lodash_1.default.head(actions) === 'longPress') &&
|
|
163
|
+
lodash_1.default.last(actions) === 'release') {
|
|
164
|
+
gestures.pop();
|
|
165
|
+
actions.pop();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
// longpress followed by anything other than release should become a press and wait
|
|
170
|
+
if (actions[0] === 'longPress') {
|
|
171
|
+
actions = ['press', 'wait', ...actions.slice(1)];
|
|
172
|
+
let press = /** @type {NonReleaseTouchAction} */ (gestures.shift());
|
|
173
|
+
press.action = 'press';
|
|
174
|
+
/** @type {NonReleaseTouchAction} */
|
|
175
|
+
let wait = {
|
|
176
|
+
action: 'wait',
|
|
177
|
+
options: { ms: press.options.duration || 1000 },
|
|
178
|
+
};
|
|
179
|
+
delete press.options.duration;
|
|
180
|
+
gestures = [press, wait, ...gestures];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
let fixedGestures = await parseTouch.bind(this)(gestures, false);
|
|
184
|
+
// fix release action then perform all actions
|
|
185
|
+
if (actions[actions.length - 1] === 'release') {
|
|
186
|
+
actions[actions.length - 1] = /** @type {TouchAction} */ (await fixRelease.bind(this)(gestures));
|
|
187
|
+
}
|
|
188
|
+
for (let g of fixedGestures) {
|
|
189
|
+
await performGesture.bind(this)(g);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.performTouch = performTouch;
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated
|
|
196
|
+
* @this {import('../driver').AndroidDriver}
|
|
197
|
+
* @param {import('./types').TouchAction[]} actions
|
|
198
|
+
* @param {string} elementId
|
|
199
|
+
* @returns {Promise<void>}
|
|
200
|
+
*/
|
|
201
|
+
async function performMultiAction(actions, elementId) {
|
|
202
|
+
// Android needs at least two actions to be able to perform a multi pointer gesture
|
|
203
|
+
if (actions.length === 1) {
|
|
204
|
+
throw new Error('Multi Pointer Gestures need at least two actions. ' +
|
|
205
|
+
'Use Touch Actions for a single action.');
|
|
206
|
+
}
|
|
207
|
+
const states = await (0, asyncbox_1.asyncmap)(actions, async (action) => await parseTouch.bind(this)(action, true), false);
|
|
208
|
+
return await this.doPerformMultiAction(elementId, states);
|
|
209
|
+
}
|
|
210
|
+
exports.performMultiAction = performMultiAction;
|
|
211
|
+
/**
|
|
212
|
+
* @deprecated
|
|
213
|
+
* @this {import('../driver').AndroidDriver}
|
|
214
|
+
* @param {string} elementId
|
|
215
|
+
* @param {import('./types').TouchState[]} states
|
|
216
|
+
* @returns {Promise<void>}
|
|
217
|
+
*/
|
|
218
|
+
async function doPerformMultiAction(elementId, states) {
|
|
219
|
+
throw new driver_1.errors.NotImplementedError('Not implemented');
|
|
220
|
+
}
|
|
221
|
+
exports.doPerformMultiAction = doPerformMultiAction;
|
|
222
|
+
// #region Internal helpers
|
|
223
|
+
/**
|
|
224
|
+
* @deprecated
|
|
16
225
|
* @param {number|null} [val]
|
|
17
226
|
* @returns {number}
|
|
18
227
|
*/
|
|
@@ -23,7 +232,18 @@ function getCoordDefault(val) {
|
|
|
23
232
|
return support_1.util.hasValue(val) ? val : 0.5;
|
|
24
233
|
}
|
|
25
234
|
/**
|
|
26
|
-
*
|
|
235
|
+
* @deprecated
|
|
236
|
+
* @param {number} number
|
|
237
|
+
* @param {number} digits
|
|
238
|
+
* @returns {number}
|
|
239
|
+
*/
|
|
240
|
+
function truncateDecimals(number, digits) {
|
|
241
|
+
const multiplier = Math.pow(10, digits), adjustedNum = number * multiplier, truncatedNum = Math[adjustedNum < 0 ? 'ceil' : 'floor'](adjustedNum);
|
|
242
|
+
return truncatedNum / multiplier;
|
|
243
|
+
}
|
|
244
|
+
exports.truncateDecimals = truncateDecimals;
|
|
245
|
+
/**
|
|
246
|
+
* @deprecated
|
|
27
247
|
* @param {NonReleaseTouchAction} waitGesture
|
|
28
248
|
* @returns {number}
|
|
29
249
|
*/
|
|
@@ -42,304 +262,203 @@ function getSwipeTouchDuration(waitGesture) {
|
|
|
42
262
|
return duration;
|
|
43
263
|
}
|
|
44
264
|
/**
|
|
45
|
-
* @
|
|
46
|
-
* @
|
|
265
|
+
* @deprecated
|
|
266
|
+
* @this {import('../driver').AndroidDriver}
|
|
267
|
+
* @param {import('./types').SwipeAction} gestures
|
|
268
|
+
* @param {number} [touchCount=1]
|
|
269
|
+
* @returns {Promise<import('./types').TouchSwipeOpts>}
|
|
47
270
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return await this.touchMove('', /** @type {number} */ (x), /** @type {number} */ (y));
|
|
64
|
-
case 'wait':
|
|
65
|
-
return await bluebird_1.default.delay(/** @type {number} */ (ms));
|
|
66
|
-
case 'longPress':
|
|
67
|
-
return await this.touchLongClick('',
|
|
68
|
-
/** @type {number} */ (x),
|
|
69
|
-
/** @type {number} */ (y), duration ?? 1000);
|
|
70
|
-
case 'cancel':
|
|
71
|
-
// TODO: clarify behavior of 'cancel' action and fix this
|
|
72
|
-
this.log.warn('Cancel action currently has no effect');
|
|
73
|
-
break;
|
|
74
|
-
default:
|
|
75
|
-
this.log.errorAndThrow(`unknown action ${action}`);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
async doTouchDrag(gestures) {
|
|
79
|
-
let longPress = gestures[0];
|
|
80
|
-
let moveTo = gestures[1];
|
|
81
|
-
let startX = longPress.options.x || 0, startY = longPress.options.y || 0, endX = moveTo.options.x || 0, endY = moveTo.options.y || 0;
|
|
82
|
-
if (longPress.options.element) {
|
|
83
|
-
let { x, y } = await this.getLocationInView(longPress.options.element);
|
|
84
|
-
startX += x || 0;
|
|
85
|
-
startY += y || 0;
|
|
271
|
+
async function getSwipeOptions(gestures, touchCount = 1) {
|
|
272
|
+
let startX = getCoordDefault(gestures[0].options.x), startY = getCoordDefault(gestures[0].options.y), endX = getCoordDefault(gestures[2].options.x), endY = getCoordDefault(gestures[2].options.y), duration = getSwipeTouchDuration(gestures[1]), element = /** @type {string} */ (gestures[0].options.element), destElement = gestures[2].options.element || gestures[0].options.element;
|
|
273
|
+
// there's no destination element handling in bootstrap and since it applies to all platforms, we handle it here
|
|
274
|
+
if (support_1.util.hasValue(destElement)) {
|
|
275
|
+
let locResult = await this.getLocationInView(destElement);
|
|
276
|
+
let sizeResult = await this.getSize(destElement);
|
|
277
|
+
let offsetX = Math.abs(endX) < 1 && Math.abs(endX) > 0 ? sizeResult.width * endX : endX;
|
|
278
|
+
let offsetY = Math.abs(endY) < 1 && Math.abs(endY) > 0 ? sizeResult.height * endY : endY;
|
|
279
|
+
endX = locResult.x + offsetX;
|
|
280
|
+
endY = locResult.y + offsetY;
|
|
281
|
+
// if the target element was provided, the coordinates for the destination need to be relative to it.
|
|
282
|
+
if (support_1.util.hasValue(element)) {
|
|
283
|
+
let firstElLocation = await this.getLocationInView(element);
|
|
284
|
+
endX -= firstElLocation.x;
|
|
285
|
+
endY -= firstElLocation.y;
|
|
86
286
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// offset coordinates
|
|
114
|
-
gestures = lodash_1.default.clone(gestures);
|
|
115
|
-
let ref = null;
|
|
116
|
-
for (let gesture of /** @type {NonReleaseTouchAction[]} */ (gestures.reverse())) {
|
|
117
|
-
let opts = gesture.options;
|
|
118
|
-
if (opts.element || (opts.x && opts.y)) {
|
|
119
|
-
ref = gesture;
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (ref) {
|
|
124
|
-
let opts = ref.options;
|
|
125
|
-
if (opts.element) {
|
|
126
|
-
let loc = await this.getLocationInView(opts.element);
|
|
127
|
-
if (opts.x && opts.y) {
|
|
128
|
-
// this is an offset from the element
|
|
129
|
-
release.options = {
|
|
130
|
-
x: loc.x + opts.x,
|
|
131
|
-
y: loc.y + opts.y,
|
|
132
|
-
};
|
|
287
|
+
}
|
|
288
|
+
// clients are responsible to use these options correctly
|
|
289
|
+
return { startX, startY, endX, endY, duration, touchCount, element };
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* @deprecated
|
|
293
|
+
* @this {import('../driver').AndroidDriver}
|
|
294
|
+
* @param {import('./types').TouchAction[]} gestures
|
|
295
|
+
* @param {boolean} [multi]
|
|
296
|
+
* @returns {Promise<import('./types').TouchState[]>}
|
|
297
|
+
*/
|
|
298
|
+
async function parseTouch(gestures, multi) {
|
|
299
|
+
// because multi-touch releases at the end by default
|
|
300
|
+
if (multi && /** @type {TouchAction} */ (lodash_1.default.last(gestures)).action === 'release') {
|
|
301
|
+
gestures.pop();
|
|
302
|
+
}
|
|
303
|
+
let touchStateObjects = await (0, asyncbox_1.asyncmap)(gestures, async (gesture) => {
|
|
304
|
+
let options = gesture.options || {};
|
|
305
|
+
if (lodash_1.default.includes(['press', 'moveTo', 'tap', 'longPress'], gesture.action)) {
|
|
306
|
+
options.offset = false;
|
|
307
|
+
let elementId = gesture.options.element;
|
|
308
|
+
if (elementId) {
|
|
309
|
+
let pos = await this.getLocationInView(elementId);
|
|
310
|
+
if (gesture.options.x || gesture.options.y) {
|
|
311
|
+
options.x = pos.x + (gesture.options.x || 0);
|
|
312
|
+
options.y = pos.y + (gesture.options.y || 0);
|
|
133
313
|
}
|
|
134
314
|
else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
x: loc.x + size.width / 2,
|
|
139
|
-
y: loc.y + size.height / 2,
|
|
140
|
-
};
|
|
315
|
+
const { width, height } = await this.getSize(elementId);
|
|
316
|
+
options.x = pos.x + width / 2;
|
|
317
|
+
options.y = pos.y + height / 2;
|
|
141
318
|
}
|
|
319
|
+
let touchStateObject = {
|
|
320
|
+
action: gesture.action,
|
|
321
|
+
options,
|
|
322
|
+
timeOffset: 0.005,
|
|
323
|
+
};
|
|
324
|
+
return touchStateObject;
|
|
142
325
|
}
|
|
143
326
|
else {
|
|
144
|
-
|
|
327
|
+
options.x = gesture.options.x || 0;
|
|
328
|
+
options.y = gesture.options.y || 0;
|
|
329
|
+
let touchStateObject = {
|
|
330
|
+
action: gesture.action,
|
|
331
|
+
options,
|
|
332
|
+
timeOffset: 0.005,
|
|
333
|
+
};
|
|
334
|
+
return touchStateObject;
|
|
145
335
|
}
|
|
146
336
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
catch (e) {
|
|
154
|
-
// sometime the element is not available when releasing, retry without it
|
|
155
|
-
if ((0, driver_1.isErrorType)(e, driver_1.errors.NoSuchElementError) &&
|
|
156
|
-
gesture.action === 'release' &&
|
|
157
|
-
gesture.options?.element) {
|
|
158
|
-
delete gesture.options.element;
|
|
159
|
-
this.log.debug(`retrying release without element opts: ${gesture.options}.`);
|
|
160
|
-
return await this.doTouchAction(gesture.action, gesture.options || {});
|
|
337
|
+
else {
|
|
338
|
+
let offset = 0.005;
|
|
339
|
+
if (gesture.action === 'wait') {
|
|
340
|
+
options = gesture.options;
|
|
341
|
+
offset = parseInt(gesture.options.ms, 10) / 1000;
|
|
161
342
|
}
|
|
162
|
-
|
|
343
|
+
let touchStateObject = {
|
|
344
|
+
action: gesture.action,
|
|
345
|
+
options,
|
|
346
|
+
timeOffset: offset,
|
|
347
|
+
};
|
|
348
|
+
return touchStateObject;
|
|
163
349
|
}
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
endX = locResult.x + offsetX;
|
|
174
|
-
endY = locResult.y + offsetY;
|
|
175
|
-
// if the target element was provided, the coordinates for the destination need to be relative to it.
|
|
176
|
-
if (support_1.util.hasValue(element)) {
|
|
177
|
-
let firstElLocation = await this.getLocationInView(element);
|
|
178
|
-
endX -= firstElLocation.x;
|
|
179
|
-
endY -= firstElLocation.y;
|
|
180
|
-
}
|
|
350
|
+
}, false);
|
|
351
|
+
// we need to change the time (which is now an offset)
|
|
352
|
+
// and the position (which may be an offset)
|
|
353
|
+
let prevPos = null, time = 0;
|
|
354
|
+
for (let state of touchStateObjects) {
|
|
355
|
+
if (lodash_1.default.isUndefined(state.options.x) && lodash_1.default.isUndefined(state.options.y) && prevPos !== null) {
|
|
356
|
+
// this happens with wait
|
|
357
|
+
state.options.x = prevPos.x;
|
|
358
|
+
state.options.y = prevPos.y;
|
|
181
359
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
// press-wait-moveTo-release is `swipe`, so use native method
|
|
187
|
-
if (gestures.length === 4 &&
|
|
188
|
-
gestures[0].action === 'press' &&
|
|
189
|
-
gestures[1].action === 'wait' &&
|
|
190
|
-
gestures[2].action === 'moveTo' &&
|
|
191
|
-
gestures[3].action === 'release') {
|
|
192
|
-
let swipeOpts = await this.getSwipeOptions(
|
|
193
|
-
/** @type {import('./types').SwipeAction} */ (gestures));
|
|
194
|
-
return await this.swipe(swipeOpts.startX, swipeOpts.startY, swipeOpts.endX, swipeOpts.endY, swipeOpts.duration, swipeOpts.touchCount, swipeOpts.element);
|
|
360
|
+
if (state.options.offset && prevPos) {
|
|
361
|
+
// the current position is an offset
|
|
362
|
+
state.options.x += prevPos.x;
|
|
363
|
+
state.options.y += prevPos.y;
|
|
195
364
|
}
|
|
196
|
-
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
return await this.doTouchDrag(/** @type {import('./types').TouchDragAction} */ (gestures));
|
|
365
|
+
delete state.options.offset;
|
|
366
|
+
if (!lodash_1.default.isUndefined(state.options.x) && !lodash_1.default.isUndefined(state.options.y)) {
|
|
367
|
+
prevPos = state.options;
|
|
200
368
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
gestures.pop();
|
|
212
|
-
actions.pop();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
// longpress followed by anything other than release should become a press and wait
|
|
217
|
-
if (actions[0] === 'longPress') {
|
|
218
|
-
actions = ['press', 'wait', ...actions.slice(1)];
|
|
219
|
-
let press = /** @type {NonReleaseTouchAction} */ (gestures.shift());
|
|
220
|
-
press.action = 'press';
|
|
221
|
-
/** @type {NonReleaseTouchAction} */
|
|
222
|
-
let wait = {
|
|
223
|
-
action: 'wait',
|
|
224
|
-
options: { ms: press.options.duration || 1000 },
|
|
225
|
-
};
|
|
226
|
-
delete press.options.duration;
|
|
227
|
-
gestures = [press, wait, ...gestures];
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
let fixedGestures = await this.parseTouch(gestures, false);
|
|
231
|
-
// fix release action then perform all actions
|
|
232
|
-
if (actions[actions.length - 1] === 'release') {
|
|
233
|
-
actions[actions.length - 1] = /** @type {TouchAction} */ (await this.fixRelease(gestures));
|
|
234
|
-
}
|
|
235
|
-
for (let g of fixedGestures) {
|
|
236
|
-
await this.performGesture(g);
|
|
369
|
+
if (multi) {
|
|
370
|
+
let timeOffset = state.timeOffset;
|
|
371
|
+
time += timeOffset;
|
|
372
|
+
state.time = truncateDecimals(time, 3);
|
|
373
|
+
// multi gestures require 'touch' rather than 'options'
|
|
374
|
+
if (!lodash_1.default.isUndefined(state.options.x) && !lodash_1.default.isUndefined(state.options.y)) {
|
|
375
|
+
state.touch = {
|
|
376
|
+
x: state.options.x,
|
|
377
|
+
y: state.options.y,
|
|
378
|
+
};
|
|
237
379
|
}
|
|
380
|
+
delete state.options;
|
|
238
381
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
382
|
+
delete state.timeOffset;
|
|
383
|
+
}
|
|
384
|
+
return touchStateObjects;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* @deprecated
|
|
388
|
+
* @this {import('../driver').AndroidDriver}
|
|
389
|
+
* @param {import('./types').TouchAction[]} gestures
|
|
390
|
+
* @returns {Promise<import('./types').ReleaseTouchAction|undefined>}
|
|
391
|
+
*/
|
|
392
|
+
async function fixRelease(gestures) {
|
|
393
|
+
let release = /** @type {import('./types').ReleaseTouchAction} */ (lodash_1.default.last(gestures));
|
|
394
|
+
// sometimes there are no options
|
|
395
|
+
release.options = release.options || {};
|
|
396
|
+
// nothing to do if release options are already set
|
|
397
|
+
if (release.options.element || (release.options.x && release.options.y)) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
// without coordinates, `release` uses the center of the screen, which,
|
|
401
|
+
// generally speaking, is not what we want
|
|
402
|
+
// therefore: loop backwards and use the last command with an element and/or
|
|
403
|
+
// offset coordinates
|
|
404
|
+
gestures = lodash_1.default.clone(gestures);
|
|
405
|
+
let ref = null;
|
|
406
|
+
for (let gesture of /** @type {NonReleaseTouchAction[]} */ (gestures.reverse())) {
|
|
407
|
+
let opts = gesture.options;
|
|
408
|
+
if (opts.element || (opts.x && opts.y)) {
|
|
409
|
+
ref = gesture;
|
|
410
|
+
break;
|
|
244
411
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
else {
|
|
257
|
-
const { width, height } = await this.getSize(elementId);
|
|
258
|
-
options.x = pos.x + width / 2;
|
|
259
|
-
options.y = pos.y + height / 2;
|
|
260
|
-
}
|
|
261
|
-
let touchStateObject = {
|
|
262
|
-
action: gesture.action,
|
|
263
|
-
options,
|
|
264
|
-
timeOffset: 0.005,
|
|
265
|
-
};
|
|
266
|
-
return touchStateObject;
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
options.x = gesture.options.x || 0;
|
|
270
|
-
options.y = gesture.options.y || 0;
|
|
271
|
-
let touchStateObject = {
|
|
272
|
-
action: gesture.action,
|
|
273
|
-
options,
|
|
274
|
-
timeOffset: 0.005,
|
|
275
|
-
};
|
|
276
|
-
return touchStateObject;
|
|
277
|
-
}
|
|
412
|
+
}
|
|
413
|
+
if (ref) {
|
|
414
|
+
let opts = ref.options;
|
|
415
|
+
if (opts.element) {
|
|
416
|
+
let loc = await this.getLocationInView(opts.element);
|
|
417
|
+
if (opts.x && opts.y) {
|
|
418
|
+
// this is an offset from the element
|
|
419
|
+
release.options = {
|
|
420
|
+
x: loc.x + opts.x,
|
|
421
|
+
y: loc.y + opts.y,
|
|
422
|
+
};
|
|
278
423
|
}
|
|
279
424
|
else {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
let touchStateObject = {
|
|
286
|
-
action: gesture.action,
|
|
287
|
-
options,
|
|
288
|
-
timeOffset: offset,
|
|
425
|
+
// this is the center of the element
|
|
426
|
+
let size = await this.getSize(opts.element);
|
|
427
|
+
release.options = {
|
|
428
|
+
x: loc.x + size.width / 2,
|
|
429
|
+
y: loc.y + size.height / 2,
|
|
289
430
|
};
|
|
290
|
-
return touchStateObject;
|
|
291
431
|
}
|
|
292
|
-
}, false);
|
|
293
|
-
// we need to change the time (which is now an offset)
|
|
294
|
-
// and the position (which may be an offset)
|
|
295
|
-
let prevPos = null, time = 0;
|
|
296
|
-
for (let state of touchStateObjects) {
|
|
297
|
-
if (lodash_1.default.isUndefined(state.options.x) && lodash_1.default.isUndefined(state.options.y) && prevPos !== null) {
|
|
298
|
-
// this happens with wait
|
|
299
|
-
state.options.x = prevPos.x;
|
|
300
|
-
state.options.y = prevPos.y;
|
|
301
|
-
}
|
|
302
|
-
if (state.options.offset && prevPos) {
|
|
303
|
-
// the current position is an offset
|
|
304
|
-
state.options.x += prevPos.x;
|
|
305
|
-
state.options.y += prevPos.y;
|
|
306
|
-
}
|
|
307
|
-
delete state.options.offset;
|
|
308
|
-
if (!lodash_1.default.isUndefined(state.options.x) && !lodash_1.default.isUndefined(state.options.y)) {
|
|
309
|
-
prevPos = state.options;
|
|
310
|
-
}
|
|
311
|
-
if (multi) {
|
|
312
|
-
let timeOffset = state.timeOffset;
|
|
313
|
-
time += timeOffset;
|
|
314
|
-
state.time = android_1.default.truncateDecimals(time, 3);
|
|
315
|
-
// multi gestures require 'touch' rather than 'options'
|
|
316
|
-
if (!lodash_1.default.isUndefined(state.options.x) && !lodash_1.default.isUndefined(state.options.y)) {
|
|
317
|
-
state.touch = {
|
|
318
|
-
x: state.options.x,
|
|
319
|
-
y: state.options.y,
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
delete state.options;
|
|
323
|
-
}
|
|
324
|
-
delete state.timeOffset;
|
|
325
432
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
async performMultiAction(actions, elementId) {
|
|
329
|
-
// Android needs at least two actions to be able to perform a multi pointer gesture
|
|
330
|
-
if (actions.length === 1) {
|
|
331
|
-
throw new Error('Multi Pointer Gestures need at least two actions. ' +
|
|
332
|
-
'Use Touch Actions for a single action.');
|
|
433
|
+
else {
|
|
434
|
+
release.options = lodash_1.default.pick(opts, 'x', 'y');
|
|
333
435
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
436
|
+
}
|
|
437
|
+
return release;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* @deprecated
|
|
441
|
+
* @this {import('../driver').AndroidDriver}
|
|
442
|
+
* @param {import('./types').TouchAction} gesture
|
|
443
|
+
* @returns {Promise<void>}
|
|
444
|
+
*/
|
|
445
|
+
async function performGesture(gesture) {
|
|
446
|
+
try {
|
|
447
|
+
return await this.doTouchAction(gesture.action, gesture.options || {});
|
|
448
|
+
}
|
|
449
|
+
catch (e) {
|
|
450
|
+
// sometime the element is not available when releasing, retry without it
|
|
451
|
+
if ((0, driver_1.isErrorType)(e, driver_1.errors.NoSuchElementError) &&
|
|
452
|
+
gesture.action === 'release' &&
|
|
453
|
+
gesture.options?.element) {
|
|
454
|
+
delete gesture.options.element;
|
|
455
|
+
this.log.debug(`retrying release without element opts: ${gesture.options}.`);
|
|
456
|
+
return await this.doTouchAction(gesture.action, gesture.options || {});
|
|
457
|
+
}
|
|
458
|
+
throw e;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
// #endregion
|
|
343
462
|
/**
|
|
344
463
|
* @typedef {import('appium-adb').ADB} ADB
|
|
345
464
|
* @typedef {import('./types').TouchAction} TouchAction
|