appium-android-driver 7.8.3 → 8.0.1
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 +32 -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 +2 -2
- 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
package/lib/commands/general.js
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import {util} from '@appium/support';
|
|
3
|
-
import {longSleep} from 'asyncbox';
|
|
4
|
-
import _ from 'lodash';
|
|
5
|
-
import moment from 'moment';
|
|
6
|
-
import androidHelpers from '../helpers/android';
|
|
7
|
-
import {requireArgs} from '../utils';
|
|
8
|
-
import {mixin} from './mixins';
|
|
9
|
-
import {errors} from 'appium/driver';
|
|
10
|
-
|
|
11
|
-
const MOMENT_FORMAT_ISO8601 = 'YYYY-MM-DDTHH:mm:ssZ';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @type {import('./mixins').GeneralMixin & ThisType<import('../driver').AndroidDriver>}
|
|
15
|
-
* @satisfies {import('@appium/types').ExternalDriver}
|
|
16
|
-
*/
|
|
17
|
-
const GeneralMixin = {
|
|
18
|
-
_cachedActivityArgs: {},
|
|
19
|
-
async keys(keys) {
|
|
20
|
-
// Protocol sends an array; rethink approach
|
|
21
|
-
keys = _.isArray(keys) ? keys.join('') : keys;
|
|
22
|
-
await this.doSendKeys({
|
|
23
|
-
text: keys,
|
|
24
|
-
replace: false,
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
async doSendKeys(params) {
|
|
29
|
-
throw new errors.NotImplementedError('Not implemented');
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
async getDeviceTime(format = MOMENT_FORMAT_ISO8601) {
|
|
33
|
-
this.log.debug(
|
|
34
|
-
'Attempting to capture android device date and time. ' + `The format specifier is '${format}'`
|
|
35
|
-
);
|
|
36
|
-
const deviceTimestamp = (
|
|
37
|
-
await this.adb.shell(['date', '+%Y-%m-%dT%T%z'])
|
|
38
|
-
).trim();
|
|
39
|
-
this.log.debug(`Got device timestamp: ${deviceTimestamp}`);
|
|
40
|
-
const parsedTimestamp = moment.utc(deviceTimestamp, 'YYYY-MM-DDTHH:mm:ssZZ');
|
|
41
|
-
if (!parsedTimestamp.isValid()) {
|
|
42
|
-
this.log.warn('Cannot parse the returned timestamp. Returning as is');
|
|
43
|
-
return deviceTimestamp;
|
|
44
|
-
}
|
|
45
|
-
// @ts-expect-error private API
|
|
46
|
-
return parsedTimestamp.utcOffset(parsedTimestamp._tzm || 0).format(format);
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
async mobileGetDeviceTime(opts = {}) {
|
|
50
|
-
return await this.getDeviceTime(opts.format);
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
async getPageSource() {
|
|
54
|
-
throw new errors.NotImplementedError('Not implemented');
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
async back() {
|
|
58
|
-
throw new errors.NotImplementedError('Not implemented');
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
async openSettingsActivity(setting) {
|
|
62
|
-
let {appPackage, appActivity} = await this.adb.getFocusedPackageAndActivity();
|
|
63
|
-
await this.adb.shell(['am', 'start', '-a', `android.settings.${setting}`]);
|
|
64
|
-
await this.adb.waitForNotActivity(
|
|
65
|
-
/** @type {string} */ (appPackage),
|
|
66
|
-
/** @type {string} */ (appActivity),
|
|
67
|
-
5000
|
|
68
|
-
);
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
async getWindowSize() {
|
|
72
|
-
throw new errors.NotImplementedError('Not implemented');
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// For W3C
|
|
76
|
-
async getWindowRect() {
|
|
77
|
-
const {width, height} = await this.getWindowSize();
|
|
78
|
-
return {
|
|
79
|
-
width,
|
|
80
|
-
height,
|
|
81
|
-
x: 0,
|
|
82
|
-
y: 0,
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @returns {Promise<string>}
|
|
88
|
-
*/
|
|
89
|
-
async getCurrentActivity() {
|
|
90
|
-
return /** @type {string} */ ((await this.adb.getFocusedPackageAndActivity()).appActivity);
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @returns {Promise<string>}
|
|
95
|
-
*/
|
|
96
|
-
async getCurrentPackage() {
|
|
97
|
-
return /** @type {string} */ ((await this.adb.getFocusedPackageAndActivity()).appPackage);
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
async background(seconds) {
|
|
101
|
-
if (seconds < 0) {
|
|
102
|
-
// if user passes in a negative seconds value, interpret that as the instruction
|
|
103
|
-
// to not bring the app back at all
|
|
104
|
-
await this.adb.goToHome();
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
let {appPackage, appActivity} = await this.adb.getFocusedPackageAndActivity();
|
|
108
|
-
await this.adb.goToHome();
|
|
109
|
-
|
|
110
|
-
// people can wait for a long time, so to be safe let's use the longSleep function and log
|
|
111
|
-
// progress periodically.
|
|
112
|
-
const sleepMs = seconds * 1000;
|
|
113
|
-
const thresholdMs = 30 * 1000; // use the spin-wait for anything over this threshold
|
|
114
|
-
// for our spin interval, use 1% of the total wait time, but nothing bigger than 30s
|
|
115
|
-
const intervalMs = _.min([30 * 1000, parseInt(String(sleepMs / 100), 10)]);
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
* @param {{elapsedMs: number, progress: number}} param0
|
|
119
|
-
*/
|
|
120
|
-
const progressCb = ({elapsedMs, progress}) => {
|
|
121
|
-
const waitSecs = (elapsedMs / 1000).toFixed(0);
|
|
122
|
-
const progressPct = (progress * 100).toFixed(2);
|
|
123
|
-
this.log.debug(`Waited ${waitSecs}s so far (${progressPct}%)`);
|
|
124
|
-
};
|
|
125
|
-
await longSleep(sleepMs, {thresholdMs, intervalMs, progressCb});
|
|
126
|
-
|
|
127
|
-
/** @type {import('appium-adb').StartAppOptions} */
|
|
128
|
-
let args;
|
|
129
|
-
if (this._cachedActivityArgs && this._cachedActivityArgs[`${appPackage}/${appActivity}`]) {
|
|
130
|
-
// the activity was started with `startActivity`, so use those args to restart
|
|
131
|
-
args = this._cachedActivityArgs[`${appPackage}/${appActivity}`];
|
|
132
|
-
} else {
|
|
133
|
-
try {
|
|
134
|
-
this.log.debug(`Activating app '${appPackage}' in order to restore it`);
|
|
135
|
-
await this.activateApp(/** @type {string} */ (appPackage));
|
|
136
|
-
return true;
|
|
137
|
-
} catch (ign) {}
|
|
138
|
-
args =
|
|
139
|
-
(appPackage === this.opts.appPackage && appActivity === this.opts.appActivity) ||
|
|
140
|
-
(appPackage === this.opts.appWaitPackage &&
|
|
141
|
-
(this.opts.appWaitActivity || '').split(',').includes(String(appActivity)))
|
|
142
|
-
? {
|
|
143
|
-
// the activity is the original session activity, so use the original args
|
|
144
|
-
pkg: /** @type {string} */ (this.opts.appPackage),
|
|
145
|
-
activity: this.opts.appActivity ?? undefined,
|
|
146
|
-
action: this.opts.intentAction,
|
|
147
|
-
category: this.opts.intentCategory,
|
|
148
|
-
flags: this.opts.intentFlags,
|
|
149
|
-
waitPkg: this.opts.appWaitPackage ?? undefined,
|
|
150
|
-
waitActivity: this.opts.appWaitActivity ?? undefined,
|
|
151
|
-
waitForLaunch: this.opts.appWaitForLaunch,
|
|
152
|
-
waitDuration: this.opts.appWaitDuration,
|
|
153
|
-
optionalIntentArguments: this.opts.optionalIntentArguments,
|
|
154
|
-
stopApp: false,
|
|
155
|
-
user: this.opts.userProfile,
|
|
156
|
-
}
|
|
157
|
-
: {
|
|
158
|
-
// the activity was started some other way, so use defaults
|
|
159
|
-
pkg: /** @type {string} */ (appPackage),
|
|
160
|
-
activity: appActivity ?? undefined,
|
|
161
|
-
waitPkg: appPackage ?? undefined,
|
|
162
|
-
waitActivity: appActivity ?? undefined,
|
|
163
|
-
stopApp: false,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
args = /** @type {import('appium-adb').StartAppOptions} */ (
|
|
167
|
-
_.pickBy(args, (value) => !_.isUndefined(value))
|
|
168
|
-
);
|
|
169
|
-
this.log.debug(
|
|
170
|
-
`Bringing application back to foreground with arguments: ${JSON.stringify(args)}`
|
|
171
|
-
);
|
|
172
|
-
return await this.adb.startApp(args);
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
async getStrings(language) {
|
|
176
|
-
if (!language) {
|
|
177
|
-
language = await this.adb.getDeviceLanguage();
|
|
178
|
-
this.log.info(`No language specified, returning strings for: ${language}`);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Clients require the resulting mapping to have both keys
|
|
182
|
-
// and values of type string
|
|
183
|
-
/** @param {StringRecord} mapping */
|
|
184
|
-
const preprocessStringsMap = (mapping) => {
|
|
185
|
-
/** @type {StringRecord} */
|
|
186
|
-
const result = {};
|
|
187
|
-
for (const [key, value] of _.toPairs(mapping)) {
|
|
188
|
-
result[key] = _.isString(value) ? value : JSON.stringify(value);
|
|
189
|
-
}
|
|
190
|
-
return result;
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
if (this.apkStrings[language]) {
|
|
194
|
-
// Return cached strings
|
|
195
|
-
return preprocessStringsMap(this.apkStrings[language]);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
this.apkStrings[language] = await androidHelpers.pushStrings(language, this.adb, this.opts);
|
|
199
|
-
|
|
200
|
-
return preprocessStringsMap(this.apkStrings[language]);
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
async launchApp() {
|
|
204
|
-
throw new errors.NotImplementedError('Not implemented');
|
|
205
|
-
},
|
|
206
|
-
|
|
207
|
-
async startActivity(
|
|
208
|
-
appPackage,
|
|
209
|
-
appActivity,
|
|
210
|
-
appWaitPackage,
|
|
211
|
-
appWaitActivity,
|
|
212
|
-
intentAction,
|
|
213
|
-
intentCategory,
|
|
214
|
-
intentFlags,
|
|
215
|
-
optionalIntentArguments,
|
|
216
|
-
dontStopAppOnReset
|
|
217
|
-
) {
|
|
218
|
-
this.log.debug(`Starting package '${appPackage}' and activity '${appActivity}'`);
|
|
219
|
-
|
|
220
|
-
// dontStopAppOnReset is both an argument here, and a desired capability
|
|
221
|
-
// if the argument is set, use it, otherwise use the cap
|
|
222
|
-
if (!util.hasValue(dontStopAppOnReset)) {
|
|
223
|
-
dontStopAppOnReset = !!this.opts.dontStopAppOnReset;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/** @type {import('appium-adb').StartAppOptions} */
|
|
227
|
-
let args = {
|
|
228
|
-
pkg: appPackage,
|
|
229
|
-
activity: appActivity,
|
|
230
|
-
waitPkg: appWaitPackage || appPackage,
|
|
231
|
-
waitActivity: appWaitActivity || appActivity,
|
|
232
|
-
action: intentAction,
|
|
233
|
-
category: intentCategory,
|
|
234
|
-
flags: intentFlags,
|
|
235
|
-
optionalIntentArguments,
|
|
236
|
-
stopApp: !dontStopAppOnReset,
|
|
237
|
-
};
|
|
238
|
-
this._cachedActivityArgs = this._cachedActivityArgs || {};
|
|
239
|
-
this._cachedActivityArgs[`${args.waitPkg}/${args.waitActivity}`] = args;
|
|
240
|
-
await this.adb.startApp(args);
|
|
241
|
-
},
|
|
242
|
-
|
|
243
|
-
async reset() {
|
|
244
|
-
await androidHelpers.resetApp(
|
|
245
|
-
this.adb,
|
|
246
|
-
Object.assign({}, this.opts, {fastReset: true})
|
|
247
|
-
);
|
|
248
|
-
// reset context since we don't know what kind on context we will end up after app launch.
|
|
249
|
-
await this.setContext();
|
|
250
|
-
return this.isChromeSession ? this.startChromeSession() : this.startAUT();
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
async startAUT() {
|
|
254
|
-
await this.adb.startApp({
|
|
255
|
-
pkg: /** @type {string} */ (this.opts.appPackage),
|
|
256
|
-
activity: this.opts.appActivity,
|
|
257
|
-
action: this.opts.intentAction,
|
|
258
|
-
category: this.opts.intentCategory,
|
|
259
|
-
flags: this.opts.intentFlags,
|
|
260
|
-
waitPkg: this.opts.appWaitPackage,
|
|
261
|
-
waitActivity: this.opts.appWaitActivity,
|
|
262
|
-
waitForLaunch: this.opts.appWaitForLaunch,
|
|
263
|
-
waitDuration: this.opts.appWaitDuration,
|
|
264
|
-
optionalIntentArguments: this.opts.optionalIntentArguments,
|
|
265
|
-
stopApp: !this.opts.dontStopAppOnReset,
|
|
266
|
-
user: this.opts.userProfile,
|
|
267
|
-
});
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
// we override setUrl to take an android URI which can be used for deep-linking
|
|
271
|
-
// inside an app, similar to starting an intent
|
|
272
|
-
async setUrl(uri) {
|
|
273
|
-
await this.adb.startUri(uri, /** @type {string} */ (this.opts.appPackage));
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
// closing app using force stop
|
|
277
|
-
async closeApp() {
|
|
278
|
-
await this.adb.forceStop(/** @type {string} */ (this.opts.appPackage));
|
|
279
|
-
// reset context since we don't know what kind on context we will end up after app launch.
|
|
280
|
-
await this.setContext();
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
async getDisplayDensity() {
|
|
284
|
-
// first try the property for devices
|
|
285
|
-
let out = await this.adb.shell(['getprop', 'ro.sf.lcd_density']);
|
|
286
|
-
if (out) {
|
|
287
|
-
let val = parseInt(out, 10);
|
|
288
|
-
// if the value is NaN, try getting the emulator property
|
|
289
|
-
if (!isNaN(val)) {
|
|
290
|
-
return val;
|
|
291
|
-
}
|
|
292
|
-
this.log.debug(`Parsed density value was NaN: "${out}"`);
|
|
293
|
-
}
|
|
294
|
-
// fallback to trying property for emulators
|
|
295
|
-
out = await this.adb.shell(['getprop', 'qemu.sf.lcd_density']);
|
|
296
|
-
if (out) {
|
|
297
|
-
let val = parseInt(out, 10);
|
|
298
|
-
if (!isNaN(val)) {
|
|
299
|
-
return val;
|
|
300
|
-
}
|
|
301
|
-
this.log.debug(`Parsed density value was NaN: "${out}"`);
|
|
302
|
-
}
|
|
303
|
-
// couldn't get anything, so error out
|
|
304
|
-
throw this.log.errorAndThrow('Failed to get display density property.');
|
|
305
|
-
},
|
|
306
|
-
|
|
307
|
-
async mobilePerformEditorAction(opts) {
|
|
308
|
-
const {action} = requireArgs('action', opts);
|
|
309
|
-
await this.settingsApp.performEditorAction(action);
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
async mobileGetNotifications() {
|
|
313
|
-
return await this.settingsApp.getNotifications();
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
async mobileListSms(opts) {
|
|
317
|
-
return await this.settingsApp.getSmsList(opts);
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
async mobileUnlock(opts = {}) {
|
|
321
|
-
const {key, type, strategy, timeoutMs} = opts;
|
|
322
|
-
if (!key && !type) {
|
|
323
|
-
await this.unlock();
|
|
324
|
-
} else {
|
|
325
|
-
// @ts-expect-error XXX: these caps should be defined in the constraints!!
|
|
326
|
-
await androidHelpers.unlock(this, this.adb, {
|
|
327
|
-
unlockKey: key,
|
|
328
|
-
unlockType: type,
|
|
329
|
-
unlockStrategy: strategy,
|
|
330
|
-
unlockSuccessTimeout: timeoutMs,
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
mixin(GeneralMixin);
|
|
337
|
-
|
|
338
|
-
export default GeneralMixin;
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* @typedef {import('appium-adb').ADB} ADB
|
|
342
|
-
* @typedef {import('@appium/types').StringRecord} StringRecord
|
|
343
|
-
*/
|
package/lib/commands/index.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import actionCmds from './actions';
|
|
2
|
-
import alertCmds from './alert';
|
|
3
|
-
import appManagementCmds from './app-management';
|
|
4
|
-
import contextCmds from './context';
|
|
5
|
-
import elementCmds from './element';
|
|
6
|
-
import emuConsoleCmds from './emu-console';
|
|
7
|
-
import executeCmds from './execute';
|
|
8
|
-
import fileActionsCmds from './file-actions';
|
|
9
|
-
import findCmds from './find';
|
|
10
|
-
import generalCmds from './general';
|
|
11
|
-
import imeCmds from './ime';
|
|
12
|
-
import intentCmds from './intent';
|
|
13
|
-
import keyboardCmds from './keyboard';
|
|
14
|
-
import logCmds from './log';
|
|
15
|
-
import mediaProjectionCmds from './media-projection';
|
|
16
|
-
import networkCmds from './network';
|
|
17
|
-
import performanceCmds from './performance';
|
|
18
|
-
import permissionsCmds from './permissions';
|
|
19
|
-
import recordscreenCmds from './recordscreen';
|
|
20
|
-
import shellCmds from './shell';
|
|
21
|
-
import screenStreamCmds from './streamscreen';
|
|
22
|
-
import systemBarsCmds from './system-bars';
|
|
23
|
-
import touchCmds from './touch';
|
|
24
|
-
|
|
25
|
-
const commands = {
|
|
26
|
-
findCmds,
|
|
27
|
-
generalCmds,
|
|
28
|
-
alertCmds,
|
|
29
|
-
elementCmds,
|
|
30
|
-
contextCmds,
|
|
31
|
-
actionCmds,
|
|
32
|
-
touchCmds,
|
|
33
|
-
imeCmds,
|
|
34
|
-
networkCmds,
|
|
35
|
-
recordscreenCmds,
|
|
36
|
-
intentCmds,
|
|
37
|
-
screenStreamCmds,
|
|
38
|
-
performanceCmds,
|
|
39
|
-
executeCmds,
|
|
40
|
-
shellCmds,
|
|
41
|
-
emuConsoleCmds,
|
|
42
|
-
systemBarsCmds,
|
|
43
|
-
appManagementCmds,
|
|
44
|
-
fileActionsCmds,
|
|
45
|
-
logCmds,
|
|
46
|
-
mediaProjectionCmds,
|
|
47
|
-
permissionsCmds,
|
|
48
|
-
keyboardCmds,
|
|
49
|
-
// add other command types here
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export {commands};
|
|
53
|
-
|
|
54
|
-
export type * from './mixins';
|