appium-android-driver 5.14.7 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.ts +282 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js.map +1 -0
- package/build/lib/commands/actions.d.ts +6 -224
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +306 -405
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +7 -9
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +24 -18
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +7 -313
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +135 -293
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/context.d.ts +8 -92
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +381 -439
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/element.d.ts +8 -35
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +153 -136
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/emu-console.d.ts +6 -48
- package/build/lib/commands/emu-console.d.ts.map +1 -1
- package/build/lib/commands/emu-console.js +19 -34
- package/build/lib/commands/emu-console.js.map +1 -1
- package/build/lib/commands/execute.d.ts +6 -5
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +77 -66
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +7 -128
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +183 -219
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +8 -12
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +19 -23
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +9 -132
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +281 -312
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/ime.d.ts +7 -10
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +47 -35
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/index.d.ts +27 -2
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/index.js +41 -19
- package/build/lib/commands/index.js.map +1 -1
- package/build/lib/commands/intent.d.ts +7 -417
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +104 -216
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +6 -5
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +16 -8
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/log.d.ts +7 -44
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +146 -108
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +7 -143
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +113 -140
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/mixins.d.ts +740 -0
- package/build/lib/commands/mixins.d.ts.map +1 -0
- package/build/lib/commands/mixins.js +19 -0
- package/build/lib/commands/mixins.js.map +1 -0
- package/build/lib/commands/network.d.ts +7 -138
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +212 -254
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +24 -70
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +144 -100
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +8 -92
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +75 -87
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +7 -193
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +151 -182
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/shell.d.ts +7 -7
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +40 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +9 -103
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +261 -218
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +22 -90
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +76 -74
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/touch.d.ts +10 -29
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +301 -285
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +978 -0
- package/build/lib/commands/types.d.ts.map +1 -0
- package/build/lib/commands/types.js +3 -0
- package/build/lib/commands/types.js.map +1 -0
- package/build/lib/constraints.d.ts +291 -0
- package/build/lib/constraints.d.ts.map +1 -0
- package/build/lib/constraints.js +300 -0
- package/build/lib/constraints.js.map +1 -0
- package/build/lib/driver.d.ts +68 -37
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +123 -80
- package/build/lib/driver.js.map +1 -1
- package/build/lib/helpers/android.d.ts +164 -0
- package/build/lib/helpers/android.d.ts.map +1 -0
- package/build/lib/helpers/android.js +819 -0
- package/build/lib/helpers/android.js.map +1 -0
- package/build/lib/helpers/index.d.ts +7 -0
- package/build/lib/helpers/index.d.ts.map +1 -0
- package/build/lib/helpers/index.js +29 -0
- package/build/lib/helpers/index.js.map +1 -0
- package/build/lib/helpers/types.d.ts +121 -0
- package/build/lib/helpers/types.d.ts.map +1 -0
- package/build/lib/helpers/types.js +3 -0
- package/build/lib/helpers/types.js.map +1 -0
- package/build/lib/helpers/unlock.d.ts +32 -0
- package/build/lib/helpers/unlock.d.ts.map +1 -0
- package/build/lib/helpers/unlock.js +273 -0
- package/build/lib/helpers/unlock.js.map +1 -0
- package/build/lib/helpers/webview.d.ts +74 -0
- package/build/lib/helpers/webview.d.ts.map +1 -0
- package/build/lib/helpers/webview.js +421 -0
- package/build/lib/helpers/webview.js.map +1 -0
- package/build/lib/index.d.ts +9 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +37 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/method-map.d.ts +0 -8
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +63 -74
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/stubs.d.ts +0 -1
- package/build/lib/stubs.d.ts.map +1 -1
- package/build/lib/stubs.js +1 -0
- package/build/lib/stubs.js.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/lib/commands/actions.js +351 -464
- package/lib/commands/alert.js +27 -17
- package/lib/commands/app-management.js +156 -314
- package/lib/commands/context.js +457 -441
- package/lib/commands/element.js +201 -157
- package/lib/commands/emu-console.js +25 -45
- package/lib/commands/execute.js +106 -90
- package/lib/commands/file-actions.js +222 -240
- package/lib/commands/find.ts +103 -0
- package/lib/commands/general.js +327 -339
- package/lib/commands/ime.js +50 -34
- package/lib/commands/{index.js → index.ts} +20 -24
- package/lib/commands/intent.js +108 -249
- package/lib/commands/keyboard.js +20 -8
- package/lib/commands/log.js +172 -116
- package/lib/commands/media-projection.js +134 -161
- package/lib/commands/mixins.ts +966 -0
- package/lib/commands/network.js +252 -281
- package/lib/commands/performance.js +203 -132
- package/lib/commands/permissions.js +108 -109
- package/lib/commands/recordscreen.js +212 -209
- package/lib/commands/shell.js +51 -40
- package/lib/commands/streamscreen.js +355 -289
- package/lib/commands/system-bars.js +92 -83
- package/lib/commands/touch.js +357 -294
- package/lib/commands/types.ts +1097 -0
- package/lib/{desired-caps.js → constraints.ts} +106 -103
- package/lib/{driver.js → driver.ts} +278 -132
- package/lib/helpers/android.ts +1143 -0
- package/lib/helpers/index.ts +6 -0
- package/lib/helpers/types.ts +134 -0
- package/lib/helpers/unlock.ts +329 -0
- package/lib/helpers/webview.ts +582 -0
- package/lib/index.ts +18 -0
- package/lib/method-map.js +87 -98
- package/lib/stubs.ts +0 -1
- package/package.json +27 -20
- package/index.js +0 -24
- package/lib/android-helpers.js +0 -983
- package/lib/commands/coverage.js +0 -18
- package/lib/commands/find.js +0 -82
- package/lib/unlock-helpers.js +0 -278
- package/lib/webview-helpers.js +0 -602
package/lib/commands/ime.js
CHANGED
|
@@ -1,42 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import {mixin} from './mixins';
|
|
4
|
+
import {errors} from 'appium/driver';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @type {import('./mixins').IMEMixin & ThisType<import('../driver').AndroidDriver>}
|
|
8
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
9
|
+
*/
|
|
10
|
+
const IMEMixin = {
|
|
11
|
+
async isIMEActivated() {
|
|
12
|
+
// eslint-disable-line require-await
|
|
13
|
+
// IME is always activated on Android devices
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
9
16
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
17
|
+
async availableIMEEngines() {
|
|
18
|
+
this.log.debug('Retrieving available IMEs');
|
|
19
|
+
let engines = await /** @type {ADB} */ (this.adb).availableIMEs();
|
|
20
|
+
this.log.debug(`Engines: ${JSON.stringify(engines)}`);
|
|
21
|
+
return engines;
|
|
22
|
+
},
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
24
|
+
async getActiveIMEEngine() {
|
|
25
|
+
this.log.debug('Retrieving current default IME');
|
|
26
|
+
return String(await /** @type {ADB} */ (this.adb).defaultIME());
|
|
27
|
+
},
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
async activateIMEEngine(imeId) {
|
|
30
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
31
|
+
this.log.debug(`Attempting to activate IME ${imeId}`);
|
|
32
|
+
let availableEngines = await adb.availableIMEs();
|
|
33
|
+
if (availableEngines.indexOf(imeId) === -1) {
|
|
34
|
+
this.log.debug('IME not found, failing');
|
|
35
|
+
throw new errors.IMENotAvailableError();
|
|
36
|
+
}
|
|
37
|
+
this.log.debug('Found installed IME, attempting to activate');
|
|
38
|
+
await adb.enableIME(imeId);
|
|
39
|
+
await adb.setIME(imeId);
|
|
40
|
+
},
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
async deactivateIMEEngine() {
|
|
43
|
+
let currentEngine = await this.getActiveIMEEngine();
|
|
44
|
+
// XXX: this allowed 'null' to be passed into `adb.shell`
|
|
45
|
+
if (currentEngine) {
|
|
46
|
+
this.log.debug(`Attempting to deactivate ${currentEngine}`);
|
|
47
|
+
await /** @type {ADB} */ (this.adb).disableIME(currentEngine);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
38
50
|
};
|
|
39
51
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
export default IMEMixin;
|
|
53
|
+
|
|
54
|
+
mixin(IMEMixin);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
58
|
+
*/
|
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import generalCmds from './general';
|
|
1
|
+
import actionCmds from './actions';
|
|
3
2
|
import alertCmds from './alert';
|
|
4
|
-
import
|
|
3
|
+
import appManagementCmds from './app-management';
|
|
5
4
|
import contextCmds from './context';
|
|
6
|
-
import
|
|
7
|
-
import touchCmds from './touch';
|
|
8
|
-
import imeCmds from './ime';
|
|
9
|
-
import networkCmds from './network';
|
|
10
|
-
import coverageCmds from './coverage';
|
|
11
|
-
import recordscreenCmds from './recordscreen';
|
|
12
|
-
import screenStreamCmds from './streamscreen';
|
|
13
|
-
import performanceCmds from './performance';
|
|
14
|
-
import executeCmds from './execute';
|
|
15
|
-
import shellCmds from './shell';
|
|
5
|
+
import elementCmds from './element';
|
|
16
6
|
import emuConsoleCmds from './emu-console';
|
|
7
|
+
import executeCmds from './execute';
|
|
17
8
|
import fileActionsCmds from './file-actions';
|
|
18
|
-
import
|
|
9
|
+
import findCmds from './find';
|
|
10
|
+
import generalCmds from './general';
|
|
11
|
+
import imeCmds from './ime';
|
|
19
12
|
import intentCmds from './intent';
|
|
20
|
-
import
|
|
13
|
+
import keyboardCmds from './keyboard';
|
|
21
14
|
import logCmds from './log';
|
|
22
15
|
import mediaProjectionCmds from './media-projection';
|
|
16
|
+
import networkCmds from './network';
|
|
17
|
+
import performanceCmds from './performance';
|
|
23
18
|
import permissionsCmds from './permissions';
|
|
24
|
-
import
|
|
25
|
-
|
|
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';
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
Object.assign(
|
|
29
|
-
commands,
|
|
25
|
+
const commands = {
|
|
30
26
|
findCmds,
|
|
31
27
|
generalCmds,
|
|
32
28
|
alertCmds,
|
|
@@ -36,7 +32,6 @@ Object.assign(
|
|
|
36
32
|
touchCmds,
|
|
37
33
|
imeCmds,
|
|
38
34
|
networkCmds,
|
|
39
|
-
coverageCmds,
|
|
40
35
|
recordscreenCmds,
|
|
41
36
|
intentCmds,
|
|
42
37
|
screenStreamCmds,
|
|
@@ -52,7 +47,8 @@ Object.assign(
|
|
|
52
47
|
permissionsCmds,
|
|
53
48
|
keyboardCmds,
|
|
54
49
|
// add other command types here
|
|
55
|
-
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export {commands};
|
|
56
53
|
|
|
57
|
-
export
|
|
58
|
-
export default commands;
|
|
54
|
+
export type * from './mixins';
|
package/lib/commands/intent.js
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import {mixin} from './mixins';
|
|
1
4
|
import _ from 'lodash';
|
|
2
|
-
import {
|
|
5
|
+
import {errors} from 'appium/driver';
|
|
3
6
|
|
|
4
7
|
const NO_VALUE_ARG_TYPE = 'sn';
|
|
5
8
|
const SUPPORTED_EXTRA_TYPES = [
|
|
6
|
-
's',
|
|
7
|
-
|
|
9
|
+
's',
|
|
10
|
+
NO_VALUE_ARG_TYPE,
|
|
11
|
+
'z',
|
|
12
|
+
'i',
|
|
13
|
+
'l',
|
|
14
|
+
'f',
|
|
15
|
+
'u',
|
|
16
|
+
'cn',
|
|
17
|
+
'ia',
|
|
18
|
+
'ial',
|
|
19
|
+
'la',
|
|
20
|
+
'lal',
|
|
21
|
+
'fa',
|
|
22
|
+
'fal',
|
|
23
|
+
'sa',
|
|
24
|
+
'sal',
|
|
8
25
|
];
|
|
9
26
|
const API_LEVEL_ANDROID_8 = 26;
|
|
10
27
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
mimeType,
|
|
19
|
-
identifier,
|
|
20
|
-
categories,
|
|
21
|
-
component,
|
|
22
|
-
extras,
|
|
23
|
-
flags,
|
|
24
|
-
} = opts;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param {import('./types').IntentOpts} opts
|
|
31
|
+
* @returns {string[]}
|
|
32
|
+
*/
|
|
33
|
+
function parseIntentSpec(opts = {}) {
|
|
34
|
+
const {intent, action, uri, mimeType, identifier, categories, component, extras, flags} = opts;
|
|
25
35
|
const resultArgs = [];
|
|
26
36
|
if (intent) {
|
|
27
37
|
resultArgs.push(intent);
|
|
@@ -40,7 +50,7 @@ function parseIntentSpec (opts = {}) {
|
|
|
40
50
|
}
|
|
41
51
|
if (categories) {
|
|
42
52
|
if (_.isArray(categories)) {
|
|
43
|
-
resultArgs.push(...
|
|
53
|
+
resultArgs.push(..._.flatMap(categories.map((cName) => ['-c', cName])));
|
|
44
54
|
} else {
|
|
45
55
|
resultArgs.push('-c', categories);
|
|
46
56
|
}
|
|
@@ -63,7 +73,7 @@ function parseIntentSpec (opts = {}) {
|
|
|
63
73
|
if (!_.includes(SUPPORTED_EXTRA_TYPES, type)) {
|
|
64
74
|
throw new errors.InvalidArgumentError(
|
|
65
75
|
`Extra argument type '${type}' is not known. ` +
|
|
66
|
-
|
|
76
|
+
`Supported intent argument types are: ${SUPPORTED_EXTRA_TYPES}`
|
|
67
77
|
);
|
|
68
78
|
}
|
|
69
79
|
if (_.isEmpty(key) || (_.isString(key) && _.trim(key) === '')) {
|
|
@@ -76,7 +86,7 @@ function parseIntentSpec (opts = {}) {
|
|
|
76
86
|
} else if (_.isUndefined(value)) {
|
|
77
87
|
throw new errors.InvalidArgumentError(
|
|
78
88
|
`Intent argument type '${type}' in '${JSON.stringify(item)}' requires a ` +
|
|
79
|
-
|
|
89
|
+
`valid value to be provided`
|
|
80
90
|
);
|
|
81
91
|
} else {
|
|
82
92
|
resultArgs.push(`--e${type}`, key, value);
|
|
@@ -90,242 +100,91 @@ function parseIntentSpec (opts = {}) {
|
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
/**
|
|
93
|
-
* @
|
|
94
|
-
* @
|
|
95
|
-
* The `current` user id is used by default
|
|
96
|
-
* @property {?boolean} wait [false] - Set it to `true` if you want to block the method call
|
|
97
|
-
* until the activity manager's process returns the control to the system.
|
|
98
|
-
* @property {?boolean} stop [false] - Set it to `true` to force stop the target
|
|
99
|
-
* app before starting the activity
|
|
100
|
-
* @property {?number|string} windowingMode - The windowing mode to launch the activity into.
|
|
101
|
-
* Check https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/WindowConfiguration.java
|
|
102
|
-
* for more details on possible windowing modes (constants starting with `WINDOWING_MODE_`).
|
|
103
|
-
* @property {?number|string} activityType - The activity type to launch the activity as.
|
|
104
|
-
* Check https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/WindowConfiguration.java
|
|
105
|
-
* for more details on possible activity types (constants starting with `ACTIVITY_TYPE_`).
|
|
106
|
-
* @property {?number|string} display - The display identifier to launch the activity into.
|
|
107
|
-
* @property {?string} intent - The name of the activity intent to start, for example
|
|
108
|
-
* `com.some.package.name/.YourServiceSubClassName`
|
|
109
|
-
* @property {?string} action - Action name
|
|
110
|
-
* @property {?string} package - Package name
|
|
111
|
-
* @property {?string} uri - Unified resource identifier
|
|
112
|
-
* @property {?string} mimeType - Mime type
|
|
113
|
-
* @property {?string} identifier - Optional identifier
|
|
114
|
-
* @property {?string|Array<string>} categories - One or more category names
|
|
115
|
-
* @property {?string} component - Component name
|
|
116
|
-
* @property {Array<string|Array<string>>} extras - Optional intent arguments. Must be represented
|
|
117
|
-
* as array of arrays, where each subarray item contains two or three string items:
|
|
118
|
-
* value type, key name and the value itself.
|
|
119
|
-
* Supported value types are:
|
|
120
|
-
* - s: string. Value must be a valid string
|
|
121
|
-
* - sn: null. Value is ignored for this type
|
|
122
|
-
* - z: boolean. Value must be either `true` or `false`
|
|
123
|
-
* - i: integer. Value must be a valid 4-byte integer number
|
|
124
|
-
* - l: long. Value must be a valid 8-byte long number
|
|
125
|
-
* - f: float: Value must be a valid float number
|
|
126
|
-
* - u: uri. Value must be a valid uniform resource identifier string
|
|
127
|
-
* - cn: component name. Value must be a valid component name string
|
|
128
|
-
* - ia: Integer[]. Value must be a string of comma-separated integers
|
|
129
|
-
* - ial: List<Integer>. Value must be a string of comma-separated integers
|
|
130
|
-
* - la: Long[]. Value must be a string of comma-separated long numbers
|
|
131
|
-
* - lal: List<Long>. Value must be a string of comma-separated long numbers
|
|
132
|
-
* - fa: Float[]. Value must be a string of comma-separated float numbers
|
|
133
|
-
* - fal: List<Float>. Value must be a string of comma-separated float numbers
|
|
134
|
-
* - sa: String[]. Value must be comma-separated strings. To embed a comma into a string,
|
|
135
|
-
* escape it using "\,"
|
|
136
|
-
* - sal: List<String>. Value must be comma-separated strings. To embed a comma into a string,
|
|
137
|
-
* escape it using "\,"
|
|
138
|
-
* For example: [['s', 'varName1', 'My String1'], ['s', 'varName2', 'My String2'], ['ia', 'arrName', '1,2,3,4']]
|
|
139
|
-
* @property {?string} flags - Intent startup-specific flags as a hexadecimal string.
|
|
140
|
-
* See https://developer.android.com/reference/android/content/Intent.html
|
|
141
|
-
* for the list of available flag values (constants starting with FLAG_ACTIVITY_).
|
|
142
|
-
* Flag values could be merged using the logical 'or' operation.
|
|
143
|
-
* For example, 0x10200000 is the combination of two flags:
|
|
144
|
-
* 0x10000000 `FLAG_ACTIVITY_NEW_TASK` | 0x00200000 `FLAG_ACTIVITY_RESET_TASK_IF_NEEDED`
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Starts the given activity intent.
|
|
149
|
-
*
|
|
150
|
-
* @param {StartActivityOptions} opts
|
|
151
|
-
* @returns {string} The command output
|
|
152
|
-
* @throws {Error} If there was a failure while starting the activity
|
|
153
|
-
* or required options are missing
|
|
103
|
+
* @type {import('./mixins').ActivityMixin & ThisType<import('../driver').AndroidDriver>}
|
|
104
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
154
105
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
user,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
cmd.push(...(parseIntentSpec(opts)));
|
|
186
|
-
return await this.adb.shell(cmd);
|
|
187
|
-
};
|
|
106
|
+
const ActivityMixin = {
|
|
107
|
+
async mobileStartActivity(opts = {}) {
|
|
108
|
+
const {user, wait, stop, windowingMode, activityType, display} = opts;
|
|
109
|
+
const cmd = [
|
|
110
|
+
'am',
|
|
111
|
+
(await /** @type {ADB} */ (this.adb).getApiLevel()) < API_LEVEL_ANDROID_8
|
|
112
|
+
? 'start'
|
|
113
|
+
: 'start-activity',
|
|
114
|
+
];
|
|
115
|
+
if (!_.isNil(user)) {
|
|
116
|
+
cmd.push('--user', String(user));
|
|
117
|
+
}
|
|
118
|
+
if (wait) {
|
|
119
|
+
cmd.push('-W');
|
|
120
|
+
}
|
|
121
|
+
if (stop) {
|
|
122
|
+
cmd.push('-S');
|
|
123
|
+
}
|
|
124
|
+
if (!_.isNil(windowingMode)) {
|
|
125
|
+
cmd.push('--windowingMode', String(windowingMode));
|
|
126
|
+
}
|
|
127
|
+
if (!_.isNil(activityType)) {
|
|
128
|
+
cmd.push('--activityType', String(activityType));
|
|
129
|
+
}
|
|
130
|
+
if (!_.isNil(display)) {
|
|
131
|
+
cmd.push('--display', String(display));
|
|
132
|
+
}
|
|
133
|
+
cmd.push(...parseIntentSpec(opts));
|
|
134
|
+
return await /** @type {ADB} */ (this.adb).shell(cmd);
|
|
135
|
+
},
|
|
188
136
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
* @property {?string} package - Package name
|
|
205
|
-
* @property {Array<Array<string>>} extras - Optional intent arguments.
|
|
206
|
-
* See above for the detailed description.
|
|
207
|
-
* @property {?string} flags - Intent startup-specific flags as a hexadecimal string.
|
|
208
|
-
* See above for the detailed description.
|
|
209
|
-
*/
|
|
137
|
+
async mobileBroadcast(opts = {}) {
|
|
138
|
+
const {user, receiverPermission, allowBackgroundActivityStarts} = opts;
|
|
139
|
+
const cmd = ['am', 'broadcast'];
|
|
140
|
+
if (!_.isNil(user)) {
|
|
141
|
+
cmd.push('--user', String(user));
|
|
142
|
+
}
|
|
143
|
+
if (receiverPermission) {
|
|
144
|
+
cmd.push('--receiver-permission', receiverPermission);
|
|
145
|
+
}
|
|
146
|
+
if (allowBackgroundActivityStarts) {
|
|
147
|
+
cmd.push('--allow-background-activity-starts');
|
|
148
|
+
}
|
|
149
|
+
cmd.push(...parseIntentSpec(opts));
|
|
150
|
+
return await /** @type {ADB} */ (this.adb).shell(cmd);
|
|
151
|
+
},
|
|
210
152
|
|
|
153
|
+
async mobileStartService(opts = {}) {
|
|
154
|
+
const {user, foreground} = opts;
|
|
155
|
+
const cmd = ['am'];
|
|
156
|
+
if ((await /** @type {ADB} */ (this.adb).getApiLevel()) < API_LEVEL_ANDROID_8) {
|
|
157
|
+
cmd.push('startservice');
|
|
158
|
+
} else {
|
|
159
|
+
cmd.push(foreground ? 'start-foreground-service' : 'start-service');
|
|
160
|
+
}
|
|
161
|
+
if (!_.isNil(user)) {
|
|
162
|
+
cmd.push('--user', String(user));
|
|
163
|
+
}
|
|
164
|
+
cmd.push(...parseIntentSpec(opts));
|
|
165
|
+
return await /** @type {ADB} */ (this.adb).shell(cmd);
|
|
166
|
+
},
|
|
211
167
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
const cmd = ['am', 'broadcast'];
|
|
227
|
-
if (!_.isNil(user)) {
|
|
228
|
-
cmd.push('--user', user);
|
|
229
|
-
}
|
|
230
|
-
if (receiverPermission) {
|
|
231
|
-
cmd.push('--receiver-permission', receiverPermission);
|
|
232
|
-
}
|
|
233
|
-
if (allowBackgroundActivityStarts) {
|
|
234
|
-
cmd.push('--allow-background-activity-starts');
|
|
235
|
-
}
|
|
236
|
-
cmd.push(...(parseIntentSpec(opts)));
|
|
237
|
-
return await this.adb.shell(cmd);
|
|
168
|
+
async mobileStopService(opts = {}) {
|
|
169
|
+
const {user} = opts;
|
|
170
|
+
const cmd = [
|
|
171
|
+
'am',
|
|
172
|
+
(await /** @type {ADB} */ (this.adb).getApiLevel()) < API_LEVEL_ANDROID_8
|
|
173
|
+
? 'stopservice'
|
|
174
|
+
: 'stop-service',
|
|
175
|
+
];
|
|
176
|
+
if (!_.isNil(user)) {
|
|
177
|
+
cmd.push('--user', String(user));
|
|
178
|
+
}
|
|
179
|
+
cmd.push(...parseIntentSpec(opts));
|
|
180
|
+
return await /** @type {ADB} */ (this.adb).shell(cmd);
|
|
181
|
+
},
|
|
238
182
|
};
|
|
239
183
|
|
|
240
|
-
|
|
241
|
-
* @typedef {Object} StartServiceOptions
|
|
242
|
-
* @property {?string|number} user ['current'] - The user ID for which the service is started.
|
|
243
|
-
* The `current` user id is used by default
|
|
244
|
-
* @property {?boolean} foreground [false] - Set it to `true` if your service must be
|
|
245
|
-
* started as foreground service. This option is ignored if the API level of the
|
|
246
|
-
* device under test is below 26 (Android 8).
|
|
247
|
-
* @property {?string} intent - The name of the service intent to start, for example
|
|
248
|
-
* `com.some.package.name/.YourServiceSubClassName`.
|
|
249
|
-
* @property {?string} action - Action name
|
|
250
|
-
* @property {?string} uri - Unified resource identifier
|
|
251
|
-
* @property {?string} mimeType - Mime type
|
|
252
|
-
* @property {?string} identifier - Optional identifier
|
|
253
|
-
* @property {?string|Array<string>} categories - One or more category names
|
|
254
|
-
* @property {?string} component - Component name
|
|
255
|
-
* @property {?string} package - Package name
|
|
256
|
-
* @property {Array<Array<string>>} extras - Optional intent arguments.
|
|
257
|
-
* See above for the detailed description.
|
|
258
|
-
* @property {?string} flags - Intent startup-specific flags as a hexadecimal string.
|
|
259
|
-
* See above for the detailed description.
|
|
260
|
-
*/
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Starts the given service intent.
|
|
264
|
-
*
|
|
265
|
-
* @param {StartServiceOptions} opts
|
|
266
|
-
* @returns {string} The command output
|
|
267
|
-
* @throws {Error} If there was a failure while starting the service
|
|
268
|
-
* or required options are missing
|
|
269
|
-
*/
|
|
270
|
-
commands.mobileStartService = async function mobileStartService (opts = {}) {
|
|
271
|
-
const {
|
|
272
|
-
user,
|
|
273
|
-
foreground,
|
|
274
|
-
} = opts;
|
|
275
|
-
const cmd = ['am'];
|
|
276
|
-
if (await this.adb.getApiLevel() < API_LEVEL_ANDROID_8) {
|
|
277
|
-
cmd.push('startservice');
|
|
278
|
-
} else {
|
|
279
|
-
cmd.push(foreground ? 'start-foreground-service' : 'start-service');
|
|
280
|
-
}
|
|
281
|
-
if (!_.isNil(user)) {
|
|
282
|
-
cmd.push('--user', user);
|
|
283
|
-
}
|
|
284
|
-
cmd.push(...(parseIntentSpec(opts)));
|
|
285
|
-
return await this.adb.shell(cmd);
|
|
286
|
-
};
|
|
184
|
+
mixin(ActivityMixin);
|
|
287
185
|
|
|
288
|
-
|
|
289
|
-
* @typedef {Object} StopServiceOptions
|
|
290
|
-
* @property {string|number} user ['current'] - The user ID for which the service is running.
|
|
291
|
-
* The `current` user id is used by default
|
|
292
|
-
* @property {?string} intent - The name of the service intent to stop, for example
|
|
293
|
-
* `com.some.package.name/.YourServiceSubClassName`.
|
|
294
|
-
* @property {?string} action - Action name
|
|
295
|
-
* @property {?string} uri - Unified resource identifier
|
|
296
|
-
* @property {?string} mimeType - Mime type
|
|
297
|
-
* @property {?string} identifier - Optional identifier
|
|
298
|
-
* @property {?string|Array<string>} categories - One or more category names
|
|
299
|
-
* @property {?string} component - Component name
|
|
300
|
-
* @property {?string} package - Package name
|
|
301
|
-
* @property {Array<Array<string>>} extras - Optional intent arguments.
|
|
302
|
-
* See above for the detailed description.
|
|
303
|
-
* @property {?string} flags - See above for the detailed description.
|
|
304
|
-
*/
|
|
186
|
+
export default ActivityMixin;
|
|
305
187
|
|
|
306
188
|
/**
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* @param {StopServiceOptions} opts
|
|
310
|
-
* @returns {string} The command output
|
|
311
|
-
* @throws {Error} If there was a failure while stopping the service
|
|
312
|
-
* or required options are missing
|
|
189
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
313
190
|
*/
|
|
314
|
-
commands.mobileStopService = async function mobileStopService (opts = {}) {
|
|
315
|
-
const {
|
|
316
|
-
user,
|
|
317
|
-
} = opts;
|
|
318
|
-
const cmd = [
|
|
319
|
-
'am',
|
|
320
|
-
(await this.adb.getApiLevel() < API_LEVEL_ANDROID_8) ? 'stopservice' : 'stop-service'
|
|
321
|
-
];
|
|
322
|
-
if (!_.isNil(user)) {
|
|
323
|
-
cmd.push('--user', user);
|
|
324
|
-
}
|
|
325
|
-
cmd.push(...(parseIntentSpec(opts)));
|
|
326
|
-
return await this.adb.shell(cmd);
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
export { commands };
|
|
331
|
-
export default commands;
|
package/lib/commands/keyboard.js
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {mixin} from './mixins';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {import('./mixins').KeyboardMixin & ThisType<import('../driver').AndroidDriver>}
|
|
7
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
8
|
+
*/
|
|
9
|
+
const KeyboardMixin = {
|
|
10
|
+
async hideKeyboard() {
|
|
11
|
+
return await /** @type {import('appium-adb').ADB} */ (this.adb).hideKeyboard();
|
|
12
|
+
},
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
async isKeyboardShown() {
|
|
15
|
+
const {isKeyboardShown} = await /** @type {import('appium-adb').ADB} */ (
|
|
16
|
+
this.adb
|
|
17
|
+
).isSoftKeyboardPresent();
|
|
18
|
+
return isKeyboardShown;
|
|
19
|
+
},
|
|
10
20
|
};
|
|
11
21
|
|
|
12
|
-
|
|
22
|
+
mixin(KeyboardMixin);
|
|
23
|
+
|
|
24
|
+
export default KeyboardMixin;
|