appium-espresso-driver 2.29.3 → 2.31.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [2.31.0](https://github.com/appium/appium-espresso-driver/compare/v2.30.0...v2.31.0) (2024-01-06)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add doctor checks ([#962](https://github.com/appium/appium-espresso-driver/issues/962)) ([bb153f4](https://github.com/appium/appium-espresso-driver/commit/bb153f413b5be3cb2f1a4f79032a5f50aefd377b))
7
+
8
+ ## [2.30.0](https://github.com/appium/appium-espresso-driver/compare/v2.29.3...v2.30.0) (2023-12-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * let mobile: getContexts gives waitForWebviewMs ([#960](https://github.com/appium/appium-espresso-driver/issues/960)) ([cefd205](https://github.com/appium/appium-espresso-driver/commit/cefd205a184187fb5c03c90defbc6acf02ed6e6d))
14
+
1
15
  ## [2.29.3](https://github.com/appium/appium-espresso-driver/compare/v2.29.2...v2.29.3) (2023-12-02)
2
16
 
3
17
 
package/README.md CHANGED
@@ -37,6 +37,12 @@ On top of standard Appium requirements Espresso driver also expects the followin
37
37
  - Both the server package and the application under test must be signed with the same digital signature. Appium does sign them automatically upon session creation, so this could only be an issue if one wants to test an application, which is already installed on the device (using `noReset=true` capability).
38
38
  - The package under test must not have mangled class names (e.g. [Proguard](https://developer.android.com/studio/build/shrink-code) must not be enabled for it)
39
39
 
40
+ ### Doctor
41
+
42
+ Since driver version 2.31.0 you can automate the validation for the most of the above
43
+ requirements as well as various optional ones needed by driver extensions by running the
44
+ `appium driver doctor espresso` server command.
45
+
40
46
 
41
47
  ## Scripts
42
48
 
@@ -655,7 +661,13 @@ buttonState | int | no | Button state id, `0` by default | 1
655
661
 
656
662
  ### mobile: getContexts
657
663
 
658
- Retrieves a webviews mapping based on CDP endpoints
664
+ Retrieves a WebViews mapping based on CDP endpoints
665
+
666
+ #### Arguments
667
+
668
+ Name | Type | Required | Description | Example
669
+ --- | --- | --- | --- | ---
670
+ waitForWebviewMs | number | no | Tells Espresso driver for how long (in milliseconds) to wait for web view(s) to appear since Espresso driver v2.30.0. If a Chrome process running on the device under test fails to create a connection to the devtools socket, then the chromedriver will rise an error similar to `failed to connect to socket 'localabstract:chrome_devtools_remote'` in Espresso driver. It could cause no WebViews found result, although a couple of retrials may fix it. This argument helps to keep trying to get WebView(s) up to the given time milliseconds as one command call. This issue tends to occur Chrome v115 and over so far. [issues#19251](https://github.com/appium/appium/issues/19251) contains more details. If set to `0`ms (the default value), then Espresso driver only checks the WebView(s) availability once. | 10000
659
671
 
660
672
  #### Returns
661
673
 
@@ -0,0 +1,4 @@
1
+ export const optionalBundletoolCheck: doctor.OptionalBundletoolCheck;
2
+ export const optionalFfmpegCheck: doctor.OptionalFfmpegCheck;
3
+ import { doctor } from 'appium-android-driver';
4
+ //# sourceMappingURL=optional-checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional-checks.d.ts","sourceRoot":"","sources":["../../../lib/doctor/optional-checks.js"],"names":[],"mappings":"AAEA,qEAAsE;AACtE,6DAA8D;uBAHvC,uBAAuB"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optionalFfmpegCheck = exports.optionalBundletoolCheck = void 0;
4
+ const appium_android_driver_1 = require("appium-android-driver");
5
+ exports.optionalBundletoolCheck = appium_android_driver_1.doctor.optionalBundletoolCheck;
6
+ exports.optionalFfmpegCheck = appium_android_driver_1.doctor.optionalFfmpegCheck;
7
+ //# sourceMappingURL=optional-checks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional-checks.js","sourceRoot":"","sources":["../../../lib/doctor/optional-checks.js"],"names":[],"mappings":";;;AAAA,iEAA+C;AAElC,QAAA,uBAAuB,GAAG,8BAAM,CAAC,uBAAuB,CAAC;AACzD,QAAA,mBAAmB,GAAG,8BAAM,CAAC,mBAAmB,CAAC"}
@@ -0,0 +1,30 @@
1
+ export const androidHomeCheck: {
2
+ varName: string;
3
+ opts: doctorCommon.EnvVarCheckOptions;
4
+ diagnose(): Promise<import("@appium/types").DoctorCheckResult>;
5
+ fix(): Promise<string>;
6
+ hasAutofix(): boolean;
7
+ isOptional(): boolean;
8
+ };
9
+ export const javaHomeCheck: {
10
+ varName: string;
11
+ opts: doctorCommon.EnvVarCheckOptions;
12
+ diagnose(): Promise<import("@appium/types").DoctorCheckResult>;
13
+ fix(): Promise<string>;
14
+ hasAutofix(): boolean;
15
+ isOptional(): boolean;
16
+ };
17
+ export const javaHomeValueCheck: doctorCommon.JavaHomeValueCheck;
18
+ export const androidSdkCheck: doctorCommon.AndroidSdkCheck;
19
+ /** @satisfies {import('@appium/types').IDoctorCheck} */
20
+ export class JavaVersionCheck {
21
+ MIN_JAVA_VERSION: number;
22
+ JAVA_VERSION_PATTERN: RegExp;
23
+ diagnose(): Promise<import("@appium/types").DoctorCheckResult>;
24
+ fix(): Promise<string>;
25
+ hasAutofix(): boolean;
26
+ isOptional(): boolean;
27
+ }
28
+ export const javaVersionCheck: JavaVersionCheck;
29
+ import { doctor as doctorCommon } from 'appium-android-driver';
30
+ //# sourceMappingURL=required-checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"required-checks.d.ts","sourceRoot":"","sources":["../../../lib/doctor/required-checks.js"],"names":[],"mappings":"AAKA;;;;;;;EAA8D;AAC9D;;;;;;;EAAwD;AACxD,iEAAkE;AAClE,2DAA4D;AAE5D,wDAAwD;AACxD;IACE,yBAAsB;IACtB,6BAA2D;IAE3D,+DAoBC;IAED,uBAGC;IAED,sBAEC;IAED,sBAEC;CACF;AACD,gDAAuD;uCAlDhB,uBAAuB"}
@@ -0,0 +1,56 @@
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.javaVersionCheck = exports.JavaVersionCheck = exports.androidSdkCheck = exports.javaHomeValueCheck = exports.javaHomeCheck = exports.androidHomeCheck = void 0;
7
+ const appium_android_driver_1 = require("appium-android-driver");
8
+ const teen_process_1 = require("teen_process");
9
+ const support_1 = require("@appium/support");
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ exports.androidHomeCheck = appium_android_driver_1.doctor.androidHomeCheck;
12
+ exports.javaHomeCheck = appium_android_driver_1.doctor.javaHomeCheck;
13
+ exports.javaHomeValueCheck = appium_android_driver_1.doctor.javaHomeValueCheck;
14
+ exports.androidSdkCheck = appium_android_driver_1.doctor.androidSdkCheck;
15
+ /** @satisfies {import('@appium/types').IDoctorCheck} */
16
+ class JavaVersionCheck {
17
+ constructor() {
18
+ this.MIN_JAVA_VERSION = 11;
19
+ this.JAVA_VERSION_PATTERN = /^\s*java\.version\s*=\s*([\d.]+)/m;
20
+ }
21
+ async diagnose() {
22
+ const javaHome = process.env.JAVA_HOME;
23
+ const fullJavaPath = node_path_1.default.join(javaHome ?? '', 'bin', `java${support_1.system.isWindows() ? '.exe' : ''}`);
24
+ if (!javaHome || !await support_1.fs.exists(fullJavaPath)) {
25
+ return support_1.doctor.nok(`Cannot retrieve Java version. Is Java installed and JAVA_HOME set to a proper path?`);
26
+ }
27
+ let javaVerMatch;
28
+ try {
29
+ const { stderr } = await (0, teen_process_1.exec)(fullJavaPath, ['-XshowSettings:properties', '-version']);
30
+ javaVerMatch = this.JAVA_VERSION_PATTERN.exec(stderr);
31
+ }
32
+ catch (e) {
33
+ return support_1.doctor.nok(`Cannot retrieve Java version: ${e.stderr || e.message}`);
34
+ }
35
+ if (!javaVerMatch) {
36
+ return support_1.doctor.nok(`The actual Java version cannot be retrieved`);
37
+ }
38
+ const majorVer = parseInt(javaVerMatch[1], 10);
39
+ return majorVer < this.MIN_JAVA_VERSION
40
+ ? support_1.doctor.nok(`The active Java version ${javaVerMatch[1]} is older than the required one`)
41
+ : support_1.doctor.ok(`The active Java version matches (${majorVer} >= ${this.MIN_JAVA_VERSION})`);
42
+ }
43
+ async fix() {
44
+ return `Upgrade to Java ${this.MIN_JAVA_VERSION}+ or update ` +
45
+ `the JAVA_HOME environment variable if it is already instsalled`;
46
+ }
47
+ hasAutofix() {
48
+ return false;
49
+ }
50
+ isOptional() {
51
+ return false;
52
+ }
53
+ }
54
+ exports.JavaVersionCheck = JavaVersionCheck;
55
+ exports.javaVersionCheck = new JavaVersionCheck();
56
+ //# sourceMappingURL=required-checks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"required-checks.js","sourceRoot":"","sources":["../../../lib/doctor/required-checks.js"],"names":[],"mappings":";;;;;;AAAA,iEAA+D;AAC/D,+CAAoC;AACpC,6CAAqD;AACrD,0DAA6B;AAEhB,QAAA,gBAAgB,GAAG,8BAAY,CAAC,gBAAgB,CAAC;AACjD,QAAA,aAAa,GAAG,8BAAY,CAAC,aAAa,CAAC;AAC3C,QAAA,kBAAkB,GAAG,8BAAY,CAAC,kBAAkB,CAAC;AACrD,QAAA,eAAe,GAAG,8BAAY,CAAC,eAAe,CAAC;AAE5D,wDAAwD;AACxD,MAAa,gBAAgB;IAA7B;QACE,qBAAgB,GAAG,EAAE,CAAC;QACtB,yBAAoB,GAAG,mCAAmC,CAAC;IAoC7D,CAAC;IAlCC,KAAK,CAAC,QAAQ;QACZ,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACvC,MAAM,YAAY,GAAG,mBAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,gBAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjG,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,YAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;YAC/C,OAAO,gBAAM,CAAC,GAAG,CAAC,qFAAqF,CAAC,CAAC;SAC1G;QACD,IAAI,YAAY,CAAC;QACjB,IAAI;YACF,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,IAAA,mBAAI,EAAC,YAAY,EAAE,CAAC,2BAA2B,EAAE,UAAU,CAAC,CAAC,CAAC;YACrF,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACvD;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,gBAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;SAC7E;QACD,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO,gBAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;SAClE;QACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,QAAQ,GAAG,IAAI,CAAC,gBAAgB;YACrC,CAAC,CAAC,gBAAM,CAAC,GAAG,CAAC,2BAA2B,YAAY,CAAC,CAAC,CAAC,iCAAiC,CAAC;YACzF,CAAC,CAAC,gBAAM,CAAC,EAAE,CAAC,oCAAoC,QAAQ,OAAO,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC7F,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,mBAAmB,IAAI,CAAC,gBAAgB,cAAc;YAC3D,gEAAgE,CAAC;IACrE,CAAC;IAED,UAAU;QACR,OAAO,KAAK,CAAC;IACf,CAAC;IAED,UAAU;QACR,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtCD,4CAsCC;AACY,QAAA,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { doctor } from 'appium-android-driver';
2
+
3
+ export const optionalBundletoolCheck = doctor.optionalBundletoolCheck;
4
+ export const optionalFfmpegCheck = doctor.optionalFfmpegCheck;
@@ -0,0 +1,51 @@
1
+ import { doctor as doctorCommon } from 'appium-android-driver';
2
+ import { exec } from 'teen_process';
3
+ import { fs, system, doctor } from '@appium/support';
4
+ import path from 'node:path';
5
+
6
+ export const androidHomeCheck = doctorCommon.androidHomeCheck;
7
+ export const javaHomeCheck = doctorCommon.javaHomeCheck;
8
+ export const javaHomeValueCheck = doctorCommon.javaHomeValueCheck;
9
+ export const androidSdkCheck = doctorCommon.androidSdkCheck;
10
+
11
+ /** @satisfies {import('@appium/types').IDoctorCheck} */
12
+ export class JavaVersionCheck {
13
+ MIN_JAVA_VERSION = 11;
14
+ JAVA_VERSION_PATTERN = /^\s*java\.version\s*=\s*([\d.]+)/m;
15
+
16
+ async diagnose() {
17
+ const javaHome = process.env.JAVA_HOME;
18
+ const fullJavaPath = path.join(javaHome ?? '', 'bin', `java${system.isWindows() ? '.exe' : ''}`);
19
+ if (!javaHome || !await fs.exists(fullJavaPath)) {
20
+ return doctor.nok(`Cannot retrieve Java version. Is Java installed and JAVA_HOME set to a proper path?`);
21
+ }
22
+ let javaVerMatch;
23
+ try {
24
+ const {stderr} = await exec(fullJavaPath, ['-XshowSettings:properties', '-version']);
25
+ javaVerMatch = this.JAVA_VERSION_PATTERN.exec(stderr);
26
+ } catch (e) {
27
+ return doctor.nok(`Cannot retrieve Java version: ${e.stderr || e.message}`);
28
+ }
29
+ if (!javaVerMatch) {
30
+ return doctor.nok(`The actual Java version cannot be retrieved`);
31
+ }
32
+ const majorVer = parseInt(javaVerMatch[1], 10);
33
+ return majorVer < this.MIN_JAVA_VERSION
34
+ ? doctor.nok(`The active Java version ${javaVerMatch[1]} is older than the required one`)
35
+ : doctor.ok(`The active Java version matches (${majorVer} >= ${this.MIN_JAVA_VERSION})`);
36
+ }
37
+
38
+ async fix() {
39
+ return `Upgrade to Java ${this.MIN_JAVA_VERSION}+ or update ` +
40
+ `the JAVA_HOME environment variable if it is already instsalled`;
41
+ }
42
+
43
+ hasAutofix() {
44
+ return false;
45
+ }
46
+
47
+ isOptional() {
48
+ return false;
49
+ }
50
+ }
51
+ export const javaVersionCheck = new JavaVersionCheck();