appium-android-driver 12.6.6 → 12.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +1 -1
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/bidi/models.d.ts.map +1 -1
- package/build/lib/commands/bidi/models.js.map +1 -1
- package/build/lib/commands/bidi/types.js +0 -1
- package/build/lib/commands/bidi/types.js.map +1 -1
- package/build/lib/commands/bluetooth.d.ts +1 -1
- package/build/lib/commands/bluetooth.d.ts.map +1 -1
- package/build/lib/commands/bluetooth.js.map +1 -1
- package/build/lib/commands/context/exports.d.ts.map +1 -1
- package/build/lib/commands/context/exports.js.map +1 -1
- package/build/lib/commands/context/helpers.d.ts.map +1 -1
- package/build/lib/commands/context/helpers.js +1 -2
- package/build/lib/commands/context/helpers.js.map +1 -1
- package/build/lib/commands/device/common.d.ts.map +1 -1
- package/build/lib/commands/device/common.js +2 -3
- package/build/lib/commands/device/common.js.map +1 -1
- package/build/lib/commands/device/emulator-actions.d.ts.map +1 -1
- package/build/lib/commands/device/emulator-actions.js.map +1 -1
- package/build/lib/commands/device/utils.d.ts.map +1 -1
- package/build/lib/commands/device/utils.js +2 -2
- package/build/lib/commands/device/utils.js.map +1 -1
- package/build/lib/commands/deviceidle.d.ts +1 -1
- package/build/lib/commands/deviceidle.d.ts.map +1 -1
- package/build/lib/commands/deviceidle.js.map +1 -1
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +1 -1
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +1 -2
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/geolocation.d.ts.map +1 -1
- package/build/lib/commands/geolocation.js.map +1 -1
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/image-injection.d.ts.map +1 -1
- package/build/lib/commands/image-injection.js.map +1 -1
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +2 -8
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/legacy.d.ts.map +1 -1
- package/build/lib/commands/legacy.js.map +1 -1
- package/build/lib/commands/lock/exports.d.ts.map +1 -1
- package/build/lib/commands/lock/exports.js.map +1 -1
- package/build/lib/commands/lock/helpers.d.ts.map +1 -1
- package/build/lib/commands/lock/helpers.js.map +1 -1
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +5 -3
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/misc.d.ts.map +1 -1
- package/build/lib/commands/misc.js.map +1 -1
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +1 -1
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/nfc.d.ts.map +1 -1
- package/build/lib/commands/nfc.js.map +1 -1
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +4 -4
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +1 -3
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/resources.js +3 -4
- package/build/lib/commands/resources.js.map +1 -1
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +4 -4
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/time.d.ts.map +1 -1
- package/build/lib/commands/time.js.map +1 -1
- package/build/lib/constraints.js +2 -2
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js.map +1 -1
- package/build/lib/execute-method-map.d.ts.map +1 -1
- package/build/lib/execute-method-map.js +32 -64
- package/build/lib/execute-method-map.js.map +1 -1
- package/build/lib/method-map.js +54 -54
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js.map +1 -1
- package/lib/commands/app-management.ts +25 -26
- package/lib/commands/appearance.ts +1 -4
- package/lib/commands/bidi/models.ts +12 -10
- package/lib/commands/bidi/types.ts +1 -1
- package/lib/commands/bluetooth.ts +3 -7
- package/lib/commands/context/cache.ts +0 -1
- package/lib/commands/context/exports.ts +3 -14
- package/lib/commands/context/helpers.ts +7 -8
- package/lib/commands/device/common.ts +51 -52
- package/lib/commands/device/emulator-actions.ts +15 -34
- package/lib/commands/device/emulator-console.ts +0 -1
- package/lib/commands/device/utils.ts +4 -3
- package/lib/commands/deviceidle.ts +1 -2
- package/lib/commands/element.ts +10 -38
- package/lib/commands/execute.ts +3 -5
- package/lib/commands/file-actions.ts +4 -17
- package/lib/commands/geolocation.ts +21 -39
- package/lib/commands/gestures.ts +1 -5
- package/lib/commands/image-injection.ts +9 -8
- package/lib/commands/ime.ts +5 -17
- package/lib/commands/intent.ts +58 -57
- package/lib/commands/keyboard.ts +6 -21
- package/lib/commands/legacy.ts +4 -11
- package/lib/commands/lock/exports.ts +4 -2
- package/lib/commands/lock/helpers.ts +4 -1
- package/lib/commands/log.ts +15 -25
- package/lib/commands/media-projection.ts +0 -1
- package/lib/commands/memory.ts +0 -1
- package/lib/commands/misc.ts +6 -20
- package/lib/commands/network.ts +9 -28
- package/lib/commands/nfc.ts +2 -6
- package/lib/commands/performance.ts +2 -8
- package/lib/commands/permissions.ts +10 -9
- package/lib/commands/recordscreen.ts +16 -18
- package/lib/commands/resources.ts +6 -7
- package/lib/commands/shell.ts +1 -1
- package/lib/commands/streamscreen.ts +2 -7
- package/lib/commands/system-bars.ts +32 -38
- package/lib/commands/time.ts +3 -10
- package/lib/constraints.ts +2 -2
- package/lib/doctor/checks.ts +0 -1
- package/lib/doctor/utils.ts +0 -1
- package/lib/driver.ts +7 -20
- package/lib/execute-method-map.ts +32 -64
- package/lib/method-map.ts +56 -57
- package/lib/utils.ts +5 -6
- package/package.json +3 -2
package/lib/commands/element.ts
CHANGED
|
@@ -28,10 +28,7 @@ export async function getAttribute(
|
|
|
28
28
|
* @returns Promise that resolves when the click is performed.
|
|
29
29
|
* @throws {errors.NotImplementedError} This method is not implemented.
|
|
30
30
|
*/
|
|
31
|
-
export async function click(
|
|
32
|
-
this: AndroidDriver,
|
|
33
|
-
elementId: string,
|
|
34
|
-
): Promise<void> {
|
|
31
|
+
export async function click(this: AndroidDriver, elementId: string): Promise<void> {
|
|
35
32
|
throw new errors.NotImplementedError('Not implemented');
|
|
36
33
|
}
|
|
37
34
|
|
|
@@ -42,10 +39,7 @@ export async function click(
|
|
|
42
39
|
* @returns Promise that resolves to the element's text content.
|
|
43
40
|
* @throws {errors.NotImplementedError} This method is not implemented.
|
|
44
41
|
*/
|
|
45
|
-
export async function getText(
|
|
46
|
-
this: AndroidDriver,
|
|
47
|
-
elementId: string,
|
|
48
|
-
): Promise<string> {
|
|
42
|
+
export async function getText(this: AndroidDriver, elementId: string): Promise<string> {
|
|
49
43
|
throw new errors.NotImplementedError('Not implemented');
|
|
50
44
|
}
|
|
51
45
|
|
|
@@ -56,10 +50,7 @@ export async function getText(
|
|
|
56
50
|
* @returns Promise that resolves to the element's position (x, y coordinates).
|
|
57
51
|
* @throws {errors.NotImplementedError} This method is not implemented.
|
|
58
52
|
*/
|
|
59
|
-
export async function getLocation(
|
|
60
|
-
this: AndroidDriver,
|
|
61
|
-
elementId: string,
|
|
62
|
-
): Promise<Position> {
|
|
53
|
+
export async function getLocation(this: AndroidDriver, elementId: string): Promise<Position> {
|
|
63
54
|
throw new errors.NotImplementedError('Not implemented');
|
|
64
55
|
}
|
|
65
56
|
|
|
@@ -70,10 +61,7 @@ export async function getLocation(
|
|
|
70
61
|
* @returns Promise that resolves to the element's size (width, height).
|
|
71
62
|
* @throws {errors.NotImplementedError} This method is not implemented.
|
|
72
63
|
*/
|
|
73
|
-
export async function getSize(
|
|
74
|
-
this: AndroidDriver,
|
|
75
|
-
elementId: string,
|
|
76
|
-
): Promise<Size> {
|
|
64
|
+
export async function getSize(this: AndroidDriver, elementId: string): Promise<Size> {
|
|
77
65
|
throw new errors.NotImplementedError('Not implemented');
|
|
78
66
|
}
|
|
79
67
|
|
|
@@ -83,11 +71,8 @@ export async function getSize(
|
|
|
83
71
|
* @param elementId The element identifier.
|
|
84
72
|
* @returns Promise that resolves to the element's class name.
|
|
85
73
|
*/
|
|
86
|
-
export async function getName(
|
|
87
|
-
this
|
|
88
|
-
elementId: string,
|
|
89
|
-
): Promise<string> {
|
|
90
|
-
return await this.getAttribute('className', elementId) as string;
|
|
74
|
+
export async function getName(this: AndroidDriver, elementId: string): Promise<string> {
|
|
75
|
+
return (await this.getAttribute('className', elementId)) as string;
|
|
91
76
|
}
|
|
92
77
|
|
|
93
78
|
/**
|
|
@@ -96,10 +81,7 @@ export async function getName(
|
|
|
96
81
|
* @param elementId The element identifier.
|
|
97
82
|
* @returns Promise that resolves to `true` if the element is displayed, `false` otherwise.
|
|
98
83
|
*/
|
|
99
|
-
export async function elementDisplayed(
|
|
100
|
-
this: AndroidDriver,
|
|
101
|
-
elementId: string,
|
|
102
|
-
): Promise<boolean> {
|
|
84
|
+
export async function elementDisplayed(this: AndroidDriver, elementId: string): Promise<boolean> {
|
|
103
85
|
return (await this.getAttribute('displayed', elementId)) === 'true';
|
|
104
86
|
}
|
|
105
87
|
|
|
@@ -109,10 +91,7 @@ export async function elementDisplayed(
|
|
|
109
91
|
* @param elementId The element identifier.
|
|
110
92
|
* @returns Promise that resolves to `true` if the element is enabled, `false` otherwise.
|
|
111
93
|
*/
|
|
112
|
-
export async function elementEnabled(
|
|
113
|
-
this: AndroidDriver,
|
|
114
|
-
elementId: string,
|
|
115
|
-
): Promise<boolean> {
|
|
94
|
+
export async function elementEnabled(this: AndroidDriver, elementId: string): Promise<boolean> {
|
|
116
95
|
return (await this.getAttribute('enabled', elementId)) === 'true';
|
|
117
96
|
}
|
|
118
97
|
|
|
@@ -122,10 +101,7 @@ export async function elementEnabled(
|
|
|
122
101
|
* @param elementId The element identifier.
|
|
123
102
|
* @returns Promise that resolves to `true` if the element is selected, `false` otherwise.
|
|
124
103
|
*/
|
|
125
|
-
export async function elementSelected(
|
|
126
|
-
this: AndroidDriver,
|
|
127
|
-
elementId: string,
|
|
128
|
-
): Promise<boolean> {
|
|
104
|
+
export async function elementSelected(this: AndroidDriver, elementId: string): Promise<boolean> {
|
|
129
105
|
return (await this.getAttribute('selected', elementId)) === 'true';
|
|
130
106
|
}
|
|
131
107
|
|
|
@@ -225,10 +201,6 @@ export async function setValueImmediate(
|
|
|
225
201
|
* @param elementId The element identifier.
|
|
226
202
|
* @returns Promise that resolves to the element's position (x, y coordinates).
|
|
227
203
|
*/
|
|
228
|
-
export async function getLocationInView(
|
|
229
|
-
this: AndroidDriver,
|
|
230
|
-
elementId: string,
|
|
231
|
-
): Promise<Position> {
|
|
204
|
+
export async function getLocationInView(this: AndroidDriver, elementId: string): Promise<Position> {
|
|
232
205
|
return await this.getLocation(elementId);
|
|
233
206
|
}
|
|
234
|
-
|
package/lib/commands/execute.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import {errors, PROTOCOLS} from 'appium/driver';
|
|
3
|
-
import {
|
|
3
|
+
import {util} from '@appium/support';
|
|
4
4
|
import type {StringRecord, Element} from '@appium/types';
|
|
5
5
|
import type {AndroidDriver} from '../driver';
|
|
6
6
|
import type {Chromedriver} from 'appium-chromedriver';
|
|
@@ -30,8 +30,7 @@ export async function execute(
|
|
|
30
30
|
throw new errors.NotImplementedError();
|
|
31
31
|
}
|
|
32
32
|
const endpoint =
|
|
33
|
-
(this.chromedriver as Chromedriver).jwproxy
|
|
34
|
-
.downstreamProtocol === PROTOCOLS.MJSONWP
|
|
33
|
+
(this.chromedriver as Chromedriver).jwproxy.downstreamProtocol === PROTOCOLS.MJSONWP
|
|
35
34
|
? '/execute'
|
|
36
35
|
: '/execute/sync';
|
|
37
36
|
return await (this.chromedriver as Chromedriver).jwproxy.command(endpoint, 'POST', {
|
|
@@ -49,7 +48,7 @@ export async function execute(
|
|
|
49
48
|
* @returns Preprocessed arguments as a StringRecord.
|
|
50
49
|
*/
|
|
51
50
|
function preprocessExecuteMethodArgs(args?: ExecuteMethodArgs): StringRecord {
|
|
52
|
-
const executeMethodArgs = (_.isArray(args) ? _.first(args) : args) ?? {} as StringRecord;
|
|
51
|
+
const executeMethodArgs = (_.isArray(args) ? _.first(args) : args) ?? ({} as StringRecord);
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
54
|
* Renames the deprecated `element` key to `elementId`. Historically,
|
|
@@ -75,4 +74,3 @@ function preprocessExecuteMethodArgs(args?: ExecuteMethodArgs): StringRecord {
|
|
|
75
74
|
// #endregion
|
|
76
75
|
|
|
77
76
|
type ExecuteMethodArgs = readonly any[] | readonly [StringRecord] | Readonly<StringRecord>;
|
|
78
|
-
|
|
@@ -25,10 +25,7 @@ const ANDROID_MEDIA_RESCAN_INTENT = 'android.intent.action.MEDIA_SCANNER_SCAN_FI
|
|
|
25
25
|
* @returns Promise that resolves to the file content as a base64-encoded string.
|
|
26
26
|
* @throws {errors.InvalidArgumentError} If the remote path points to a folder instead of a file.
|
|
27
27
|
*/
|
|
28
|
-
export async function pullFile(
|
|
29
|
-
this: AndroidDriver,
|
|
30
|
-
remotePath: string,
|
|
31
|
-
): Promise<string> {
|
|
28
|
+
export async function pullFile(this: AndroidDriver, remotePath: string): Promise<string> {
|
|
32
29
|
if (remotePath.endsWith('/')) {
|
|
33
30
|
throw new errors.InvalidArgumentError(
|
|
34
31
|
`It is expected that remote path points to a file and not to a folder. ` +
|
|
@@ -164,10 +161,7 @@ export async function pushFile(
|
|
|
164
161
|
* @param remotePath The full path to the remote folder.
|
|
165
162
|
* @returns Promise that resolves to the folder content as a base64-encoded zip file string.
|
|
166
163
|
*/
|
|
167
|
-
export async function pullFolder(
|
|
168
|
-
this: AndroidDriver,
|
|
169
|
-
remotePath: string,
|
|
170
|
-
): Promise<string> {
|
|
164
|
+
export async function pullFolder(this: AndroidDriver, remotePath: string): Promise<string> {
|
|
171
165
|
const tmpRoot = await tempDir.openDir();
|
|
172
166
|
try {
|
|
173
167
|
await this.adb.pull(remotePath, tmpRoot);
|
|
@@ -189,10 +183,7 @@ export async function pullFolder(
|
|
|
189
183
|
* @returns Promise that resolves to `true` if the file was successfully deleted, `false` if it doesn't exist.
|
|
190
184
|
* @throws {errors.InvalidArgumentError} If the remote path points to a folder instead of a file.
|
|
191
185
|
*/
|
|
192
|
-
export async function mobileDeleteFile(
|
|
193
|
-
this: AndroidDriver,
|
|
194
|
-
remotePath: string,
|
|
195
|
-
): Promise<boolean> {
|
|
186
|
+
export async function mobileDeleteFile(this: AndroidDriver, remotePath: string): Promise<boolean> {
|
|
196
187
|
if (remotePath.endsWith('/')) {
|
|
197
188
|
throw new errors.InvalidArgumentError(
|
|
198
189
|
`It is expected that remote path points to a folder and not to a file. ` +
|
|
@@ -288,10 +279,7 @@ function parseContainerPath(remotePath: string): [string, string] {
|
|
|
288
279
|
* and adds matching items to the device's media library.
|
|
289
280
|
* Exceptions are ignored and written into the log.
|
|
290
281
|
*/
|
|
291
|
-
async function scanMedia(
|
|
292
|
-
this: AndroidDriver,
|
|
293
|
-
remotePath: string,
|
|
294
|
-
): Promise<void> {
|
|
282
|
+
async function scanMedia(this: AndroidDriver, remotePath: string): Promise<void> {
|
|
295
283
|
this.log.debug(`Performing media scan of '${remotePath}'`);
|
|
296
284
|
try {
|
|
297
285
|
// https://github.com/appium/appium/issues/16184
|
|
@@ -356,4 +344,3 @@ function createFSTests(adb: ADB) {
|
|
|
356
344
|
}
|
|
357
345
|
|
|
358
346
|
// #endregion
|
|
359
|
-
|
|
@@ -21,17 +21,12 @@ const MOCK_APP_IDS_STORE = '/data/local/tmp/mock_apps.json';
|
|
|
21
21
|
* @param location The geolocation object containing latitude, longitude, and altitude.
|
|
22
22
|
* @returns Promise that resolves to the current geolocation after setting it.
|
|
23
23
|
*/
|
|
24
|
-
export async function setGeoLocation(
|
|
25
|
-
this: AndroidDriver,
|
|
26
|
-
location: Location,
|
|
27
|
-
): Promise<Location> {
|
|
24
|
+
export async function setGeoLocation(this: AndroidDriver, location: Location): Promise<Location> {
|
|
28
25
|
await this.settingsApp.setGeoLocation(location, this.isEmulator());
|
|
29
26
|
try {
|
|
30
27
|
return await this.getGeoLocation();
|
|
31
28
|
} catch (e) {
|
|
32
|
-
this.log.warn(
|
|
33
|
-
`Could not get the current geolocation info: ${(e as Error).message}`,
|
|
34
|
-
);
|
|
29
|
+
this.log.warn(`Could not get the current geolocation info: ${(e as Error).message}`);
|
|
35
30
|
this.log.warn(`Returning the default zero'ed values`);
|
|
36
31
|
return {
|
|
37
32
|
latitude: GEO_EPSILON,
|
|
@@ -66,15 +61,18 @@ export async function mobileSetGeolocation(
|
|
|
66
61
|
bearing?: number,
|
|
67
62
|
accuracy?: number,
|
|
68
63
|
): Promise<void> {
|
|
69
|
-
await this.settingsApp.setGeoLocation(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
await this.settingsApp.setGeoLocation(
|
|
65
|
+
{
|
|
66
|
+
latitude,
|
|
67
|
+
longitude,
|
|
68
|
+
altitude,
|
|
69
|
+
satellites,
|
|
70
|
+
speed,
|
|
71
|
+
bearing,
|
|
72
|
+
accuracy,
|
|
73
|
+
},
|
|
74
|
+
this.isEmulator(),
|
|
75
|
+
);
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
/**
|
|
@@ -102,9 +100,7 @@ export async function mobileRefreshGpsCache(
|
|
|
102
100
|
*
|
|
103
101
|
* @returns Promise that resolves to the current geolocation object.
|
|
104
102
|
*/
|
|
105
|
-
export async function getGeoLocation(
|
|
106
|
-
this: AndroidDriver,
|
|
107
|
-
): Promise<Location> {
|
|
103
|
+
export async function getGeoLocation(this: AndroidDriver): Promise<Location> {
|
|
108
104
|
const {latitude, longitude, altitude} = await this.settingsApp.getGeoLocation();
|
|
109
105
|
return {
|
|
110
106
|
latitude: parseFloat(String(latitude)) || GEO_EPSILON,
|
|
@@ -118,9 +114,7 @@ export async function getGeoLocation(
|
|
|
118
114
|
*
|
|
119
115
|
* @returns Promise that resolves to the current geolocation object.
|
|
120
116
|
*/
|
|
121
|
-
export async function mobileGetGeolocation(
|
|
122
|
-
this: AndroidDriver,
|
|
123
|
-
): Promise<Location> {
|
|
117
|
+
export async function mobileGetGeolocation(this: AndroidDriver): Promise<Location> {
|
|
124
118
|
return await this.getGeoLocation();
|
|
125
119
|
}
|
|
126
120
|
|
|
@@ -129,9 +123,7 @@ export async function mobileGetGeolocation(
|
|
|
129
123
|
*
|
|
130
124
|
* @returns Promise that resolves to `true` if location services are enabled, `false` otherwise.
|
|
131
125
|
*/
|
|
132
|
-
export async function isLocationServicesEnabled(
|
|
133
|
-
this: AndroidDriver,
|
|
134
|
-
): Promise<boolean> {
|
|
126
|
+
export async function isLocationServicesEnabled(this: AndroidDriver): Promise<boolean> {
|
|
135
127
|
return (await this.adb.getLocationProviders()).includes('gps');
|
|
136
128
|
}
|
|
137
129
|
|
|
@@ -140,9 +132,7 @@ export async function isLocationServicesEnabled(
|
|
|
140
132
|
*
|
|
141
133
|
* @returns Promise that resolves when the location services state is toggled.
|
|
142
134
|
*/
|
|
143
|
-
export async function toggleLocationServices(
|
|
144
|
-
this: AndroidDriver,
|
|
145
|
-
): Promise<void> {
|
|
135
|
+
export async function toggleLocationServices(this: AndroidDriver): Promise<void> {
|
|
146
136
|
this.log.info('Toggling location services');
|
|
147
137
|
const isGpsEnabled = await this.isLocationServicesEnabled();
|
|
148
138
|
this.log.debug(
|
|
@@ -158,9 +148,7 @@ export async function toggleLocationServices(
|
|
|
158
148
|
* @returns Promise that resolves when the geolocation is reset.
|
|
159
149
|
* @throws {Error} If called on an emulator (geolocation reset does not work on emulators).
|
|
160
150
|
*/
|
|
161
|
-
export async function mobileResetGeolocation(
|
|
162
|
-
this: AndroidDriver,
|
|
163
|
-
): Promise<void> {
|
|
151
|
+
export async function mobileResetGeolocation(this: AndroidDriver): Promise<void> {
|
|
164
152
|
if (this.isEmulator()) {
|
|
165
153
|
throw new Error('Geolocation reset does not work on emulators');
|
|
166
154
|
}
|
|
@@ -175,10 +163,7 @@ export async function mobileResetGeolocation(
|
|
|
175
163
|
* @param appId The application package identifier.
|
|
176
164
|
* @returns Promise that resolves when the mock location permission is set.
|
|
177
165
|
*/
|
|
178
|
-
export async function setMockLocationApp(
|
|
179
|
-
this: AndroidDriver,
|
|
180
|
-
appId: string,
|
|
181
|
-
): Promise<void> {
|
|
166
|
+
export async function setMockLocationApp(this: AndroidDriver, appId: string): Promise<void> {
|
|
182
167
|
try {
|
|
183
168
|
await this.adb.shell(['appops', 'set', appId, 'android:mock_location', 'allow']);
|
|
184
169
|
} catch (err) {
|
|
@@ -214,9 +199,7 @@ export async function setMockLocationApp(
|
|
|
214
199
|
*
|
|
215
200
|
* @returns Promise that resolves when the mock location permissions are reset.
|
|
216
201
|
*/
|
|
217
|
-
async function resetMockLocation(
|
|
218
|
-
this: AndroidDriver,
|
|
219
|
-
): Promise<void> {
|
|
202
|
+
async function resetMockLocation(this: AndroidDriver): Promise<void> {
|
|
220
203
|
try {
|
|
221
204
|
const thirdPartyPkgIdsPromise = getThirdPartyPackages.bind(this)();
|
|
222
205
|
let pkgIds: string[] = [];
|
|
@@ -255,4 +238,3 @@ async function resetMockLocation(
|
|
|
255
238
|
}
|
|
256
239
|
|
|
257
240
|
// #endregion Internal helpers
|
|
258
|
-
|
package/lib/commands/gestures.ts
CHANGED
|
@@ -10,10 +10,6 @@ import type {AndroidDriver} from '../driver';
|
|
|
10
10
|
* @returns Promise that resolves when all actions are performed.
|
|
11
11
|
* @throws {errors.NotImplementedError} This method is not implemented.
|
|
12
12
|
*/
|
|
13
|
-
export async function performActions(
|
|
14
|
-
this: AndroidDriver,
|
|
15
|
-
actions: StringRecord[],
|
|
16
|
-
): Promise<void> {
|
|
13
|
+
export async function performActions(this: AndroidDriver, actions: StringRecord[]): Promise<void> {
|
|
17
14
|
throw new errors.NotImplementedError('Not implemented');
|
|
18
15
|
}
|
|
19
|
-
|
|
@@ -35,7 +35,7 @@ export async function prepareEmulatorForImageInjection(
|
|
|
35
35
|
this: AndroidDriver,
|
|
36
36
|
sdkRoot: string,
|
|
37
37
|
): Promise<boolean> {
|
|
38
|
-
const {
|
|
38
|
+
const {injectedImageProperties: props} = this.opts;
|
|
39
39
|
if (!props) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
@@ -48,7 +48,9 @@ export async function prepareEmulatorForImageInjection(
|
|
|
48
48
|
if (await fs.exists(configPath)) {
|
|
49
49
|
const configPayload = await fs.readFile(configPath, 'utf8');
|
|
50
50
|
if (configPayload.includes(strProps)) {
|
|
51
|
-
this.log.info(
|
|
51
|
+
this.log.info(
|
|
52
|
+
`The image injection config at '${configPath}' is already up to date. Doing nothing`,
|
|
53
|
+
);
|
|
52
54
|
return false;
|
|
53
55
|
}
|
|
54
56
|
const updatedPayload = `${DEFAULT_CONFIG_PAYLOAD_PREFIX}
|
|
@@ -62,8 +64,8 @@ export async function prepareEmulatorForImageInjection(
|
|
|
62
64
|
}
|
|
63
65
|
this.log.info(
|
|
64
66
|
`The image injection config at '${configPath}' has been successfully updated with ` +
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
`${size}, ${position}, ${rotation}. ` +
|
|
68
|
+
`Expecting further emulator restart to reload the changed config.`,
|
|
67
69
|
);
|
|
68
70
|
return true;
|
|
69
71
|
}
|
|
@@ -92,14 +94,14 @@ export async function mobileInjectEmulatorCameraImage(
|
|
|
92
94
|
|
|
93
95
|
if (!_.isString(payload) || _.size(payload) <= PNG_MAGIC_LENGTH) {
|
|
94
96
|
throw new errors.InvalidArgumentError(
|
|
95
|
-
`You must provide a valid base64-encoded .PNG data as the 'payload' argument
|
|
97
|
+
`You must provide a valid base64-encoded .PNG data as the 'payload' argument`,
|
|
96
98
|
);
|
|
97
99
|
}
|
|
98
100
|
const pngBuffer = Buffer.from(payload, 'base64');
|
|
99
101
|
const magic = pngBuffer.toString('hex', 0, PNG_MAGIC_LENGTH);
|
|
100
102
|
if (magic !== PNG_MAGIC) {
|
|
101
103
|
throw new errors.InvalidArgumentError(
|
|
102
|
-
'The provided image payload must contain a valid base64-encoded .PNG data'
|
|
104
|
+
'The provided image payload must contain a valid base64-encoded .PNG data',
|
|
103
105
|
);
|
|
104
106
|
}
|
|
105
107
|
|
|
@@ -111,7 +113,7 @@ export async function mobileInjectEmulatorCameraImage(
|
|
|
111
113
|
await fs.writeFile(tmpImagePath, pngBuffer);
|
|
112
114
|
await this.adb.execEmuConsoleCommand(`virtualscene-image table ${tmpImagePath}`);
|
|
113
115
|
this.log.info(
|
|
114
|
-
`The provided image has been successully injected to the ${this.adb.curDeviceId} emulator
|
|
116
|
+
`The provided image has been successully injected to the ${this.adb.curDeviceId} emulator`,
|
|
115
117
|
);
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -124,4 +126,3 @@ function calculateImageHash(buffer: Buffer): string {
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
// #endregion
|
|
127
|
-
|
package/lib/commands/ime.ts
CHANGED
|
@@ -6,9 +6,7 @@ import type {AndroidDriver} from '../driver';
|
|
|
6
6
|
*
|
|
7
7
|
* @returns Promise that resolves to `true` (IME is always activated on Android devices).
|
|
8
8
|
*/
|
|
9
|
-
export async function isIMEActivated(
|
|
10
|
-
this: AndroidDriver,
|
|
11
|
-
): Promise<boolean> {
|
|
9
|
+
export async function isIMEActivated(this: AndroidDriver): Promise<boolean> {
|
|
12
10
|
// IME is always activated on Android devices
|
|
13
11
|
return true;
|
|
14
12
|
}
|
|
@@ -18,9 +16,7 @@ export async function isIMEActivated(
|
|
|
18
16
|
*
|
|
19
17
|
* @returns Promise that resolves to an array of IME engine identifiers.
|
|
20
18
|
*/
|
|
21
|
-
export async function availableIMEEngines(
|
|
22
|
-
this: AndroidDriver,
|
|
23
|
-
): Promise<string[]> {
|
|
19
|
+
export async function availableIMEEngines(this: AndroidDriver): Promise<string[]> {
|
|
24
20
|
this.log.debug('Retrieving available IMEs');
|
|
25
21
|
const engines = await this.adb.availableIMEs();
|
|
26
22
|
this.log.debug(`Engines: ${JSON.stringify(engines)}`);
|
|
@@ -32,9 +28,7 @@ export async function availableIMEEngines(
|
|
|
32
28
|
*
|
|
33
29
|
* @returns Promise that resolves to the active IME engine identifier.
|
|
34
30
|
*/
|
|
35
|
-
export async function getActiveIMEEngine(
|
|
36
|
-
this: AndroidDriver,
|
|
37
|
-
): Promise<string> {
|
|
31
|
+
export async function getActiveIMEEngine(this: AndroidDriver): Promise<string> {
|
|
38
32
|
this.log.debug('Retrieving current default IME');
|
|
39
33
|
return String(await this.adb.defaultIME());
|
|
40
34
|
}
|
|
@@ -46,10 +40,7 @@ export async function getActiveIMEEngine(
|
|
|
46
40
|
* @returns Promise that resolves when the IME is activated.
|
|
47
41
|
* @throws {errors.IMENotAvailableError} If the IME is not available.
|
|
48
42
|
*/
|
|
49
|
-
export async function activateIMEEngine(
|
|
50
|
-
this: AndroidDriver,
|
|
51
|
-
imeId: string,
|
|
52
|
-
): Promise<void> {
|
|
43
|
+
export async function activateIMEEngine(this: AndroidDriver, imeId: string): Promise<void> {
|
|
53
44
|
this.log.debug(`Attempting to activate IME ${imeId}`);
|
|
54
45
|
const availableEngines = await this.adb.availableIMEs();
|
|
55
46
|
if (availableEngines.indexOf(imeId) === -1) {
|
|
@@ -66,9 +57,7 @@ export async function activateIMEEngine(
|
|
|
66
57
|
*
|
|
67
58
|
* @returns Promise that resolves when the IME is deactivated.
|
|
68
59
|
*/
|
|
69
|
-
export async function deactivateIMEEngine(
|
|
70
|
-
this: AndroidDriver,
|
|
71
|
-
): Promise<void> {
|
|
60
|
+
export async function deactivateIMEEngine(this: AndroidDriver): Promise<void> {
|
|
72
61
|
const currentEngine = await this.getActiveIMEEngine();
|
|
73
62
|
// XXX: this allowed 'null' to be passed into `adb.shell`
|
|
74
63
|
if (currentEngine) {
|
|
@@ -76,4 +65,3 @@ export async function deactivateIMEEngine(
|
|
|
76
65
|
await this.adb.disableIME(currentEngine);
|
|
77
66
|
}
|
|
78
67
|
}
|
|
79
|
-
|
package/lib/commands/intent.ts
CHANGED
|
@@ -125,10 +125,7 @@ export async function mobileStartActivity(
|
|
|
125
125
|
extras?: string[][],
|
|
126
126
|
flags?: string,
|
|
127
127
|
): Promise<string> {
|
|
128
|
-
const cmd = [
|
|
129
|
-
'am',
|
|
130
|
-
'start-activity',
|
|
131
|
-
];
|
|
128
|
+
const cmd = ['am', 'start-activity'];
|
|
132
129
|
if (!_.isNil(user)) {
|
|
133
130
|
cmd.push('--user', String(user));
|
|
134
131
|
}
|
|
@@ -147,18 +144,20 @@ export async function mobileStartActivity(
|
|
|
147
144
|
if (!_.isNil(display)) {
|
|
148
145
|
cmd.push('--display', String(display));
|
|
149
146
|
}
|
|
150
|
-
cmd.push(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
147
|
+
cmd.push(
|
|
148
|
+
...parseIntentSpec({
|
|
149
|
+
intent,
|
|
150
|
+
action,
|
|
151
|
+
package: pkg,
|
|
152
|
+
uri,
|
|
153
|
+
mimeType,
|
|
154
|
+
identifier,
|
|
155
|
+
component,
|
|
156
|
+
categories,
|
|
157
|
+
extras,
|
|
158
|
+
flags,
|
|
159
|
+
}),
|
|
160
|
+
);
|
|
162
161
|
return await this.adb.shell(cmd);
|
|
163
162
|
}
|
|
164
163
|
|
|
@@ -210,18 +209,20 @@ export async function mobileBroadcast(
|
|
|
210
209
|
if (allowBackgroundActivityStarts) {
|
|
211
210
|
cmd.push('--allow-background-activity-starts');
|
|
212
211
|
}
|
|
213
|
-
cmd.push(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
212
|
+
cmd.push(
|
|
213
|
+
...parseIntentSpec({
|
|
214
|
+
intent,
|
|
215
|
+
action,
|
|
216
|
+
package: pkg,
|
|
217
|
+
uri,
|
|
218
|
+
mimeType,
|
|
219
|
+
identifier,
|
|
220
|
+
component,
|
|
221
|
+
categories,
|
|
222
|
+
extras,
|
|
223
|
+
flags,
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
225
226
|
return await this.adb.shell(cmd);
|
|
226
227
|
}
|
|
227
228
|
|
|
@@ -267,18 +268,20 @@ export async function mobileStartService(
|
|
|
267
268
|
if (!_.isNil(user)) {
|
|
268
269
|
cmd.push('--user', String(user));
|
|
269
270
|
}
|
|
270
|
-
cmd.push(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
271
|
+
cmd.push(
|
|
272
|
+
...parseIntentSpec({
|
|
273
|
+
intent,
|
|
274
|
+
action,
|
|
275
|
+
package: pkg,
|
|
276
|
+
uri,
|
|
277
|
+
mimeType,
|
|
278
|
+
identifier,
|
|
279
|
+
component,
|
|
280
|
+
categories,
|
|
281
|
+
extras,
|
|
282
|
+
flags,
|
|
283
|
+
}),
|
|
284
|
+
);
|
|
282
285
|
return await this.adb.shell(cmd);
|
|
283
286
|
}
|
|
284
287
|
|
|
@@ -316,25 +319,24 @@ export async function mobileStopService(
|
|
|
316
319
|
extras?: string[][],
|
|
317
320
|
flags?: string,
|
|
318
321
|
): Promise<string> {
|
|
319
|
-
const cmd = [
|
|
320
|
-
'am',
|
|
321
|
-
'stop-service',
|
|
322
|
-
];
|
|
322
|
+
const cmd = ['am', 'stop-service'];
|
|
323
323
|
if (!_.isNil(user)) {
|
|
324
324
|
cmd.push('--user', String(user));
|
|
325
325
|
}
|
|
326
|
-
cmd.push(
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
326
|
+
cmd.push(
|
|
327
|
+
...parseIntentSpec({
|
|
328
|
+
intent,
|
|
329
|
+
action,
|
|
330
|
+
package: pkg,
|
|
331
|
+
uri,
|
|
332
|
+
mimeType,
|
|
333
|
+
identifier,
|
|
334
|
+
component,
|
|
335
|
+
categories,
|
|
336
|
+
extras,
|
|
337
|
+
flags,
|
|
338
|
+
}),
|
|
339
|
+
);
|
|
338
340
|
try {
|
|
339
341
|
return await this.adb.shell(cmd);
|
|
340
342
|
} catch (e) {
|
|
@@ -419,4 +421,3 @@ function parseIntentSpec(opts: IntentOpts = {}): string[] {
|
|
|
419
421
|
}
|
|
420
422
|
|
|
421
423
|
// #endregion
|
|
422
|
-
|
package/lib/commands/keyboard.ts
CHANGED
|
@@ -10,9 +10,7 @@ import type {SendKeysOpts} from './types';
|
|
|
10
10
|
*
|
|
11
11
|
* @returns Promise that resolves to `true` if the keyboard was hidden, `false` otherwise.
|
|
12
12
|
*/
|
|
13
|
-
export async function hideKeyboard(
|
|
14
|
-
this: AndroidDriver,
|
|
15
|
-
): Promise<boolean> {
|
|
13
|
+
export async function hideKeyboard(this: AndroidDriver): Promise<boolean> {
|
|
16
14
|
return await this.adb.hideKeyboard();
|
|
17
15
|
}
|
|
18
16
|
|
|
@@ -21,9 +19,7 @@ export async function hideKeyboard(
|
|
|
21
19
|
*
|
|
22
20
|
* @returns Promise that resolves to `true` if the keyboard is shown, `false` otherwise.
|
|
23
21
|
*/
|
|
24
|
-
export async function isKeyboardShown(
|
|
25
|
-
this: AndroidDriver,
|
|
26
|
-
): Promise<boolean> {
|
|
22
|
+
export async function isKeyboardShown(this: AndroidDriver): Promise<boolean> {
|
|
27
23
|
const {isKeyboardShown} = await this.adb.isSoftKeyboardPresent();
|
|
28
24
|
return isKeyboardShown;
|
|
29
25
|
}
|
|
@@ -34,10 +30,7 @@ export async function isKeyboardShown(
|
|
|
34
30
|
* @param keys The keys to send, either as a string or an array of strings (which will be joined).
|
|
35
31
|
* @returns Promise that resolves when the keys are sent.
|
|
36
32
|
*/
|
|
37
|
-
export async function keys(
|
|
38
|
-
this: AndroidDriver,
|
|
39
|
-
keys: string | string[],
|
|
40
|
-
): Promise<void> {
|
|
33
|
+
export async function keys(this: AndroidDriver, keys: string | string[]): Promise<void> {
|
|
41
34
|
// Protocol sends an array; rethink approach
|
|
42
35
|
const keysStr = _.isArray(keys) ? keys.join('') : keys;
|
|
43
36
|
await this.doSendKeys({
|
|
@@ -53,10 +46,7 @@ export async function keys(
|
|
|
53
46
|
* @returns Promise that resolves when the keys are sent.
|
|
54
47
|
* @throws {errors.NotImplementedError} This method is not implemented.
|
|
55
48
|
*/
|
|
56
|
-
export async function doSendKeys(
|
|
57
|
-
this: AndroidDriver,
|
|
58
|
-
params: SendKeysOpts,
|
|
59
|
-
): Promise<void> {
|
|
49
|
+
export async function doSendKeys(this: AndroidDriver, params: SendKeysOpts): Promise<void> {
|
|
60
50
|
throw new errors.NotImplementedError('Not implemented');
|
|
61
51
|
}
|
|
62
52
|
|
|
@@ -131,9 +121,7 @@ export async function mobilePerformEditorAction(
|
|
|
131
121
|
* @deprecated
|
|
132
122
|
* @returns Promise that resolves to the default IME identifier that was active before.
|
|
133
123
|
*/
|
|
134
|
-
export async function initUnicodeKeyboard(
|
|
135
|
-
this: AndroidDriver,
|
|
136
|
-
): Promise<string | null> {
|
|
124
|
+
export async function initUnicodeKeyboard(this: AndroidDriver): Promise<string | null> {
|
|
137
125
|
this.log.debug('Enabling Unicode keyboard support');
|
|
138
126
|
|
|
139
127
|
// get the default IME so we can return back to it later if we want
|
|
@@ -151,13 +139,10 @@ export async function initUnicodeKeyboard(
|
|
|
151
139
|
*
|
|
152
140
|
* @returns Promise that resolves when the keyboard is hidden.
|
|
153
141
|
*/
|
|
154
|
-
export async function hideKeyboardCompletely(
|
|
155
|
-
this: AndroidDriver,
|
|
156
|
-
): Promise<void> {
|
|
142
|
+
export async function hideKeyboardCompletely(this: AndroidDriver): Promise<void> {
|
|
157
143
|
this.log.debug(`Hiding the on-screen keyboard by setting IME to '${EMPTY_IME}'`);
|
|
158
144
|
await this.adb.enableIME(EMPTY_IME);
|
|
159
145
|
await this.adb.setIME(EMPTY_IME);
|
|
160
146
|
}
|
|
161
147
|
|
|
162
148
|
// #endregion
|
|
163
|
-
|