appium-android-driver 6.0.1 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +4 -107
- package/build/lib/commands/actions.d.ts +0 -1
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +14 -139
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +0 -1
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/element.d.ts +0 -1
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +14 -48
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +0 -1
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +1 -1
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +0 -1
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +6 -11
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/index.d.ts +23 -23
- package/build/lib/commands/mixins.d.ts +2 -6
- package/build/lib/commands/mixins.d.ts.map +1 -1
- package/build/lib/commands/mixins.js.map +1 -1
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +27 -55
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +4 -4
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +0 -4
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/touch.d.ts +0 -1
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +1 -15
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/constraints.d.ts +0 -9
- package/build/lib/constraints.d.ts.map +1 -1
- package/build/lib/constraints.js +0 -9
- package/build/lib/constraints.js.map +1 -1
- package/build/lib/driver.d.ts +2 -50
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +1 -476
- package/build/lib/driver.js.map +1 -1
- package/build/lib/helpers/android.d.ts +0 -2
- package/build/lib/helpers/android.d.ts.map +1 -1
- package/build/lib/helpers/android.js +0 -2
- package/build/lib/helpers/android.js.map +1 -1
- package/build/lib/helpers/webview.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 +0 -1
- package/build/lib/stubs.js.map +1 -1
- package/build/lib/utils.d.ts +3 -4
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +3 -4
- package/build/lib/utils.js.map +1 -1
- package/lib/commands/actions.js +15 -163
- package/lib/commands/context.js +0 -1
- package/lib/commands/element.js +14 -68
- package/lib/commands/execute.js +0 -1
- package/lib/commands/find.ts +1 -2
- package/lib/commands/general.js +6 -11
- package/lib/commands/mixins.ts +0 -6
- package/lib/commands/network.js +28 -61
- package/lib/commands/performance.js +0 -4
- package/lib/commands/touch.js +1 -20
- package/lib/constraints.ts +0 -9
- package/lib/driver.ts +7 -595
- package/lib/helpers/android.ts +0 -4
- package/lib/helpers/webview.ts +1 -1
- package/lib/stubs.ts +0 -1
- package/lib/utils.js +4 -5
- package/package.json +3 -6
- package/bootstrap/README.md +0 -19
- package/bootstrap/bin/AppiumBootstrap.jar +0 -0
- package/build/lib/bootstrap.d.ts +0 -29
- package/build/lib/bootstrap.d.ts.map +0 -1
- package/build/lib/bootstrap.js +0 -213
- package/build/lib/bootstrap.js.map +0 -1
- package/build/lib/uiautomator.d.ts +0 -24
- package/build/lib/uiautomator.d.ts.map +0 -1
- package/build/lib/uiautomator.js +0 -102
- package/build/lib/uiautomator.js.map +0 -1
- package/lib/bootstrap.js +0 -227
- package/lib/uiautomator.js +0 -109
package/lib/utils.js
CHANGED
|
@@ -6,16 +6,15 @@ export const ADB_SHELL_FEATURE = 'adb_shell';
|
|
|
6
6
|
/**
|
|
7
7
|
* Assert the presence of particular keys in the given object
|
|
8
8
|
*
|
|
9
|
-
* @template {Object} T
|
|
10
9
|
* @param {string|string[]} argNames one or more key names
|
|
11
|
-
* @param {
|
|
12
|
-
* @returns {
|
|
10
|
+
* @param {any} opts the object to check
|
|
11
|
+
* @returns {Record<string, any>} the same given object
|
|
13
12
|
*/
|
|
14
|
-
export function requireArgs (argNames, opts
|
|
13
|
+
export function requireArgs (argNames, opts) {
|
|
15
14
|
for (const argName of (_.isArray(argNames) ? argNames : [argNames])) {
|
|
16
15
|
if (!_.has(opts, argName)) {
|
|
17
16
|
throw new errors.InvalidArgumentError(`'${argName}' argument must be provided`);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
return opts;
|
|
21
|
-
}
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-android-driver",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Android UiAutomator and Chrome support for Appium",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"appium",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"lib",
|
|
29
29
|
"build",
|
|
30
|
-
"bootstrap/bin/AppiumBootstrap.jar",
|
|
31
30
|
"CHANGELOG.md",
|
|
32
31
|
"!build/test",
|
|
33
32
|
"!build/tsconfig.tsbuildinfo"
|
|
@@ -36,7 +35,6 @@
|
|
|
36
35
|
"build": "tsc -b",
|
|
37
36
|
"clean": "npm run build -- --clean",
|
|
38
37
|
"dev": "npm run build -- --watch",
|
|
39
|
-
"e2e-test": "mocha --exit --timeout 10m \"./test/functional/**/*-specs.js\"",
|
|
40
38
|
"lint": "eslint .",
|
|
41
39
|
"lint:commit": "commitlint",
|
|
42
40
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -70,10 +68,9 @@
|
|
|
70
68
|
"portfinder": "^1.0.6",
|
|
71
69
|
"portscanner": "2.2.0",
|
|
72
70
|
"semver": "^7.0.0",
|
|
73
|
-
"shared-preferences-builder": "^0.x",
|
|
74
71
|
"source-map-support": "^0.x",
|
|
75
72
|
"teen_process": "^2.0.0",
|
|
76
|
-
"type-fest": "^
|
|
73
|
+
"type-fest": "^4.4.0",
|
|
77
74
|
"ws": "^8.0.0"
|
|
78
75
|
},
|
|
79
76
|
"devDependencies": {
|
|
@@ -119,7 +116,7 @@
|
|
|
119
116
|
"prettier": "^3.0.1",
|
|
120
117
|
"rimraf": "^5.0.0",
|
|
121
118
|
"semantic-release": "^21.1.0",
|
|
122
|
-
"sinon": "^
|
|
119
|
+
"sinon": "^16.0.0",
|
|
123
120
|
"ts-node": "^10.9.1",
|
|
124
121
|
"typescript": "^5.1.6",
|
|
125
122
|
"xpath": "^0.x"
|
package/bootstrap/README.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Bootstrap Android
|
|
2
|
-
===
|
|
3
|
-
|
|
4
|
-
To install the Android Maven dependencies in your local environment, run the following:
|
|
5
|
-
|
|
6
|
-
* Clone https://github.com/mosabua/maven-android-sdk-deployer into your workstation
|
|
7
|
-
* Set the ANDROID_HOME environment to the location of the Android SDK, eg. `export ANDROID_HOME=/Developer/adt-bundle-mac-x86_64-20130219/sdk/`
|
|
8
|
-
* Run `mvn install -P 4.4` from the `maven-android-sdk-deployer` directory. The build will fail if API 19 and some extra packages are not installed.
|
|
9
|
-
* Please install all sdk and api versions of android for building `maven-android-sdk-deployer`.
|
|
10
|
-
|
|
11
|
-
You can then compile the bootstrap project by running
|
|
12
|
-
|
|
13
|
-
mvn package -P 4.4
|
|
14
|
-
|
|
15
|
-
If mvn package fails, try deleting your ANDROID_HOME folder and downloading everything again. If it still doesn't work try:
|
|
16
|
-
|
|
17
|
-
android-sdk/tools/android update sdk --no-ui --obsolete --force
|
|
18
|
-
|
|
19
|
-
and then run `mvn clean ; mvn install`
|
|
Binary file
|
package/build/lib/bootstrap.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
export default AndroidBootstrap;
|
|
3
|
-
export class AndroidBootstrap {
|
|
4
|
-
constructor(adb: any, systemPort?: number, webSocket?: undefined);
|
|
5
|
-
adb: any;
|
|
6
|
-
systemPort: number;
|
|
7
|
-
webSocket: any;
|
|
8
|
-
set ignoreUnexpectedShutdown(arg: any);
|
|
9
|
-
get ignoreUnexpectedShutdown(): any;
|
|
10
|
-
get onUnexpectedShutdown(): B<any>;
|
|
11
|
-
_onUnexpectedShutdownPromise: B<any> | undefined;
|
|
12
|
-
start(appPackage: any, disableAndroidWatchers?: boolean, acceptSslCerts?: boolean): Promise<any>;
|
|
13
|
-
process: any;
|
|
14
|
-
socketClient: net.Socket | undefined;
|
|
15
|
-
sendCommand(type: any, extra?: {}): Promise<any>;
|
|
16
|
-
sendAction(action: any, params?: {}): Promise<any>;
|
|
17
|
-
shutdown(): Promise<void>;
|
|
18
|
-
uiAutomator: UiAutomator | null | undefined;
|
|
19
|
-
init(): Promise<void>;
|
|
20
|
-
_ignoreUnexpectedShutdown: any;
|
|
21
|
-
}
|
|
22
|
-
export namespace COMMAND_TYPES {
|
|
23
|
-
let ACTION: string;
|
|
24
|
-
let SHUTDOWN: string;
|
|
25
|
-
}
|
|
26
|
-
import B from 'bluebird';
|
|
27
|
-
import net from 'net';
|
|
28
|
-
import UiAutomator from './uiautomator';
|
|
29
|
-
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../lib/bootstrap.js"],"names":[],"mappings":";;AAuCA;IACE,kEAKC;IAJC,SAAc;IACd,mBAA4B;IAC5B,eAA0B;IA4K5B,uCAGC;IAED,oCAEC;IA/KD,mCASC;IANG,iDAEE;IAMN,iGA4EC;IArEG,aAMC;IA6CG,qCAA6D;IAoBrE,iDA4CC;IAED,mDAGC;IAED,0BAaC;IADC,4CAAuB;IAIzB,sBAUC;IAIC,+BAAuC;CAM1C;;;;;cA1Na,UAAU;gBAJR,KAAK;wBADG,eAAe"}
|
package/build/lib/bootstrap.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.COMMAND_TYPES = exports.AndroidBootstrap = void 0;
|
|
7
|
-
const uiautomator_1 = __importDefault(require("./uiautomator"));
|
|
8
|
-
const net_1 = __importDefault(require("net"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
11
|
-
const driver_1 = require("appium/driver");
|
|
12
|
-
const bluebird_1 = __importDefault(require("bluebird"));
|
|
13
|
-
const support_1 = require("@appium/support");
|
|
14
|
-
const log = support_1.logger.getLogger('AndroidBootstrap');
|
|
15
|
-
const COMMAND_TYPES = {
|
|
16
|
-
ACTION: 'action',
|
|
17
|
-
SHUTDOWN: 'shutdown'
|
|
18
|
-
};
|
|
19
|
-
exports.COMMAND_TYPES = COMMAND_TYPES;
|
|
20
|
-
const SEND_COMMAND_TIMEOUT = 1 * 60 * 1000;
|
|
21
|
-
/**
|
|
22
|
-
* Calculates the path to the current module's root folder
|
|
23
|
-
*
|
|
24
|
-
* @returns {string} The full path to module root
|
|
25
|
-
* @throws {Error} If the current module root folder cannot be determined
|
|
26
|
-
*/
|
|
27
|
-
const getModuleRoot = lodash_1.default.memoize(async function getModuleRoot() {
|
|
28
|
-
let currentDir = path_1.default.dirname(path_1.default.resolve(__filename));
|
|
29
|
-
let isAtFsRoot = false;
|
|
30
|
-
while (!isAtFsRoot) {
|
|
31
|
-
const manifestPath = path_1.default.join(currentDir, 'package.json');
|
|
32
|
-
try {
|
|
33
|
-
if (await support_1.fs.exists(manifestPath) &&
|
|
34
|
-
JSON.parse(await support_1.fs.readFile(manifestPath, 'utf8')).name === 'appium-android-driver') {
|
|
35
|
-
return currentDir;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (ign) { }
|
|
39
|
-
currentDir = path_1.default.dirname(currentDir);
|
|
40
|
-
isAtFsRoot = currentDir.length <= path_1.default.dirname(currentDir).length;
|
|
41
|
-
}
|
|
42
|
-
throw new Error('Cannot find the root folder of the appium-android-driver Node.js module');
|
|
43
|
-
});
|
|
44
|
-
class AndroidBootstrap {
|
|
45
|
-
constructor(adb, systemPort = 4724, webSocket = undefined) {
|
|
46
|
-
this.adb = adb;
|
|
47
|
-
this.systemPort = systemPort;
|
|
48
|
-
this.webSocket = webSocket;
|
|
49
|
-
this.ignoreUnexpectedShutdown = false;
|
|
50
|
-
}
|
|
51
|
-
get onUnexpectedShutdown() {
|
|
52
|
-
if (!this._onUnexpectedShutdownPromise) {
|
|
53
|
-
let reject;
|
|
54
|
-
this._onUnexpectedShutdownPromise = new bluebird_1.default(function _onUnexpectedShutdownPromise(_resolve, _reject) {
|
|
55
|
-
reject = _reject;
|
|
56
|
-
});
|
|
57
|
-
this._onUnexpectedShutdownPromise.cancel = reject;
|
|
58
|
-
}
|
|
59
|
-
return this._onUnexpectedShutdownPromise;
|
|
60
|
-
}
|
|
61
|
-
async start(appPackage, disableAndroidWatchers = false, acceptSslCerts = false) {
|
|
62
|
-
try {
|
|
63
|
-
const startDetector = (s) => /Appium Socket Server Ready/.test(s);
|
|
64
|
-
const bootstrapJar = path_1.default.resolve(await getModuleRoot(), 'bootstrap', 'bin', 'AppiumBootstrap.jar');
|
|
65
|
-
await this.init();
|
|
66
|
-
await this.adb.forwardPort(this.systemPort, 4724);
|
|
67
|
-
this.process = await this.uiAutomator.start(bootstrapJar, 'io.appium.android.bootstrap.Bootstrap', startDetector, '-e', 'pkg', appPackage, '-e', 'disableAndroidWatchers', disableAndroidWatchers, '-e', 'acceptSslCerts', acceptSslCerts);
|
|
68
|
-
// process the output
|
|
69
|
-
this.process.on('output', (stdout, stderr) => {
|
|
70
|
-
const alertRe = /Emitting system alert message/;
|
|
71
|
-
if (alertRe.test(stdout)) {
|
|
72
|
-
log.debug('Emitting alert message...');
|
|
73
|
-
if (this.webSocket) {
|
|
74
|
-
this.webSocket.sockets.emit('alert', { message: stdout });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// the bootstrap logger wraps its own log lines with
|
|
78
|
-
// [APPIUM-UIAUTO] ... [APPIUM-UIAUTO]
|
|
79
|
-
// and leaves actual UiAutomator logs as they are
|
|
80
|
-
let stdoutLines = (stdout || '').split('\n');
|
|
81
|
-
const uiautoLog = /\[APPIUM-UIAUTO\](.+)\[\/APPIUM-UIAUTO\]/;
|
|
82
|
-
for (let line of stdoutLines) {
|
|
83
|
-
if (line.trim()) {
|
|
84
|
-
if (uiautoLog.test(line)) {
|
|
85
|
-
let innerLine = uiautoLog.exec(line)[1].trim();
|
|
86
|
-
let logMethod = log.info.bind(log);
|
|
87
|
-
// if the bootstrap log considers something debug, log that as
|
|
88
|
-
// debug and not info
|
|
89
|
-
if (/\[debug\]/.test(innerLine)) {
|
|
90
|
-
logMethod = log.debug.bind(log);
|
|
91
|
-
}
|
|
92
|
-
logMethod(`[BOOTSTRAP LOG] ${innerLine}`);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
log.debug(`[UIAUTO STDOUT] ${line}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
let stderrLines = (stderr || '').split('\n');
|
|
100
|
-
for (let line of stderrLines) {
|
|
101
|
-
if (line.trim()) {
|
|
102
|
-
log.debug(`[UIAUTO STDERR] ${line}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
// only return when the socket client has connected
|
|
107
|
-
return await new bluebird_1.default((resolve, reject) => {
|
|
108
|
-
try {
|
|
109
|
-
this.socketClient = net_1.default.connect(this.systemPort, '127.0.0.1');
|
|
110
|
-
// Windows: the socket errors out when ADB restarts. Let's catch it to avoid crashing.
|
|
111
|
-
this.socketClient.on('error', (err) => {
|
|
112
|
-
if (!this.ignoreUnexpectedShutdown) {
|
|
113
|
-
throw new Error(`Android bootstrap socket crashed: ${err}`);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
this.socketClient.once('connect', () => {
|
|
117
|
-
log.info('Android bootstrap socket is now connected');
|
|
118
|
-
resolve();
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
reject(err);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
log.errorAndThrow(`Error occured while starting AndroidBootstrap. Original error: ${err}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async sendCommand(type, extra = {}) {
|
|
131
|
-
if (!this.socketClient) {
|
|
132
|
-
throw new Error('Socket connection closed unexpectedly');
|
|
133
|
-
}
|
|
134
|
-
return await new bluebird_1.default((resolve, reject) => {
|
|
135
|
-
let cmd = Object.assign({ cmd: type }, extra);
|
|
136
|
-
let cmdJson = `${JSON.stringify(cmd)} \n`;
|
|
137
|
-
log.debug(`Sending command to android: ${lodash_1.default.truncate(cmdJson, { length: 1000 }).trim()}`);
|
|
138
|
-
this.socketClient.write(cmdJson);
|
|
139
|
-
this.socketClient.setEncoding('utf8');
|
|
140
|
-
let streamData = '';
|
|
141
|
-
let sendCommandTimeoutHandler = null;
|
|
142
|
-
this.socketClient.on('data', (data) => {
|
|
143
|
-
if (sendCommandTimeoutHandler) {
|
|
144
|
-
clearTimeout(sendCommandTimeoutHandler);
|
|
145
|
-
}
|
|
146
|
-
log.debug('Received command result from bootstrap');
|
|
147
|
-
try {
|
|
148
|
-
streamData = JSON.parse(streamData + data);
|
|
149
|
-
// we successfully parsed JSON so we've got all the data,
|
|
150
|
-
// remove the socket listener and evaluate
|
|
151
|
-
this.socketClient.removeAllListeners('data');
|
|
152
|
-
if (streamData.status === 0) {
|
|
153
|
-
return resolve(streamData.value);
|
|
154
|
-
}
|
|
155
|
-
reject((0, driver_1.errorFromCode)(streamData.status, streamData.value));
|
|
156
|
-
}
|
|
157
|
-
catch (err) {
|
|
158
|
-
if (!lodash_1.default.isString(streamData)) {
|
|
159
|
-
log.error('Got an unexpected error inside socket listener');
|
|
160
|
-
log.error(err.stack);
|
|
161
|
-
return reject((0, driver_1.errorFromCode)(13, err.message));
|
|
162
|
-
}
|
|
163
|
-
log.debug(`Stream still not complete, waiting up to ${SEND_COMMAND_TIMEOUT}ms for the data to arrive`);
|
|
164
|
-
streamData += data;
|
|
165
|
-
sendCommandTimeoutHandler = setTimeout(() => {
|
|
166
|
-
const errMsg = `Server socket stopped responding. The recent response was '${streamData}'`;
|
|
167
|
-
log.error(errMsg);
|
|
168
|
-
this.socketClient.removeAllListeners('data');
|
|
169
|
-
reject((0, driver_1.errorFromCode)(13, errMsg));
|
|
170
|
-
}, SEND_COMMAND_TIMEOUT);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
async sendAction(action, params = {}) {
|
|
176
|
-
let extra = { action, params };
|
|
177
|
-
return await this.sendCommand(COMMAND_TYPES.ACTION, extra);
|
|
178
|
-
}
|
|
179
|
-
async shutdown() {
|
|
180
|
-
if (!this.uiAutomator) {
|
|
181
|
-
log.warn('Cannot shut down Android bootstrap; it has already shut down');
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
// remove listners so we don't trigger unexpected shutdown
|
|
185
|
-
this.uiAutomator.removeAllListeners(uiautomator_1.default.EVENT_CHANGED);
|
|
186
|
-
if (this.socketClient) {
|
|
187
|
-
await this.sendCommand(COMMAND_TYPES.SHUTDOWN);
|
|
188
|
-
}
|
|
189
|
-
await this.uiAutomator.shutdown();
|
|
190
|
-
this.uiAutomator = null;
|
|
191
|
-
}
|
|
192
|
-
// this helper function makes unit testing easier.
|
|
193
|
-
async init() {
|
|
194
|
-
this.uiAutomator = new uiautomator_1.default(this.adb);
|
|
195
|
-
// Handle unexpected UiAutomator shutdown
|
|
196
|
-
this.uiAutomator.on(uiautomator_1.default.EVENT_CHANGED, (msg) => {
|
|
197
|
-
if (msg.state === uiautomator_1.default.STATE_STOPPED) {
|
|
198
|
-
this.uiAutomator = null;
|
|
199
|
-
this.onUnexpectedShutdown.cancel(new Error('UiAUtomator shut down unexpectedly'));
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
set ignoreUnexpectedShutdown(ignore) {
|
|
204
|
-
log.debug(`${ignore ? 'Ignoring' : 'Watching for'} bootstrap disconnect`);
|
|
205
|
-
this._ignoreUnexpectedShutdown = ignore;
|
|
206
|
-
}
|
|
207
|
-
get ignoreUnexpectedShutdown() {
|
|
208
|
-
return this._ignoreUnexpectedShutdown;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
exports.AndroidBootstrap = AndroidBootstrap;
|
|
212
|
-
exports.default = AndroidBootstrap;
|
|
213
|
-
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../lib/bootstrap.js"],"names":[],"mappings":";;;;;;AAAA,gEAAwC;AACxC,8CAAsB;AACtB,gDAAwB;AACxB,oDAAuB;AACvB,0CAA8C;AAC9C,wDAAyB;AACzB,6CAA6C;AAG7C,MAAM,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;AACjD,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAoNyB,sCAAa;AAnNxC,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,aAAa,GAAG,gBAAC,CAAC,OAAO,CAAC,KAAK,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E,CAAC,GAAG,EAAE,EAAE;YACrD,IAAI,GAAG,CAAC,KAAK,KAAK,qBAAW,CAAC,aAAa,EAAE;gBAC3C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;gBACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;aACnF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,wBAAwB,CAAE,MAAM;QAClC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,uBAAuB,CAAC,CAAC;QAC1E,IAAI,CAAC,yBAAyB,GAAG,MAAM,CAAC;IAC1C,CAAC;IAED,IAAI,wBAAwB;QAC1B,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACxC,CAAC;CACF;AAEQ,4CAAgB;AACzB,kBAAe,gBAAgB,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
export default UiAutomator;
|
|
3
|
-
export class UiAutomator extends events {
|
|
4
|
-
constructor(adb: any);
|
|
5
|
-
adb: any;
|
|
6
|
-
tempPath: string;
|
|
7
|
-
start(uiAutomatorBinaryPath: any, className: any, startDetector: any, ...extraParams: any[]): Promise<any>;
|
|
8
|
-
proc: any;
|
|
9
|
-
shutdown(): Promise<void>;
|
|
10
|
-
parseJarNameFromPath(binaryPath: any): string;
|
|
11
|
-
changeState(state: any): void;
|
|
12
|
-
state: any;
|
|
13
|
-
killUiAutomatorOnDevice(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
export namespace UiAutomator {
|
|
16
|
-
let EVENT_ERROR: string;
|
|
17
|
-
let EVENT_CHANGED: string;
|
|
18
|
-
let STATE_STOPPING: string;
|
|
19
|
-
let STATE_STOPPED: string;
|
|
20
|
-
let STATE_STARTING: string;
|
|
21
|
-
let STATE_ONLINE: string;
|
|
22
|
-
}
|
|
23
|
-
import events from 'events';
|
|
24
|
-
//# sourceMappingURL=uiautomator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uiautomator.d.ts","sourceRoot":"","sources":["../../lib/uiautomator.js"],"names":[],"mappings":";;AAMA;IACE,sBAOC;IAFC,SAAc;IACd,iBAAkC;IAGpC,2GA6CC;IA7BG,UAA2C;IA+B/C,0BAQC;IAED,8CAQC;IAED,8BAIC;IAFC,WAAkB;IAIpB,yCAMC;CAEF;;;;;;;;;mBAjGkB,QAAQ"}
|
package/build/lib/uiautomator.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UiAutomator = void 0;
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
const support_1 = require("@appium/support");
|
|
9
|
-
const log = support_1.logger.getLogger('UiAutomator');
|
|
10
|
-
class UiAutomator extends events_1.default.EventEmitter {
|
|
11
|
-
constructor(adb) {
|
|
12
|
-
if (!adb) {
|
|
13
|
-
log.errorAndThrow('adb is required to instantiate UiAutomator');
|
|
14
|
-
}
|
|
15
|
-
super();
|
|
16
|
-
this.adb = adb;
|
|
17
|
-
this.tempPath = '/data/local/tmp/';
|
|
18
|
-
}
|
|
19
|
-
async start(uiAutomatorBinaryPath, className, startDetector, ...extraParams) {
|
|
20
|
-
let processIsAlive;
|
|
21
|
-
try {
|
|
22
|
-
log.debug('Starting UiAutomator');
|
|
23
|
-
this.changeState(UiAutomator.STATE_STARTING);
|
|
24
|
-
log.debug('Parsing uiautomator jar');
|
|
25
|
-
// expecting a path like /ads/ads/foo.jar or \asd\asd\foo.jar
|
|
26
|
-
let jarName = this.parseJarNameFromPath(uiAutomatorBinaryPath);
|
|
27
|
-
await this.adb.push(uiAutomatorBinaryPath, this.tempPath);
|
|
28
|
-
// killing any uiautomator existing processes
|
|
29
|
-
await this.killUiAutomatorOnDevice();
|
|
30
|
-
log.debug('Starting UIAutomator');
|
|
31
|
-
let args = ['shell', 'uiautomator', 'runtest', jarName, '-c', className, ...extraParams];
|
|
32
|
-
this.proc = this.adb.createSubProcess(args);
|
|
33
|
-
// handle out-of-bound exit by simply emitting a stopped state
|
|
34
|
-
this.proc.on('exit', (code, signal) => {
|
|
35
|
-
processIsAlive = false;
|
|
36
|
-
// cleanup
|
|
37
|
-
if (this.state !== UiAutomator.STATE_STOPPED &&
|
|
38
|
-
this.state !== UiAutomator.STATE_STOPPING) {
|
|
39
|
-
let msg = `UiAutomator exited unexpectedly with code ${code}, ` +
|
|
40
|
-
`signal ${signal}`;
|
|
41
|
-
log.error(msg);
|
|
42
|
-
}
|
|
43
|
-
else if (this.state === UiAutomator.STATE_STOPPING) {
|
|
44
|
-
log.debug('UiAutomator shut down normally');
|
|
45
|
-
}
|
|
46
|
-
this.changeState(UiAutomator.STATE_STOPPED);
|
|
47
|
-
});
|
|
48
|
-
await this.proc.start(startDetector);
|
|
49
|
-
processIsAlive = true;
|
|
50
|
-
this.changeState(UiAutomator.STATE_ONLINE);
|
|
51
|
-
return this.proc;
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
this.emit(UiAutomator.EVENT_ERROR, e);
|
|
55
|
-
if (processIsAlive) {
|
|
56
|
-
await this.killUiAutomatorOnDevice();
|
|
57
|
-
await this.proc.stop();
|
|
58
|
-
}
|
|
59
|
-
log.errorAndThrow(e);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
async shutdown() {
|
|
63
|
-
log.debug('Shutting down UiAutomator');
|
|
64
|
-
if (this.state !== UiAutomator.STATE_STOPPED) {
|
|
65
|
-
this.changeState(UiAutomator.STATE_STOPPING);
|
|
66
|
-
await this.proc.stop();
|
|
67
|
-
}
|
|
68
|
-
await this.killUiAutomatorOnDevice();
|
|
69
|
-
this.changeState(UiAutomator.STATE_STOPPED);
|
|
70
|
-
}
|
|
71
|
-
parseJarNameFromPath(binaryPath) {
|
|
72
|
-
let reTest = /.*(\/|\\)(.*\.jar)/.exec(binaryPath);
|
|
73
|
-
if (!reTest) {
|
|
74
|
-
throw new Error(`Unable to parse jar name from ${binaryPath}`);
|
|
75
|
-
}
|
|
76
|
-
let jarName = reTest[2];
|
|
77
|
-
log.debug(`Found jar name: '${jarName}'`);
|
|
78
|
-
return jarName;
|
|
79
|
-
}
|
|
80
|
-
changeState(state) {
|
|
81
|
-
log.debug(`Moving to state '${state}'`);
|
|
82
|
-
this.state = state;
|
|
83
|
-
this.emit(UiAutomator.EVENT_CHANGED, { state });
|
|
84
|
-
}
|
|
85
|
-
async killUiAutomatorOnDevice() {
|
|
86
|
-
try {
|
|
87
|
-
await this.adb.killProcessesByName('uiautomator');
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
log.warn(`Error while killing uiAutomator: ${e}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.UiAutomator = UiAutomator;
|
|
95
|
-
UiAutomator.EVENT_ERROR = 'uiautomator_error';
|
|
96
|
-
UiAutomator.EVENT_CHANGED = 'stateChanged';
|
|
97
|
-
UiAutomator.STATE_STOPPING = 'stopping';
|
|
98
|
-
UiAutomator.STATE_STOPPED = 'stopped';
|
|
99
|
-
UiAutomator.STATE_STARTING = 'starting';
|
|
100
|
-
UiAutomator.STATE_ONLINE = 'online';
|
|
101
|
-
exports.default = UiAutomator;
|
|
102
|
-
//# sourceMappingURL=uiautomator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uiautomator.js","sourceRoot":"","sources":["../../lib/uiautomator.js"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,6CAAyC;AAGzC,MAAM,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAE5C,M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