appium-android-driver 5.14.6 → 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/CHANGELOG.md +7 -0
- 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 +26 -19
- package/index.js +0 -24
- package/lib/android-helpers.js +0 -983
- package/lib/commands/coverage.js +0 -18
- package/lib/commands/find.js +0 -82
- package/lib/unlock-helpers.js +0 -278
- package/lib/webview-helpers.js +0 -602
|
@@ -1,313 +1,155 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// @ts-check
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.commands = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const asyncbox_1 = require("asyncbox");
|
|
9
7
|
const support_1 = require("@appium/support");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
8
|
+
const asyncbox_1 = require("asyncbox");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const helpers_1 = require("../helpers");
|
|
12
11
|
const utils_1 = require("../utils");
|
|
12
|
+
const mixins_1 = require("./mixins");
|
|
13
13
|
const APP_EXTENSIONS = ['.apk', '.apks'];
|
|
14
14
|
const RESOLVER_ACTIVITY_NAME = 'android/com.android.internal.app.ResolverActivity';
|
|
15
|
-
const commands = {};
|
|
16
|
-
exports.commands = commands;
|
|
17
|
-
/**
|
|
18
|
-
* Verify whether an application is installed or not
|
|
19
|
-
*
|
|
20
|
-
* @param {string} appId - Application package identifier
|
|
21
|
-
* @returns {boolean} true if the app is installed
|
|
22
|
-
*/
|
|
23
|
-
commands.isAppInstalled = async function isAppInstalled(appId) {
|
|
24
|
-
return await this.adb.isAppInstalled(appId);
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {Object} MobileAppInstalledOptions
|
|
28
|
-
* @property {string} appId - Application package identifier. Must be always provided.
|
|
29
|
-
*/
|
|
30
15
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
16
|
+
* @type {import('./mixins').AppManagementMixin & ThisType<import('../driver').AndroidDriver>}
|
|
17
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
18
|
+
*/
|
|
19
|
+
const AppManagementMixin = {
|
|
20
|
+
async isAppInstalled(appId) {
|
|
21
|
+
return await /** @type {ADB} */ (this.adb).isAppInstalled(appId);
|
|
22
|
+
},
|
|
23
|
+
async mobileIsAppInstalled(opts) {
|
|
24
|
+
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
25
|
+
return await this.isAppInstalled(appId);
|
|
26
|
+
},
|
|
27
|
+
async queryAppState(appId) {
|
|
28
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
29
|
+
this.log.info(`Querying the state of '${appId}'`);
|
|
30
|
+
if (!(await adb.isAppInstalled(appId))) {
|
|
31
|
+
return helpers_1.APP_STATE.NOT_INSTALLED;
|
|
32
|
+
}
|
|
33
|
+
if (!(await adb.processExists(appId))) {
|
|
34
|
+
return helpers_1.APP_STATE.NOT_RUNNING;
|
|
35
|
+
}
|
|
36
|
+
const appIdRe = new RegExp(`\\b${lodash_1.default.escapeRegExp(appId)}/`);
|
|
37
|
+
for (const line of (await adb.dumpWindows()).split('\n')) {
|
|
38
|
+
if (appIdRe.test(line) && ['mCurrentFocus', 'mFocusedApp'].some((x) => line.includes(x))) {
|
|
39
|
+
return helpers_1.APP_STATE.RUNNING_IN_FOREGROUND;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return helpers_1.APP_STATE.RUNNING_IN_BACKGROUND;
|
|
43
|
+
},
|
|
44
|
+
async mobileQueryAppState(opts) {
|
|
45
|
+
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
46
|
+
return await this.queryAppState(appId);
|
|
47
|
+
},
|
|
48
|
+
async activateApp(appId) {
|
|
49
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
50
|
+
this.log.debug(`Activating '${appId}'`);
|
|
51
|
+
const apiLevel = await adb.getApiLevel();
|
|
52
|
+
// Fallback to Monkey in older APIs
|
|
53
|
+
if (apiLevel < 24) {
|
|
54
|
+
// The monkey command could raise an issue as https://stackoverflow.com/questions/44860475/how-to-use-the-monkey-command-with-an-android-system-that-doesnt-have-physical
|
|
55
|
+
// but '--pct-syskeys 0' could cause another background process issue. https://github.com/appium/appium/issues/16941#issuecomment-1129837285
|
|
56
|
+
const cmd = ['monkey', '-p', appId, '-c', 'android.intent.category.LAUNCHER', '1'];
|
|
57
|
+
let output = '';
|
|
58
|
+
try {
|
|
59
|
+
output = await adb.shell(cmd);
|
|
60
|
+
this.log.debug(`Command stdout: ${output}`);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
this.log.errorAndThrow(`Cannot activate '${appId}'. Original error: ${ /** @type {Error} */(e).message}`);
|
|
64
|
+
}
|
|
65
|
+
if (output.includes('monkey aborted')) {
|
|
66
|
+
this.log.errorAndThrow(`Cannot activate '${appId}'. Are you sure it is installed?`);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let activityName = await adb.resolveLaunchableActivity(appId);
|
|
71
|
+
if (activityName === RESOLVER_ACTIVITY_NAME) {
|
|
72
|
+
// https://github.com/appium/appium/issues/17128
|
|
73
|
+
this.log.debug(`The launchable activity name of '${appId}' was resolved to '${activityName}'. ` +
|
|
74
|
+
`Switching the resolver to not use cmd`);
|
|
75
|
+
activityName = await adb.resolveLaunchableActivity(appId, { preferCmd: false });
|
|
76
|
+
}
|
|
77
|
+
const stdout = await adb.shell([
|
|
78
|
+
'am',
|
|
79
|
+
apiLevel < 26 ? 'start' : 'start-activity',
|
|
80
|
+
'-a',
|
|
81
|
+
'android.intent.action.MAIN',
|
|
82
|
+
'-c',
|
|
83
|
+
'android.intent.category.LAUNCHER',
|
|
84
|
+
// FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
85
|
+
// https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_TASK
|
|
86
|
+
// https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
87
|
+
'-f',
|
|
88
|
+
'0x10200000',
|
|
89
|
+
'-n',
|
|
90
|
+
activityName,
|
|
91
|
+
]);
|
|
92
|
+
this.log.debug(stdout);
|
|
93
|
+
if (/^error:/im.test(stdout)) {
|
|
94
|
+
throw new Error(`Cannot activate '${appId}'. Original error: ${stdout}`);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
async mobileActivateApp(opts) {
|
|
98
|
+
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
99
|
+
return await this.activateApp(appId);
|
|
100
|
+
},
|
|
101
|
+
async removeApp(appId, opts = {}) {
|
|
102
|
+
return await /** @type {ADB} */ (this.adb).uninstallApk(appId, opts);
|
|
103
|
+
},
|
|
104
|
+
async mobileRemoveApp(opts) {
|
|
105
|
+
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
106
|
+
return await this.removeApp(appId, opts);
|
|
107
|
+
},
|
|
108
|
+
async terminateApp(appId, options = {}) {
|
|
109
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
110
|
+
this.log.info(`Terminating '${appId}'`);
|
|
111
|
+
if (!(await adb.processExists(appId))) {
|
|
112
|
+
this.log.info(`The app '${appId}' is not running`);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
await adb.forceStop(appId);
|
|
116
|
+
const timeout = support_1.util.hasValue(options.timeout) && !Number.isNaN(options.timeout)
|
|
117
|
+
? parseInt(String(options.timeout), 10)
|
|
118
|
+
: 500;
|
|
119
|
+
if (timeout <= 0) {
|
|
120
|
+
this.log.info(`'${appId}' has been terminated. Skip checking the application process state ` +
|
|
121
|
+
`since the timeout was set as ${timeout}ms`);
|
|
122
|
+
return true;
|
|
63
123
|
}
|
|
64
|
-
}
|
|
65
|
-
return android_helpers_1.APP_STATE.RUNNING_IN_BACKGROUND;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* @typedef {Object} MobileQueryAppStateOptions
|
|
69
|
-
* @property {string} appId - Application package identifier. Must be always provided.
|
|
70
|
-
*/
|
|
71
|
-
/**
|
|
72
|
-
* Queries the current state of the app.
|
|
73
|
-
*
|
|
74
|
-
* @param {MobileQueryAppStateOptions} opts
|
|
75
|
-
* @returns {number} Same as in `queryAppState`
|
|
76
|
-
*/
|
|
77
|
-
commands.mobileQueryAppState = async function mobileQueryAppState(opts = {}) {
|
|
78
|
-
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
79
|
-
return await this.queryAppState(appId);
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Activates the given application or launches it if necessary.
|
|
83
|
-
* The action literally simulates
|
|
84
|
-
* clicking the corresponding application icon on the dashboard.
|
|
85
|
-
*
|
|
86
|
-
* @param {string} appId - Application package identifier
|
|
87
|
-
* @throws {Error} If the app cannot be activated
|
|
88
|
-
*/
|
|
89
|
-
commands.activateApp = async function activateApp(appId) {
|
|
90
|
-
this.log.debug(`Activating '${appId}'`);
|
|
91
|
-
const apiLevel = await this.adb.getApiLevel();
|
|
92
|
-
// Fallback to Monkey in older APIs
|
|
93
|
-
if (apiLevel < 24) {
|
|
94
|
-
// The monkey command could raise an issue as https://stackoverflow.com/questions/44860475/how-to-use-the-monkey-command-with-an-android-system-that-doesnt-have-physical
|
|
95
|
-
// but '--pct-syskeys 0' could cause another background process issue. https://github.com/appium/appium/issues/16941#issuecomment-1129837285
|
|
96
|
-
const cmd = ['monkey',
|
|
97
|
-
'-p', appId,
|
|
98
|
-
'-c', 'android.intent.category.LAUNCHER',
|
|
99
|
-
'1'];
|
|
100
|
-
let output = '';
|
|
101
124
|
try {
|
|
102
|
-
|
|
103
|
-
this.log.debug(`Command stdout: ${output}`);
|
|
125
|
+
await (0, asyncbox_1.waitForCondition)(async () => (await this.queryAppState(appId)) <= helpers_1.APP_STATE.NOT_RUNNING, { waitMs: timeout, intervalMs: 100 });
|
|
104
126
|
}
|
|
105
127
|
catch (e) {
|
|
106
|
-
this.log.errorAndThrow(`
|
|
128
|
+
this.log.errorAndThrow(`'${appId}' is still running after ${timeout}ms timeout`);
|
|
107
129
|
}
|
|
108
|
-
|
|
109
|
-
this.log.errorAndThrow(`Cannot activate '${appId}'. Are you sure it is installed?`);
|
|
110
|
-
}
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
let activityName = await this.adb.resolveLaunchableActivity(appId);
|
|
114
|
-
if (activityName === RESOLVER_ACTIVITY_NAME) {
|
|
115
|
-
// https://github.com/appium/appium/issues/17128
|
|
116
|
-
this.log.debug(`The launchable activity name of '${appId}' was resolved to '${activityName}'. ` +
|
|
117
|
-
`Switching the resolver to not use cmd`);
|
|
118
|
-
activityName = await this.adb.resolveLaunchableActivity(appId, { preferCmd: false });
|
|
119
|
-
}
|
|
120
|
-
const stdout = await this.adb.shell([
|
|
121
|
-
'am', (apiLevel < 26) ? 'start' : 'start-activity',
|
|
122
|
-
'-a', 'android.intent.action.MAIN',
|
|
123
|
-
'-c', 'android.intent.category.LAUNCHER',
|
|
124
|
-
// FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
125
|
-
// https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_TASK
|
|
126
|
-
// https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
127
|
-
'-f', '0x10200000',
|
|
128
|
-
'-n', activityName,
|
|
129
|
-
]);
|
|
130
|
-
this.log.debug(stdout);
|
|
131
|
-
if (/^error:/mi.test(stdout)) {
|
|
132
|
-
throw new Error(`Cannot activate '${appId}'. Original error: ${stdout}`);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* @typedef {Object} MobileActivateAppOptions
|
|
137
|
-
* @property {string} appId - Application package identifier. Must be always provided.
|
|
138
|
-
*/
|
|
139
|
-
/**
|
|
140
|
-
* Activates the given application or launches it if necessary.
|
|
141
|
-
* The action literally simulates
|
|
142
|
-
* clicking the corresponding application icon on the dashboard.
|
|
143
|
-
*
|
|
144
|
-
* @param {MobileActivateAppOptions} opts
|
|
145
|
-
* @throws {Error} If the app cannot be activated
|
|
146
|
-
*/
|
|
147
|
-
commands.mobileActivateApp = async function mobileActivateApp(opts = {}) {
|
|
148
|
-
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
149
|
-
return await this.activateApp(appId);
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* @typedef {Object} UninstallOptions
|
|
153
|
-
* @property {number} timeout [20000] - The count of milliseconds to wait until the
|
|
154
|
-
* app is uninstalled.
|
|
155
|
-
* @property {boolean} keepData [false] - Set to true in order to keep the
|
|
156
|
-
* application data and cache folders after uninstall.
|
|
157
|
-
*/
|
|
158
|
-
/**
|
|
159
|
-
* Remove the corresponding application if is installed.
|
|
160
|
-
* The call is ignored if the app is not installed.
|
|
161
|
-
*
|
|
162
|
-
* @param {string} appId - Application package identifier
|
|
163
|
-
* @param {?UninstallOptions} options - The set of removal options
|
|
164
|
-
* @returns {boolean} True if the package was found on the device and
|
|
165
|
-
* successfully uninstalled.
|
|
166
|
-
*/
|
|
167
|
-
commands.removeApp = async function removeApp(appId, options = {}) {
|
|
168
|
-
return await this.adb.uninstallApk(appId, options);
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* @typedef {Object} MobileRemoveAppOptions
|
|
172
|
-
* @property {string} appId - Application package identifier. Must be always provided.
|
|
173
|
-
*/
|
|
174
|
-
/**
|
|
175
|
-
* Remove the corresponding application if is installed.
|
|
176
|
-
* The call is ignored if the app is not installed.
|
|
177
|
-
*
|
|
178
|
-
* @param {MobileRemoveAppOptions} opts
|
|
179
|
-
* @returns {boolean} Same as in `removeApp`
|
|
180
|
-
*/
|
|
181
|
-
commands.mobileRemoveApp = async function mobileRemoveApp(opts = {}) {
|
|
182
|
-
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
183
|
-
return await this.removeApp(appId, opts);
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* @typedef {Object} TerminateOptions
|
|
187
|
-
* @property {number|string} timeout [500] - The count of milliseconds to wait until the
|
|
188
|
-
* app is terminated. The method will skip
|
|
189
|
-
* checking the app state check if the timeout
|
|
190
|
-
* was lower or equal to zero. Then, the return
|
|
191
|
-
* value will be true.
|
|
192
|
-
*/
|
|
193
|
-
/**
|
|
194
|
-
* Terminates the app if it is running. If the given timeout was lower or equal to zero,
|
|
195
|
-
* it returns true after terminating the app without checking the app state.
|
|
196
|
-
*
|
|
197
|
-
* @param {string} appId - Application package identifier
|
|
198
|
-
* @param {?TerminateOptions} options - The set of application termination options
|
|
199
|
-
* @returns {boolean} True if the app has been successfully terminated.
|
|
200
|
-
* @throws {Error} if the app has not been terminated within the given timeout.
|
|
201
|
-
*/
|
|
202
|
-
commands.terminateApp = async function terminateApp(appId, options = {}) {
|
|
203
|
-
this.log.info(`Terminating '${appId}'`);
|
|
204
|
-
if (!(await this.adb.processExists(appId))) {
|
|
205
|
-
this.log.info(`The app '${appId}' is not running`);
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
await this.adb.forceStop(appId);
|
|
209
|
-
const timeout = support_1.util.hasValue(options.timeout) && !isNaN(options.timeout) ? parseInt(options.timeout, 10) : 500;
|
|
210
|
-
if (timeout <= 0) {
|
|
211
|
-
this.log.info(`'${appId}' has been terminated. Skip checking the application process state ` +
|
|
212
|
-
`since the timeout was set as ${timeout}ms`);
|
|
130
|
+
this.log.info(`'${appId}' has been successfully terminated`);
|
|
213
131
|
return true;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
132
|
+
},
|
|
133
|
+
async mobileTerminateApp(opts) {
|
|
134
|
+
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
135
|
+
return await this.terminateApp(appId, opts);
|
|
136
|
+
},
|
|
137
|
+
async installApp(appPath, opts) {
|
|
138
|
+
const localPath = await this.helpers.configureApp(appPath, APP_EXTENSIONS);
|
|
139
|
+
await /** @type {ADB} */ (this.adb).install(localPath, opts);
|
|
140
|
+
},
|
|
141
|
+
async mobileInstallApp(opts) {
|
|
142
|
+
const { appPath } = (0, utils_1.requireArgs)('appPath', opts);
|
|
143
|
+
return await this.installApp(appPath, opts);
|
|
144
|
+
},
|
|
145
|
+
async mobileClearApp(opts) {
|
|
146
|
+
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
147
|
+
await /** @type {ADB} */ (this.adb).clear(appId);
|
|
148
|
+
},
|
|
223
149
|
};
|
|
150
|
+
(0, mixins_1.mixin)(AppManagementMixin);
|
|
151
|
+
exports.default = AppManagementMixin;
|
|
224
152
|
/**
|
|
225
|
-
* @typedef {
|
|
226
|
-
* @property {string} appId - Application package identifier. Must be always provided.
|
|
227
|
-
* @property {number|string} timeout [500] - The count of milliseconds to wait until the
|
|
228
|
-
* app is terminated.
|
|
229
|
-
*/
|
|
230
|
-
/**
|
|
231
|
-
* Terminates the app if it is running.
|
|
232
|
-
*
|
|
233
|
-
* @param {MobileTerminateAppOptions} opts
|
|
234
|
-
* @returns {boolean} Same as in `terminateApp`
|
|
235
|
-
* @throws {Error} if the app has not been terminated within the given timeout.
|
|
153
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
236
154
|
*/
|
|
237
|
-
commands.mobileTerminateApp = async function mobileTerminateApp(opts = {}) {
|
|
238
|
-
const { appId } = (0, utils_1.requireArgs)('appId', opts);
|
|
239
|
-
return await this.terminateApp(appId, opts);
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* @typedef {Object} InstallOptions
|
|
243
|
-
* @property {number} timeout [60000] - The count of milliseconds to wait until the
|
|
244
|
-
* app is installed.
|
|
245
|
-
* @property {boolean} allowTestPackages [false] - Set to true in order to allow test
|
|
246
|
-
* packages installation.
|
|
247
|
-
* @property {boolean} useSdcard [false] - Set to true to install the app on sdcard
|
|
248
|
-
* instead of the device memory.
|
|
249
|
-
* @property {boolean} grantPermissions [false] - Set to true in order to grant all the
|
|
250
|
-
* permissions requested in the application's manifest
|
|
251
|
-
* automatically after the installation is completed
|
|
252
|
-
* under Android 6+.
|
|
253
|
-
* @property {boolean} replace [true] - Set it to false if you don't want
|
|
254
|
-
* the application to be upgraded/reinstalled
|
|
255
|
-
* if it is already present on the device.
|
|
256
|
-
*/
|
|
257
|
-
/**
|
|
258
|
-
* Installs the given application to the device under test
|
|
259
|
-
*
|
|
260
|
-
* @param {string} appPath - The local apk path or a remote url
|
|
261
|
-
* @param {?InstallOptions} options - The set of installation options
|
|
262
|
-
* @throws {Error} if the given apk does not exist or is not reachable
|
|
263
|
-
*/
|
|
264
|
-
commands.installApp = async function installApp(appPath, options = {}) {
|
|
265
|
-
const localPath = await this.helpers.configureApp(appPath, APP_EXTENSIONS);
|
|
266
|
-
await this.adb.install(localPath, options);
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* @typedef {Object} MobileInstallAppOptions
|
|
270
|
-
* @property {string} appPath - The local apk path or a remote url. Must be always provided.
|
|
271
|
-
* @property {number} timeout [60000] - The count of milliseconds to wait until the
|
|
272
|
-
* app is installed.
|
|
273
|
-
* @property {boolean} allowTestPackages [false] - Set to true in order to allow test
|
|
274
|
-
* packages installation.
|
|
275
|
-
* @property {boolean} useSdcard [false] - Set to true to install the app on sdcard
|
|
276
|
-
* instead of the device memory.
|
|
277
|
-
* @property {boolean} grantPermissions [false] - Set to true in order to grant all the
|
|
278
|
-
* permissions requested in the application's manifest
|
|
279
|
-
* automatically after the installation is completed
|
|
280
|
-
* under Android 6+.
|
|
281
|
-
* @property {boolean} replace [true] - Set it to false if you don't want
|
|
282
|
-
* the application to be upgraded/reinstalled
|
|
283
|
-
* if it is already present on the device.
|
|
284
|
-
*/
|
|
285
|
-
/**
|
|
286
|
-
* Installs the given application to the device under test
|
|
287
|
-
*
|
|
288
|
-
* @param {MobileInstallAppOptions} opts
|
|
289
|
-
* @throws {Error} if the given apk does not exist or is not reachable
|
|
290
|
-
*/
|
|
291
|
-
commands.mobileInstallApp = async function mobileInstallApp(opts = {}) {
|
|
292
|
-
const { appPath } = (0, utils_1.requireArgs)('appPath', opts);
|
|
293
|
-
return await this.installApp(appPath, opts);
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* @typedef {Object} ClearAppOptions
|
|
297
|
-
* @property {!string} appId The identifier of the application package to be cleared
|
|
298
|
-
*/
|
|
299
|
-
/**
|
|
300
|
-
* Deletes all data associated with a package.
|
|
301
|
-
*
|
|
302
|
-
* @param {ClearAppOptions} opts
|
|
303
|
-
* @throws {Error} If cleaning of the app data fails
|
|
304
|
-
*/
|
|
305
|
-
commands.mobileClearApp = async function mobileClearApp(opts = {}) {
|
|
306
|
-
const { appId } = opts;
|
|
307
|
-
if (!appId) {
|
|
308
|
-
throw new driver_1.errors.InvalidArgumentError(`The 'appId' argument is required`);
|
|
309
|
-
}
|
|
310
|
-
await this.adb.clear(appId);
|
|
311
|
-
};
|
|
312
|
-
exports.default = commands;
|
|
313
155
|
//# sourceMappingURL=app-management.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-management.js","sourceRoot":"","sources":["../../../lib/commands/app-management.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-management.js","sourceRoot":"","sources":["../../../lib/commands/app-management.js"],"names":[],"mappings":";AAAA,YAAY;;;;;AAEZ,6CAAqC;AACrC,uCAA0C;AAC1C,oDAAuB;AACvB,wCAAqC;AACrC,oCAAqC;AACrC,qCAA+B;AAE/B,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACzC,MAAM,sBAAsB,GAAG,mDAAmD,CAAC;AAEnF;;;GAGG;AACH,MAAM,kBAAkB,GAAG;IACzB,KAAK,CAAC,cAAc,CAAC,KAAK;QACxB,OAAO,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,IAAI;QAC7B,MAAM,EAAC,KAAK,EAAC,GAAG,IAAA,mBAAW,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3C,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,KAAK;QACvB,MAAM,GAAG,GAAG,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,KAAK,GAAG,CAAC,CAAC;QAClD,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE;YACtC,OAAO,mBAAS,CAAC,aAAa,CAAC;SAChC;Q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CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,IAAI;QACzB,MAAM,EAAC,OAAO,EAAC,GAAG,IAAA,mBAAW,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC/C,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAAI;QACvB,MAAM,EAAC,KAAK,EAAC,GAAG,IAAA,mBAAW,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3C,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;CACF,CAAC;AAEF,IAAA,cAAK,EAAC,kBAAkB,CAAC,CAAC;AAE1B,kBAAe,kBAAkB,CAAC;AAElC;;GAEG"}
|
|
@@ -1,94 +1,10 @@
|
|
|
1
|
-
export default
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* prefix plus PID or package name
|
|
10
|
-
*/
|
|
11
|
-
webview: string;
|
|
12
|
-
/**
|
|
13
|
-
* Webview information as it is retrieved by
|
|
14
|
-
* /json/version CDP endpoint
|
|
15
|
-
*/
|
|
16
|
-
info: any | null;
|
|
17
|
-
/**
|
|
18
|
-
* Webview pages list as it is retrieved by
|
|
19
|
-
* /json/list CDP endpoint
|
|
20
|
-
*/
|
|
21
|
-
pages: Array<any> | null;
|
|
22
|
-
};
|
|
23
|
-
export namespace commands {
|
|
24
|
-
function getCurrentContext(): Promise<any>;
|
|
25
|
-
function getContexts(): Promise<any>;
|
|
26
|
-
function setContext(name: any): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {Object} WebviewsMapping
|
|
29
|
-
* @property {string} proc The name of the Devtools Unix socket
|
|
30
|
-
* @property {string} webview The web view alias. Looks like `WEBVIEW_`
|
|
31
|
-
* prefix plus PID or package name
|
|
32
|
-
* @property {?Object} info Webview information as it is retrieved by
|
|
33
|
-
* /json/version CDP endpoint
|
|
34
|
-
* @property {?Array<Object>} pages Webview pages list as it is retrieved by
|
|
35
|
-
* /json/list CDP endpoint
|
|
36
|
-
* @propery {?string} webviewName An actual webview name for switching context.
|
|
37
|
-
* This value becomes null when failing to find a PID for a webview.
|
|
38
|
-
*
|
|
39
|
-
* The following json demonstrates the example of WebviewsMapping object.
|
|
40
|
-
* Note that `description` in `page` can be an empty string most likely when it comes to Mobile Chrome)
|
|
41
|
-
* {
|
|
42
|
-
* "proc": "@webview_devtools_remote_22138",
|
|
43
|
-
* "webview": "WEBVIEW_22138",
|
|
44
|
-
* "info": {
|
|
45
|
-
* "Android-Package": "io.appium.settings",
|
|
46
|
-
* "Browser": "Chrome/74.0.3729.185",
|
|
47
|
-
* "Protocol-Version": "1.3",
|
|
48
|
-
* "User-Agent": "Mozilla/5.0 (Linux; Android 10; Android SDK built for x86 Build/QSR1.190920.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.185 Mobile Safari/537.36",
|
|
49
|
-
* "V8-Version": "7.4.288.28",
|
|
50
|
-
* "WebKit-Version": "537.36 (@22955682f94ce09336197bfb8dffea991fa32f0d)",
|
|
51
|
-
* "webSocketDebuggerUrl": "ws://127.0.0.1:10900/devtools/browser"
|
|
52
|
-
* },
|
|
53
|
-
* "pages": [
|
|
54
|
-
* {
|
|
55
|
-
* "description": "{\"attached\":true,\"empty\":false,\"height\":1458,\"screenX\":0,\"screenY\":336,\"visible\":true,\"width\":1080}",
|
|
56
|
-
* "devtoolsFrontendUrl": "http://chrome-devtools-frontend.appspot.com/serve_rev/@22955682f94ce09336197bfb8dffea991fa32f0d/inspector.html?ws=127.0.0.1:10900/devtools/page/27325CC50B600D31B233F45E09487B1F",
|
|
57
|
-
* "id": "27325CC50B600D31B233F45E09487B1F",
|
|
58
|
-
* "title": "Releases · appium/appium · GitHub",
|
|
59
|
-
* "type": "page",
|
|
60
|
-
* "url": "https://github.com/appium/appium/releases",
|
|
61
|
-
* "webSocketDebuggerUrl": "ws://127.0.0.1:10900/devtools/page/27325CC50B600D31B233F45E09487B1F"
|
|
62
|
-
* }
|
|
63
|
-
* ],
|
|
64
|
-
* "webviewName": "WEBVIEW_com.io.appium.setting"
|
|
65
|
-
* }
|
|
66
|
-
*/
|
|
67
|
-
/**
|
|
68
|
-
* Returns a webviewsMapping based on CDP endpoints
|
|
69
|
-
*
|
|
70
|
-
* @return {Array<WebviewsMapping>} webviewsMapping
|
|
71
|
-
*/
|
|
72
|
-
function mobileGetContexts(): WebviewsMapping[];
|
|
73
|
-
}
|
|
74
|
-
export namespace helpers {
|
|
75
|
-
function assignContexts(webviewsMapping: any): string[];
|
|
76
|
-
function switchContext(name: any, webviewsMapping: any): Promise<void>;
|
|
77
|
-
function defaultContextName(): string;
|
|
78
|
-
function defaultWebviewName(): string;
|
|
79
|
-
function isWebContext(): boolean;
|
|
80
|
-
function startChromedriverProxy(context: any, webviewsMapping: any): Promise<void>;
|
|
81
|
-
function suspendChromedriverProxy(): void;
|
|
82
|
-
function onChromedriverStop(context: any): Promise<void>;
|
|
83
|
-
function stopChromedriverProxies(): Promise<void>;
|
|
84
|
-
function isChromedriverContext(viewName: any): boolean;
|
|
85
|
-
function shouldDismissChromeWelcome(): any;
|
|
86
|
-
function dismissChromeWelcome(): Promise<void>;
|
|
87
|
-
function startChromeSession(): Promise<void>;
|
|
88
|
-
function isChromedriverAutodownloadEnabled(): boolean;
|
|
89
|
-
function setupNewChromedriver(opts: any, curDeviceId: any, adb: any, context?: null): Promise<Chromedriver>;
|
|
90
|
-
}
|
|
91
|
-
export function setupNewChromedriver(opts: any, curDeviceId: any, adb: any, context?: null): Promise<Chromedriver>;
|
|
92
|
-
declare let extensions: {};
|
|
1
|
+
export default ContextMixin;
|
|
2
|
+
export const setupNewChromedriver: (opts: import("../driver").AndroidDriverOpts, curDeviceId: string, adb: import("appium-adb").default, context?: string | undefined) => Promise<Chromedriver>;
|
|
3
|
+
export type ADB = import('appium-adb').ADB;
|
|
4
|
+
/**
|
|
5
|
+
* @type {import('./mixins').ContextMixin & ThisType<import('../driver').AndroidDriver>}
|
|
6
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
7
|
+
*/
|
|
8
|
+
declare const ContextMixin: import('./mixins').ContextMixin & ThisType<import('../driver').AndroidDriver>;
|
|
93
9
|
import Chromedriver from 'appium-chromedriver';
|
|
94
10
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../lib/commands/context.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../lib/commands/context.js"],"names":[],"mappings":";AA0eA,gMAAsE;kBAGzD,OAAO,YAAY,EAAE,GAAG;AAxdrC;;;GAGG;AACH,4BAHU,OAAO,UAAU,EAAE,YAAY,GAAG,SAAS,OAAO,WAAW,EAAE,aAAa,CAAC,CA+crF;yBAleuB,qBAAqB"}
|