appium-android-driver 7.8.3 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/build/lib/commands/app-management.d.ts +129 -5
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +433 -128
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/appearance.d.ts +17 -4
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js +32 -33
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/context/cache.d.ts +19 -0
- package/build/lib/commands/context/cache.d.ts.map +1 -0
- package/build/lib/commands/context/cache.js +32 -0
- package/build/lib/commands/context/cache.js.map +1 -0
- package/build/lib/commands/context/exports.d.ts +141 -0
- package/build/lib/commands/context/exports.d.ts.map +1 -0
- package/build/lib/commands/context/exports.js +351 -0
- package/build/lib/commands/context/exports.js.map +1 -0
- package/build/lib/commands/context/helpers.d.ts +98 -0
- package/build/lib/commands/context/helpers.d.ts.map +1 -0
- package/build/lib/commands/context/helpers.js +715 -0
- package/build/lib/commands/context/helpers.js.map +1 -0
- package/build/lib/commands/device/common.d.ts +23 -0
- package/build/lib/commands/device/common.d.ts.map +1 -0
- package/build/lib/commands/device/common.js +230 -0
- package/build/lib/commands/device/common.js.map +1 -0
- package/build/lib/commands/device/emulator-actions.d.ts +114 -0
- package/build/lib/commands/device/emulator-actions.d.ts.map +1 -0
- package/build/lib/commands/device/emulator-actions.js +197 -0
- package/build/lib/commands/device/emulator-actions.js.map +1 -0
- package/build/lib/commands/device/emulator-console.d.ts +7 -0
- package/build/lib/commands/device/emulator-console.d.ts.map +1 -0
- package/build/lib/commands/device/emulator-console.js +24 -0
- package/build/lib/commands/device/emulator-console.js.map +1 -0
- package/build/lib/commands/device/utils.d.ts +50 -0
- package/build/lib/commands/device/utils.d.ts.map +1 -0
- package/build/lib/commands/device/utils.js +238 -0
- package/build/lib/commands/device/utils.js.map +1 -0
- package/build/lib/commands/deviceidle.d.ts +8 -5
- package/build/lib/commands/deviceidle.d.ts.map +1 -1
- package/build/lib/commands/deviceidle.js +31 -37
- package/build/lib/commands/deviceidle.js.map +1 -1
- package/build/lib/commands/element.d.ts +99 -5
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +152 -116
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts +12 -4
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +83 -78
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +42 -5
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +230 -194
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +5 -4
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +7 -10
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/geolocation.d.ts +45 -0
- package/build/lib/commands/geolocation.d.ts.map +1 -0
- package/build/lib/commands/geolocation.js +182 -0
- package/build/lib/commands/geolocation.js.map +1 -0
- package/build/lib/commands/ime.d.ts +25 -5
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +59 -42
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/intent.d.ts +56 -5
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +135 -83
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +58 -4
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +119 -17
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/lock/exports.d.ts +301 -0
- package/build/lib/commands/lock/exports.d.ts.map +1 -0
- package/build/lib/commands/lock/exports.js +121 -0
- package/build/lib/commands/lock/exports.js.map +1 -0
- package/build/lib/commands/lock/helpers.d.ts +349 -0
- package/build/lib/commands/lock/helpers.d.ts.map +1 -0
- package/build/lib/commands/lock/helpers.js +375 -0
- package/build/lib/commands/lock/helpers.js.map +1 -0
- package/build/lib/commands/log.d.ts +59 -5
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +150 -140
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +16 -5
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +69 -58
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/memory.d.ts +9 -5
- package/build/lib/commands/memory.d.ts.map +1 -1
- package/build/lib/commands/memory.js +19 -24
- package/build/lib/commands/memory.js.map +1 -1
- package/build/lib/commands/misc.d.ts +42 -0
- package/build/lib/commands/misc.d.ts.map +1 -0
- package/build/lib/commands/misc.js +100 -0
- package/build/lib/commands/misc.js.map +1 -0
- package/build/lib/commands/network.d.ts +61 -5
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +196 -189
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +67 -27
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +105 -80
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +12 -6
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +65 -62
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +44 -5
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +131 -126
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/resources.d.ts +16 -0
- package/build/lib/commands/resources.d.ts.map +1 -0
- package/build/lib/commands/resources.js +91 -0
- package/build/lib/commands/resources.js.map +1 -0
- package/build/lib/commands/shell.d.ts +8 -5
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +29 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +34 -6
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +166 -162
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +18 -13
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +68 -64
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/time.d.ts +14 -0
- package/build/lib/commands/time.d.ts.map +1 -0
- package/build/lib/commands/time.js +39 -0
- package/build/lib/commands/time.js.map +1 -0
- package/build/lib/commands/touch.d.ts +99 -6
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +399 -280
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +110 -2
- package/build/lib/commands/types.d.ts.map +1 -1
- package/build/lib/doctor/checks.d.ts.map +1 -1
- package/build/lib/doctor/checks.js +4 -4
- package/build/lib/doctor/checks.js.map +1 -1
- package/build/lib/driver.d.ts +224 -27
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +232 -7
- package/build/lib/driver.js.map +1 -1
- package/build/lib/index.d.ts +1 -4
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +1 -13
- package/build/lib/index.js.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/method-map.d.ts +0 -23
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +0 -11
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/utils.d.ts +12 -0
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +38 -2
- package/build/lib/utils.js.map +1 -1
- package/lib/commands/app-management.js +470 -145
- package/lib/commands/appearance.js +29 -36
- package/lib/commands/context/cache.js +29 -0
- package/lib/commands/context/exports.js +379 -0
- package/lib/commands/context/helpers.js +802 -0
- package/lib/commands/device/common.js +264 -0
- package/lib/commands/device/emulator-actions.js +194 -0
- package/lib/commands/device/emulator-console.js +24 -0
- package/lib/commands/device/utils.js +285 -0
- package/lib/commands/deviceidle.js +31 -44
- package/lib/commands/element.js +149 -142
- package/lib/commands/execute.js +86 -87
- package/lib/commands/file-actions.js +249 -222
- package/lib/commands/find.ts +13 -19
- package/lib/commands/geolocation.js +179 -0
- package/lib/commands/ime.js +53 -45
- package/lib/commands/intent.js +149 -91
- package/lib/commands/keyboard.js +114 -17
- package/lib/commands/lock/exports.js +139 -0
- package/lib/commands/lock/helpers.js +379 -0
- package/lib/commands/log.js +170 -166
- package/lib/commands/media-projection.js +75 -70
- package/lib/commands/memory.js +17 -29
- package/lib/commands/misc.js +94 -0
- package/lib/commands/network.js +209 -223
- package/lib/commands/performance.js +88 -73
- package/lib/commands/permissions.js +83 -84
- package/lib/commands/recordscreen.js +171 -170
- package/lib/commands/resources.js +96 -0
- package/lib/commands/shell.js +28 -42
- package/lib/commands/streamscreen.js +207 -206
- package/lib/commands/system-bars.js +76 -77
- package/lib/commands/time.js +36 -0
- package/lib/commands/touch.js +442 -346
- package/lib/commands/types.ts +123 -2
- package/lib/doctor/checks.js +24 -16
- package/lib/driver.ts +454 -12
- package/lib/index.ts +1 -13
- package/lib/logger.js +1 -1
- package/lib/method-map.js +0 -11
- package/lib/utils.js +40 -3
- package/package.json +1 -1
- package/build/lib/commands/actions.d.ts +0 -8
- package/build/lib/commands/actions.d.ts.map +0 -1
- package/build/lib/commands/actions.js +0 -207
- package/build/lib/commands/actions.js.map +0 -1
- package/build/lib/commands/alert.d.ts +0 -8
- package/build/lib/commands/alert.d.ts.map +0 -1
- package/build/lib/commands/alert.js +0 -29
- package/build/lib/commands/alert.js.map +0 -1
- package/build/lib/commands/context.d.ts +0 -10
- package/build/lib/commands/context.d.ts.map +0 -1
- package/build/lib/commands/context.js +0 -431
- package/build/lib/commands/context.js.map +0 -1
- package/build/lib/commands/emu-console.d.ts +0 -7
- package/build/lib/commands/emu-console.d.ts.map +0 -1
- package/build/lib/commands/emu-console.js +0 -27
- package/build/lib/commands/emu-console.js.map +0 -1
- package/build/lib/commands/general.d.ts +0 -9
- package/build/lib/commands/general.d.ts.map +0 -1
- package/build/lib/commands/general.js +0 -293
- package/build/lib/commands/general.js.map +0 -1
- package/build/lib/commands/index.d.ts +0 -28
- package/build/lib/commands/index.d.ts.map +0 -1
- package/build/lib/commands/index.js +0 -57
- package/build/lib/commands/index.js.map +0 -1
- package/build/lib/commands/mixins.d.ts +0 -747
- package/build/lib/commands/mixins.d.ts.map +0 -1
- package/build/lib/commands/mixins.js +0 -19
- package/build/lib/commands/mixins.js.map +0 -1
- package/build/lib/helpers/android.d.ts +0 -163
- package/build/lib/helpers/android.d.ts.map +0 -1
- package/build/lib/helpers/android.js +0 -818
- package/build/lib/helpers/android.js.map +0 -1
- package/build/lib/helpers/index.d.ts +0 -7
- package/build/lib/helpers/index.d.ts.map +0 -1
- package/build/lib/helpers/index.js +0 -29
- package/build/lib/helpers/index.js.map +0 -1
- package/build/lib/helpers/types.d.ts +0 -122
- package/build/lib/helpers/types.d.ts.map +0 -1
- package/build/lib/helpers/types.js +0 -3
- package/build/lib/helpers/types.js.map +0 -1
- package/build/lib/helpers/unlock.d.ts +0 -32
- package/build/lib/helpers/unlock.d.ts.map +0 -1
- package/build/lib/helpers/unlock.js +0 -273
- package/build/lib/helpers/unlock.js.map +0 -1
- package/build/lib/helpers/webview.d.ts +0 -74
- package/build/lib/helpers/webview.d.ts.map +0 -1
- package/build/lib/helpers/webview.js +0 -448
- package/build/lib/helpers/webview.js.map +0 -1
- package/lib/commands/actions.js +0 -244
- package/lib/commands/alert.js +0 -34
- package/lib/commands/context.js +0 -507
- package/lib/commands/emu-console.js +0 -31
- package/lib/commands/general.js +0 -343
- package/lib/commands/index.ts +0 -54
- package/lib/commands/mixins.ts +0 -976
- package/lib/helpers/android.ts +0 -1153
- package/lib/helpers/index.ts +0 -6
- package/lib/helpers/types.ts +0 -136
- package/lib/helpers/unlock.ts +0 -329
- package/lib/helpers/webview.ts +0 -610
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import {resetMockLocation, setMockLocationApp} from '../geolocation';
|
|
4
|
+
import {SETTINGS_HELPER_ID} from 'io.appium.settings';
|
|
5
|
+
import {hideKeyboardCompletely, initUnicodeKeyboard} from '../keyboard';
|
|
6
|
+
import {
|
|
7
|
+
createBaseADB,
|
|
8
|
+
prepareEmulator,
|
|
9
|
+
validatePackageActivityNames,
|
|
10
|
+
pushSettingsApp,
|
|
11
|
+
} from './utils';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @this {AndroidDriver}
|
|
15
|
+
* @returns {Promise<import('../types').ADBDeviceInfo>}
|
|
16
|
+
*/
|
|
17
|
+
export async function getDeviceInfoFromCaps() {
|
|
18
|
+
// we can create a throwaway ADB instance here, so there is no dependency
|
|
19
|
+
// on instantiating on earlier (at this point, we have no udid)
|
|
20
|
+
// we can only use this ADB object for commands that would not be confused
|
|
21
|
+
// if multiple devices are connected
|
|
22
|
+
/** @type {import('appium-adb').ADB} */
|
|
23
|
+
const adb = this.adb ?? (await createBaseADB(this.opts));
|
|
24
|
+
let udid = this.opts.udid;
|
|
25
|
+
let emPort;
|
|
26
|
+
|
|
27
|
+
// a specific avd name was given. try to initialize with that
|
|
28
|
+
if (this.opts?.avd) {
|
|
29
|
+
await prepareEmulator.bind(this)();
|
|
30
|
+
udid = adb.curDeviceId;
|
|
31
|
+
emPort = adb.emulatorPort;
|
|
32
|
+
} else {
|
|
33
|
+
// no avd given. lets try whatever's plugged in devices/emulators
|
|
34
|
+
this.log.info('Retrieving device list');
|
|
35
|
+
const devices = await adb.getDevicesWithRetry();
|
|
36
|
+
|
|
37
|
+
// udid was given, lets try to init with that device
|
|
38
|
+
if (udid) {
|
|
39
|
+
if (!_.includes(_.map(devices, 'udid'), udid)) {
|
|
40
|
+
throw this.log.errorAndThrow(`Device ${udid} was not in the list of connected devices`);
|
|
41
|
+
}
|
|
42
|
+
emPort = adb.getPortFromEmulatorString(udid);
|
|
43
|
+
} else if (this.opts.platformVersion) {
|
|
44
|
+
this.opts.platformVersion = `${this.opts.platformVersion}`.trim();
|
|
45
|
+
|
|
46
|
+
// a platform version was given. lets try to find a device with the same os
|
|
47
|
+
const platformVersion = semver.coerce(this.opts.platformVersion) || this.opts.platformVersion;
|
|
48
|
+
this.log.info(`Looking for a device with Android '${platformVersion}'`);
|
|
49
|
+
|
|
50
|
+
// in case we fail to find something, give the user a useful log that has
|
|
51
|
+
// the device udids and os versions so they know what's available
|
|
52
|
+
const availDevices = [];
|
|
53
|
+
let partialMatchCandidate;
|
|
54
|
+
// first try started devices/emulators
|
|
55
|
+
for (const device of devices) {
|
|
56
|
+
// direct adb calls to the specific device
|
|
57
|
+
adb.setDeviceId(device.udid);
|
|
58
|
+
/** @type {string} */
|
|
59
|
+
const rawDeviceOS = await adb.getPlatformVersion();
|
|
60
|
+
// The device OS could either be a number, like `6.0`
|
|
61
|
+
// or an abbreviation, like `R`
|
|
62
|
+
availDevices.push(`${device.udid} (${rawDeviceOS})`);
|
|
63
|
+
const deviceOS = semver.coerce(rawDeviceOS) || rawDeviceOS;
|
|
64
|
+
if (!deviceOS) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const semverPV = platformVersion;
|
|
69
|
+
const semverDO = deviceOS;
|
|
70
|
+
|
|
71
|
+
const bothVersionsCanBeCoerced = semver.valid(deviceOS) && semver.valid(platformVersion);
|
|
72
|
+
const bothVersionsAreStrings = _.isString(deviceOS) && _.isString(platformVersion);
|
|
73
|
+
if (
|
|
74
|
+
(bothVersionsCanBeCoerced &&
|
|
75
|
+
/** @type {semver.SemVer} */ (semverDO).version ===
|
|
76
|
+
/** @type {semver.SemVer} */ (semverPV).version) ||
|
|
77
|
+
(bothVersionsAreStrings && _.toLower(deviceOS) === _.toLower(platformVersion))
|
|
78
|
+
) {
|
|
79
|
+
// Got an exact match - proceed immediately
|
|
80
|
+
udid = device.udid;
|
|
81
|
+
break;
|
|
82
|
+
} else if (!bothVersionsCanBeCoerced) {
|
|
83
|
+
// There is no point to check for partial match if either of version numbers is not coercible
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (
|
|
88
|
+
((!_.includes(this.opts.platformVersion, '.') &&
|
|
89
|
+
/** @type {semver.SemVer} */ (semverPV).major ===
|
|
90
|
+
/** @type {semver.SemVer} */ (semverDO).major) ||
|
|
91
|
+
(/** @type {semver.SemVer} */ (semverPV).major ===
|
|
92
|
+
/** @type {semver.SemVer} */ (semverDO).major &&
|
|
93
|
+
/** @type {semver.SemVer} */ (semverPV).minor ===
|
|
94
|
+
/** @type {semver.SemVer} */ (semverDO).minor)) &&
|
|
95
|
+
// Got a partial match - make sure we consider the most recent
|
|
96
|
+
// device version available on the host system
|
|
97
|
+
((partialMatchCandidate && semver.gt(deviceOS, _.values(partialMatchCandidate)[0])) ||
|
|
98
|
+
!partialMatchCandidate)
|
|
99
|
+
) {
|
|
100
|
+
partialMatchCandidate = {[device.udid]: deviceOS};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!udid && partialMatchCandidate) {
|
|
104
|
+
udid = _.keys(partialMatchCandidate)[0];
|
|
105
|
+
adb.setDeviceId(udid);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!udid) {
|
|
109
|
+
// we couldn't find anything! quit
|
|
110
|
+
throw this.log.errorAndThrow(
|
|
111
|
+
`Unable to find an active device or emulator ` +
|
|
112
|
+
`with OS ${this.opts.platformVersion}. The following are available: ` +
|
|
113
|
+
availDevices.join(', '),
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
emPort = adb.getPortFromEmulatorString(udid);
|
|
118
|
+
} else {
|
|
119
|
+
// a udid was not given, grab the first device we see
|
|
120
|
+
udid = devices[0].udid;
|
|
121
|
+
emPort = adb.getPortFromEmulatorString(udid);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.log.info(`Using device: ${udid}`);
|
|
126
|
+
return {udid: String(udid), emPort: emPort ?? false};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @this {AndroidDriver}
|
|
131
|
+
* @property {(AndroidDriverOpts & {emPort?: number})?} [opts=null]
|
|
132
|
+
* @returns {Promise<import('appium-adb').ADB>}
|
|
133
|
+
*/
|
|
134
|
+
export async function createADB(opts = null) {
|
|
135
|
+
// @ts-expect-error do not put arbitrary properties on opts
|
|
136
|
+
const {udid, emPort} = opts ?? {};
|
|
137
|
+
const adb = await createBaseADB(opts);
|
|
138
|
+
adb.setDeviceId(udid ?? '');
|
|
139
|
+
if (emPort) {
|
|
140
|
+
adb.setEmulatorPort(emPort);
|
|
141
|
+
}
|
|
142
|
+
return adb;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @this {AndroidDriver}
|
|
147
|
+
* @returns {Promise<import('../types').ADBLaunchInfo | undefined>}
|
|
148
|
+
*/
|
|
149
|
+
export async function getLaunchInfo() {
|
|
150
|
+
if (!this.opts.app) {
|
|
151
|
+
this.log.warn('No app sent in, not parsing package/activity');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
let {appPackage, appActivity, appWaitPackage, appWaitActivity} = this.opts;
|
|
155
|
+
const {app} = this.opts;
|
|
156
|
+
|
|
157
|
+
validatePackageActivityNames.bind(this)();
|
|
158
|
+
|
|
159
|
+
if (appPackage && appActivity) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this.log.debug('Parsing package and activity from app manifest');
|
|
164
|
+
const {apkPackage, apkActivity} = await this.adb.packageAndLaunchActivityFromManifest(app);
|
|
165
|
+
if (apkPackage && !appPackage) {
|
|
166
|
+
appPackage = apkPackage;
|
|
167
|
+
}
|
|
168
|
+
if (!appWaitPackage) {
|
|
169
|
+
appWaitPackage = appPackage;
|
|
170
|
+
}
|
|
171
|
+
if (apkActivity && !appActivity) {
|
|
172
|
+
appActivity = apkActivity;
|
|
173
|
+
}
|
|
174
|
+
if (!appWaitActivity) {
|
|
175
|
+
appWaitActivity = appActivity;
|
|
176
|
+
}
|
|
177
|
+
this.log.debug(`Parsed package and activity are: ${apkPackage}/${apkActivity}`);
|
|
178
|
+
return {appPackage, appWaitPackage, appActivity, appWaitActivity};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @this {AndroidDriver}
|
|
183
|
+
* @returns
|
|
184
|
+
*/
|
|
185
|
+
export async function initDevice() {
|
|
186
|
+
const {
|
|
187
|
+
skipDeviceInitialization,
|
|
188
|
+
locale,
|
|
189
|
+
language,
|
|
190
|
+
localeScript,
|
|
191
|
+
unicodeKeyboard,
|
|
192
|
+
hideKeyboard,
|
|
193
|
+
disableWindowAnimation,
|
|
194
|
+
skipUnlock,
|
|
195
|
+
mockLocationApp,
|
|
196
|
+
skipLogcatCapture,
|
|
197
|
+
logcatFormat,
|
|
198
|
+
logcatFilterSpecs,
|
|
199
|
+
} = this.opts;
|
|
200
|
+
|
|
201
|
+
if (skipDeviceInitialization) {
|
|
202
|
+
this.log.info(`'skipDeviceInitialization' is set. Skipping device initialization.`);
|
|
203
|
+
} else {
|
|
204
|
+
if (this.isEmulator()) {
|
|
205
|
+
// Check if the device wake up only for an emulator.
|
|
206
|
+
// It takes 1 second or so even when the device is already awake in a real device.
|
|
207
|
+
await this.adb.waitForDevice();
|
|
208
|
+
}
|
|
209
|
+
// pushSettingsApp required before calling ensureDeviceLocale for API Level 24+
|
|
210
|
+
|
|
211
|
+
// Some feature such as location/wifi are not necessary for all users,
|
|
212
|
+
// but they require the settings app. So, try to configure it while Appium
|
|
213
|
+
// does not throw error even if they fail.
|
|
214
|
+
const shouldThrowError = Boolean(
|
|
215
|
+
language ||
|
|
216
|
+
locale ||
|
|
217
|
+
localeScript ||
|
|
218
|
+
unicodeKeyboard ||
|
|
219
|
+
hideKeyboard ||
|
|
220
|
+
disableWindowAnimation ||
|
|
221
|
+
!skipUnlock,
|
|
222
|
+
);
|
|
223
|
+
await pushSettingsApp.bind(this)(shouldThrowError);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (!this.isEmulator()) {
|
|
227
|
+
if (mockLocationApp || _.isUndefined(mockLocationApp)) {
|
|
228
|
+
await setMockLocationApp.bind(this)(mockLocationApp || SETTINGS_HELPER_ID);
|
|
229
|
+
} else {
|
|
230
|
+
await resetMockLocation.bind(this)();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (language && locale) {
|
|
235
|
+
await this.ensureDeviceLocale(language, locale, localeScript);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (skipLogcatCapture) {
|
|
239
|
+
this.log.info(`'skipLogcatCapture' is set. Skipping starting logcat capture.`);
|
|
240
|
+
} else {
|
|
241
|
+
await this.adb.startLogcat({
|
|
242
|
+
format: logcatFormat,
|
|
243
|
+
filterSpecs: logcatFilterSpecs,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (hideKeyboard) {
|
|
248
|
+
await hideKeyboardCompletely.bind(this)();
|
|
249
|
+
} else if (hideKeyboard === false) {
|
|
250
|
+
await this.adb.shell(['ime', 'reset']);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (unicodeKeyboard) {
|
|
254
|
+
this.log.warn(
|
|
255
|
+
`The 'unicodeKeyboard' capability has been deprecated and will be removed. ` +
|
|
256
|
+
`Set the 'hideKeyboard' capability to 'true' in order to make the on-screen keyboard invisible.`,
|
|
257
|
+
);
|
|
258
|
+
return await initUnicodeKeyboard.bind(this)();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @typedef {import('../../driver').AndroidDriver} AndroidDriver
|
|
264
|
+
*/
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {util} from '@appium/support';
|
|
2
|
+
import {requireArgs} from '../../utils';
|
|
3
|
+
import {requireEmulator} from './utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use mobile: extension
|
|
7
|
+
* @this {import('../../driver').AndroidDriver}
|
|
8
|
+
* @param {string|number} fingerprintId
|
|
9
|
+
* @returns {Promise<void>}
|
|
10
|
+
*/
|
|
11
|
+
export async function fingerprint(fingerprintId) {
|
|
12
|
+
requireEmulator.bind(this)('fingerprint is only available for emulators');
|
|
13
|
+
await this.adb.fingerprint(String(fingerprintId));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @this {import('../../driver').AndroidDriver}
|
|
18
|
+
* @param {import('../types').FingerprintOpts} opts
|
|
19
|
+
* @returns {Promise<void>}
|
|
20
|
+
*/
|
|
21
|
+
export async function mobileFingerprint(opts) {
|
|
22
|
+
const {fingerprintId} = requireArgs('fingerprintId', opts);
|
|
23
|
+
await this.fingerprint(fingerprintId);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use mobile: extension
|
|
28
|
+
* @this {import('../../driver').AndroidDriver}
|
|
29
|
+
* @param {string} phoneNumber
|
|
30
|
+
* @param {string} message
|
|
31
|
+
* @returns {Promise<void>}
|
|
32
|
+
*/
|
|
33
|
+
export async function sendSMS(phoneNumber, message) {
|
|
34
|
+
requireEmulator.bind(this)('sendSMS is only available for emulators');
|
|
35
|
+
await this.adb.sendSMS(phoneNumber, message);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @this {import('../../driver').AndroidDriver}
|
|
40
|
+
* @param {import('../types').SendSMSOpts} opts
|
|
41
|
+
* @returns {Promise<void>}
|
|
42
|
+
*/
|
|
43
|
+
export async function mobileSendSms(opts) {
|
|
44
|
+
const {phoneNumber, message} = requireArgs(['phoneNumber', 'message'], opts);
|
|
45
|
+
await this.sendSMS(phoneNumber, message);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Use mobile: extension
|
|
50
|
+
* @this {import('../../driver').AndroidDriver}
|
|
51
|
+
* @param {string} phoneNumber
|
|
52
|
+
* @param {string} action
|
|
53
|
+
* @returns {Promise<void>}
|
|
54
|
+
*/
|
|
55
|
+
export async function gsmCall(phoneNumber, action) {
|
|
56
|
+
requireEmulator.bind(this)('gsmCall is only available for emulators');
|
|
57
|
+
await this.adb.gsmCall(phoneNumber, /** @type {any} */ (action));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @this {import('../../driver').AndroidDriver}
|
|
62
|
+
* @param {import('../types').GsmCallOpts} opts
|
|
63
|
+
* @returns {Promise<void>}
|
|
64
|
+
*/
|
|
65
|
+
export async function mobileGsmCall(opts) {
|
|
66
|
+
const {phoneNumber, action} = requireArgs(['phoneNumber', 'action'], opts);
|
|
67
|
+
await this.gsmCall(phoneNumber, action);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated Use mobile: extension
|
|
72
|
+
* @this {import('../../driver').AndroidDriver}
|
|
73
|
+
* @param {import('../types').GsmSignalStrength} signalStrengh
|
|
74
|
+
* @returns {Promise<void>}
|
|
75
|
+
*/
|
|
76
|
+
export async function gsmSignal(signalStrengh) {
|
|
77
|
+
requireEmulator.bind(this)('gsmSignal is only available for emulators');
|
|
78
|
+
await this.adb.gsmSignal(signalStrengh);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @this {import('../../driver').AndroidDriver}
|
|
83
|
+
* @param {import('../types').GsmSignalStrengthOpts} opts
|
|
84
|
+
* @returns {Promise<void>}
|
|
85
|
+
*/
|
|
86
|
+
export async function mobileGsmSignal(opts) {
|
|
87
|
+
const {strength} = requireArgs('strength', opts);
|
|
88
|
+
await this.gsmSignal(strength);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use mobile: extension
|
|
93
|
+
* @this {import('../../driver').AndroidDriver}
|
|
94
|
+
* @param {import('../types').GsmVoiceState} state
|
|
95
|
+
* @returns {Promise<void>}
|
|
96
|
+
*/
|
|
97
|
+
export async function gsmVoice(state) {
|
|
98
|
+
requireEmulator.bind(this)('gsmVoice is only available for emulators');
|
|
99
|
+
await this.adb.gsmVoice(state);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @this {import('../../driver').AndroidDriver}
|
|
104
|
+
* @param {import('../types').GsmVoiceOpts} opts
|
|
105
|
+
* @returns {Promise<void>}
|
|
106
|
+
*/
|
|
107
|
+
export async function mobileGsmVoice(opts) {
|
|
108
|
+
const {state} = requireArgs('state', opts);
|
|
109
|
+
await this.gsmVoice(state);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated Use mobile: extension
|
|
114
|
+
* @this {import('../../driver').AndroidDriver}
|
|
115
|
+
* @param {import('../types').PowerACState} state
|
|
116
|
+
* @returns {Promise<void>}
|
|
117
|
+
*/
|
|
118
|
+
export async function powerAC(state) {
|
|
119
|
+
requireEmulator.bind(this)('powerAC is only available for emulators');
|
|
120
|
+
await this.adb.powerAC(state);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @this {import('../../driver').AndroidDriver}
|
|
125
|
+
* @param {import('../types').PowerACOpts} opts
|
|
126
|
+
* @returns {Promise<void>}
|
|
127
|
+
*/
|
|
128
|
+
export async function mobilePowerAc(opts) {
|
|
129
|
+
const {state} = requireArgs('state', opts);
|
|
130
|
+
await this.powerAC(state);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Use mobile: extension
|
|
135
|
+
* @this {import('../../driver').AndroidDriver}
|
|
136
|
+
* @param {number} batteryPercent
|
|
137
|
+
* @returns {Promise<void>}
|
|
138
|
+
*/
|
|
139
|
+
export async function powerCapacity(batteryPercent) {
|
|
140
|
+
requireEmulator.bind(this)('powerCapacity is only available for emulators');
|
|
141
|
+
await this.adb.powerCapacity(batteryPercent);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @this {import('../../driver').AndroidDriver}
|
|
146
|
+
* @param {import('../types').PowerCapacityOpts} opts
|
|
147
|
+
* @return {Promise<void>}
|
|
148
|
+
*/
|
|
149
|
+
export async function mobilePowerCapacity(opts) {
|
|
150
|
+
const {percent} = requireArgs('percent', opts);
|
|
151
|
+
await this.powerCapacity(percent);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use mobile: extension
|
|
156
|
+
* @this {import('../../driver').AndroidDriver}
|
|
157
|
+
* @param {import('../types').NetworkSpeed} networkSpeed
|
|
158
|
+
* @returns {Promise<void>}
|
|
159
|
+
*/
|
|
160
|
+
export async function networkSpeed(networkSpeed) {
|
|
161
|
+
requireEmulator.bind(this)('networkSpeed is only available for emulators');
|
|
162
|
+
await this.adb.networkSpeed(networkSpeed);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @this {import('../../driver').AndroidDriver}
|
|
167
|
+
* @param {import('../types').NetworkSpeedOpts} opts
|
|
168
|
+
* @returns {Promise<void>}
|
|
169
|
+
*/
|
|
170
|
+
export async function mobileNetworkSpeed(opts) {
|
|
171
|
+
const {speed} = requireArgs('speed', opts);
|
|
172
|
+
await this.networkSpeed(speed);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @this {import('../../driver').AndroidDriver}
|
|
177
|
+
* @param {import('../types').SensorSetOpts} opts
|
|
178
|
+
* @returns {Promise<void>}
|
|
179
|
+
*/
|
|
180
|
+
export async function sensorSet(opts) {
|
|
181
|
+
requireEmulator.bind(this)('sensorSet is only available for emulators');
|
|
182
|
+
const {sensorType, value} = opts;
|
|
183
|
+
if (!util.hasValue(sensorType)) {
|
|
184
|
+
this.log.errorAndThrow(`'sensorType' argument is required`);
|
|
185
|
+
}
|
|
186
|
+
if (!util.hasValue(value)) {
|
|
187
|
+
this.log.errorAndThrow(`'value' argument is required`);
|
|
188
|
+
}
|
|
189
|
+
await this.adb.sensorSet(sensorType, /** @type {any} */ (value));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
194
|
+
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {errors} from 'appium/driver';
|
|
2
|
+
|
|
3
|
+
const EMU_CONSOLE_FEATURE = 'emulator_console';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @this {import('../../driver').AndroidDriver}
|
|
7
|
+
* @param {import('../types').ExecOptions} opts
|
|
8
|
+
* @returns {Promise<string>}
|
|
9
|
+
*/
|
|
10
|
+
export async function mobileExecEmuConsoleCommand(opts) {
|
|
11
|
+
this.ensureFeatureEnabled(EMU_CONSOLE_FEATURE);
|
|
12
|
+
|
|
13
|
+
const {command, execTimeout, connTimeout, initTimeout} = opts;
|
|
14
|
+
|
|
15
|
+
if (!command) {
|
|
16
|
+
throw new errors.InvalidArgumentError(`The 'command' argument is mandatory`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await /** @type {import('appium-adb').ADB} */ (this.adb).execEmuConsoleCommand(command, {
|
|
20
|
+
execTimeout,
|
|
21
|
+
connTimeout,
|
|
22
|
+
initTimeout,
|
|
23
|
+
});
|
|
24
|
+
}
|