appium-android-driver 4.53.0 → 5.0.2
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/README.md +0 -2
- package/build/index.js +6 -4
- package/build/lib/android-helpers.js +12 -9
- package/build/lib/bootstrap.js +7 -7
- package/build/lib/commands/actions.js +13 -13
- package/build/lib/commands/alert.js +7 -7
- package/build/lib/commands/app-management.js +6 -6
- package/build/lib/commands/context.js +10 -8
- package/build/lib/commands/element.js +5 -5
- package/build/lib/commands/execute.js +7 -6
- package/build/lib/commands/file-actions.js +12 -12
- package/build/lib/commands/find.js +6 -6
- package/build/lib/commands/general.js +7 -69
- package/build/lib/commands/ime.js +4 -4
- package/build/lib/commands/index.js +4 -2
- package/build/lib/commands/intent.js +7 -7
- package/build/lib/commands/log.js +6 -6
- package/build/lib/commands/network.js +11 -4
- package/build/lib/commands/performance.js +1 -1
- package/build/lib/commands/recordscreen.js +15 -15
- package/build/lib/commands/shell.js +3 -3
- package/build/lib/commands/streamscreen.js +7 -7
- package/build/lib/commands/system-bars.js +144 -0
- package/build/lib/commands/touch.js +8 -8
- package/build/lib/desired-caps.js +1 -1
- package/build/lib/driver.js +12 -12
- package/build/lib/logger.js +3 -3
- package/build/lib/server.js +4 -4
- package/build/lib/uiautomator.js +3 -3
- package/build/lib/unlock-helpers.js +8 -8
- package/build/lib/webview-helpers.js +7 -7
- package/lib/android-helpers.js +1 -1
- package/lib/bootstrap.js +2 -2
- package/lib/commands/actions.js +1 -1
- package/lib/commands/alert.js +1 -1
- package/lib/commands/app-management.js +4 -2
- package/lib/commands/context.js +2 -2
- package/lib/commands/element.js +1 -1
- package/lib/commands/execute.js +3 -1
- package/lib/commands/file-actions.js +1 -1
- package/lib/commands/find.js +2 -2
- package/lib/commands/general.js +1 -83
- package/lib/commands/ime.js +1 -1
- package/lib/commands/index.js +2 -0
- package/lib/commands/intent.js +1 -1
- package/lib/commands/log.js +1 -1
- package/lib/commands/network.js +22 -1
- package/lib/commands/recordscreen.js +1 -1
- package/lib/commands/shell.js +1 -1
- package/lib/commands/streamscreen.js +1 -1
- package/lib/commands/system-bars.js +131 -0
- package/lib/commands/touch.js +2 -2
- package/lib/driver.js +2 -2
- package/lib/logger.js +1 -1
- package/lib/server.js +1 -1
- package/lib/uiautomator.js +1 -1
- package/lib/unlock-helpers.js +1 -1
- package/lib/webview-helpers.js +1 -1
- package/package.json +17 -15
- package/lib/.DS_Store +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import log from '../logger';
|
|
3
|
+
|
|
4
|
+
const WINDOW_TITLE_PATTERN = /^\s+Window\s#\d+\sWindow\{[0-9a-f]+\s\w+\s([\w-]+)\}:$/;
|
|
5
|
+
const FRAME_PATTERN = /^\s+mFrame=\[([0-9.-]+),([0-9.-]+)\]\[([0-9.-]+),([0-9.-]+)\]/m;
|
|
6
|
+
const SURFACE_PATTERN = /^\s+Surface:\sshown=(true|false)/m;
|
|
7
|
+
const STATUS_BAR_WINDOW_NAME_PREFIX = 'StatusBar';
|
|
8
|
+
const NAVIGATION_BAR_WINDOW_NAME_PREFIX = 'NavigationBar';
|
|
9
|
+
const DEFAULT_WINDOW_PROPERTIES = {
|
|
10
|
+
visible: false,
|
|
11
|
+
x: 0, y: 0, width: 0, height: 0,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const commands = {};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} WindowProperties
|
|
18
|
+
* @property {boolean} visible Whether the window is visible
|
|
19
|
+
* @property {number} x Window x coordinate
|
|
20
|
+
* @property {number} y Window y coordinate
|
|
21
|
+
* @property {number} width Window width
|
|
22
|
+
* @property {number} height Window height
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Parses window properties from adb dumpsys output
|
|
27
|
+
*
|
|
28
|
+
* @param {string} name The name of the window whose properties are being parsed
|
|
29
|
+
* @param {Array<string>} props The list of particular window property lines.
|
|
30
|
+
* Check the corresponding unit tests for more details on the input format.
|
|
31
|
+
* @returns {WindowProperties} Parsed properties object
|
|
32
|
+
* @throws {Error} If there was an issue while parsing the properties string
|
|
33
|
+
*/
|
|
34
|
+
function parseWindowProperties (name, props) {
|
|
35
|
+
const result = _.cloneDeep(DEFAULT_WINDOW_PROPERTIES);
|
|
36
|
+
const propLines = props.join('\n');
|
|
37
|
+
const frameMatch = FRAME_PATTERN.exec(propLines);
|
|
38
|
+
if (!frameMatch) {
|
|
39
|
+
log.debug(propLines);
|
|
40
|
+
throw new Error(`Cannot parse the frame size from '${name}' window properties`);
|
|
41
|
+
}
|
|
42
|
+
result.x = parseFloat(frameMatch[1]);
|
|
43
|
+
result.y = parseFloat(frameMatch[2]);
|
|
44
|
+
const left = parseFloat(frameMatch[3]);
|
|
45
|
+
const top = parseFloat(frameMatch[4]);
|
|
46
|
+
result.width = left - result.x;
|
|
47
|
+
result.height = top - result.y;
|
|
48
|
+
const visibilityMatch = SURFACE_PATTERN.exec(propLines);
|
|
49
|
+
if (!visibilityMatch) {
|
|
50
|
+
log.debug(propLines);
|
|
51
|
+
throw new Error(`Cannot parse the visibility value from '${name}' window properties`);
|
|
52
|
+
}
|
|
53
|
+
result.visible = visibilityMatch[1] === 'true';
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Extracts status and navigation bar information from the window manager output.
|
|
59
|
+
*
|
|
60
|
+
* @param {Array<string>} lines Output from dumpsys command.
|
|
61
|
+
* Check the corresponding unit tests for more details on the input format.
|
|
62
|
+
* @return {Object} An object containing two items where keys are statusBar and navigationBar,
|
|
63
|
+
* and values are corresponding WindowProperties objects
|
|
64
|
+
* @throws {Error} If no window properties could be parsed
|
|
65
|
+
*/
|
|
66
|
+
function parseWindows (lines) {
|
|
67
|
+
const windows = {};
|
|
68
|
+
let currentWindowName = null;
|
|
69
|
+
let windowNameRowIndent = null;
|
|
70
|
+
for (const line of lines.split('\n').map(_.trimEnd)) {
|
|
71
|
+
const currentIndent = line.length - _.trimStart(line).length;
|
|
72
|
+
if (_.isNil(windowNameRowIndent) || currentIndent <= windowNameRowIndent) {
|
|
73
|
+
const match = WINDOW_TITLE_PATTERN.exec(line);
|
|
74
|
+
if (!match) {
|
|
75
|
+
currentWindowName = null;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
currentWindowName = match[1];
|
|
79
|
+
if (_.isNil(windowNameRowIndent)) {
|
|
80
|
+
windowNameRowIndent = currentIndent;
|
|
81
|
+
}
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (!currentWindowName || currentIndent <= windowNameRowIndent) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!_.isArray(windows[currentWindowName])) {
|
|
89
|
+
windows[currentWindowName] = [];
|
|
90
|
+
}
|
|
91
|
+
windows[currentWindowName].push(line);
|
|
92
|
+
}
|
|
93
|
+
if (_.isEmpty(windows)) {
|
|
94
|
+
log.debug(lines.join('\n'));
|
|
95
|
+
throw new Error('Cannot parse any window information from the dumpsys output');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const result = {statusBar: null, navigationBar: null};
|
|
99
|
+
for (const [name, props] of _.toPairs(windows)) {
|
|
100
|
+
if (name.startsWith(STATUS_BAR_WINDOW_NAME_PREFIX)) {
|
|
101
|
+
result.statusBar = parseWindowProperties(name, props);
|
|
102
|
+
} else if (name.startsWith(NAVIGATION_BAR_WINDOW_NAME_PREFIX)) {
|
|
103
|
+
result.navigationBar = parseWindowProperties(name, props);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const unmatchedWindows = [
|
|
107
|
+
['statusBar', STATUS_BAR_WINDOW_NAME_PREFIX],
|
|
108
|
+
['navigationBar', NAVIGATION_BAR_WINDOW_NAME_PREFIX]
|
|
109
|
+
].filter(([name]) => _.isNil(result[name]));
|
|
110
|
+
for (const [window, namePrefix] of unmatchedWindows) {
|
|
111
|
+
log.info(`No windows have been found whose title matches to ` +
|
|
112
|
+
`'${namePrefix}'. Assuming it is invisible. ` +
|
|
113
|
+
`Only the following windows are available: ${_.keys(windows)}`);
|
|
114
|
+
result[window] = _.cloneDeep(DEFAULT_WINDOW_PROPERTIES);
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
commands.getSystemBars = async function getSystemBars () {
|
|
120
|
+
let stdout;
|
|
121
|
+
try {
|
|
122
|
+
stdout = await this.adb.shell(['dumpsys', 'window', 'windows']);
|
|
123
|
+
} catch (e) {
|
|
124
|
+
throw new Error(`Cannot retrieve system bars details. Original error: ${e.message}`);
|
|
125
|
+
}
|
|
126
|
+
return parseWindows(stdout);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// for unit tests
|
|
130
|
+
export { parseWindows, parseWindowProperties };
|
|
131
|
+
export default commands;
|
package/lib/commands/touch.js
CHANGED
|
@@ -2,9 +2,9 @@ import log from '../logger';
|
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import androidHelpers from '../android-helpers';
|
|
4
4
|
import B from 'bluebird';
|
|
5
|
-
import { errors, isErrorType } from 'appium
|
|
5
|
+
import { errors, isErrorType } from '@appium/base-driver';
|
|
6
6
|
import { asyncmap } from 'asyncbox';
|
|
7
|
-
import { util } from 'appium
|
|
7
|
+
import { util } from '@appium/support';
|
|
8
8
|
|
|
9
9
|
let commands = {}, helpers = {}, extensions = {};
|
|
10
10
|
|
package/lib/driver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseDriver, DeviceSettings } from 'appium
|
|
1
|
+
import { BaseDriver, DeviceSettings } from '@appium/base-driver';
|
|
2
2
|
import desiredConstraints from './desired-caps';
|
|
3
3
|
import commands from './commands/index';
|
|
4
4
|
import {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import log from './logger';
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
import { DEFAULT_ADB_PORT } from 'appium-adb';
|
|
11
|
-
import { fs, tempDir, util } from 'appium
|
|
11
|
+
import { fs, tempDir, util } from '@appium/support';
|
|
12
12
|
import { retryInterval } from 'asyncbox';
|
|
13
13
|
import { SharedPrefsBuilder } from 'shared-preferences-builder';
|
|
14
14
|
import B from 'bluebird';
|
package/lib/logger.js
CHANGED
package/lib/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import log from './logger';
|
|
2
|
-
import { server as baseServer, routeConfiguringFunction as makeRouter } from 'appium
|
|
2
|
+
import { server as baseServer, routeConfiguringFunction as makeRouter } from '@appium/base-driver';
|
|
3
3
|
import AndroidDriver from './driver';
|
|
4
4
|
|
|
5
5
|
async function startServer (port, host) {
|
package/lib/uiautomator.js
CHANGED
package/lib/unlock-helpers.js
CHANGED
package/lib/webview-helpers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import logger from './logger';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
-
import { util } from 'appium
|
|
4
|
+
import { util } from '@appium/support';
|
|
5
5
|
import { findAPortNotInUse } from 'portscanner';
|
|
6
6
|
import LRU from 'lru-cache';
|
|
7
7
|
import B from 'bluebird';
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"mobile",
|
|
10
10
|
"mobile testing"
|
|
11
11
|
],
|
|
12
|
-
"version": "
|
|
12
|
+
"version": "5.0.2",
|
|
13
13
|
"author": "appium",
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
15
|
"repository": {
|
|
@@ -35,25 +35,25 @@
|
|
|
35
35
|
"bootstrap/bin/AppiumBootstrap.jar"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@appium/base-driver": "^8.0.0",
|
|
39
|
+
"@appium/support": "^2.55.3",
|
|
38
40
|
"@babel/runtime": "^7.0.0",
|
|
39
|
-
"appium-adb": "^
|
|
40
|
-
"appium-
|
|
41
|
-
"appium-chromedriver": "^4.13.0",
|
|
42
|
-
"appium-support": "^2.47.1",
|
|
41
|
+
"appium-adb": "^9.0.0",
|
|
42
|
+
"appium-chromedriver": "^5.0.1",
|
|
43
43
|
"asyncbox": "^2.8.0",
|
|
44
44
|
"axios": "^0.x",
|
|
45
45
|
"bluebird": "^3.4.7",
|
|
46
|
-
"io.appium.settings": "^
|
|
47
|
-
"jimp": "^0.
|
|
46
|
+
"io.appium.settings": "^4.0.0",
|
|
47
|
+
"jimp": "^0.x",
|
|
48
48
|
"lodash": "^4.17.4",
|
|
49
|
-
"lru-cache": "^
|
|
49
|
+
"lru-cache": "^7.3.0",
|
|
50
50
|
"moment": "^2.24.0",
|
|
51
51
|
"moment-timezone": "^0.5.26",
|
|
52
52
|
"portfinder": "^1.0.6",
|
|
53
53
|
"portscanner": "2.2.0",
|
|
54
|
-
"shared-preferences-builder": "^0.
|
|
54
|
+
"shared-preferences-builder": "^0.x",
|
|
55
55
|
"semver": "^7.0.0",
|
|
56
|
-
"source-map-support": "^0.
|
|
56
|
+
"source-map-support": "^0.x",
|
|
57
57
|
"teen_process": "^1.9.0",
|
|
58
58
|
"ws": "^8.0.0"
|
|
59
59
|
},
|
|
@@ -77,18 +77,20 @@
|
|
|
77
77
|
"precommit-test"
|
|
78
78
|
],
|
|
79
79
|
"devDependencies": {
|
|
80
|
+
"@appium/gulp-plugins": "^6.0.0",
|
|
81
|
+
"@appium/eslint-config-appium": "^5.0.0",
|
|
82
|
+
"@appium/test-support": "^1.0.0",
|
|
83
|
+
"@babel/core": "^7.16.0",
|
|
84
|
+
"@babel/eslint-parser": "^7.16.3",
|
|
80
85
|
"@xmldom/xmldom": "^0.x",
|
|
81
|
-
"android-apidemos": "^
|
|
82
|
-
"appium-gulp-plugins": "^5.4.0",
|
|
83
|
-
"appium-test-support": "^1.0.0",
|
|
86
|
+
"android-apidemos": "^4.0.0",
|
|
84
87
|
"chai": "^4.1.2",
|
|
85
88
|
"chai-as-promised": "^7.1.1",
|
|
86
|
-
"eslint-config-appium": "^4.0.1",
|
|
87
89
|
"gulp": "^4.0.0",
|
|
88
90
|
"mocha": "^9.0.0",
|
|
89
91
|
"mock-fs": "^5.0.0",
|
|
90
92
|
"pre-commit": "^1.1.3",
|
|
91
|
-
"sinon": "^
|
|
93
|
+
"sinon": "^13.0.0",
|
|
92
94
|
"xpath": "^0.x"
|
|
93
95
|
}
|
|
94
96
|
}
|
package/lib/.DS_Store
DELETED
|
Binary file
|