appium-uiautomator2-driver 2.32.0 → 2.32.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/lib/commands/actions.js +10 -10
  3. package/build/lib/commands/actions.js.map +1 -1
  4. package/build/lib/commands/alert.js +3 -3
  5. package/build/lib/commands/alert.js.map +1 -1
  6. package/build/lib/commands/app-strings.d.ts.map +1 -1
  7. package/build/lib/commands/app-strings.js +3 -4
  8. package/build/lib/commands/app-strings.js.map +1 -1
  9. package/build/lib/commands/element.js +19 -19
  10. package/build/lib/commands/element.js.map +1 -1
  11. package/build/lib/commands/general.d.ts.map +1 -1
  12. package/build/lib/commands/general.js +17 -19
  13. package/build/lib/commands/general.js.map +1 -1
  14. package/build/lib/commands/gestures.js +11 -11
  15. package/build/lib/commands/gestures.js.map +1 -1
  16. package/build/lib/commands/touch.js +3 -3
  17. package/build/lib/commands/touch.js.map +1 -1
  18. package/build/lib/constraints.d.ts +0 -3
  19. package/build/lib/constraints.d.ts.map +1 -1
  20. package/build/lib/constraints.js +0 -3
  21. package/build/lib/constraints.js.map +1 -1
  22. package/build/lib/driver.d.ts +2 -4
  23. package/build/lib/driver.d.ts.map +1 -1
  24. package/build/lib/driver.js +36 -84
  25. package/build/lib/driver.js.map +1 -1
  26. package/build/lib/types.d.ts +7 -9
  27. package/build/lib/types.d.ts.map +1 -1
  28. package/build/lib/uiautomator2.d.ts +1 -1
  29. package/build/tsconfig.tsbuildinfo +1 -1
  30. package/lib/commands/actions.js +10 -10
  31. package/lib/commands/alert.js +3 -3
  32. package/lib/commands/app-strings.js +3 -4
  33. package/lib/commands/element.js +19 -19
  34. package/lib/commands/general.js +17 -18
  35. package/lib/commands/gestures.js +11 -11
  36. package/lib/commands/touch.js +3 -3
  37. package/lib/constraints.ts +0 -3
  38. package/lib/driver.ts +44 -99
  39. package/lib/types.ts +7 -11
  40. package/npm-shrinkwrap.json +24 -24
  41. package/package.json +3 -3
package/lib/driver.ts CHANGED
@@ -25,10 +25,10 @@ import {executeMethodMap} from './execute-method-map';
25
25
  import {APKS_EXTENSION, APK_EXTENSION} from './extensions';
26
26
  import uiautomator2Helpers from './helpers';
27
27
  import {newMethodMap} from './method-map';
28
+ import type { EmptyObject } from 'type-fest';
28
29
  import type {
29
30
  Uiautomator2Settings,
30
31
  Uiautomator2DeviceDetails,
31
- Uiautomator2DeviceInfo,
32
32
  Uiautomator2DriverCaps,
33
33
  Uiautomator2DriverOpts,
34
34
  Uiautomator2SessionCaps,
@@ -174,7 +174,7 @@ class AndroidUiautomator2Driver
174
174
 
175
175
  static executeMethodMap = executeMethodMap;
176
176
 
177
- uiautomator2?: UiAutomator2Server;
177
+ uiautomator2: UiAutomator2Server;
178
178
 
179
179
  /**
180
180
  * @privateRemarks moved from `this.opts`
@@ -278,11 +278,6 @@ class AndroidUiautomator2Driver
278
278
  this.log.info(`Chrome-type package and activity are ${pkg} and ${activity}`);
279
279
  }
280
280
 
281
- // @ts-expect-error FIXME: missing CLI option?
282
- if (this.opts.reboot) {
283
- this.setAvdFromCapabilities(startSessionOpts);
284
- }
285
-
286
281
  if (this.opts.app) {
287
282
  // find and copy, or download and unzip an app url or path
288
283
  this.opts.app = await this.helpers.configureApp(this.opts.app, [
@@ -317,12 +312,29 @@ class AndroidUiautomator2Driver
317
312
  }
318
313
 
319
314
  async getDeviceDetails(): Promise<Uiautomator2DeviceDetails> {
320
- const [pixelRatio, statBarHeight, viewportRect] = await B.all([
315
+ const [
316
+ pixelRatio,
317
+ statBarHeight,
318
+ viewportRect,
319
+ {apiVersion, platformVersion, manufacturer, model, realDisplaySize, displayDensity},
320
+ ] = await B.all([
321
321
  this.getDevicePixelRatio(),
322
322
  this.getStatusBarHeight(),
323
323
  this.getViewPortRect(),
324
+ this.mobileGetDeviceInfo(),
324
325
  ]);
325
- return {pixelRatio, statBarHeight, viewportRect};
326
+
327
+ return {
328
+ pixelRatio,
329
+ statBarHeight,
330
+ viewportRect,
331
+ deviceApiLevel: _.parseInt(apiVersion),
332
+ platformVersion,
333
+ deviceManufacturer: manufacturer,
334
+ deviceModel: model,
335
+ deviceScreenSize: realDisplaySize,
336
+ deviceScreenDensity: displayDensity,
337
+ };
326
338
  }
327
339
 
328
340
  override get driverData() {
@@ -337,27 +349,6 @@ class AndroidUiautomator2Driver
337
349
  return {...sessionData, ...uia2Data};
338
350
  }
339
351
 
340
- setAvdFromCapabilities(caps: Uiautomator2StartSessionOpts) {
341
- if (this.opts.avd) {
342
- this.log.info('avd name defined, ignoring device name and platform version');
343
- } else {
344
- if (!caps.deviceName) {
345
- this.log.errorAndThrow(
346
- 'avd or deviceName should be specified when reboot option is enables'
347
- );
348
- throw new Error(); // unreachable
349
- }
350
- if (!caps.platformVersion) {
351
- this.log.errorAndThrow(
352
- 'avd or platformVersion should be specified when reboot option is enabled'
353
- );
354
- throw new Error(); // unreachable
355
- }
356
- const avdDevice = caps.deviceName.replace(/[^a-zA-Z0-9_.]/g, '-');
357
- this.opts.avd = `${avdDevice}__${caps.platformVersion}`;
358
- }
359
- }
360
-
361
352
  async allocateSystemPort() {
362
353
  const forwardPort = async (localPort: number) => {
363
354
  this.log.debug(
@@ -534,11 +525,18 @@ class AndroidUiautomator2Driver
534
525
 
535
526
  // launch UiAutomator2 and wait till its online and we have a session
536
527
  await uiautomator2.startSession(capsWithSessionInfo);
528
+ // now that everything has started successfully, turn on proxying so all
529
+ // subsequent session requests go straight to/from uiautomator2
530
+ this.jwpProxyActive = true;
537
531
 
538
- const capsWithSessionAndDeviceInfo = {
539
- ...capsWithSessionInfo,
540
- ...(await this.getDeviceInfoFromUia2()),
541
- };
532
+ const deviceInfoPromise: Promise<Uiautomator2DeviceDetails|EmptyObject> = (async () => {
533
+ try {
534
+ return await this.getDeviceDetails();
535
+ } catch (e) {
536
+ this.log.warn(`Cannot fetch device details. Original error: ${e.message}`);
537
+ return {};
538
+ }
539
+ })();
542
540
 
543
541
  // Unlock the device after the session is started.
544
542
  if (!this.opts.skipUnlock) {
@@ -570,24 +568,7 @@ class AndroidUiautomator2Driver
570
568
  await retryInterval(timeout / 500, 500, this.setContext.bind(this), viewName);
571
569
  }
572
570
 
573
- // now that everything has started successfully, turn on proxying so all
574
- // subsequent session requests go straight to/from uiautomator2
575
- this.jwpProxyActive = true;
576
-
577
- return {...capsWithSessionAndDeviceInfo, ...(await this.getDeviceDetails())};
578
- }
579
-
580
- async getDeviceInfoFromUia2(): Promise<Uiautomator2DeviceInfo> {
581
- const {apiVersion, platformVersion, manufacturer, model, realDisplaySize, displayDensity} =
582
- await this.mobileGetDeviceInfo();
583
- return {
584
- deviceApiLevel: _.parseInt(apiVersion),
585
- platformVersion,
586
- deviceManufacturer: manufacturer,
587
- deviceModel: model,
588
- deviceScreenSize: realDisplaySize,
589
- deviceScreenDensity: displayDensity,
590
- };
571
+ return {...capsWithSessionInfo, ...(await deviceInfoPromise)};
591
572
  }
592
573
 
593
574
  async initUiAutomator2Server() {
@@ -668,7 +649,7 @@ class AndroidUiautomator2Driver
668
649
  ) {
669
650
  if (
670
651
  !this.opts.noSign &&
671
- !(await this.adb!.checkApkCert(this.opts.app, this.opts.appPackage, {
652
+ !(await this.adb!.checkApkCert(this.opts.app, this.opts.appPackage!, {
672
653
  requireDefaultCert: false,
673
654
  }))
674
655
  ) {
@@ -705,14 +686,6 @@ class AndroidUiautomator2Driver
705
686
  `and waiting for '${appWaitPackage}/${appWaitActivity}'`
706
687
  );
707
688
 
708
- if (this.caps.androidCoverage) {
709
- this.log.info(
710
- `androidCoverage is configured. ` +
711
- ` Starting instrumentation of '${this.caps.androidCoverage}'...`
712
- );
713
- await this.adb!.androidCoverage(this.caps.androidCoverage, appWaitPackage!, appWaitActivity!);
714
- return;
715
- }
716
689
  if (
717
690
  this.opts.noReset &&
718
691
  !this.opts.forceAppLaunch &&
@@ -764,22 +737,20 @@ class AndroidUiautomator2Driver
764
737
 
765
738
  await androidHelpers.removeAllSessionWebSocketHandlers(this.server, this.sessionId);
766
739
 
767
- if (this.uiautomator2) {
740
+ try {
741
+ await this.stopChromedriverProxies();
742
+ } catch (err) {
743
+ this.log.warn(`Unable to stop ChromeDriver proxies: ${(err as Error).message}`);
744
+ }
745
+
746
+ if (this.jwpProxyActive) {
768
747
  try {
769
- await this.stopChromedriverProxies();
748
+ await this.uiautomator2.deleteSession();
770
749
  } catch (err) {
771
- this.log.warn(`Unable to stop ChromeDriver proxies: ${(err as Error).message}`);
772
- }
773
- if (this.jwpProxyActive) {
774
- try {
775
- await this.uiautomator2.deleteSession();
776
- } catch (err) {
777
- this.log.warn(`Unable to proxy deleteSession to UiAutomator2: ${(err as Error).message}`);
778
- }
750
+ this.log.warn(`Unable to proxy deleteSession to UiAutomator2: ${(err as Error).message}`);
779
751
  }
780
- this.uiautomator2 = undefined;
752
+ this.jwpProxyActive = false;
781
753
  }
782
- this.jwpProxyActive = false;
783
754
 
784
755
  if (this.adb) {
785
756
  await B.all(
@@ -792,21 +763,6 @@ class AndroidUiautomator2Driver
792
763
  })
793
764
  );
794
765
 
795
- if (this.caps.androidCoverage) {
796
- this.log.info('Shutting down the adb process of instrumentation...');
797
- await this.adb.endAndroidCoverage();
798
- // Use this broadcast intent to notify it's time to dump coverage to file
799
- if (this.caps.androidCoverageEndIntent) {
800
- this.log.info(
801
- `Sending intent broadcast '${this.caps.androidCoverageEndIntent}' at the end of instrumenting.`
802
- );
803
- await this.adb.broadcast(this.caps.androidCoverageEndIntent);
804
- } else {
805
- this.log.warn(
806
- 'No androidCoverageEndIntent is configured in caps. Possibly you cannot get coverage file.'
807
- );
808
- }
809
- }
810
766
  if (this.opts.appPackage) {
811
767
  if (
812
768
  !this.isChromeSession &&
@@ -856,17 +812,6 @@ class AndroidUiautomator2Driver
856
812
  this.log.info('Restoring hidden api policy to the device default configuration');
857
813
  await this.adb.setDefaultHiddenApiPolicy(!!this.opts.ignoreHiddenApiPolicyError);
858
814
  }
859
-
860
- // @ts-expect-error unknown option
861
- if (this.opts.reboot) {
862
- const avdName = this.opts.avd!.replace('@', '');
863
- this.log.debug(`Closing emulator '${avdName}'`);
864
- try {
865
- await this.adb.killEmulator(avdName);
866
- } catch (err) {
867
- this.log.warn(`Unable to close emulator: ${(err as Error).message}`);
868
- }
869
- }
870
815
  }
871
816
  if (this.mjpegStream) {
872
817
  this.log.info('Closing MJPEG stream');
package/lib/types.ts CHANGED
@@ -9,15 +9,6 @@ export type Uiautomator2DriverCaps = DriverCaps<Uiautomator2Constraints>;
9
9
 
10
10
  export type W3CUiautomator2DriverCaps = W3CDriverCaps<Uiautomator2Constraints>;
11
11
 
12
- export interface Uiautomator2DeviceInfo {
13
- deviceApiLevel: number;
14
- deviceScreenSize: string;
15
- deviceScreenDensity: string;
16
- deviceModel: string;
17
- deviceManufacturer: string;
18
- platformVersion: string;
19
- }
20
-
21
12
  export interface Uiautomator2SessionInfo {
22
13
  deviceName: string;
23
14
  deviceUDID: string;
@@ -27,6 +18,12 @@ export interface Uiautomator2DeviceDetails {
27
18
  pixelRatio: string;
28
19
  statBarHeight: number;
29
20
  viewportRect: RelativeRect;
21
+ deviceApiLevel: number;
22
+ deviceScreenSize: string;
23
+ deviceScreenDensity: string;
24
+ deviceModel: string;
25
+ deviceManufacturer: string;
26
+ platformVersion: string;
30
27
  }
31
28
 
32
29
  export interface Uiautomator2ServerInfo {
@@ -48,8 +45,7 @@ export interface Uiautomator2StartSessionOpts
48
45
  export interface Uiautomator2SessionCaps
49
46
  extends Uiautomator2ServerInfo,
50
47
  Uiautomator2SessionInfo,
51
- Uiautomator2DeviceInfo,
52
- Uiautomator2DeviceDetails {}
48
+ Partial<Uiautomator2DeviceDetails> {}
53
49
 
54
50
  export interface Uiautomator2Settings {
55
51
  ignoreUnimportantViews: boolean;
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "appium-uiautomator2-driver",
3
- "version": "2.32.0",
3
+ "version": "2.32.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-uiautomator2-driver",
9
- "version": "2.32.0",
9
+ "version": "2.32.2",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
- "appium-adb": "^9.14.12",
13
- "appium-android-driver": "^7.1.0",
12
+ "appium-adb": "^10.0.0",
13
+ "appium-android-driver": "^7.1.3",
14
14
  "appium-chromedriver": "^5.6.5",
15
15
  "appium-uiautomator2-server": "^5.12.2",
16
16
  "asyncbox": "^2.3.1",
@@ -864,11 +864,11 @@
864
864
  }
865
865
  },
866
866
  "node_modules/@types/bluebird": {
867
- "version": "3.5.40",
867
+ "version": "3.5.41",
868
868
  "license": "MIT"
869
869
  },
870
870
  "node_modules/@types/body-parser": {
871
- "version": "1.19.3",
871
+ "version": "1.19.4",
872
872
  "license": "MIT",
873
873
  "dependencies": {
874
874
  "@types/connect": "*",
@@ -876,7 +876,7 @@
876
876
  }
877
877
  },
878
878
  "node_modules/@types/connect": {
879
- "version": "3.4.36",
879
+ "version": "3.4.37",
880
880
  "license": "MIT",
881
881
  "dependencies": {
882
882
  "@types/node": "*"
@@ -893,7 +893,7 @@
893
893
  }
894
894
  },
895
895
  "node_modules/@types/express-serve-static-core": {
896
- "version": "4.17.37",
896
+ "version": "4.17.38",
897
897
  "license": "MIT",
898
898
  "dependencies": {
899
899
  "@types/node": "*",
@@ -912,7 +912,7 @@
912
912
  "license": "MIT"
913
913
  },
914
914
  "node_modules/@types/http-errors": {
915
- "version": "2.0.2",
915
+ "version": "2.0.3",
916
916
  "license": "MIT"
917
917
  },
918
918
  "node_modules/@types/jsftp": {
@@ -960,14 +960,14 @@
960
960
  }
961
961
  },
962
962
  "node_modules/@types/node": {
963
- "version": "20.8.6",
963
+ "version": "20.8.7",
964
964
  "license": "MIT",
965
965
  "dependencies": {
966
966
  "undici-types": "~5.25.1"
967
967
  }
968
968
  },
969
969
  "node_modules/@types/normalize-package-data": {
970
- "version": "2.4.2",
970
+ "version": "2.4.3",
971
971
  "license": "MIT"
972
972
  },
973
973
  "node_modules/@types/npmlog": {
@@ -979,22 +979,22 @@
979
979
  "license": "MIT"
980
980
  },
981
981
  "node_modules/@types/qs": {
982
- "version": "6.9.8",
982
+ "version": "6.9.9",
983
983
  "license": "MIT"
984
984
  },
985
985
  "node_modules/@types/range-parser": {
986
- "version": "1.2.5",
986
+ "version": "1.2.6",
987
987
  "license": "MIT"
988
988
  },
989
989
  "node_modules/@types/readdir-glob": {
990
- "version": "1.1.2",
990
+ "version": "1.1.3",
991
991
  "license": "MIT",
992
992
  "dependencies": {
993
993
  "@types/node": "*"
994
994
  }
995
995
  },
996
996
  "node_modules/@types/send": {
997
- "version": "0.17.2",
997
+ "version": "0.17.3",
998
998
  "license": "MIT",
999
999
  "dependencies": {
1000
1000
  "@types/mime": "^1",
@@ -1009,7 +1009,7 @@
1009
1009
  }
1010
1010
  },
1011
1011
  "node_modules/@types/serve-static": {
1012
- "version": "1.15.3",
1012
+ "version": "1.15.4",
1013
1013
  "license": "MIT",
1014
1014
  "dependencies": {
1015
1015
  "@types/http-errors": "*",
@@ -1026,7 +1026,7 @@
1026
1026
  "license": "MIT"
1027
1027
  },
1028
1028
  "node_modules/@types/triple-beam": {
1029
- "version": "1.3.3",
1029
+ "version": "1.3.4",
1030
1030
  "extraneous": true,
1031
1031
  "license": "MIT"
1032
1032
  },
@@ -1147,7 +1147,7 @@
1147
1147
  }
1148
1148
  },
1149
1149
  "node_modules/appium-adb": {
1150
- "version": "9.14.12",
1150
+ "version": "10.0.0",
1151
1151
  "license": "Apache-2.0",
1152
1152
  "dependencies": {
1153
1153
  "@appium/support": "^4.0.0",
@@ -1175,10 +1175,10 @@
1175
1175
  }
1176
1176
  },
1177
1177
  "node_modules/appium-android-driver": {
1178
- "version": "7.1.0",
1178
+ "version": "7.1.3",
1179
1179
  "license": "Apache-2.0",
1180
1180
  "dependencies": {
1181
- "appium-adb": "^9.12.0",
1181
+ "appium-adb": "^10.0.0",
1182
1182
  "appium-chromedriver": "^5.5.1",
1183
1183
  "asyncbox": "^2.8.0",
1184
1184
  "axios": "^1.x",
@@ -1211,14 +1211,14 @@
1211
1211
  }
1212
1212
  },
1213
1213
  "node_modules/appium-chromedriver": {
1214
- "version": "5.6.13",
1214
+ "version": "5.6.14",
1215
1215
  "hasInstallScript": true,
1216
1216
  "license": "Apache-2.0",
1217
1217
  "dependencies": {
1218
1218
  "@appium/base-driver": "^9.1.0",
1219
1219
  "@appium/support": "^4.0.0",
1220
1220
  "@xmldom/xmldom": "^0.x",
1221
- "appium-adb": "^9.14.1",
1221
+ "appium-adb": "^10.0.0",
1222
1222
  "asyncbox": "^2.0.2",
1223
1223
  "axios": "^1.x",
1224
1224
  "bluebird": "^3.5.1",
@@ -4218,7 +4218,7 @@
4218
4218
  }
4219
4219
  },
4220
4220
  "node_modules/teen_process": {
4221
- "version": "2.0.50",
4221
+ "version": "2.0.51",
4222
4222
  "license": "Apache-2.0",
4223
4223
  "dependencies": {
4224
4224
  "bluebird": "3.7.2",
@@ -4279,7 +4279,7 @@
4279
4279
  }
4280
4280
  },
4281
4281
  "node_modules/type-fest": {
4282
- "version": "4.4.0",
4282
+ "version": "4.5.0",
4283
4283
  "license": "(MIT OR CC0-1.0)",
4284
4284
  "engines": {
4285
4285
  "node": ">=16"
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "automated testing",
8
8
  "android"
9
9
  ],
10
- "version": "2.32.0",
10
+ "version": "2.32.2",
11
11
  "bugs": {
12
12
  "url": "https://github.com/appium/appium-uiautomator2-driver/issues"
13
13
  },
@@ -62,8 +62,8 @@
62
62
  "singleQuote": true
63
63
  },
64
64
  "dependencies": {
65
- "appium-adb": "^9.14.12",
66
- "appium-android-driver": "^7.1.0",
65
+ "appium-adb": "^10.0.0",
66
+ "appium-android-driver": "^7.1.3",
67
67
  "appium-chromedriver": "^5.6.5",
68
68
  "appium-uiautomator2-server": "^5.12.2",
69
69
  "asyncbox": "^2.3.1",