appium-uiautomator2-driver 7.3.0 → 7.5.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 +12 -0
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +1 -5
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/aut.d.ts +10 -0
- package/build/lib/commands/aut.d.ts.map +1 -0
- package/build/lib/commands/aut.js +122 -0
- package/build/lib/commands/aut.js.map +1 -0
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +2 -6
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js +2 -6
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +0 -8
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/screenshot.js +7 -8
- package/build/lib/commands/screenshot.js.map +1 -1
- package/build/lib/css-converter.js +9 -12
- package/build/lib/css-converter.js.map +1 -1
- package/build/lib/driver.d.ts +20 -16
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +25 -391
- package/build/lib/driver.js.map +1 -1
- package/build/lib/{uiautomator2.d.ts → uiautomator2-server/core.d.ts} +1 -3
- package/build/lib/uiautomator2-server/core.d.ts.map +1 -0
- package/build/lib/{uiautomator2.js → uiautomator2-server/core.js} +14 -16
- package/build/lib/uiautomator2-server/core.js.map +1 -0
- package/build/lib/uiautomator2-server/index.d.ts +4 -0
- package/build/lib/uiautomator2-server/index.d.ts.map +1 -0
- package/build/lib/uiautomator2-server/index.js +18 -0
- package/build/lib/uiautomator2-server/index.js.map +1 -0
- package/build/lib/uiautomator2-server/packages.d.ts +3 -0
- package/build/lib/uiautomator2-server/packages.d.ts.map +1 -0
- package/build/lib/uiautomator2-server/packages.js +6 -0
- package/build/lib/uiautomator2-server/packages.js.map +1 -0
- package/build/lib/uiautomator2-server/session.d.ts +25 -0
- package/build/lib/uiautomator2-server/session.d.ts.map +1 -0
- package/build/lib/uiautomator2-server/session.js +303 -0
- package/build/lib/uiautomator2-server/session.js.map +1 -0
- package/build/lib/{helpers.d.ts → utils/app.d.ts} +1 -1
- package/build/lib/utils/app.d.ts.map +1 -0
- package/build/lib/{helpers.js → utils/app.js} +1 -1
- package/build/lib/utils/app.js.map +1 -0
- package/build/lib/utils/index.d.ts +5 -0
- package/build/lib/utils/index.d.ts.map +1 -0
- package/build/lib/utils/index.js +21 -0
- package/build/lib/utils/index.js.map +1 -0
- package/build/lib/utils/lang.d.ts +15 -0
- package/build/lib/utils/lang.d.ts.map +1 -0
- package/build/lib/utils/lang.js +37 -0
- package/build/lib/utils/lang.js.map +1 -0
- package/build/lib/utils/memoize.d.ts +11 -0
- package/build/lib/utils/memoize.d.ts.map +1 -0
- package/build/lib/utils/memoize.js +26 -0
- package/build/lib/utils/memoize.js.map +1 -0
- package/build/lib/utils/object.d.ts +6 -0
- package/build/lib/utils/object.d.ts.map +1 -0
- package/build/lib/utils/object.js +15 -0
- package/build/lib/utils/object.js.map +1 -0
- package/lib/commands/app-management.ts +1 -2
- package/lib/commands/aut.ts +132 -0
- package/lib/commands/element.ts +2 -3
- package/lib/commands/gestures.ts +2 -3
- package/lib/commands/keyboard.ts +0 -5
- package/lib/commands/screenshot.ts +7 -7
- package/lib/css-converter.ts +9 -9
- package/lib/driver.ts +42 -474
- package/lib/{uiautomator2.ts → uiautomator2-server/core.ts} +2 -4
- package/lib/uiautomator2-server/index.ts +14 -0
- package/lib/uiautomator2-server/packages.ts +2 -0
- package/lib/uiautomator2-server/session.ts +354 -0
- package/lib/utils/index.ts +4 -0
- package/lib/utils/lang.ts +34 -0
- package/lib/utils/memoize.ts +26 -0
- package/lib/utils/object.ts +14 -0
- package/npm-shrinkwrap.json +84 -21
- package/package.json +1 -3
- package/build/lib/helpers.d.ts.map +0 -1
- package/build/lib/helpers.js.map +0 -1
- package/build/lib/uiautomator2.d.ts.map +0 -1
- package/build/lib/uiautomator2.js.map +0 -1
- /package/lib/{helpers.ts → utils/app.ts} +0 -0
package/build/lib/driver.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { DriverData, ExternalDriver, InitialOpts, RouteMatcher, SingularSessionData, StringRecord, SessionCapabilities } from '@appium/types';
|
|
2
|
+
import { type ADB } from 'appium-adb';
|
|
2
3
|
import { AndroidDriver } from 'appium-android-driver';
|
|
3
4
|
import { mjpeg } from 'appium/support';
|
|
4
5
|
import { type Uiautomator2Constraints } from './constraints';
|
|
5
|
-
import type { Uiautomator2Settings, Uiautomator2DeviceDetails, Uiautomator2DriverCaps, Uiautomator2DriverOpts,
|
|
6
|
-
import { UiAutomator2Server } from './uiautomator2';
|
|
6
|
+
import type { Uiautomator2Settings, Uiautomator2DeviceDetails, Uiautomator2DriverCaps, Uiautomator2DriverOpts, W3CUiautomator2DriverCaps } from './types';
|
|
7
|
+
import type { UiAutomator2Server } from './uiautomator2-server';
|
|
8
|
+
import { allocateMjpegServerPort, allocateSystemPort, initServer, performExecution, performPostExecSetup, performPreExecSetup, releaseMjpegServerPort, releaseSystemPort, requireServer, startSession } from './uiautomator2-server';
|
|
7
9
|
import { mobileGetActionHistory, mobileScheduleAction, mobileUnscheduleAction, releaseActions } from './commands/actions';
|
|
8
10
|
import { getAlertText, mobileAcceptAlert, mobileDismissAlert, postAcceptAlert, postDismissAlert } from './commands/alert';
|
|
9
11
|
import { mobileInstallMultipleApks } from './commands/app-management';
|
|
12
|
+
import { checkAppPresent, ensureAppStarts, initAUT, prepareSessionApp } from './commands/aut';
|
|
10
13
|
import { mobileGetBatteryInfo } from './commands/battery';
|
|
11
14
|
import { getClipboard, setClipboard } from './commands/clipboard';
|
|
12
15
|
import { active, getElementRect, getElementScreenshot, clear, mobileReplaceElementValue } from './commands/element';
|
|
@@ -1047,25 +1050,27 @@ declare class AndroidUiautomator2Driver extends AndroidDriver implements Externa
|
|
|
1047
1050
|
getWindowRect: AndroidDriver["getWindowRect"];
|
|
1048
1051
|
getWindowSize: AndroidDriver["getWindowSize"];
|
|
1049
1052
|
mobileViewPortRect: typeof mobileViewPortRect;
|
|
1053
|
+
prepareSessionApp: typeof prepareSessionApp;
|
|
1054
|
+
checkAppPresent: typeof checkAppPresent;
|
|
1055
|
+
initAUT: typeof initAUT;
|
|
1056
|
+
ensureAppStarts: typeof ensureAppStarts;
|
|
1057
|
+
allocateSystemPort: typeof allocateSystemPort;
|
|
1058
|
+
releaseSystemPort: typeof releaseSystemPort;
|
|
1059
|
+
allocateMjpegServerPort: typeof allocateMjpegServerPort;
|
|
1060
|
+
releaseMjpegServerPort: typeof releaseMjpegServerPort;
|
|
1061
|
+
performSessionPreExecSetup: typeof performPreExecSetup;
|
|
1062
|
+
performSessionExecution: typeof performExecution;
|
|
1063
|
+
performSessionPostExecSetup: typeof performPostExecSetup;
|
|
1064
|
+
startUiAutomator2Session: typeof startSession;
|
|
1065
|
+
initUiAutomator2Server: typeof initServer;
|
|
1066
|
+
requireUiautomator2: typeof requireServer;
|
|
1050
1067
|
constructor(opts?: InitialOpts, shouldValidateCaps?: boolean);
|
|
1051
1068
|
get driverData(): {};
|
|
1052
1069
|
validateDesiredCaps(caps: any): caps is Uiautomator2DriverCaps;
|
|
1053
1070
|
createSession(w3cCaps1: W3CUiautomator2DriverCaps, w3cCaps2?: W3CUiautomator2DriverCaps, w3cCaps3?: W3CUiautomator2DriverCaps, driverData?: DriverData[]): Promise<any>;
|
|
1054
1071
|
getDeviceDetails(): Promise<Uiautomator2DeviceDetails>;
|
|
1055
1072
|
getSession(): Promise<SingularSessionData<Uiautomator2Constraints>>;
|
|
1056
|
-
allocateSystemPort(): Promise<void>;
|
|
1057
|
-
releaseSystemPort(): Promise<void>;
|
|
1058
|
-
allocateMjpegServerPort(): Promise<void>;
|
|
1059
|
-
releaseMjpegServerPort(): Promise<void>;
|
|
1060
|
-
performSessionPreExecSetup(): Promise<StringRecord | undefined>;
|
|
1061
|
-
performSessionExecution(capsWithSessionInfo: StringRecord): Promise<void>;
|
|
1062
|
-
performSessionPostExecSetup(): Promise<void>;
|
|
1063
|
-
startUiAutomator2Session(caps: Uiautomator2StartSessionOpts): Promise<Uiautomator2SessionCaps>;
|
|
1064
|
-
initUiAutomator2Server(): Promise<UiAutomator2Server>;
|
|
1065
|
-
initAUT(): Promise<void>;
|
|
1066
|
-
ensureAppStarts(): Promise<void>;
|
|
1067
1073
|
deleteSession(): Promise<void>;
|
|
1068
|
-
checkAppPresent(): Promise<void>;
|
|
1069
1074
|
onSettingsUpdate(): Promise<void>;
|
|
1070
1075
|
proxyActive(sessionId: string): boolean;
|
|
1071
1076
|
canProxy(sessionId: string): boolean;
|
|
@@ -1073,8 +1078,7 @@ declare class AndroidUiautomator2Driver extends AndroidDriver implements Externa
|
|
|
1073
1078
|
updateSettings(settings: Uiautomator2Settings): Promise<void>;
|
|
1074
1079
|
getSettings(): Promise<StringRecord>;
|
|
1075
1080
|
getAppiumSessionCapabilities(): Promise<SessionCapabilities<Uiautomator2Constraints>>;
|
|
1076
|
-
|
|
1077
|
-
private requireUiautomator2;
|
|
1081
|
+
requireAdb(): ADB;
|
|
1078
1082
|
}
|
|
1079
1083
|
export { AndroidUiautomator2Driver };
|
|
1080
1084
|
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../lib/driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../lib/driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAmB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,UAAU,CAAC,EAAE,UAAU,EAAE,GACxB,OAAO,CAAC,GAAG,CAAC;IA0ET,gBAAgB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IA0B7C,UAAU,IAAI,OAAO,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAWnE,aAAa;IA8GtB,gBAAgB;IAKb,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAMvC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAMpC,iBAAiB,IAAI,YAAY,EAAE;IAoB7B,cAAc,CAAC,QAAQ,EAAE,oBAAoB;IAK7C,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAUpC,4BAA4B,IAAI,OAAO,CACpD,mBAAmB,CAAC,uBAAuB,CAAC,CAC7C;IAID,UAAU,IAAI,GAAG;CAOlB;AAED,OAAO,EAAC,yBAAyB,EAAC,CAAC"}
|
package/build/lib/driver.js
CHANGED
|
@@ -6,22 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AndroidUiautomator2Driver = void 0;
|
|
7
7
|
const appium_adb_1 = require("appium-adb");
|
|
8
8
|
const appium_android_driver_1 = require("appium-android-driver");
|
|
9
|
-
const io_appium_settings_1 = require("io.appium.settings");
|
|
10
9
|
const driver_1 = require("appium/driver");
|
|
11
10
|
const support_1 = require("appium/support");
|
|
12
|
-
const asyncbox_1 = require("asyncbox");
|
|
13
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
14
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
15
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
-
const portscanner_1 = require("portscanner");
|
|
17
11
|
const constraints_1 = __importDefault(require("./constraints"));
|
|
18
|
-
const extensions_1 = require("./extensions");
|
|
19
12
|
const method_map_1 = require("./method-map");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const uiautomator2_server_1 = require("./uiautomator2-server");
|
|
22
15
|
const actions_1 = require("./commands/actions");
|
|
23
16
|
const alert_1 = require("./commands/alert");
|
|
24
17
|
const app_management_1 = require("./commands/app-management");
|
|
18
|
+
const aut_1 = require("./commands/aut");
|
|
25
19
|
const battery_1 = require("./commands/battery");
|
|
26
20
|
const clipboard_1 = require("./commands/clipboard");
|
|
27
21
|
const element_1 = require("./commands/element");
|
|
@@ -34,21 +28,6 @@ const navigation_1 = require("./commands/navigation");
|
|
|
34
28
|
const screenshot_1 = require("./commands/screenshot");
|
|
35
29
|
const viewport_1 = require("./commands/viewport");
|
|
36
30
|
const execute_method_map_1 = require("./execute-method-map");
|
|
37
|
-
// The range of ports we can use on the system for communicating to the
|
|
38
|
-
// UiAutomator2 HTTP server on the device
|
|
39
|
-
const DEVICE_PORT_RANGE = [8200, 8299];
|
|
40
|
-
// The guard is needed to avoid dynamic system port allocation conflicts for
|
|
41
|
-
// parallel driver sessions
|
|
42
|
-
const DEVICE_PORT_ALLOCATION_GUARD = support_1.util.getLockFileGuard(node_path_1.default.resolve(node_os_1.default.tmpdir(), 'uia2_device_port_guard'), { timeout: 25, tryRecovery: true });
|
|
43
|
-
// This is the port that UiAutomator2 listens to on the device. We will forward
|
|
44
|
-
// one of the ports above on the system to this port on the device.
|
|
45
|
-
const DEVICE_PORT = 6790;
|
|
46
|
-
// This is the port that the UiAutomator2 MJPEG server listens to on the device.
|
|
47
|
-
// We will forward one of the ports above on the system to this port on the
|
|
48
|
-
// device.
|
|
49
|
-
const MJPEG_SERVER_DEVICE_PORT = 7810;
|
|
50
|
-
const MIN_SUPPORTED_API_LEVEL = 26;
|
|
51
|
-
const LOCALHOST_IP4 = '127.0.0.1';
|
|
52
31
|
// NO_PROXY contains the paths that we never want to proxy to UiAutomator2 server.
|
|
53
32
|
// TODO: Add the list of paths that we never want to proxy to UiAutomator2 server.
|
|
54
33
|
// TODO: Need to segregate the paths better way using regular expressions wherever applicable.
|
|
@@ -222,6 +201,20 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
222
201
|
getWindowRect = viewport_1.getWindowRect;
|
|
223
202
|
getWindowSize = viewport_1.getWindowSize;
|
|
224
203
|
mobileViewPortRect = viewport_1.mobileViewPortRect;
|
|
204
|
+
prepareSessionApp = aut_1.prepareSessionApp;
|
|
205
|
+
checkAppPresent = aut_1.checkAppPresent;
|
|
206
|
+
initAUT = aut_1.initAUT;
|
|
207
|
+
ensureAppStarts = aut_1.ensureAppStarts;
|
|
208
|
+
allocateSystemPort = uiautomator2_server_1.allocateSystemPort;
|
|
209
|
+
releaseSystemPort = uiautomator2_server_1.releaseSystemPort;
|
|
210
|
+
allocateMjpegServerPort = uiautomator2_server_1.allocateMjpegServerPort;
|
|
211
|
+
releaseMjpegServerPort = uiautomator2_server_1.releaseMjpegServerPort;
|
|
212
|
+
performSessionPreExecSetup = uiautomator2_server_1.performPreExecSetup;
|
|
213
|
+
performSessionExecution = uiautomator2_server_1.performExecution;
|
|
214
|
+
performSessionPostExecSetup = uiautomator2_server_1.performPostExecSetup;
|
|
215
|
+
startUiAutomator2Session = uiautomator2_server_1.startSession;
|
|
216
|
+
initUiAutomator2Server = uiautomator2_server_1.initServer;
|
|
217
|
+
requireUiautomator2 = uiautomator2_server_1.requireServer;
|
|
225
218
|
constructor(opts = {}, shouldValidateCaps = true) {
|
|
226
219
|
// `shell` overwrites adb.shell, so remove
|
|
227
220
|
// @ts-expect-error FIXME: what is this?
|
|
@@ -235,7 +228,7 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
235
228
|
'css selector',
|
|
236
229
|
'-android uiautomator',
|
|
237
230
|
];
|
|
238
|
-
this.desiredCapConstraints =
|
|
231
|
+
this.desiredCapConstraints = structuredClone(constraints_1.default);
|
|
239
232
|
this.jwpProxyActive = false;
|
|
240
233
|
this.jwpProxyAvoid = NO_PROXY;
|
|
241
234
|
this._originalIme = null;
|
|
@@ -245,8 +238,8 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
245
238
|
this.caps = {};
|
|
246
239
|
this.opts = opts;
|
|
247
240
|
// memoize functions here, so that they are done on a per-instance basis
|
|
248
|
-
this.getStatusBarHeight =
|
|
249
|
-
this.getDevicePixelRatio =
|
|
241
|
+
this.getStatusBarHeight = (0, utils_1.memoize)(this.getStatusBarHeight);
|
|
242
|
+
this.getDevicePixelRatio = (0, utils_1.memoize)(this.getDevicePixelRatio);
|
|
250
243
|
}
|
|
251
244
|
get driverData() {
|
|
252
245
|
// TODO fill out resource info here
|
|
@@ -277,7 +270,7 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
277
270
|
adbPort: appium_adb_1.DEFAULT_ADB_PORT,
|
|
278
271
|
androidInstallTimeout: 90000,
|
|
279
272
|
};
|
|
280
|
-
|
|
273
|
+
(0, utils_1.assignDefaults)(this.opts, defaultOpts);
|
|
281
274
|
this.opts.adbPort = this.opts.adbPort || appium_adb_1.DEFAULT_ADB_PORT;
|
|
282
275
|
// get device udid for this session
|
|
283
276
|
const { udid, emPort } = await this.getDeviceInfoFromCaps();
|
|
@@ -301,23 +294,7 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
301
294
|
this.opts.appActivity = this.caps.appActivity = activity;
|
|
302
295
|
this.log.info(`Chrome-type package and activity are ${pkg} and ${activity}`);
|
|
303
296
|
}
|
|
304
|
-
|
|
305
|
-
// find and copy, or download and unzip an app url or path
|
|
306
|
-
this.opts.app = await this.helpers.configureApp(this.opts.app, [
|
|
307
|
-
extensions_1.APK_EXTENSION,
|
|
308
|
-
extensions_1.APKS_EXTENSION,
|
|
309
|
-
]);
|
|
310
|
-
await this.checkAppPresent();
|
|
311
|
-
}
|
|
312
|
-
else if (this.opts.appPackage) {
|
|
313
|
-
// the app isn't an actual app file but rather something we want to
|
|
314
|
-
// assume is on the device and just launch via the appPackage
|
|
315
|
-
this.log.info(`Starting '${this.opts.appPackage}' directly on the device`);
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
this.log.info(`Neither 'app' nor 'appPackage' was set. Starting UiAutomator2 ` +
|
|
319
|
-
'without the target application');
|
|
320
|
-
}
|
|
297
|
+
await this.prepareSessionApp();
|
|
321
298
|
const result = await this.startUiAutomator2Session(startSessionOpts);
|
|
322
299
|
if (this.opts.mjpegScreenshotUrl) {
|
|
323
300
|
this.log.info(`Starting MJPEG stream reading URL: '${this.opts.mjpegScreenshotUrl}'`);
|
|
@@ -342,7 +319,7 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
342
319
|
pixelRatio,
|
|
343
320
|
statBarHeight,
|
|
344
321
|
viewportRect,
|
|
345
|
-
deviceApiLevel:
|
|
322
|
+
deviceApiLevel: Number.parseInt(String(apiVersion), 10),
|
|
346
323
|
platformVersion,
|
|
347
324
|
deviceManufacturer: manufacturer,
|
|
348
325
|
deviceModel: model,
|
|
@@ -356,341 +333,11 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
356
333
|
const uia2Data = (await this.requireUiautomator2().jwproxy.command('/', 'GET', {}));
|
|
357
334
|
return { ...sessionData, ...uia2Data };
|
|
358
335
|
}
|
|
359
|
-
async allocateSystemPort() {
|
|
360
|
-
const adb = this.requireAdb();
|
|
361
|
-
const forwardPort = async (localPort) => {
|
|
362
|
-
this.log.debug(`Forwarding UiAutomator2 Server port ${DEVICE_PORT} to local port ${localPort}`);
|
|
363
|
-
if ((await (0, portscanner_1.checkPortStatus)(localPort, LOCALHOST_IP4)) === 'open') {
|
|
364
|
-
throw this.log.errorWithException(`UiAutomator2 Server cannot start because the local port #${localPort} is busy. ` +
|
|
365
|
-
`Make sure the port you provide via 'systemPort' capability is not occupied. ` +
|
|
366
|
-
`This situation might often be a result of an inaccurate sessions management, e.g. ` +
|
|
367
|
-
`old automation sessions on the same device must always be closed before starting new ones.`);
|
|
368
|
-
}
|
|
369
|
-
await adb.forwardPort(localPort, DEVICE_PORT);
|
|
370
|
-
};
|
|
371
|
-
if (this.opts.systemPort) {
|
|
372
|
-
this.systemPort = this.opts.systemPort;
|
|
373
|
-
return await forwardPort(this.systemPort);
|
|
374
|
-
}
|
|
375
|
-
await DEVICE_PORT_ALLOCATION_GUARD(async () => {
|
|
376
|
-
const [startPort, endPort] = DEVICE_PORT_RANGE;
|
|
377
|
-
try {
|
|
378
|
-
this.systemPort = await (0, portscanner_1.findAPortNotInUse)(startPort, endPort);
|
|
379
|
-
}
|
|
380
|
-
catch {
|
|
381
|
-
throw this.log.errorWithException(`Cannot find any free port in range ${startPort}..${endPort}}. ` +
|
|
382
|
-
`Please set the available port number by providing the systemPort capability or ` +
|
|
383
|
-
`double check the processes that are locking ports within this range and terminate ` +
|
|
384
|
-
`these which are not needed anymore`);
|
|
385
|
-
}
|
|
386
|
-
await forwardPort(this.systemPort);
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
async releaseSystemPort() {
|
|
390
|
-
const adb = this.adb;
|
|
391
|
-
const systemPort = this.systemPort;
|
|
392
|
-
if (!systemPort || !adb) {
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
if (this.opts.systemPort) {
|
|
396
|
-
// We assume if the systemPort is provided manually then it must be unique,
|
|
397
|
-
// so there is no need for the explicit synchronization
|
|
398
|
-
await adb.removePortForward(systemPort);
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
await DEVICE_PORT_ALLOCATION_GUARD(async () => await adb.removePortForward(systemPort));
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
async allocateMjpegServerPort() {
|
|
405
|
-
if (this.opts.mjpegServerPort) {
|
|
406
|
-
const adb = this.requireAdb();
|
|
407
|
-
this.log.debug(`MJPEG broadcasting requested, forwarding MJPEG server port ${MJPEG_SERVER_DEVICE_PORT} ` +
|
|
408
|
-
`to local port ${this.opts.mjpegServerPort}`);
|
|
409
|
-
await adb.forwardPort(this.opts.mjpegServerPort, MJPEG_SERVER_DEVICE_PORT);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
async releaseMjpegServerPort() {
|
|
413
|
-
if (this.opts.mjpegServerPort && this.adb) {
|
|
414
|
-
await this.adb.removePortForward(this.opts.mjpegServerPort);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
async performSessionPreExecSetup() {
|
|
418
|
-
const apiLevel = await this.adb.getApiLevel();
|
|
419
|
-
if (apiLevel < MIN_SUPPORTED_API_LEVEL) {
|
|
420
|
-
throw this.log.errorWithException('UIAutomator2 only supports Android 8.0 (Oreo) and above');
|
|
421
|
-
}
|
|
422
|
-
const preflightPromises = [];
|
|
423
|
-
if (apiLevel >= 28) {
|
|
424
|
-
// Android P
|
|
425
|
-
preflightPromises.push((async () => {
|
|
426
|
-
this.log.info('Relaxing hidden api policy');
|
|
427
|
-
try {
|
|
428
|
-
await this.adb.setHiddenApiPolicy('1', !!this.opts.ignoreHiddenApiPolicyError);
|
|
429
|
-
}
|
|
430
|
-
catch (err) {
|
|
431
|
-
throw this.log.errorWithException('Hidden API policy (https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces) cannot be enabled. ' +
|
|
432
|
-
'This might be happening because the device under test is not configured properly. ' +
|
|
433
|
-
'Please check https://github.com/appium/appium/issues/13802 for more details. ' +
|
|
434
|
-
'You could also set the "appium:ignoreHiddenApiPolicyError" capability to true in order to ' +
|
|
435
|
-
'ignore this error, which might later lead to unexpected crashes or behavior of ' +
|
|
436
|
-
`the automation server. Original error: ${err.message}`);
|
|
437
|
-
}
|
|
438
|
-
})());
|
|
439
|
-
}
|
|
440
|
-
if (support_1.util.hasValue(this.opts.gpsEnabled)) {
|
|
441
|
-
preflightPromises.push((async () => {
|
|
442
|
-
this.log.info(`Trying to ${this.opts.gpsEnabled ? 'enable' : 'disable'} gps location provider`);
|
|
443
|
-
await this.adb.toggleGPSLocationProvider(Boolean(this.opts.gpsEnabled));
|
|
444
|
-
})());
|
|
445
|
-
}
|
|
446
|
-
if (this.opts.hideKeyboard) {
|
|
447
|
-
preflightPromises.push((async () => {
|
|
448
|
-
this._originalIme = await this.adb.defaultIME();
|
|
449
|
-
})());
|
|
450
|
-
}
|
|
451
|
-
let appInfo;
|
|
452
|
-
preflightPromises.push((async () => {
|
|
453
|
-
// get appPackage et al from manifest if necessary
|
|
454
|
-
appInfo = await this.getLaunchInfo();
|
|
455
|
-
})());
|
|
456
|
-
// start settings app, set the language/locale, start logcat etc...
|
|
457
|
-
preflightPromises.push(this.initDevice());
|
|
458
|
-
await Promise.all(preflightPromises);
|
|
459
|
-
this.opts = { ...this.opts, ...(appInfo ?? {}) };
|
|
460
|
-
return appInfo;
|
|
461
|
-
}
|
|
462
|
-
async performSessionExecution(capsWithSessionInfo) {
|
|
463
|
-
await Promise.all([
|
|
464
|
-
// Prepare the device by forwarding the UiAutomator2 port
|
|
465
|
-
// This call mutates this.systemPort if it is not set explicitly
|
|
466
|
-
this.allocateSystemPort(),
|
|
467
|
-
// Prepare the device by forwarding the UiAutomator2 MJPEG server port (if
|
|
468
|
-
// applicable)
|
|
469
|
-
this.allocateMjpegServerPort(),
|
|
470
|
-
]);
|
|
471
|
-
const [uiautomator2] = await Promise.all([
|
|
472
|
-
// set up the modified UiAutomator2 server etc
|
|
473
|
-
this.initUiAutomator2Server(),
|
|
474
|
-
(async () => {
|
|
475
|
-
// Should be after installing io.appium.settings
|
|
476
|
-
if (this.opts.disableWindowAnimation && (await this.adb.getApiLevel()) < 26) {
|
|
477
|
-
// API level 26 is Android 8.0.
|
|
478
|
-
// Granting android.permission.SET_ANIMATION_SCALE is necessary to handle animations under API level 26
|
|
479
|
-
// Read https://github.com/appium/appium/pull/11640#issuecomment-438260477
|
|
480
|
-
// `--no-window-animation` works over Android 8 to disable all of animations
|
|
481
|
-
if (await this.adb.isAnimationOn()) {
|
|
482
|
-
this.log.info('Disabling animation via io.appium.settings');
|
|
483
|
-
await this.settingsApp.setAnimationState(false);
|
|
484
|
-
this._wasWindowAnimationDisabled = true;
|
|
485
|
-
}
|
|
486
|
-
else {
|
|
487
|
-
this.log.info('Window animation is already disabled');
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
})(),
|
|
491
|
-
// set up app under test
|
|
492
|
-
// prepare our actual AUT, get it on the device, etc...
|
|
493
|
-
this.initAUT(),
|
|
494
|
-
]);
|
|
495
|
-
// launch UiAutomator2 and wait till its online and we have a session
|
|
496
|
-
await uiautomator2.startSession(capsWithSessionInfo);
|
|
497
|
-
// now that everything has started successfully, turn on proxying so all
|
|
498
|
-
// subsequent session requests go straight to/from uiautomator2
|
|
499
|
-
this.jwpProxyActive = true;
|
|
500
|
-
}
|
|
501
|
-
async performSessionPostExecSetup() {
|
|
502
|
-
// Unlock the device after the session is started.
|
|
503
|
-
if (!this.opts.skipUnlock) {
|
|
504
|
-
// unlock the device to prepare it for testing
|
|
505
|
-
await this.unlock();
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
this.log.debug(`'skipUnlock' capability set, so skipping device unlock`);
|
|
509
|
-
}
|
|
510
|
-
if (this.isChromeSession) {
|
|
511
|
-
// start a chromedriver session
|
|
512
|
-
await this.startChromeSession();
|
|
513
|
-
}
|
|
514
|
-
else if (this.opts.autoLaunch && this.opts.appPackage) {
|
|
515
|
-
await this.ensureAppStarts();
|
|
516
|
-
}
|
|
517
|
-
// if the initial orientation is requested, set it
|
|
518
|
-
if (support_1.util.hasValue(this.opts.orientation)) {
|
|
519
|
-
this.log.debug(`Setting initial orientation to '${this.opts.orientation}'`);
|
|
520
|
-
await this.setOrientation(this.opts.orientation);
|
|
521
|
-
}
|
|
522
|
-
// if we want to immediately get into a webview, set our context
|
|
523
|
-
// appropriately
|
|
524
|
-
if (this.opts.autoWebview) {
|
|
525
|
-
const viewName = this.defaultWebviewName();
|
|
526
|
-
const timeout = this.opts.autoWebviewTimeout || 2000;
|
|
527
|
-
this.log.info(`Setting auto webview to context '${viewName}' with timeout ${timeout}ms`);
|
|
528
|
-
await (0, asyncbox_1.retryInterval)(timeout / 500, 500, this.setContext.bind(this), viewName);
|
|
529
|
-
}
|
|
530
|
-
// We would like to notify about the initial context setting
|
|
531
|
-
if ((await this.getCurrentContext()) === this.defaultContextName()) {
|
|
532
|
-
await this.notifyBiDiContextChange();
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
async startUiAutomator2Session(caps) {
|
|
536
|
-
const appInfo = await this.performSessionPreExecSetup();
|
|
537
|
-
// set actual device name, udid, platform version, screen size, screen density, model and manufacturer details
|
|
538
|
-
const deviceName = this.adb?.curDeviceId;
|
|
539
|
-
const deviceUDID = this.opts.udid;
|
|
540
|
-
if (!deviceName) {
|
|
541
|
-
throw this.log.errorWithException('Could not determine device name (ADB curDeviceId is empty)');
|
|
542
|
-
}
|
|
543
|
-
if (!deviceUDID) {
|
|
544
|
-
throw this.log.errorWithException('Device UDID is not set in session options');
|
|
545
|
-
}
|
|
546
|
-
const sessionInfo = {
|
|
547
|
-
deviceName,
|
|
548
|
-
deviceUDID,
|
|
549
|
-
};
|
|
550
|
-
const capsWithSessionInfo = {
|
|
551
|
-
...caps,
|
|
552
|
-
...sessionInfo,
|
|
553
|
-
};
|
|
554
|
-
// Adding AUT info in the capabilities if it does not exist in caps
|
|
555
|
-
if (appInfo) {
|
|
556
|
-
for (const capName of ['appPackage', 'appActivity']) {
|
|
557
|
-
if (!capsWithSessionInfo[capName] && appInfo[capName]) {
|
|
558
|
-
capsWithSessionInfo[capName] = appInfo[capName];
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
await this.performSessionExecution(capsWithSessionInfo);
|
|
563
|
-
const deviceInfoPromise = (async () => {
|
|
564
|
-
try {
|
|
565
|
-
return await this.getDeviceDetails();
|
|
566
|
-
}
|
|
567
|
-
catch (e) {
|
|
568
|
-
this.log.warn(`Cannot fetch device details. Original error: ${e.message}`);
|
|
569
|
-
return {};
|
|
570
|
-
}
|
|
571
|
-
})();
|
|
572
|
-
await this.performSessionPostExecSetup();
|
|
573
|
-
return { ...capsWithSessionInfo, ...(await deviceInfoPromise) };
|
|
574
|
-
}
|
|
575
|
-
async initUiAutomator2Server() {
|
|
576
|
-
const uiautomator2Opts = {
|
|
577
|
-
host: this.opts.remoteAdbHost || LOCALHOST_IP4,
|
|
578
|
-
systemPort: this.systemPort,
|
|
579
|
-
adb: this.adb,
|
|
580
|
-
disableWindowAnimation: !!this.opts.disableWindowAnimation,
|
|
581
|
-
disableSuppressAccessibilityService: this.opts.disableSuppressAccessibilityService,
|
|
582
|
-
readTimeout: this.opts.uiautomator2ServerReadTimeout,
|
|
583
|
-
basePath: this.basePath,
|
|
584
|
-
};
|
|
585
|
-
// now that we have package and activity, we can create an instance of
|
|
586
|
-
// uiautomator2 with the appropriate options
|
|
587
|
-
this.uiautomator2 = new uiautomator2_1.UiAutomator2Server(this.log, uiautomator2Opts);
|
|
588
|
-
this.proxyReqRes = this.uiautomator2.proxyReqRes.bind(this.uiautomator2);
|
|
589
|
-
this.proxyCommand = this.uiautomator2.proxyCommand.bind(this.uiautomator2);
|
|
590
|
-
if (this.opts.skipServerInstallation) {
|
|
591
|
-
this.log.info(`'skipServerInstallation' is set. Skipping UIAutomator2 server installation.`);
|
|
592
|
-
}
|
|
593
|
-
else {
|
|
594
|
-
await this.uiautomator2.installServerApk(this.opts.uiautomator2ServerInstallTimeout);
|
|
595
|
-
try {
|
|
596
|
-
await this.requireAdb().addToDeviceIdleWhitelist(io_appium_settings_1.SETTINGS_HELPER_ID, uiautomator2_1.SERVER_PACKAGE_ID, uiautomator2_1.SERVER_TEST_PACKAGE_ID);
|
|
597
|
-
}
|
|
598
|
-
catch (e) {
|
|
599
|
-
const err = e;
|
|
600
|
-
this.log.warn(`Cannot add server packages to the Doze whitelist. Original error: ` +
|
|
601
|
-
(err.stderr || err.message));
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
return this.uiautomator2;
|
|
605
|
-
}
|
|
606
|
-
async initAUT() {
|
|
607
|
-
// Uninstall any uninstallOtherPackages which were specified in caps
|
|
608
|
-
if (this.opts.uninstallOtherPackages) {
|
|
609
|
-
await this.uninstallOtherPackages(appium_android_driver_1.utils.parseArray(this.opts.uninstallOtherPackages), [
|
|
610
|
-
io_appium_settings_1.SETTINGS_HELPER_ID,
|
|
611
|
-
uiautomator2_1.SERVER_PACKAGE_ID,
|
|
612
|
-
uiautomator2_1.SERVER_TEST_PACKAGE_ID,
|
|
613
|
-
]);
|
|
614
|
-
}
|
|
615
|
-
// Install any "otherApps" that were specified in caps
|
|
616
|
-
if (this.opts.otherApps) {
|
|
617
|
-
let otherApps;
|
|
618
|
-
try {
|
|
619
|
-
otherApps = appium_android_driver_1.utils.parseArray(this.opts.otherApps);
|
|
620
|
-
}
|
|
621
|
-
catch (e) {
|
|
622
|
-
throw this.log.errorWithException(`Could not parse "otherApps" capability: ${e.message}`);
|
|
623
|
-
}
|
|
624
|
-
otherApps = await Promise.all(otherApps.map((app) => this.helpers.configureApp(app, [extensions_1.APK_EXTENSION, extensions_1.APKS_EXTENSION])));
|
|
625
|
-
await this.installOtherApks(otherApps);
|
|
626
|
-
}
|
|
627
|
-
if (this.opts.app && this.opts.appPackage) {
|
|
628
|
-
const adb = this.requireAdb();
|
|
629
|
-
const appPackage = this.opts.appPackage;
|
|
630
|
-
if ((this.opts.noReset && !(await adb.isAppInstalled(appPackage))) || !this.opts.noReset) {
|
|
631
|
-
if (!this.opts.noSign &&
|
|
632
|
-
!(await adb.checkApkCert(this.opts.app, appPackage, {
|
|
633
|
-
requireDefaultCert: false,
|
|
634
|
-
}))) {
|
|
635
|
-
await (0, helpers_1.signApp)(adb, this.opts.app);
|
|
636
|
-
}
|
|
637
|
-
if (!this.opts.skipUninstall) {
|
|
638
|
-
await adb.uninstallApk(appPackage);
|
|
639
|
-
}
|
|
640
|
-
await this.installAUT();
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
this.log.debug('noReset has been requested and the app is already installed. Doing nothing');
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
else {
|
|
647
|
-
if (this.opts.fullReset) {
|
|
648
|
-
throw this.log.errorWithException('Full reset requires an app capability, use fastReset if app is not provided');
|
|
649
|
-
}
|
|
650
|
-
this.log.debug('No app capability. Assuming it is already on the device');
|
|
651
|
-
if (this.opts.fastReset && this.opts.appPackage) {
|
|
652
|
-
await this.resetAUT();
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
async ensureAppStarts() {
|
|
657
|
-
const adb = this.requireAdb();
|
|
658
|
-
const appPackage = this.opts.appPackage;
|
|
659
|
-
const appActivity = this.opts.appActivity;
|
|
660
|
-
if (!appPackage) {
|
|
661
|
-
throw this.log.errorWithException('appPackage capability is required to start the application');
|
|
662
|
-
}
|
|
663
|
-
// make sure we have an activity and package to wait for
|
|
664
|
-
const appWaitPackage = this.opts.appWaitPackage || appPackage;
|
|
665
|
-
const appWaitActivity = this.opts.appWaitActivity || appActivity;
|
|
666
|
-
this.log.info(`Starting '${appPackage}${appActivity ? '/' + appActivity : ''}` +
|
|
667
|
-
`and waiting for '${appWaitPackage}${appWaitActivity ? '/' + appWaitActivity : ''}'`);
|
|
668
|
-
if (this.opts.noReset && !this.opts.forceAppLaunch && (await adb.processExists(appPackage))) {
|
|
669
|
-
this.log.info(`'${appPackage}' is already running and noReset is enabled. ` +
|
|
670
|
-
`Set forceAppLaunch capability to true if the app must be forcefully restarted on session startup.`);
|
|
671
|
-
return;
|
|
672
|
-
}
|
|
673
|
-
await adb.startApp({
|
|
674
|
-
pkg: appPackage,
|
|
675
|
-
activity: appActivity,
|
|
676
|
-
action: this.opts.intentAction || 'android.intent.action.MAIN',
|
|
677
|
-
category: this.opts.intentCategory || 'android.intent.category.LAUNCHER',
|
|
678
|
-
flags: this.opts.intentFlags || '0x10200000', // FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
679
|
-
waitPkg: this.opts.appWaitPackage,
|
|
680
|
-
waitActivity: this.opts.appWaitActivity,
|
|
681
|
-
waitForLaunch: this.opts.appWaitForLaunch,
|
|
682
|
-
waitDuration: this.opts.appWaitDuration,
|
|
683
|
-
optionalIntentArguments: this.opts.optionalIntentArguments,
|
|
684
|
-
stopApp: this.opts.forceAppLaunch || !this.opts.dontStopAppOnReset,
|
|
685
|
-
retry: true,
|
|
686
|
-
user: this.opts.userProfile,
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
336
|
async deleteSession() {
|
|
690
337
|
this.log.debug('Deleting UiAutomator2 session');
|
|
691
338
|
const screenRecordingStopTasks = [
|
|
692
339
|
async () => {
|
|
693
|
-
if (
|
|
340
|
+
if (this._screenRecordingProperties) {
|
|
694
341
|
await this.stopRecordingScreen();
|
|
695
342
|
}
|
|
696
343
|
},
|
|
@@ -700,7 +347,7 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
700
347
|
}
|
|
701
348
|
},
|
|
702
349
|
async () => {
|
|
703
|
-
if (
|
|
350
|
+
if (this._screenStreamingProps) {
|
|
704
351
|
await this.mobileStopScreenStreaming();
|
|
705
352
|
}
|
|
706
353
|
},
|
|
@@ -789,12 +436,6 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
789
436
|
}
|
|
790
437
|
await super.deleteSession();
|
|
791
438
|
}
|
|
792
|
-
async checkAppPresent() {
|
|
793
|
-
this.log.debug('Checking whether app is actually present');
|
|
794
|
-
if (!this.opts.app || !(await support_1.fs.exists(this.opts.app))) {
|
|
795
|
-
throw this.log.errorWithException(`Could not find app apk at '${this.opts.app}'`);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
439
|
async onSettingsUpdate() {
|
|
799
440
|
// intentionally do nothing here, since commands.updateSettings proxies
|
|
800
441
|
// settings to the uiauto2 server already
|
|
@@ -848,13 +489,6 @@ class AndroidUiautomator2Driver extends appium_android_driver_1.AndroidDriver {
|
|
|
848
489
|
}
|
|
849
490
|
return adb;
|
|
850
491
|
}
|
|
851
|
-
requireUiautomator2() {
|
|
852
|
-
const server = this.uiautomator2;
|
|
853
|
-
if (!server) {
|
|
854
|
-
throw this.log.errorWithException('UiAutomator2 server is not initialized');
|
|
855
|
-
}
|
|
856
|
-
return server;
|
|
857
|
-
}
|
|
858
492
|
}
|
|
859
493
|
exports.AndroidUiautomator2Driver = AndroidUiautomator2Driver;
|
|
860
494
|
//# sourceMappingURL=driver.js.map
|