appium-android-driver 5.14.7 → 6.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/build/index.d.ts +282 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js.map +1 -0
- package/build/lib/commands/actions.d.ts +6 -224
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +306 -405
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +7 -9
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +24 -18
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +7 -313
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +135 -293
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/context.d.ts +8 -92
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +381 -439
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/element.d.ts +8 -35
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +153 -136
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/emu-console.d.ts +6 -48
- package/build/lib/commands/emu-console.d.ts.map +1 -1
- package/build/lib/commands/emu-console.js +19 -34
- package/build/lib/commands/emu-console.js.map +1 -1
- package/build/lib/commands/execute.d.ts +6 -5
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +77 -66
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +7 -128
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +183 -219
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +8 -12
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +19 -23
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +9 -132
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +281 -312
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/ime.d.ts +7 -10
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +47 -35
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/index.d.ts +27 -2
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/index.js +41 -19
- package/build/lib/commands/index.js.map +1 -1
- package/build/lib/commands/intent.d.ts +7 -417
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +104 -216
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +6 -5
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +16 -8
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/log.d.ts +7 -44
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +146 -108
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +7 -143
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +113 -140
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/mixins.d.ts +740 -0
- package/build/lib/commands/mixins.d.ts.map +1 -0
- package/build/lib/commands/mixins.js +19 -0
- package/build/lib/commands/mixins.js.map +1 -0
- package/build/lib/commands/network.d.ts +7 -138
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +212 -254
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +24 -70
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +144 -100
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +8 -92
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +75 -87
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +7 -193
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +151 -182
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/shell.d.ts +7 -7
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +40 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +9 -103
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +261 -218
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +22 -90
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +76 -74
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/touch.d.ts +10 -29
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +301 -285
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +978 -0
- package/build/lib/commands/types.d.ts.map +1 -0
- package/build/lib/commands/types.js +3 -0
- package/build/lib/commands/types.js.map +1 -0
- package/build/lib/constraints.d.ts +291 -0
- package/build/lib/constraints.d.ts.map +1 -0
- package/build/lib/constraints.js +300 -0
- package/build/lib/constraints.js.map +1 -0
- package/build/lib/driver.d.ts +68 -37
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +123 -80
- package/build/lib/driver.js.map +1 -1
- package/build/lib/helpers/android.d.ts +164 -0
- package/build/lib/helpers/android.d.ts.map +1 -0
- package/build/lib/helpers/android.js +819 -0
- package/build/lib/helpers/android.js.map +1 -0
- package/build/lib/helpers/index.d.ts +7 -0
- package/build/lib/helpers/index.d.ts.map +1 -0
- package/build/lib/helpers/index.js +29 -0
- package/build/lib/helpers/index.js.map +1 -0
- package/build/lib/helpers/types.d.ts +121 -0
- package/build/lib/helpers/types.d.ts.map +1 -0
- package/build/lib/helpers/types.js +3 -0
- package/build/lib/helpers/types.js.map +1 -0
- package/build/lib/helpers/unlock.d.ts +32 -0
- package/build/lib/helpers/unlock.d.ts.map +1 -0
- package/build/lib/helpers/unlock.js +273 -0
- package/build/lib/helpers/unlock.js.map +1 -0
- package/build/lib/helpers/webview.d.ts +74 -0
- package/build/lib/helpers/webview.d.ts.map +1 -0
- package/build/lib/helpers/webview.js +421 -0
- package/build/lib/helpers/webview.js.map +1 -0
- package/build/lib/index.d.ts +9 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +37 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/method-map.d.ts +0 -8
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +63 -74
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/stubs.d.ts +0 -1
- package/build/lib/stubs.d.ts.map +1 -1
- package/build/lib/stubs.js +1 -0
- package/build/lib/stubs.js.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/lib/commands/actions.js +351 -464
- package/lib/commands/alert.js +27 -17
- package/lib/commands/app-management.js +156 -314
- package/lib/commands/context.js +457 -441
- package/lib/commands/element.js +201 -157
- package/lib/commands/emu-console.js +25 -45
- package/lib/commands/execute.js +106 -90
- package/lib/commands/file-actions.js +222 -240
- package/lib/commands/find.ts +103 -0
- package/lib/commands/general.js +327 -339
- package/lib/commands/ime.js +50 -34
- package/lib/commands/{index.js → index.ts} +20 -24
- package/lib/commands/intent.js +108 -249
- package/lib/commands/keyboard.js +20 -8
- package/lib/commands/log.js +172 -116
- package/lib/commands/media-projection.js +134 -161
- package/lib/commands/mixins.ts +966 -0
- package/lib/commands/network.js +252 -281
- package/lib/commands/performance.js +203 -132
- package/lib/commands/permissions.js +108 -109
- package/lib/commands/recordscreen.js +212 -209
- package/lib/commands/shell.js +51 -40
- package/lib/commands/streamscreen.js +355 -289
- package/lib/commands/system-bars.js +92 -83
- package/lib/commands/touch.js +357 -294
- package/lib/commands/types.ts +1097 -0
- package/lib/{desired-caps.js → constraints.ts} +106 -103
- package/lib/{driver.js → driver.ts} +278 -132
- package/lib/helpers/android.ts +1143 -0
- package/lib/helpers/index.ts +6 -0
- package/lib/helpers/types.ts +134 -0
- package/lib/helpers/unlock.ts +329 -0
- package/lib/helpers/webview.ts +582 -0
- package/lib/index.ts +18 -0
- package/lib/method-map.js +87 -98
- package/lib/stubs.ts +0 -1
- package/package.json +27 -20
- package/index.js +0 -24
- package/lib/android-helpers.js +0 -983
- package/lib/commands/coverage.js +0 -18
- package/lib/commands/find.js +0 -82
- package/lib/unlock-helpers.js +0 -278
- package/lib/webview-helpers.js +0 -602
|
@@ -1,431 +1,332 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// @ts-check
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.helpers = exports.commands = void 0;
|
|
7
|
-
const android_helpers_1 = __importDefault(require("../android-helpers"));
|
|
8
7
|
const support_1 = require("@appium/support");
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
8
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
11
10
|
const teen_process_1 = require("teen_process");
|
|
11
|
+
const helpers_1 = require("../helpers");
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
|
+
const mixins_1 = require("./mixins");
|
|
13
14
|
const swipeStepsPerSec = 28;
|
|
14
15
|
const dragStepsPerSec = 40;
|
|
15
|
-
const commands = {};
|
|
16
|
-
exports.commands = commands;
|
|
17
|
-
const helpers = {};
|
|
18
|
-
exports.helpers = helpers;
|
|
19
|
-
const extensions = {};
|
|
20
|
-
commands.keyevent = async function keyevent(keycode, metastate = null) {
|
|
21
|
-
// TODO deprecate keyevent; currently wd only implements keyevent
|
|
22
|
-
this.log.warn('keyevent will be deprecated use pressKeyCode');
|
|
23
|
-
return await this.pressKeyCode(keycode, metastate);
|
|
24
|
-
};
|
|
25
|
-
commands.pressKeyCode = async function pressKeyCode(keycode, metastate = null) {
|
|
26
|
-
return await this.bootstrap.sendAction('pressKeyCode', { keycode, metastate });
|
|
27
|
-
};
|
|
28
|
-
commands.longPressKeyCode = async function longPressKeyCode(keycode, metastate = null) {
|
|
29
|
-
return await this.bootstrap.sendAction('longPressKeyCode', { keycode, metastate });
|
|
30
|
-
};
|
|
31
|
-
commands.getOrientation = async function getOrientation() {
|
|
32
|
-
let params = {
|
|
33
|
-
naturalOrientation: !!this.opts.androidNaturalOrientation,
|
|
34
|
-
};
|
|
35
|
-
let orientation = await this.bootstrap.sendAction('orientation', params);
|
|
36
|
-
return orientation.toUpperCase();
|
|
37
|
-
};
|
|
38
|
-
commands.setOrientation = async function setOrientation(orientation) {
|
|
39
|
-
orientation = orientation.toUpperCase();
|
|
40
|
-
let params = {
|
|
41
|
-
orientation,
|
|
42
|
-
naturalOrientation: !!this.opts.androidNaturalOrientation,
|
|
43
|
-
};
|
|
44
|
-
return await this.bootstrap.sendAction('orientation', params);
|
|
45
|
-
};
|
|
46
|
-
commands.fakeFlick = async function fakeFlick(xSpeed, ySpeed) {
|
|
47
|
-
return await this.bootstrap.sendAction('flick', { xSpeed, ySpeed });
|
|
48
|
-
};
|
|
49
|
-
commands.fakeFlickElement = async function fakeFlickElement(elementId, xoffset, yoffset, speed) {
|
|
50
|
-
let params = { xoffset, yoffset, speed, elementId };
|
|
51
|
-
return await this.bootstrap.sendAction('element:flick', params);
|
|
52
|
-
};
|
|
53
|
-
commands.swipe = async function swipe(startX, startY, endX, endY, duration, touchCount, elId) {
|
|
54
|
-
if (startX === 'null') {
|
|
55
|
-
startX = 0.5;
|
|
56
|
-
}
|
|
57
|
-
if (startY === 'null') {
|
|
58
|
-
startY = 0.5;
|
|
59
|
-
}
|
|
60
|
-
let swipeOpts = { startX, startY, endX, endY, steps: Math.round(duration * swipeStepsPerSec) };
|
|
61
|
-
// going the long way and checking for undefined and null since
|
|
62
|
-
// we can't be assured `elId` is a string and not an int
|
|
63
|
-
if (support_1.util.hasValue(elId)) {
|
|
64
|
-
swipeOpts.elementId = elId;
|
|
65
|
-
}
|
|
66
|
-
return await this.doSwipe(swipeOpts);
|
|
67
|
-
};
|
|
68
|
-
commands.doSwipe = async function doSwipe(swipeOpts) {
|
|
69
|
-
if (support_1.util.hasValue(swipeOpts.elementId)) {
|
|
70
|
-
return await this.bootstrap.sendAction('element:swipe', swipeOpts);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
return await this.bootstrap.sendAction('swipe', swipeOpts);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
commands.pinchClose = async function pinchClose(startX, startY, endX, endY, duration, percent, steps, elId) {
|
|
77
|
-
let pinchOpts = {
|
|
78
|
-
direction: 'in',
|
|
79
|
-
elementId: elId,
|
|
80
|
-
percent,
|
|
81
|
-
steps,
|
|
82
|
-
};
|
|
83
|
-
return await this.bootstrap.sendAction('element:pinch', pinchOpts);
|
|
84
|
-
};
|
|
85
|
-
commands.pinchOpen = async function pinchOpen(startX, startY, endX, endY, duration, percent, steps, elId) {
|
|
86
|
-
let pinchOpts = { direction: 'out', elementId: elId, percent, steps };
|
|
87
|
-
return await this.bootstrap.sendAction('element:pinch', pinchOpts);
|
|
88
|
-
};
|
|
89
|
-
commands.flick = async function flick(element, xSpeed, ySpeed, xOffset, yOffset, speed) {
|
|
90
|
-
if (element) {
|
|
91
|
-
await this.fakeFlickElement(element, xOffset, yOffset, speed);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
await this.fakeFlick(xSpeed, ySpeed);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
commands.drag = async function drag(startX, startY, endX, endY, duration, touchCount, elementId, destElId) {
|
|
98
|
-
let dragOpts = {
|
|
99
|
-
elementId,
|
|
100
|
-
destElId,
|
|
101
|
-
startX,
|
|
102
|
-
startY,
|
|
103
|
-
endX,
|
|
104
|
-
endY,
|
|
105
|
-
steps: Math.round(duration * dragStepsPerSec),
|
|
106
|
-
};
|
|
107
|
-
return await this.doDrag(dragOpts);
|
|
108
|
-
};
|
|
109
|
-
commands.doDrag = async function doDrag(dragOpts) {
|
|
110
|
-
if (support_1.util.hasValue(dragOpts.elementId)) {
|
|
111
|
-
return await this.bootstrap.sendAction('element:drag', dragOpts);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return await this.bootstrap.sendAction('drag', dragOpts);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* @typedef {Object} LockOptions
|
|
119
|
-
* @property {number?} seconds The number to keep the locked.
|
|
120
|
-
* 0 or empty value will keep the device locked.
|
|
121
|
-
*/
|
|
122
|
-
/**
|
|
123
|
-
* Lock the device (and optionally unlock it after a certain amount of time).
|
|
124
|
-
|
|
125
|
-
* @param {LockOptions} opts
|
|
126
|
-
* @throws {Error} if lock or unlock operation fails
|
|
127
|
-
*/
|
|
128
|
-
commands.mobileLock = async function mobileLock(opts = {}) {
|
|
129
|
-
const { seconds } = opts;
|
|
130
|
-
return await this.lock(seconds);
|
|
131
|
-
};
|
|
132
|
-
commands.lock = async function lock(seconds) {
|
|
133
|
-
await this.adb.lock();
|
|
134
|
-
if (isNaN(seconds)) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const floatSeconds = parseFloat(seconds);
|
|
138
|
-
if (floatSeconds <= 0) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
await bluebird_1.default.delay(1000 * floatSeconds);
|
|
142
|
-
await this.unlock();
|
|
143
|
-
};
|
|
144
|
-
commands.isLocked = async function isLocked() {
|
|
145
|
-
return await this.adb.isScreenLocked();
|
|
146
|
-
};
|
|
147
|
-
commands.unlock = async function unlock() {
|
|
148
|
-
return await android_helpers_1.default.unlock(this, this.adb, this.caps);
|
|
149
|
-
};
|
|
150
|
-
commands.openNotifications = async function openNotifications() {
|
|
151
|
-
return await this.bootstrap.sendAction('openNotification');
|
|
152
|
-
};
|
|
153
|
-
commands.setLocation = async function setLocation(latitude, longitude) {
|
|
154
|
-
return await this.adb.sendTelnetCommand(`geo fix ${longitude} ${latitude}`);
|
|
155
|
-
};
|
|
156
|
-
commands.fingerprint = async function fingerprint(fingerprintId) {
|
|
157
|
-
if (!this.isEmulator()) {
|
|
158
|
-
this.log.errorAndThrow('fingerprint method is only available for emulators');
|
|
159
|
-
}
|
|
160
|
-
await this.adb.fingerprint(fingerprintId);
|
|
161
|
-
};
|
|
162
16
|
/**
|
|
163
|
-
* @
|
|
164
|
-
* @
|
|
165
|
-
* was "scanned". It is a unique integer that you assign for each virtual fingerprint.
|
|
166
|
-
* When the app is running you can run this same command each time the
|
|
167
|
-
* emulator prompts you for a fingerprint, you can run the adb command and pass it
|
|
168
|
-
* the finger_id to simulate the fingerprint scan.
|
|
17
|
+
* @type {import('./mixins').ActionsMixin & ThisType<import('../driver').AndroidDriver>}
|
|
18
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
169
19
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
await this.gsmSignal(strength);
|
|
241
|
-
};
|
|
242
|
-
commands.gsmVoice = async function gsmVoice(state) {
|
|
243
|
-
if (!this.isEmulator()) {
|
|
244
|
-
this.log.errorAndThrow('gsmVoice method is only available for emulators');
|
|
245
|
-
}
|
|
246
|
-
await this.adb.gsmVoice(state);
|
|
247
|
-
};
|
|
248
|
-
/**
|
|
249
|
-
* @typedef {Object} GsmVoiceOptions
|
|
250
|
-
* @property {on|off} state
|
|
251
|
-
*/
|
|
252
|
-
/**
|
|
253
|
-
* Emulate GSM voice state change event.
|
|
254
|
-
* Only works on emulators.
|
|
255
|
-
*
|
|
256
|
-
* @param {GsmVoiceOptions} opts
|
|
257
|
-
*/
|
|
258
|
-
commands.mobileGsmVoice = async function mobileGsmVoice(opts = {}) {
|
|
259
|
-
const { state } = (0, utils_1.requireArgs)('state', opts);
|
|
260
|
-
await this.gsmVoice(state);
|
|
261
|
-
};
|
|
262
|
-
commands.powerAC = async function powerAC(state) {
|
|
263
|
-
if (!this.isEmulator()) {
|
|
264
|
-
this.log.errorAndThrow('powerAC method is only available for emulators');
|
|
265
|
-
}
|
|
266
|
-
await this.adb.powerAC(state);
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* @typedef {Object} PowerAcOptions
|
|
270
|
-
* @property {on|off} state
|
|
271
|
-
*/
|
|
272
|
-
/**
|
|
273
|
-
* Emulate AC power state change.
|
|
274
|
-
* Only works on emulators.
|
|
275
|
-
*
|
|
276
|
-
* @param {GsmVoiceOptions} opts
|
|
277
|
-
*/
|
|
278
|
-
commands.mobilePowerAc = async function mobilePowerAc(opts = {}) {
|
|
279
|
-
const { state } = (0, utils_1.requireArgs)('state', opts);
|
|
280
|
-
await this.powerAC(state);
|
|
281
|
-
};
|
|
282
|
-
commands.powerCapacity = async function powerCapacity(batteryPercent) {
|
|
283
|
-
if (!this.isEmulator()) {
|
|
284
|
-
this.log.errorAndThrow('powerCapacity method is only available for emulators');
|
|
285
|
-
}
|
|
286
|
-
await this.adb.powerCapacity(batteryPercent);
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* @typedef {Object} PowerCapacityOptions
|
|
290
|
-
* @property {number} percent - Percentage value in range [0, 100]
|
|
291
|
-
*/
|
|
292
|
-
/**
|
|
293
|
-
* Emulate power capacity change.
|
|
294
|
-
* Only works on emulators.
|
|
295
|
-
*
|
|
296
|
-
* @param {PowerCapacityOptions} opts
|
|
297
|
-
*/
|
|
298
|
-
commands.mobilePowerCapacity = async function mobilePowerCapacity(opts = {}) {
|
|
299
|
-
const { percent } = (0, utils_1.requireArgs)('percent', opts);
|
|
300
|
-
await this.powerCapacity(percent);
|
|
301
|
-
};
|
|
302
|
-
commands.networkSpeed = async function networkSpeed(networkSpeed) {
|
|
303
|
-
if (!this.isEmulator()) {
|
|
304
|
-
this.log.errorAndThrow('networkSpeed method is only available for emulators');
|
|
305
|
-
}
|
|
306
|
-
await this.adb.networkSpeed(networkSpeed);
|
|
307
|
-
};
|
|
308
|
-
/**
|
|
309
|
-
* @typedef {Object} NetworkSpeedOptions
|
|
310
|
-
* @property {gsm|scsd|gprs|edge|umts|hsdpa|lte|evdo|full} speed
|
|
311
|
-
*/
|
|
312
|
-
/**
|
|
313
|
-
* Emulate different network connection speed modes.
|
|
314
|
-
* Only works on emulators.
|
|
315
|
-
*
|
|
316
|
-
* @param {NetworkSpeedOptions} opts
|
|
317
|
-
*/
|
|
318
|
-
commands.mobileNetworkSpeed = async function mobileNetworkSpeed(opts = {}) {
|
|
319
|
-
const { speed } = (0, utils_1.requireArgs)('speed', opts);
|
|
320
|
-
await this.networkSpeed(speed);
|
|
321
|
-
};
|
|
322
|
-
/**
|
|
323
|
-
* Emulate sensors values on the connected emulator.
|
|
324
|
-
*
|
|
325
|
-
* @typedef {Object} Sensor
|
|
326
|
-
* @property {string} sensorType - sensor type declared in adb.SENSORS
|
|
327
|
-
* @property {string} value - value to set to the sensor
|
|
328
|
-
*
|
|
329
|
-
* @param {Object} Sensor
|
|
330
|
-
* @throws {Error} - If sensorType is not defined
|
|
331
|
-
* @throws {Error} - If value for the se sor is not defined
|
|
332
|
-
* @throws {Error} - If deviceType is not an emulator
|
|
333
|
-
*/
|
|
334
|
-
commands.sensorSet = async function sensorSet(sensor = {}) {
|
|
335
|
-
const { sensorType, value } = sensor;
|
|
336
|
-
if (!support_1.util.hasValue(sensorType)) {
|
|
337
|
-
this.log.errorAndThrow(`'sensorType' argument is required`);
|
|
338
|
-
}
|
|
339
|
-
if (!support_1.util.hasValue(value)) {
|
|
340
|
-
this.log.errorAndThrow(`'value' argument is required`);
|
|
341
|
-
}
|
|
342
|
-
if (!this.isEmulator()) {
|
|
343
|
-
this.log.errorAndThrow('sensorSet method is only available for emulators');
|
|
344
|
-
}
|
|
345
|
-
await this.adb.sensorSet(sensorType, value);
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
|
-
* @param {ADB} adb
|
|
349
|
-
* @param {Object} opts
|
|
350
|
-
* @returns {Promise<Buffer>}
|
|
351
|
-
*/
|
|
352
|
-
helpers.getScreenshotDataWithAdbShell = async function getScreenshotDataWithAdbShell(adb, opts) {
|
|
353
|
-
const localFile = await support_1.tempDir.path({ prefix: 'appium', suffix: '.png' });
|
|
354
|
-
if (await support_1.fs.exists(localFile)) {
|
|
355
|
-
await support_1.fs.unlink(localFile);
|
|
356
|
-
}
|
|
357
|
-
try {
|
|
358
|
-
const pngDir = opts.androidScreenshotPath || '/data/local/tmp/';
|
|
359
|
-
const png = path_1.default.posix.resolve(pngDir, 'screenshot.png');
|
|
360
|
-
await adb.shell(['/system/bin/rm', `${png};`, '/system/bin/screencap', '-p', png]);
|
|
361
|
-
if (!(await adb.fileSize(png))) {
|
|
362
|
-
throw new Error('The size of the taken screenshot equals to zero.');
|
|
20
|
+
const ActionsMixin = {
|
|
21
|
+
async keyevent(keycode, metastate) {
|
|
22
|
+
// TODO deprecate keyevent; currently wd only implements keyevent
|
|
23
|
+
this.log.warn('keyevent will be deprecated use pressKeyCode');
|
|
24
|
+
return await this.pressKeyCode(keycode, metastate);
|
|
25
|
+
},
|
|
26
|
+
async pressKeyCode(keycode, metastate) {
|
|
27
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('pressKeyCode', {
|
|
28
|
+
keycode,
|
|
29
|
+
metastate: metastate ?? null,
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
async longPressKeyCode(keycode, metastate) {
|
|
33
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('longPressKeyCode', {
|
|
34
|
+
keycode,
|
|
35
|
+
metastate: metastate ?? null,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
async getOrientation() {
|
|
39
|
+
let params = {
|
|
40
|
+
naturalOrientation: !!this.opts.androidNaturalOrientation,
|
|
41
|
+
};
|
|
42
|
+
let orientation = await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('orientation', params);
|
|
43
|
+
return orientation.toUpperCase();
|
|
44
|
+
},
|
|
45
|
+
async setOrientation(orientation) {
|
|
46
|
+
let params = {
|
|
47
|
+
orientation: orientation.toUpperCase(),
|
|
48
|
+
naturalOrientation: !!this.opts.androidNaturalOrientation,
|
|
49
|
+
};
|
|
50
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('orientation', params);
|
|
51
|
+
},
|
|
52
|
+
async fakeFlick(xSpeed, ySpeed) {
|
|
53
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('flick', {
|
|
54
|
+
xSpeed,
|
|
55
|
+
ySpeed,
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
async fakeFlickElement(elementId, xoffset, yoffset, speed) {
|
|
59
|
+
let params = { xoffset, yoffset, speed, elementId };
|
|
60
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('element:flick', params);
|
|
61
|
+
},
|
|
62
|
+
async swipe(startX, startY, endX, endY, duration, touchCount, elId) {
|
|
63
|
+
if (startX === 'null') {
|
|
64
|
+
startX = 0.5;
|
|
65
|
+
}
|
|
66
|
+
if (startY === 'null') {
|
|
67
|
+
startY = 0.5;
|
|
68
|
+
}
|
|
69
|
+
/** @type {import('./types').SwipeOpts} */
|
|
70
|
+
const swipeOpts = {
|
|
71
|
+
startX,
|
|
72
|
+
startY,
|
|
73
|
+
endX,
|
|
74
|
+
endY,
|
|
75
|
+
steps: Math.round(duration * swipeStepsPerSec),
|
|
76
|
+
};
|
|
77
|
+
// going the long way and checking for undefined and null since
|
|
78
|
+
// we can't be assured `elId` is a string and not an int
|
|
79
|
+
if (support_1.util.hasValue(elId)) {
|
|
80
|
+
swipeOpts.elementId = elId;
|
|
81
|
+
}
|
|
82
|
+
return await this.doSwipe(swipeOpts);
|
|
83
|
+
},
|
|
84
|
+
async doSwipe(swipeOpts) {
|
|
85
|
+
if (support_1.util.hasValue(swipeOpts.elementId)) {
|
|
86
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('element:swipe', swipeOpts);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('swipe', swipeOpts);
|
|
363
90
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
91
|
+
},
|
|
92
|
+
async pinchClose(startX, startY, endX, endY, duration, percent, steps, elId) {
|
|
93
|
+
let pinchOpts = {
|
|
94
|
+
direction: 'in',
|
|
95
|
+
elementId: elId,
|
|
96
|
+
percent,
|
|
97
|
+
steps,
|
|
98
|
+
};
|
|
99
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('element:pinch', pinchOpts);
|
|
100
|
+
},
|
|
101
|
+
async pinchOpen(startX, startY, endX, endY, duration, percent, steps, elId) {
|
|
102
|
+
let pinchOpts = { direction: 'out', elementId: elId, percent, steps };
|
|
103
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('element:pinch', pinchOpts);
|
|
104
|
+
},
|
|
105
|
+
async flick(element, xSpeed, ySpeed, xOffset, yOffset, speed) {
|
|
106
|
+
if (element) {
|
|
107
|
+
await this.fakeFlickElement(element, xOffset, yOffset, speed);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
await this.fakeFlick(xSpeed, ySpeed);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
async drag(startX, startY, endX, endY, duration, touchCount, elementId, destElId) {
|
|
114
|
+
let dragOpts = {
|
|
115
|
+
elementId,
|
|
116
|
+
destElId,
|
|
117
|
+
startX,
|
|
118
|
+
startY,
|
|
119
|
+
endX,
|
|
120
|
+
endY,
|
|
121
|
+
steps: Math.round(duration * dragStepsPerSec),
|
|
122
|
+
};
|
|
123
|
+
return await this.doDrag(dragOpts);
|
|
124
|
+
},
|
|
125
|
+
async doDrag(dragOpts) {
|
|
126
|
+
if (support_1.util.hasValue(dragOpts.elementId)) {
|
|
127
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('element:drag', dragOpts);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('drag', dragOpts);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
async mobileLock(opts = {}) {
|
|
134
|
+
const { seconds } = opts;
|
|
135
|
+
return await this.lock(seconds);
|
|
136
|
+
},
|
|
137
|
+
async lock(seconds) {
|
|
138
|
+
await /** @type {ADB} */ (this.adb).lock();
|
|
139
|
+
if (Number.isNaN(seconds)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const floatSeconds = parseFloat(String(seconds));
|
|
143
|
+
if (floatSeconds <= 0) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
await bluebird_1.default.delay(1000 * floatSeconds);
|
|
147
|
+
await this.unlock();
|
|
148
|
+
},
|
|
149
|
+
async isLocked() {
|
|
150
|
+
return await /** @type {ADB} */ (this.adb).isScreenLocked();
|
|
151
|
+
},
|
|
152
|
+
async unlock() {
|
|
153
|
+
return await helpers_1.AndroidHelpers.unlock(this, /** @type {ADB} */ (this.adb), this.caps);
|
|
154
|
+
},
|
|
155
|
+
async openNotifications() {
|
|
156
|
+
return await /** @type {AndroidBootstrap} */ (this.bootstrap).sendAction('openNotification');
|
|
157
|
+
},
|
|
158
|
+
async setLocation(latitude, longitude) {
|
|
159
|
+
await /** @type {ADB} */ (this.adb).sendTelnetCommand(`geo fix ${longitude} ${latitude}`);
|
|
160
|
+
},
|
|
161
|
+
async fingerprint(fingerprintId) {
|
|
162
|
+
if (!this.isEmulator()) {
|
|
163
|
+
this.log.errorAndThrow('fingerprint method is only available for emulators');
|
|
164
|
+
}
|
|
165
|
+
await /** @type {ADB} */ (this.adb).fingerprint(String(fingerprintId));
|
|
166
|
+
},
|
|
167
|
+
async mobileFingerprint(opts) {
|
|
168
|
+
const { fingerprintId } = (0, utils_1.requireArgs)('fingerprintId', opts);
|
|
169
|
+
await this.fingerprint(fingerprintId);
|
|
170
|
+
},
|
|
171
|
+
async sendSMS(phoneNumber, message) {
|
|
172
|
+
if (!this.isEmulator()) {
|
|
173
|
+
this.log.errorAndThrow('sendSMS method is only available for emulators');
|
|
174
|
+
}
|
|
175
|
+
await /** @type {ADB} */ (this.adb).sendSMS(phoneNumber, message);
|
|
176
|
+
},
|
|
177
|
+
async mobileSendSms(opts) {
|
|
178
|
+
const { phoneNumber, message } = (0, utils_1.requireArgs)(['phoneNumber', 'message'], opts);
|
|
179
|
+
await this.sendSMS(phoneNumber, message);
|
|
180
|
+
},
|
|
181
|
+
async gsmCall(phoneNumber, action) {
|
|
182
|
+
if (!this.isEmulator()) {
|
|
183
|
+
this.log.errorAndThrow('gsmCall method is only available for emulators');
|
|
184
|
+
}
|
|
185
|
+
await /** @type {ADB} */ (this.adb).gsmCall(phoneNumber, action);
|
|
186
|
+
},
|
|
187
|
+
async mobileGsmCall(opts) {
|
|
188
|
+
const { phoneNumber, action } = (0, utils_1.requireArgs)(['phoneNumber', 'action'], opts);
|
|
189
|
+
await this.gsmCall(phoneNumber, action);
|
|
190
|
+
},
|
|
191
|
+
async gsmSignal(signalStrengh) {
|
|
192
|
+
if (!this.isEmulator()) {
|
|
193
|
+
this.log.errorAndThrow('gsmSignal method is only available for emulators');
|
|
194
|
+
}
|
|
195
|
+
await /** @type {ADB} */ (this.adb).gsmSignal(signalStrengh);
|
|
196
|
+
},
|
|
197
|
+
async mobileGsmSignal(opts) {
|
|
198
|
+
const { strength } = (0, utils_1.requireArgs)('strength', opts);
|
|
199
|
+
await this.gsmSignal(strength);
|
|
200
|
+
},
|
|
201
|
+
async gsmVoice(state) {
|
|
202
|
+
if (!this.isEmulator()) {
|
|
203
|
+
this.log.errorAndThrow('gsmVoice method is only available for emulators');
|
|
204
|
+
}
|
|
205
|
+
await /** @type {ADB} */ (this.adb).gsmVoice(state);
|
|
206
|
+
},
|
|
207
|
+
async mobileGsmVoice(opts) {
|
|
208
|
+
const { state } = (0, utils_1.requireArgs)('state', opts);
|
|
209
|
+
await this.gsmVoice(state);
|
|
210
|
+
},
|
|
211
|
+
async powerAC(state) {
|
|
212
|
+
if (!this.isEmulator()) {
|
|
213
|
+
this.log.errorAndThrow('powerAC method is only available for emulators');
|
|
214
|
+
}
|
|
215
|
+
await /** @type {ADB} */ (this.adb).powerAC(state);
|
|
216
|
+
},
|
|
217
|
+
async mobilePowerAc(opts) {
|
|
218
|
+
const { state } = (0, utils_1.requireArgs)('state', opts);
|
|
219
|
+
await this.powerAC(state);
|
|
220
|
+
},
|
|
221
|
+
async powerCapacity(batteryPercent) {
|
|
222
|
+
if (!this.isEmulator()) {
|
|
223
|
+
this.log.errorAndThrow('powerCapacity method is only available for emulators');
|
|
224
|
+
}
|
|
225
|
+
await /** @type {ADB} */ (this.adb).powerCapacity(batteryPercent);
|
|
226
|
+
},
|
|
227
|
+
async mobilePowerCapacity(opts) {
|
|
228
|
+
const { percent } = (0, utils_1.requireArgs)('percent', opts);
|
|
229
|
+
await this.powerCapacity(percent);
|
|
230
|
+
},
|
|
231
|
+
async networkSpeed(networkSpeed) {
|
|
232
|
+
if (!this.isEmulator()) {
|
|
233
|
+
this.log.errorAndThrow('networkSpeed method is only available for emulators');
|
|
234
|
+
}
|
|
235
|
+
await /** @type {ADB} */ (this.adb).networkSpeed(networkSpeed);
|
|
236
|
+
},
|
|
237
|
+
async mobileNetworkSpeed(opts) {
|
|
238
|
+
const { speed } = (0, utils_1.requireArgs)('speed', opts);
|
|
239
|
+
await this.networkSpeed(speed);
|
|
240
|
+
},
|
|
241
|
+
async sensorSet(opts) {
|
|
242
|
+
const { sensorType, value } = opts;
|
|
243
|
+
if (!support_1.util.hasValue(sensorType)) {
|
|
244
|
+
this.log.errorAndThrow(`'sensorType' argument is required`);
|
|
245
|
+
}
|
|
246
|
+
if (!support_1.util.hasValue(value)) {
|
|
247
|
+
this.log.errorAndThrow(`'value' argument is required`);
|
|
248
|
+
}
|
|
249
|
+
if (!this.isEmulator()) {
|
|
250
|
+
this.log.errorAndThrow('sensorSet method is only available for emulators');
|
|
251
|
+
}
|
|
252
|
+
await /** @type {ADB} */ (this.adb).sensorSet(sensorType, value);
|
|
253
|
+
},
|
|
254
|
+
async getScreenshotDataWithAdbShell(adb, opts) {
|
|
255
|
+
const localFile = await support_1.tempDir.path({ prefix: 'appium', suffix: '.png' });
|
|
368
256
|
if (await support_1.fs.exists(localFile)) {
|
|
369
257
|
await support_1.fs.unlink(localFile);
|
|
370
258
|
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
/**
|
|
374
|
-
* @param {ADB} adb
|
|
375
|
-
* @returns {Promise<Buffer>}
|
|
376
|
-
*/
|
|
377
|
-
helpers.getScreenshotDataWithAdbExecOut = async function getScreenshotDataWithAdbExecOut(adb) {
|
|
378
|
-
const { stdout, stderr, code } = await (0, teen_process_1.exec)(adb.executable.path, [...adb.executable.defaultArgs, 'exec-out', '/system/bin/screencap', '-p'], { encoding: 'binary', isBuffer: true });
|
|
379
|
-
// if there is an error, throw
|
|
380
|
-
if (code || stderr.length) {
|
|
381
|
-
throw new Error(`Screenshot returned error, code: '${code}', stderr: '${stderr.toString()}'`);
|
|
382
|
-
}
|
|
383
|
-
// if we don't get anything at all, throw
|
|
384
|
-
if (!stdout.length) {
|
|
385
|
-
throw new Error('Screenshot returned no data');
|
|
386
|
-
}
|
|
387
|
-
return stdout;
|
|
388
|
-
};
|
|
389
|
-
commands.getScreenshot = async function getScreenshot() {
|
|
390
|
-
const apiLevel = await this.adb.getApiLevel();
|
|
391
|
-
let image = null;
|
|
392
|
-
if (apiLevel > 20) {
|
|
393
259
|
try {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
260
|
+
const pngDir = opts.androidScreenshotPath || '/data/local/tmp/';
|
|
261
|
+
const png = path_1.default.posix.resolve(pngDir, 'screenshot.png');
|
|
262
|
+
await adb.shell(['/system/bin/rm', `${png};`, '/system/bin/screencap', '-p', png]);
|
|
263
|
+
if (!(await adb.fileSize(png))) {
|
|
264
|
+
throw new Error('The size of the taken screenshot equals to zero.');
|
|
265
|
+
}
|
|
266
|
+
await adb.pull(png, localFile);
|
|
267
|
+
return await support_1.fs.readFile(localFile);
|
|
397
268
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
269
|
+
finally {
|
|
270
|
+
if (await support_1.fs.exists(localFile)) {
|
|
271
|
+
await support_1.fs.unlink(localFile);
|
|
272
|
+
}
|
|
401
273
|
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
274
|
+
},
|
|
275
|
+
async getScreenshotDataWithAdbExecOut(adb) {
|
|
276
|
+
const { stdout, stderr, code } = await (0, teen_process_1.exec)(adb.executable.path, [...adb.executable.defaultArgs, 'exec-out', '/system/bin/screencap', '-p'], { encoding: 'binary', isBuffer: true });
|
|
277
|
+
// if there is an error, throw
|
|
278
|
+
if (code || stderr.length) {
|
|
279
|
+
throw new Error(`Screenshot returned error, code: '${code}', stderr: '${stderr.toString()}'`);
|
|
406
280
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
`the current view`;
|
|
411
|
-
this.log.errorAndThrow(err);
|
|
281
|
+
// if we don't get anything at all, throw
|
|
282
|
+
if (!stdout.length) {
|
|
283
|
+
throw new Error('Screenshot returned no data');
|
|
412
284
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
.
|
|
285
|
+
return stdout;
|
|
286
|
+
},
|
|
287
|
+
async getScreenshot() {
|
|
288
|
+
const apiLevel = await /** @type {ADB} */ (this.adb).getApiLevel();
|
|
289
|
+
let image = null;
|
|
290
|
+
if (apiLevel > 20) {
|
|
291
|
+
try {
|
|
292
|
+
// This screenshoting approach is way faster, since it requires less external commands
|
|
293
|
+
// to be executed. Unfortunately, exec-out option is only supported by newer Android/SDK versions (5.0 and later)
|
|
294
|
+
image = await this.getScreenshotDataWithAdbExecOut(/** @type {ADB} */ (this.adb));
|
|
295
|
+
}
|
|
296
|
+
catch (e) {
|
|
297
|
+
this.log.info(`Cannot get screenshot data with 'adb exec-out' because of '${
|
|
298
|
+
/** @type {Error} */ (e).message}'. ` + `Defaulting to 'adb shell' call`);
|
|
299
|
+
}
|
|
422
300
|
}
|
|
423
|
-
|
|
424
|
-
|
|
301
|
+
if (!image) {
|
|
302
|
+
try {
|
|
303
|
+
image = await this.getScreenshotDataWithAdbShell(/** @type {ADB} */ (this.adb), this.opts);
|
|
304
|
+
}
|
|
305
|
+
catch (e) {
|
|
306
|
+
const err = `Cannot get screenshot data because of '${ /** @type {Error} */(e).message}'. ` +
|
|
307
|
+
`Make sure the 'LayoutParams.FLAG_SECURE' is not set for ` +
|
|
308
|
+
`the current view`;
|
|
309
|
+
this.log.error(err);
|
|
310
|
+
throw new Error(err);
|
|
311
|
+
}
|
|
425
312
|
}
|
|
426
|
-
|
|
427
|
-
|
|
313
|
+
if (apiLevel < 23) {
|
|
314
|
+
// Android bug 8433742 - rotate screenshot if screen is rotated
|
|
315
|
+
let screenOrientation = await /** @type {ADB} */ (this.adb).getScreenOrientation();
|
|
316
|
+
try {
|
|
317
|
+
image = await support_1.imageUtil.requireSharp()(image).rotate(-90 * screenOrientation).toBuffer();
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
this.log.warn(`Could not rotate screenshot due to error: ${err}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return image.toString('base64');
|
|
324
|
+
},
|
|
428
325
|
};
|
|
429
|
-
|
|
430
|
-
exports.default =
|
|
326
|
+
(0, mixins_1.mixin)(ActionsMixin);
|
|
327
|
+
exports.default = ActionsMixin;
|
|
328
|
+
/**
|
|
329
|
+
* @typedef {import('../bootstrap').AndroidBootstrap} AndroidBootstrap
|
|
330
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
331
|
+
*/
|
|
431
332
|
//# sourceMappingURL=actions.js.map
|