appium-uiautomator2-driver 2.30.0 → 2.31.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/lib/driver.ts CHANGED
@@ -27,7 +27,6 @@ import uiautomator2Helpers from './helpers';
27
27
  import {newMethodMap} from './method-map';
28
28
  import type {
29
29
  Uiautomator2Settings,
30
- Uiautomator2CreateResult,
31
30
  Uiautomator2DeviceDetails,
32
31
  Uiautomator2DeviceInfo,
33
32
  Uiautomator2DriverCaps,
@@ -163,14 +162,12 @@ const CHROME_NO_PROXY: RouteMatcher[] = [
163
162
  const MEMOIZED_FUNCTIONS = ['getStatusBarHeight', 'getDevicePixelRatio'] as const;
164
163
 
165
164
  class AndroidUiautomator2Driver
166
- extends AndroidDriver<Uiautomator2Settings, Uiautomator2CreateResult>
165
+ extends AndroidDriver
167
166
  implements
168
167
  ExternalDriver<
169
168
  Uiautomator2Constraints,
170
169
  string,
171
- StringRecord,
172
- Uiautomator2Settings,
173
- Uiautomator2CreateResult
170
+ StringRecord
174
171
  >
175
172
  {
176
173
  static newMethodMap = newMethodMap;
@@ -236,12 +233,12 @@ class AndroidUiautomator2Driver
236
233
  );
237
234
  }
238
235
 
239
- override async createSession(
236
+ async createSession(
240
237
  w3cCaps1: W3CUiautomator2DriverCaps,
241
238
  w3cCaps2?: W3CUiautomator2DriverCaps,
242
239
  w3cCaps3?: W3CUiautomator2DriverCaps,
243
240
  driverData?: DriverData[]
244
- ): Promise<Uiautomator2CreateResult> {
241
+ ): Promise<any> {
245
242
  try {
246
243
  // TODO handle otherSessionData for multiple sessions
247
244
  const [sessionId, caps] = (await BaseDriver.prototype.createSession.call(
@@ -340,11 +337,7 @@ class AndroidUiautomator2Driver
340
337
  return {...sessionData, ...uia2Data};
341
338
  }
342
339
 
343
- override isEmulator() {
344
- return helpers.isEmulator(this.adb, this.opts);
345
- }
346
-
347
- override setAvdFromCapabilities(caps: Uiautomator2StartSessionOpts) {
340
+ setAvdFromCapabilities(caps: Uiautomator2StartSessionOpts) {
348
341
  if (this.opts.avd) {
349
342
  this.log.info('avd name defined, ignoring device name and platform version');
350
343
  } else {
@@ -458,7 +451,18 @@ class AndroidUiautomator2Driver
458
451
  if (apiLevel >= 28) {
459
452
  // Android P
460
453
  this.log.info('Relaxing hidden api policy');
461
- await this.adb.setHiddenApiPolicy('1', !!this.opts.ignoreHiddenApiPolicyError);
454
+ try {
455
+ await this.adb.setHiddenApiPolicy('1', !!this.opts.ignoreHiddenApiPolicyError);
456
+ } catch (err) {
457
+ this.log.errorAndThrow(
458
+ 'Hidden API policy (https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces) cannot be enabled. ' +
459
+ 'This might be happening because the device under test is not configured properly. ' +
460
+ 'Please check https://github.com/appium/appium/issues/13802 for more details. ' +
461
+ 'You could also set the "appium:ignoreHiddenApiPolicyError" capability to true in order to ' +
462
+ 'ignore this error, which might later lead to unexpected crashes or behavior of ' +
463
+ `the automation server. Original error: ${err.message}`
464
+ );
465
+ }
462
466
  }
463
467
 
464
468
  // check if we have to enable/disable gps before running the application
@@ -737,7 +741,7 @@ class AndroidUiautomator2Driver
737
741
  });
738
742
  }
739
743
 
740
- override async deleteSession() {
744
+ async deleteSession() {
741
745
  this.log.debug('Deleting UiAutomator2 session');
742
746
 
743
747
  const screenRecordingStopTasks = [
@@ -871,7 +875,7 @@ class AndroidUiautomator2Driver
871
875
  await BaseDriver.prototype.deleteSession.call(this);
872
876
  }
873
877
 
874
- override async checkAppPresent() {
878
+ async checkAppPresent() {
875
879
  this.log.debug('Checking whether app is actually present');
876
880
  if (!(await fs.exists(this.opts.app))) {
877
881
  this.log.errorAndThrow(`Could not find app apk at '${this.opts.app}'`);
@@ -879,36 +883,24 @@ class AndroidUiautomator2Driver
879
883
  }
880
884
  }
881
885
 
882
- override async onSettingsUpdate() {
886
+ async onSettingsUpdate() {
883
887
  // intentionally do nothing here, since commands.updateSettings proxies
884
888
  // settings to the uiauto2 server already
885
889
  }
886
890
 
887
- // Need to override android-driver's version of this since we don't actually
888
- // have a bootstrap; instead we just restart adb and re-forward the UiAutomator2
889
- // port
890
- override async wrapBootstrapDisconnect(wrapped: () => Promise<void>) {
891
- await wrapped();
892
- this.adb!.restart();
893
- await this.allocateSystemPort();
894
- await this.allocateMjpegServerPort();
895
- }
896
-
897
- override proxyActive(sessionId: string) {
898
- BaseDriver.prototype.proxyActive.call(this, sessionId);
899
-
891
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
892
+ proxyActive(sessionId: string) {
900
893
  // we always have an active proxy to the UiAutomator2 server
901
894
  return true;
902
895
  }
903
896
 
904
- override canProxy(sessionId: string) {
905
- BaseDriver.prototype.canProxy.call(this, sessionId);
906
-
897
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
898
+ canProxy(sessionId: string) {
907
899
  // we can always proxy to the uiautomator2 server
908
900
  return true;
909
901
  }
910
902
 
911
- override getProxyAvoidList() {
903
+ getProxyAvoidList() {
912
904
  // we are maintaining two sets of NO_PROXY lists, one for chromedriver(CHROME_NO_PROXY)
913
905
  // and one for uiautomator2(NO_PROXY), based on current context will return related NO_PROXY list
914
906
  if (util.hasValue(this.chromedriver)) {
@@ -927,10 +919,6 @@ class AndroidUiautomator2Driver
927
919
  return this.jwpProxyAvoid;
928
920
  }
929
921
 
930
- get isChromeSession() {
931
- return helpers.isChromeBrowser(this.opts.browserName);
932
- }
933
-
934
922
  async updateSettings(settings: Uiautomator2Settings) {
935
923
  await this.settings.update(settings);
936
924
  await this.uiautomator2!.jwproxy.command('/appium/settings', 'POST', {settings});
@@ -942,7 +930,7 @@ class AndroidUiautomator2Driver
942
930
  '/appium/settings',
943
931
  'GET'
944
932
  )) as Partial<Uiautomator2Settings>;
945
- return {...driverSettings, ...serverSettings};
933
+ return {...driverSettings, ...serverSettings} as any;
946
934
  }
947
935
  }
948
936
 
package/lib/types.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type {DriverCaps, DriverOpts, W3CDriverCaps} from '@appium/types';
2
- import type {AndroidSettings} from 'appium-android-driver';
3
2
  import type {EmptyObject} from 'type-fest';
4
3
  import type {RelativeRect} from './commands/types';
5
4
  import type {Uiautomator2Constraints} from './constraints';
@@ -52,8 +51,7 @@ export interface Uiautomator2SessionCaps
52
51
  Uiautomator2DeviceInfo,
53
52
  Uiautomator2DeviceDetails {}
54
53
 
55
- export type Uiautomator2CreateResult = [string, Uiautomator2SessionCaps];
56
-
57
- export interface Uiautomator2Settings extends AndroidSettings {
54
+ export interface Uiautomator2Settings {
55
+ ignoreUnimportantViews: boolean;
58
56
  allowInvisibleElements: boolean;
59
57
  }
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "appium-uiautomator2-driver",
3
- "version": "2.30.0",
3
+ "version": "2.31.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-uiautomator2-driver",
9
- "version": "2.30.0",
9
+ "version": "2.31.1",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "appium-adb": "^9.14.12",
13
- "appium-android-driver": "^6.0.0",
13
+ "appium-android-driver": "^7.0.1",
14
14
  "appium-chromedriver": "^5.6.5",
15
15
  "appium-uiautomator2-server": "^5.12.2",
16
16
  "asyncbox": "^2.3.1",
@@ -70,7 +70,7 @@
70
70
  "rimraf": "^5.0.0",
71
71
  "semantic-release": "^21.1.0",
72
72
  "sharp": "^0.x",
73
- "sinon": "^15.0.0",
73
+ "sinon": "^16.1.0",
74
74
  "sinon-chai": "^3.7.0",
75
75
  "ts-node": "^10.9.1",
76
76
  "typescript": "~5.0",
@@ -829,7 +829,7 @@
829
829
  }
830
830
  },
831
831
  "node_modules/@types/node": {
832
- "version": "20.8.5",
832
+ "version": "20.8.6",
833
833
  "license": "MIT",
834
834
  "dependencies": {
835
835
  "undici-types": "~5.25.1"
@@ -1044,7 +1044,7 @@
1044
1044
  }
1045
1045
  },
1046
1046
  "node_modules/appium-android-driver": {
1047
- "version": "6.0.1",
1047
+ "version": "7.0.2",
1048
1048
  "license": "Apache-2.0",
1049
1049
  "dependencies": {
1050
1050
  "appium-adb": "^9.12.0",
@@ -1054,16 +1054,15 @@
1054
1054
  "bluebird": "^3.4.7",
1055
1055
  "io.appium.settings": "^5.0.0",
1056
1056
  "lodash": "^4.17.4",
1057
- "lru-cache": "^7.3.0",
1057
+ "lru-cache": "^10.0.1",
1058
1058
  "moment": "^2.24.0",
1059
1059
  "moment-timezone": "^0.5.26",
1060
1060
  "portfinder": "^1.0.6",
1061
1061
  "portscanner": "2.2.0",
1062
1062
  "semver": "^7.0.0",
1063
- "shared-preferences-builder": "^0.x",
1064
1063
  "source-map-support": "^0.x",
1065
1064
  "teen_process": "^2.0.0",
1066
- "type-fest": "^3.11.1",
1065
+ "type-fest": "^4.4.0",
1067
1066
  "ws": "^8.0.0"
1068
1067
  },
1069
1068
  "engines": {
@@ -1074,6 +1073,23 @@
1074
1073
  "appium": "^2.0.0-beta.40"
1075
1074
  }
1076
1075
  },
1076
+ "node_modules/appium-android-driver/node_modules/lru-cache": {
1077
+ "version": "10.0.1",
1078
+ "license": "ISC",
1079
+ "engines": {
1080
+ "node": "14 || >=16.14"
1081
+ }
1082
+ },
1083
+ "node_modules/appium-android-driver/node_modules/type-fest": {
1084
+ "version": "4.4.0",
1085
+ "license": "(MIT OR CC0-1.0)",
1086
+ "engines": {
1087
+ "node": ">=16"
1088
+ },
1089
+ "funding": {
1090
+ "url": "https://github.com/sponsors/sindresorhus"
1091
+ }
1092
+ },
1077
1093
  "node_modules/appium-chromedriver": {
1078
1094
  "version": "5.6.13",
1079
1095
  "hasInstallScript": true,
@@ -2757,24 +2773,19 @@
2757
2773
  }
2758
2774
  },
2759
2775
  "node_modules/logform": {
2760
- "version": "2.5.1",
2776
+ "version": "2.6.0",
2761
2777
  "extraneous": true,
2762
2778
  "license": "MIT",
2763
2779
  "dependencies": {
2764
- "@colors/colors": "1.5.0",
2780
+ "@colors/colors": "1.6.0",
2765
2781
  "@types/triple-beam": "^1.3.2",
2766
2782
  "fecha": "^4.2.0",
2767
2783
  "ms": "^2.1.1",
2768
2784
  "safe-stable-stringify": "^2.3.1",
2769
2785
  "triple-beam": "^1.3.0"
2770
- }
2771
- },
2772
- "node_modules/logform/node_modules/@colors/colors": {
2773
- "version": "1.5.0",
2774
- "extraneous": true,
2775
- "license": "MIT",
2786
+ },
2776
2787
  "engines": {
2777
- "node": ">=0.1.90"
2788
+ "node": ">= 12.0.0"
2778
2789
  }
2779
2790
  },
2780
2791
  "node_modules/lru-cache": {
@@ -3780,21 +3791,6 @@
3780
3791
  "version": "1.2.0",
3781
3792
  "license": "ISC"
3782
3793
  },
3783
- "node_modules/shared-preferences-builder": {
3784
- "version": "0.0.4",
3785
- "license": "MIT",
3786
- "dependencies": {
3787
- "lodash": "^4.17.4",
3788
- "xmlbuilder": "^9.0.1"
3789
- }
3790
- },
3791
- "node_modules/shared-preferences-builder/node_modules/xmlbuilder": {
3792
- "version": "9.0.7",
3793
- "license": "MIT",
3794
- "engines": {
3795
- "node": ">=4.0"
3796
- }
3797
- },
3798
3794
  "node_modules/shebang-command": {
3799
3795
  "version": "2.0.0",
3800
3796
  "license": "MIT",
@@ -4461,7 +4457,7 @@
4461
4457
  }
4462
4458
  },
4463
4459
  "node_modules/winston-transport": {
4464
- "version": "4.5.0",
4460
+ "version": "4.6.0",
4465
4461
  "extraneous": true,
4466
4462
  "license": "MIT",
4467
4463
  "dependencies": {
@@ -4470,7 +4466,7 @@
4470
4466
  "triple-beam": "^1.3.0"
4471
4467
  },
4472
4468
  "engines": {
4473
- "node": ">= 6.4.0"
4469
+ "node": ">= 12.0.0"
4474
4470
  }
4475
4471
  },
4476
4472
  "node_modules/winston/node_modules/@colors/colors": {
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "automated testing",
8
8
  "android"
9
9
  ],
10
- "version": "2.30.0",
10
+ "version": "2.31.1",
11
11
  "bugs": {
12
12
  "url": "https://github.com/appium/appium-uiautomator2-driver/issues"
13
13
  },
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "appium-adb": "^9.14.12",
66
- "appium-android-driver": "^6.0.0",
66
+ "appium-android-driver": "^7.0.1",
67
67
  "appium-chromedriver": "^5.6.5",
68
68
  "appium-uiautomator2-server": "^5.12.2",
69
69
  "asyncbox": "^2.3.1",
@@ -123,7 +123,7 @@
123
123
  "rimraf": "^5.0.0",
124
124
  "semantic-release": "^21.1.0",
125
125
  "sharp": "^0.x",
126
- "sinon": "^15.0.0",
126
+ "sinon": "^16.1.0",
127
127
  "sinon-chai": "^3.7.0",
128
128
  "ts-node": "^10.9.1",
129
129
  "typescript": "~5.0",