appium-espresso-driver 9.0.3 → 9.0.5

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 (101) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/build/lib/commands/actions.d.ts +1 -1
  4. package/build/lib/commands/actions.d.ts.map +1 -1
  5. package/build/lib/commands/actions.js.map +1 -1
  6. package/build/lib/commands/app-install.d.ts.map +1 -1
  7. package/build/lib/commands/app-install.js +4 -9
  8. package/build/lib/commands/app-install.js.map +1 -1
  9. package/build/lib/commands/app-management.d.ts.map +1 -1
  10. package/build/lib/commands/app-management.js.map +1 -1
  11. package/build/lib/commands/context.d.ts +1 -1
  12. package/build/lib/commands/context.d.ts.map +1 -1
  13. package/build/lib/commands/context.js.map +1 -1
  14. package/build/lib/commands/element.d.ts.map +1 -1
  15. package/build/lib/commands/element.js.map +1 -1
  16. package/build/lib/commands/idling-resources.d.ts.map +1 -1
  17. package/build/lib/commands/idling-resources.js.map +1 -1
  18. package/build/lib/commands/misc.d.ts.map +1 -1
  19. package/build/lib/commands/misc.js +1 -1
  20. package/build/lib/commands/misc.js.map +1 -1
  21. package/build/lib/commands/screenshot.d.ts.map +1 -1
  22. package/build/lib/commands/screenshot.js.map +1 -1
  23. package/build/lib/commands/server/builder.d.ts.map +1 -1
  24. package/build/lib/commands/server/builder.js +8 -15
  25. package/build/lib/commands/server/builder.js.map +1 -1
  26. package/build/lib/commands/server/runner.d.ts +2 -2
  27. package/build/lib/commands/server/runner.d.ts.map +1 -1
  28. package/build/lib/commands/server/runner.js +8 -14
  29. package/build/lib/commands/server/runner.js.map +1 -1
  30. package/build/lib/commands/server/startup.d.ts.map +1 -1
  31. package/build/lib/commands/server/startup.js.map +1 -1
  32. package/build/lib/commands/services.d.ts.map +1 -1
  33. package/build/lib/commands/services.js.map +1 -1
  34. package/build/lib/doctor/required-checks.d.ts +1 -1
  35. package/build/lib/doctor/required-checks.d.ts.map +1 -1
  36. package/build/lib/doctor/required-checks.js +2 -2
  37. package/build/lib/doctor/required-checks.js.map +1 -1
  38. package/build/lib/driver.d.ts +7 -7
  39. package/build/lib/driver.d.ts.map +1 -1
  40. package/build/lib/driver.js +14 -18
  41. package/build/lib/driver.js.map +1 -1
  42. package/build/lib/execute-method-map.d.ts.map +1 -1
  43. package/build/lib/execute-method-map.js +1 -7
  44. package/build/lib/execute-method-map.js.map +1 -1
  45. package/build/lib/method-map.js.map +1 -1
  46. package/build/lib/types.d.ts.map +1 -1
  47. package/build/lib/utils/package.d.ts.map +1 -1
  48. package/build/lib/utils/package.js +2 -2
  49. package/build/lib/utils/package.js.map +1 -1
  50. package/espresso-server/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk +0 -0
  51. package/espresso-server/buildSrc/.gradle/9.6.1/executionHistory/executionHistory.bin +0 -0
  52. package/espresso-server/buildSrc/.gradle/9.6.1/executionHistory/executionHistory.lock +0 -0
  53. package/espresso-server/buildSrc/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  54. package/espresso-server/buildSrc/.gradle/buildOutputCleanup/cache.properties +1 -1
  55. package/espresso-server/buildSrc/.gradle/file-system.probe +0 -0
  56. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin +0 -0
  57. package/espresso-server/gradle/libs.versions.toml +1 -1
  58. package/espresso-server/library/src/main/java/io/appium/espressoserver/lib/helpers/Version.kt +1 -1
  59. package/lib/commands/actions.ts +2 -1
  60. package/lib/commands/app-install.ts +9 -19
  61. package/lib/commands/app-management.ts +2 -1
  62. package/lib/commands/context.ts +2 -1
  63. package/lib/commands/element.ts +31 -76
  64. package/lib/commands/idling-resources.ts +9 -26
  65. package/lib/commands/misc.ts +14 -36
  66. package/lib/commands/screenshot.ts +1 -4
  67. package/lib/commands/server/builder.ts +13 -28
  68. package/lib/commands/server/runner.ts +24 -70
  69. package/lib/commands/server/startup.ts +2 -8
  70. package/lib/commands/services.ts +1 -5
  71. package/lib/doctor/required-checks.ts +6 -11
  72. package/lib/driver.ts +24 -37
  73. package/lib/execute-method-map.ts +1 -7
  74. package/lib/method-map.ts +1 -1
  75. package/lib/types.ts +1 -0
  76. package/lib/utils/package.ts +3 -2
  77. package/npm-shrinkwrap.json +175 -250
  78. package/package.json +58 -69
  79. package/scripts/build-espresso.mjs +7 -10
  80. package/scripts/diagnose-app.mjs +8 -13
  81. package/scripts/lib/dependency-versions/apk-dex.mjs +2 -1
  82. package/scripts/lib/dependency-versions/apk-kotlin-metadata.mjs +4 -2
  83. package/scripts/lib/dependency-versions/apk-meta-inf.mjs +4 -3
  84. package/scripts/lib/dependency-versions/apk-scan.mjs +4 -3
  85. package/scripts/lib/dependency-versions/comparison.mjs +3 -3
  86. package/scripts/lib/dependency-versions/gradle-scan.mjs +9 -11
  87. package/scripts/lib/dependency-versions/index.mjs +2 -9
  88. package/scripts/lib/dependency-versions/report.mjs +2 -5
  89. package/scripts/lib/dependency-versions/server-versions.mjs +3 -1
  90. package/scripts/lib/dependency-versions/tracked-modules.mjs +3 -12
  91. package/scripts/lib/dependency-versions/version-utils.mjs +1 -0
  92. package/scripts/lib/diagnose/app-input.mjs +4 -4
  93. package/scripts/lib/diagnose/checks/compile-sdk.mjs +1 -0
  94. package/scripts/lib/diagnose/checks/internet-permission.mjs +1 -2
  95. package/scripts/lib/diagnose/checks/startup-provider.mjs +2 -1
  96. package/scripts/lib/diagnose/diagnosis.mjs +2 -2
  97. package/scripts/lib/diagnose/gradle-utils.mjs +1 -5
  98. package/scripts/lib/diagnose/index.mjs +1 -5
  99. package/scripts/lib/diagnose/report.mjs +12 -4
  100. package/scripts/print-espresso-path.mjs +1 -0
  101. package/scripts/sync-version.mjs +8 -13
@@ -1,5 +1,6 @@
1
1
  import {errors} from 'appium/driver.js';
2
2
  import {util} from 'appium/support.js';
3
+
3
4
  import type {EspressoDriver} from '../driver.js';
4
5
 
5
6
  /**
@@ -29,10 +30,7 @@ export async function mobileFlashElement(
29
30
  * @param elementId - The ID of the element for which to dismiss autofill
30
31
  * @returns Promise that resolves when the autofill is dismissed
31
32
  */
32
- export async function mobileDismissAutofill(
33
- this: EspressoDriver,
34
- elementId: string,
35
- ): Promise<void> {
33
+ export async function mobileDismissAutofill(this: EspressoDriver, elementId: string): Promise<void> {
36
34
  await this.espresso.jwproxy.command(
37
35
  `/session/:sessionId/appium/execute_mobile/${elementId}/dismiss_autofill`,
38
36
  'POST',
@@ -77,16 +75,8 @@ export async function mobileSwipe(
77
75
  * @param gravity - Optional gravity value for drawer positioning (e.g., Gravity.START, Gravity.END)
78
76
  * @returns Promise that resolves when the drawer is opened
79
77
  */
80
- export async function mobileOpenDrawer(
81
- this: EspressoDriver,
82
- elementId: string,
83
- gravity?: number,
84
- ): Promise<any> {
85
- return await this.espresso.jwproxy.command(
86
- `/appium/execute_mobile/${elementId}/open_drawer`,
87
- 'POST',
88
- {gravity},
89
- );
78
+ export async function mobileOpenDrawer(this: EspressoDriver, elementId: string, gravity?: number): Promise<any> {
79
+ return await this.espresso.jwproxy.command(`/appium/execute_mobile/${elementId}/open_drawer`, 'POST', {gravity});
90
80
  }
91
81
 
92
82
  /**
@@ -96,16 +86,8 @@ export async function mobileOpenDrawer(
96
86
  * @param gravity - Optional gravity value for drawer positioning (e.g., Gravity.START, Gravity.END)
97
87
  * @returns Promise that resolves when the drawer is closed
98
88
  */
99
- export async function mobileCloseDrawer(
100
- this: EspressoDriver,
101
- elementId: string,
102
- gravity?: number,
103
- ): Promise<any> {
104
- return await this.espresso.jwproxy.command(
105
- `/appium/execute_mobile/${elementId}/close_drawer`,
106
- 'POST',
107
- {gravity},
108
- );
89
+ export async function mobileCloseDrawer(this: EspressoDriver, elementId: string, gravity?: number): Promise<any> {
90
+ return await this.espresso.jwproxy.command(`/appium/execute_mobile/${elementId}/close_drawer`, 'POST', {gravity});
109
91
  }
110
92
 
111
93
  /**
@@ -124,15 +106,11 @@ export async function mobileSetDate(
124
106
  monthOfYear: number,
125
107
  dayOfMonth: number,
126
108
  ): Promise<any> {
127
- return await this.espresso.jwproxy.command(
128
- `/appium/execute_mobile/${elementId}/set_date`,
129
- 'POST',
130
- {
131
- year,
132
- monthOfYear,
133
- dayOfMonth,
134
- },
135
- );
109
+ return await this.espresso.jwproxy.command(`/appium/execute_mobile/${elementId}/set_date`, 'POST', {
110
+ year,
111
+ monthOfYear,
112
+ dayOfMonth,
113
+ });
136
114
  }
137
115
 
138
116
  /**
@@ -149,14 +127,10 @@ export async function mobileSetTime(
149
127
  hours: number,
150
128
  minutes: number,
151
129
  ): Promise<any> {
152
- return await this.espresso.jwproxy.command(
153
- `/appium/execute_mobile/${elementId}/set_time`,
154
- 'POST',
155
- {
156
- hours,
157
- minutes,
158
- },
159
- );
130
+ return await this.espresso.jwproxy.command(`/appium/execute_mobile/${elementId}/set_time`, 'POST', {
131
+ hours,
132
+ minutes,
133
+ });
160
134
  }
161
135
 
162
136
  /**
@@ -174,15 +148,9 @@ export async function mobileNavigateTo(
174
148
  ): Promise<any> {
175
149
  const menuItemIdAsNumber = parseInt(`${menuItemId}`, 10);
176
150
  if (Number.isNaN(menuItemIdAsNumber) || menuItemIdAsNumber < 0) {
177
- throw new errors.InvalidArgumentError(
178
- `'menuItemId' must be a non-negative number. Found ${menuItemId}`,
179
- );
151
+ throw new errors.InvalidArgumentError(`'menuItemId' must be a non-negative number. Found ${menuItemId}`);
180
152
  }
181
- return await this.espresso.jwproxy.command(
182
- `/appium/execute_mobile/${elementId}/navigate_to`,
183
- 'POST',
184
- {menuItemId},
185
- );
153
+ return await this.espresso.jwproxy.command(`/appium/execute_mobile/${elementId}/navigate_to`, 'POST', {menuItemId});
186
154
  }
187
155
 
188
156
  /**
@@ -206,17 +174,13 @@ export async function mobileClickAction(
206
174
  inputDevice?: number,
207
175
  buttonState?: number,
208
176
  ): Promise<any> {
209
- return await this.espresso.jwproxy.command(
210
- `/appium/execute_mobile/${elementId}/click_action`,
211
- 'POST',
212
- {
213
- tapper,
214
- coordinatesProvider,
215
- precisionDescriber,
216
- inputDevice,
217
- buttonState,
218
- },
219
- );
177
+ return await this.espresso.jwproxy.command(`/appium/execute_mobile/${elementId}/click_action`, 'POST', {
178
+ tapper,
179
+ coordinatesProvider,
180
+ precisionDescriber,
181
+ inputDevice,
182
+ buttonState,
183
+ });
220
184
  }
221
185
 
222
186
  /**
@@ -243,23 +207,17 @@ export async function mobileScrollToPage(
243
207
  );
244
208
  }
245
209
  if ((scrollToPage ?? 0) < 0) {
246
- throw new errors.InvalidArgumentError(
247
- `"scrollToPage" must be a non-negative integer. Found '${scrollToPage}'`,
248
- );
210
+ throw new errors.InvalidArgumentError(`"scrollToPage" must be a non-negative integer. Found '${scrollToPage}'`);
249
211
  }
250
212
  if (util.hasValue(scrollTo) && util.hasValue(scrollToPage)) {
251
213
  this.log.warn(`'scrollTo' and 'scrollToPage' where both provided. Defaulting to 'scrollTo'`);
252
214
  }
253
215
 
254
- return await this.espresso.jwproxy.command(
255
- `/appium/execute_mobile/${elementId}/scroll_to_page`,
256
- 'POST',
257
- {
258
- scrollTo,
259
- scrollToPage,
260
- smoothScroll,
261
- },
262
- );
216
+ return await this.espresso.jwproxy.command(`/appium/execute_mobile/${elementId}/scroll_to_page`, 'POST', {
217
+ scrollTo,
218
+ scrollToPage,
219
+ smoothScroll,
220
+ });
263
221
  }
264
222
 
265
223
  /**
@@ -267,9 +225,6 @@ export async function mobileScrollToPage(
267
225
  * @param action - The editor action to perform (can be a string or numeric action code)
268
226
  * @returns Promise that resolves when the editor action is performed
269
227
  */
270
- export async function mobilePerformEditorAction(
271
- this: EspressoDriver,
272
- action: string | number,
273
- ): Promise<void> {
228
+ export async function mobilePerformEditorAction(this: EspressoDriver, action: string | number): Promise<void> {
274
229
  await this.espresso.jwproxy.command('/appium/device/perform_editor_action', 'POST', {action});
275
230
  }
@@ -16,17 +16,10 @@ import type {EspressoDriver} from '../driver.js';
16
16
  * @throws {Error} If there was a failure while parsing options or registering
17
17
  * the actual instances
18
18
  */
19
- export async function mobileRegisterIdlingResources(
20
- this: EspressoDriver,
21
- classNames: string,
22
- ): Promise<any> {
23
- return await this.espresso.jwproxy.command(
24
- '/appium/execute_mobile/register_idling_resources',
25
- 'POST',
26
- {
27
- classNames,
28
- },
29
- );
19
+ export async function mobileRegisterIdlingResources(this: EspressoDriver, classNames: string): Promise<any> {
20
+ return await this.espresso.jwproxy.command('/appium/execute_mobile/register_idling_resources', 'POST', {
21
+ classNames,
22
+ });
30
23
  }
31
24
 
32
25
  /**
@@ -44,17 +37,10 @@ export async function mobileRegisterIdlingResources(
44
37
  * @throws {Error} If there was a failure while parsing options or unregistering
45
38
  * the actual instances
46
39
  */
47
- export async function mobileUnregisterIdlingResources(
48
- this: EspressoDriver,
49
- classNames: string,
50
- ): Promise<any> {
51
- return await this.espresso.jwproxy.command(
52
- '/appium/execute_mobile/unregister_idling_resources',
53
- 'POST',
54
- {
55
- classNames,
56
- },
57
- );
40
+ export async function mobileUnregisterIdlingResources(this: EspressoDriver, classNames: string): Promise<any> {
41
+ return await this.espresso.jwproxy.command('/appium/execute_mobile/unregister_idling_resources', 'POST', {
42
+ classNames,
43
+ });
58
44
  }
59
45
 
60
46
  /**
@@ -64,10 +50,7 @@ export async function mobileUnregisterIdlingResources(
64
50
  * @returns Promise that resolves to the list of fully qualified class names
65
51
  */
66
52
  export async function mobileListIdlingResources(this: EspressoDriver): Promise<string[]> {
67
- return (await this.espresso.jwproxy.command(
68
- '/appium/execute_mobile/list_idling_resources',
69
- 'GET',
70
- )) as string[];
53
+ return (await this.espresso.jwproxy.command('/appium/execute_mobile/list_idling_resources', 'GET')) as string[];
71
54
  }
72
55
 
73
56
  /**
@@ -1,6 +1,7 @@
1
- import {util} from 'appium/support.js';
2
- import {errors} from 'appium/driver.js';
3
1
  import type {StringRecord} from '@appium/types';
2
+ import {errors} from 'appium/driver.js';
3
+ import {util} from 'appium/support.js';
4
+
4
5
  import type {EspressoDriver} from '../driver.js';
5
6
  import type {DeviceInfo} from '../types.js';
6
7
 
@@ -30,15 +31,11 @@ export async function mobilePressKey(
30
31
  flags?: number,
31
32
  isLongPress: boolean = false,
32
33
  ): Promise<void> {
33
- await this.espresso.jwproxy.command(
34
- `/appium/device/${isLongPress ? 'long_' : ''}press_keycode`,
35
- 'POST',
36
- {
37
- keycode,
38
- metastate,
39
- flags,
40
- },
41
- );
34
+ await this.espresso.jwproxy.command(`/appium/device/${isLongPress ? 'long_' : ''}press_keycode`, 'POST', {
35
+ keycode,
36
+ metastate,
37
+ flags,
38
+ });
42
39
  }
43
40
 
44
41
  /**
@@ -58,11 +55,7 @@ export async function mobileGetDeviceInfo(this: EspressoDriver): Promise<DeviceI
58
55
  * @returns Promise that resolves to true if the toast is visible, false otherwise
59
56
  * @throws {errors.InvalidArgumentError} If text is not provided
60
57
  */
61
- export async function mobileIsToastVisible(
62
- this: EspressoDriver,
63
- text: string,
64
- isRegexp?: boolean,
65
- ): Promise<any> {
58
+ export async function mobileIsToastVisible(this: EspressoDriver, text: string, isRegexp?: boolean): Promise<any> {
66
59
  if (!util.hasValue(text)) {
67
60
  throw new errors.InvalidArgumentError(`'text' argument is mandatory`);
68
61
  }
@@ -76,11 +69,7 @@ export async function mobileIsToastVisible(
76
69
  * @returns Promise that resolves to the display density value
77
70
  */
78
71
  export async function getDisplayDensity(this: EspressoDriver): Promise<number> {
79
- return (await this.espresso.jwproxy.command(
80
- '/appium/device/display_density',
81
- 'GET',
82
- {},
83
- )) as number;
72
+ return (await this.espresso.jwproxy.command('/appium/device/display_density', 'GET', {})) as number;
84
73
  }
85
74
 
86
75
  /**
@@ -138,9 +127,7 @@ export async function mobileBackdoor(
138
127
  elementId?: string,
139
128
  ): Promise<any> {
140
129
  if (target === 'element' && !elementId) {
141
- throw new errors.InvalidArgumentError(
142
- `'elementId' is required if 'target' equals to 'element'`,
143
- );
130
+ throw new errors.InvalidArgumentError(`'elementId' is required if 'target' equals to 'element'`);
144
131
  }
145
132
  return await this.espresso.jwproxy.command(`/appium/execute_mobile/backdoor`, 'POST', {
146
133
  target,
@@ -186,10 +173,7 @@ export async function mobileUiautomator(
186
173
  * @returns {Promise<string>} uiautomator DOM xml as string
187
174
  */
188
175
  export async function mobileUiautomatorPageSource(this: EspressoDriver): Promise<string> {
189
- return (await this.espresso.jwproxy.command(
190
- `/appium/execute_mobile/uiautomator_page_source`,
191
- 'GET',
192
- )) as string;
176
+ return (await this.espresso.jwproxy.command(`/appium/execute_mobile/uiautomator_page_source`, 'GET')) as string;
193
177
  }
194
178
 
195
179
  /**
@@ -198,10 +182,7 @@ export async function mobileUiautomatorPageSource(this: EspressoDriver): Promise
198
182
  * @param settings - Settings object containing key-value pairs of settings to apply
199
183
  * @returns Promise that resolves when settings are updated
200
184
  */
201
- export async function updateSettings(
202
- this: EspressoDriver,
203
- settings: SettingsOptions,
204
- ): Promise<void> {
185
+ export async function updateSettings(this: EspressoDriver, settings: SettingsOptions): Promise<void> {
205
186
  await this.settings.update(settings);
206
187
  try {
207
188
  await this.espresso.jwproxy.command(`/appium/settings`, 'POST', {settings});
@@ -216,9 +197,6 @@ export async function updateSettings(
216
197
  */
217
198
  export async function getSettings(this: EspressoDriver): Promise<Record<string, any>> {
218
199
  const driverSettings = this.settings.getSettings();
219
- const serverSettings = (await this.espresso.jwproxy.command(`/appium/settings`, 'GET')) as Record<
220
- string,
221
- any
222
- >;
200
+ const serverSettings = (await this.espresso.jwproxy.command(`/appium/settings`, 'GET')) as Record<string, any>;
223
201
  return {...driverSettings, ...serverSettings};
224
202
  }
@@ -15,10 +15,7 @@ const DISPLAY_PATTERN = /^Display\s+(\d+)\s+\(.+display\s+(\d+)\).+displayName="
15
15
  * and values contain display information and base64-encoded PNG screenshot data
16
16
  * @throws {Error} If display information cannot be determined or if a provided displayId is not found
17
17
  */
18
- export async function mobileScreenshots(
19
- this: EspressoDriver,
20
- displayId?: number | string,
21
- ): Promise<ScreenshotsInfo> {
18
+ export async function mobileScreenshots(this: EspressoDriver, displayId?: number | string): Promise<ScreenshotsInfo> {
22
19
  const displaysInfo = await this.adb.shell(['dumpsys', 'SurfaceFlinger', '--display-id']);
23
20
  const infos: Record<string, {id: string; isDefault: boolean; name: string}> = {};
24
21
  let match;
@@ -1,18 +1,16 @@
1
- import {SubProcess} from 'teen_process';
2
- import {fs, system} from 'appium/support.js';
3
- import path from 'node:path';
4
1
  import {EOL} from 'node:os';
5
- import {escapeRegExp} from '../../utils/index.js';
2
+ import path from 'node:path';
3
+
6
4
  import type {AppiumLogger} from '@appium/types';
5
+ import {fs, system} from 'appium/support.js';
6
+ import {SubProcess} from 'teen_process';
7
+
8
+ import {escapeRegExp} from '../../utils/index.js';
7
9
 
8
10
  const GRADLE_VERSION_KEY = 'gradle';
9
11
  const GRADLE_URL_PREFIX = 'distributionUrl=';
10
- export const GRADLE_URL_TEMPLATE =
11
- 'https\\://services.gradle.org/distributions/gradle-VERSION-all.zip';
12
- const DEPENDENCY_PROP_NAMES = [
13
- 'additionalAppDependencies',
14
- 'additionalAndroidTestDependencies',
15
- ] as const;
12
+ export const GRADLE_URL_TEMPLATE = 'https\\://services.gradle.org/distributions/gradle-VERSION-all.zip';
13
+ const DEPENDENCY_PROP_NAMES = ['additionalAppDependencies', 'additionalAndroidTestDependencies'] as const;
16
14
 
17
15
  export const VERSION_KEYS = [
18
16
  GRADLE_VERSION_KEY,
@@ -114,8 +112,7 @@ export class ServerBuilder {
114
112
 
115
113
  private getCommand(): {cmd: string; args: string[]} {
116
114
  const cmd = system.isWindows() ? 'gradlew.bat' : path.resolve(this.serverPath, 'gradlew');
117
- const buildProperty = (key: string, value?: string): string | null =>
118
- value ? `-P${key}=${value}` : null;
115
+ const buildProperty = (key: string, value?: string): string | null => (value ? `-P${key}=${value}` : null);
119
116
  const args: string[] = VERSION_KEYS.filter((key) => key !== GRADLE_VERSION_KEY)
120
117
  .map((key) => {
121
118
  const serverVersion = this.serverVersions[key];
@@ -157,12 +154,7 @@ export class ServerBuilder {
157
154
  }
158
155
 
159
156
  private async setGradleWrapperVersion(version: string): Promise<void> {
160
- const propertiesPath = path.resolve(
161
- this.serverPath,
162
- 'gradle',
163
- 'wrapper',
164
- 'gradle-wrapper.properties',
165
- );
157
+ const propertiesPath = path.resolve(this.serverPath, 'gradle', 'wrapper', 'gradle-wrapper.properties');
166
158
  const originalProperties = await fs.readFile(propertiesPath, 'utf8');
167
159
  const newProperties = this.updateGradleDistUrl(originalProperties, version);
168
160
  await fs.writeFile(propertiesPath, newProperties, 'utf8');
@@ -204,9 +196,7 @@ export class ServerBuilder {
204
196
  let configuration = await fs.readFile(buildPath, 'utf8');
205
197
  for (const propName of DEPENDENCY_PROP_NAMES) {
206
198
  const prefix = propName === DEPENDENCY_PROP_NAMES[0] ? 'api' : 'androidTestImplementation';
207
- const deps = this[propName]
208
- .filter((line) => line.trim())
209
- .map((line) => `${prefix}("${line}")`);
199
+ const deps = this[propName].filter((line) => line.trim()).map((line) => `${prefix}("${line}")`);
210
200
  if (deps.length === 0) {
211
201
  continue;
212
202
  }
@@ -219,10 +209,7 @@ export class ServerBuilder {
219
209
 
220
210
  private async runBuildProcess(): Promise<void> {
221
211
  const {cmd, args} = this.getCommand();
222
- this.log.debug(
223
- `Beginning build with command '${cmd} ${args.join(' ')}' ` +
224
- `in directory '${this.serverPath}'`,
225
- );
212
+ this.log.debug(`Beginning build with command '${cmd} ${args.join(' ')}' in directory '${this.serverPath}'`);
226
213
  const gradlebuild = new SubProcess(cmd, args, {
227
214
  cwd: this.serverPath,
228
215
  stdio: ['ignore', 'pipe', 'pipe'],
@@ -244,9 +231,7 @@ export class ServerBuilder {
244
231
  await gradlebuild.start();
245
232
  await gradlebuild.join();
246
233
  } catch (err: any) {
247
- const msg =
248
- `Unable to build Espresso server - ${err.message}\n` +
249
- `Gradle error message:${EOL}${gradleError.join('\n')}`;
234
+ const msg = `Unable to build Espresso server - ${err.message}\nGradle error message:${EOL}${gradleError.join('\n')}`;
250
235
  throw this.log.errorWithException(msg);
251
236
  } finally {
252
237
  gradlebuild.removeAllListeners();
@@ -1,28 +1,19 @@
1
- import {JWProxy, errors} from 'appium/driver.js';
2
- import {sleep, waitForCondition} from 'asyncbox';
3
1
  import path from 'node:path';
4
2
  import {fileURLToPath} from 'node:url';
3
+
4
+ import type {AppiumLogger, StringRecord, HTTPMethod, HTTPBody, ProxyResponse, ProxyOptions} from '@appium/types';
5
+ import type {ADB} from 'appium-adb';
6
+ import {JWProxy, errors} from 'appium/driver.js';
5
7
  import {fs, node, util, timing} from 'appium/support.js';
6
- import {getPackageInfoSync, getPackageInfo, isPlainObject} from '../../utils/index.js';
7
- import {ServerBuilder, buildServerSigningConfig, type ServerSigningConfig} from './builder.js';
8
- import {
9
- ESPRESSO_SERVER_LAUNCH_TIMEOUT_MS,
10
- TARGET_PACKAGE_CONTAINER,
11
- TEST_APK_PKG,
12
- } from './constants.js';
8
+ import {sleep, waitForCondition} from 'asyncbox';
13
9
  import axios from 'axios';
14
10
  import * as semver from 'semver';
15
- import type {
16
- AppiumLogger,
17
- StringRecord,
18
- HTTPMethod,
19
- HTTPBody,
20
- ProxyResponse,
21
- ProxyOptions,
22
- } from '@appium/types';
23
- import type {ADB} from 'appium-adb';
24
11
  import type {SubProcess} from 'teen_process';
25
12
 
13
+ import {getPackageInfoSync, getPackageInfo, isPlainObject} from '../../utils/index.js';
14
+ import {ServerBuilder, buildServerSigningConfig, type ServerSigningConfig} from './builder.js';
15
+ import {ESPRESSO_SERVER_LAUNCH_TIMEOUT_MS, TARGET_PACKAGE_CONTAINER, TEST_APK_PKG} from './constants.js';
16
+
26
17
  export interface EspressoRunnerOptions {
27
18
  adb: ADB;
28
19
  tmpDir: string;
@@ -146,13 +137,7 @@ export class EspressoRunner {
146
137
  this.disableSuppressAccessibilityService = opts.disableSuppressAccessibilityService;
147
138
 
148
139
  // Espresso Server app needs to be signed with same keyStore as appPackage
149
- if (
150
- opts.useKeystore &&
151
- opts.keystorePath &&
152
- opts.keystorePassword &&
153
- opts.keyAlias &&
154
- opts.keyPassword
155
- ) {
140
+ if (opts.useKeystore && opts.keystorePath && opts.keystorePassword && opts.keyAlias && opts.keyPassword) {
156
141
  this.signingConfig = buildServerSigningConfig({
157
142
  keystoreFile: opts.keystorePath,
158
143
  keystorePassword: opts.keystorePassword,
@@ -188,13 +173,10 @@ export class EspressoRunner {
188
173
  this.adb.APP_INSTALL_STATE.OLDER_VERSION_INSTALLED,
189
174
  this.adb.APP_INSTALL_STATE.NEWER_VERSION_INSTALLED,
190
175
  ].includes(appState);
191
- const shouldInstallApp =
192
- shouldUninstallApp || [this.adb.APP_INSTALL_STATE.NOT_INSTALLED].includes(appState);
176
+ const shouldInstallApp = shouldUninstallApp || [this.adb.APP_INSTALL_STATE.NOT_INSTALLED].includes(appState);
193
177
 
194
178
  if (shouldUninstallApp) {
195
- this.log.info(
196
- `Uninstalling Espresso Test Server apk from the target device (pkg: '${TEST_APK_PKG}')`,
197
- );
179
+ this.log.info(`Uninstalling Espresso Test Server apk from the target device (pkg: '${TEST_APK_PKG}')`);
198
180
  try {
199
181
  await this.adb.uninstallApk(TEST_APK_PKG);
200
182
  } catch (err: any) {
@@ -203,21 +185,15 @@ export class EspressoRunner {
203
185
  }
204
186
 
205
187
  if (shouldInstallApp) {
206
- this.log.info(
207
- `Installing Espresso Test Server apk from the target device (path: '${this.modServerPath}')`,
208
- );
188
+ this.log.info(`Installing Espresso Test Server apk from the target device (path: '${this.modServerPath}')`);
209
189
  try {
210
190
  await this.adb.install(this.modServerPath, {
211
191
  replace: false,
212
192
  timeout: this.androidInstallTimeout,
213
193
  });
214
- this.log.info(
215
- `Installed Espresso Test Server apk '${this.modServerPath}' (pkg: '${TEST_APK_PKG}')`,
216
- );
194
+ this.log.info(`Installed Espresso Test Server apk '${this.modServerPath}' (pkg: '${TEST_APK_PKG}')`);
217
195
  } catch (err: any) {
218
- throw this.log.errorWithException(
219
- `Cannot install '${this.modServerPath}' because of '${err.message}'`,
220
- );
196
+ throw this.log.errorWithException(`Cannot install '${this.modServerPath}' because of '${err.message}'`);
221
197
  }
222
198
  }
223
199
  }
@@ -275,9 +251,7 @@ export class EspressoRunner {
275
251
  this.log.debug(`The build folder root could be customized by changing the 'tmpDir' capability`);
276
252
  await fs.rimraf(serverPath);
277
253
  await fs.mkdirp(serverPath);
278
- this.log.debug(
279
- `Copying espresso server template from ('${getTestServerRoot()}' to '${serverPath}')`,
280
- );
254
+ this.log.debug(`Copying espresso server template from ('${getTestServerRoot()}' to '${serverPath}')`);
281
255
  await copyGradleProjectRecursively(getTestServerRoot(), serverPath);
282
256
  this.log.debug('Bulding espresso server');
283
257
  await new ServerBuilder(this.log, {
@@ -318,19 +292,13 @@ export class EspressoRunner {
318
292
  ];
319
293
 
320
294
  if (typeof this.disableSuppressAccessibilityService === 'boolean') {
321
- cmd.push(
322
- '-e',
323
- 'DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES',
324
- String(this.disableSuppressAccessibilityService),
325
- );
295
+ cmd.push('-e', 'DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES', String(this.disableSuppressAccessibilityService));
326
296
  }
327
297
 
328
298
  cmd.push(`${TEST_APK_PKG}/androidx.test.runner.AndroidJUnitRunner`);
329
299
 
330
300
  const {manifestPayload} = await getPackageInfo();
331
- this.log.info(
332
- `Starting Espresso Server v${manifestPayload.version} with cmd: adb ${cmd.join(' ')}`,
333
- );
301
+ this.log.info(`Starting Espresso Server v${manifestPayload.version} with cmd: adb ${cmd.join(' ')}`);
334
302
 
335
303
  let hasSocketError = false;
336
304
  // start the instrumentation process
@@ -423,9 +391,7 @@ export class EspressoRunner {
423
391
  try {
424
392
  await this.jwproxy.command('/', 'DELETE');
425
393
  } catch (err: any) {
426
- this.log.warn(
427
- `Did not get confirmation Espresso deleteSession worked; ` + `Error was: ${err}`,
428
- );
394
+ this.log.warn(`Did not get confirmation Espresso deleteSession worked; Error was: ${err}`);
429
395
  }
430
396
 
431
397
  if (this.instProcess?.isRunning) {
@@ -445,9 +411,7 @@ export class EspressoRunner {
445
411
  ).data as SessionsResponse;
446
412
  const activeSessionIds = value.map((sess) => sess.id);
447
413
  if (activeSessionIds.length) {
448
- this.log.debug(
449
- `The following obsolete sessions are still running: ${JSON.stringify(activeSessionIds)}`,
450
- );
414
+ this.log.debug(`The following obsolete sessions are still running: ${JSON.stringify(activeSessionIds)}`);
451
415
  this.log.debug('Cleaning up the obsolete sessions');
452
416
  await Promise.all(
453
417
  activeSessionIds.map((id) =>
@@ -469,15 +433,10 @@ export class EspressoRunner {
469
433
 
470
434
  private async recordTargetAppPackage(): Promise<void> {
471
435
  await this.adb.shell([`echo "${this.appPackage}" > "${TARGET_PACKAGE_CONTAINER}"`]);
472
- this.log.info(
473
- `Recorded the target application package '${this.appPackage}' to ${TARGET_PACKAGE_CONTAINER}`,
474
- );
436
+ this.log.info(`Recorded the target application package '${this.appPackage}' to ${TARGET_PACKAGE_CONTAINER}`);
475
437
  }
476
438
 
477
- private async _verifyServerStatus(
478
- driverVersion: string,
479
- serverStatus: ServerStatus,
480
- ): Promise<boolean> {
439
+ private async _verifyServerStatus(driverVersion: string, serverStatus: ServerStatus): Promise<boolean> {
481
440
  if (!isPlainObject(serverStatus) || !isPlainObject(serverStatus.build)) {
482
441
  throw this.log.errorWithException(
483
442
  `The Espresso server version integrated with the application under test is not compatible ` +
@@ -487,9 +446,7 @@ export class EspressoRunner {
487
446
  const {
488
447
  build: {version: serverVersion, packageName: serverPackageName},
489
448
  } = serverStatus;
490
- const appLabel = serverPackageName
491
- ? `'${serverPackageName}' application`
492
- : 'application under test';
449
+ const appLabel = serverPackageName ? `'${serverPackageName}' application` : 'application under test';
493
450
  const parsedServerVersion = semver.coerce(serverVersion);
494
451
  const parsedDriverVersion = semver.coerce(driverVersion);
495
452
  if (parsedServerVersion && parsedDriverVersion) {
@@ -544,10 +501,7 @@ let testServerRoot: string | undefined;
544
501
  * @param sourceBaseDir directory to copy files from
545
502
  * @param targetBaseDir directory to copy files to
546
503
  */
547
- export async function copyGradleProjectRecursively(
548
- sourceBaseDir: string,
549
- targetBaseDir: string,
550
- ): Promise<void> {
504
+ export async function copyGradleProjectRecursively(sourceBaseDir: string, targetBaseDir: string): Promise<void> {
551
505
  // @ts-ignore it is ok to have the async callback
552
506
  await fs.walkDir(sourceBaseDir, true, async (itemPath: string, isDirectory: boolean) => {
553
507
  const relativePath = path.relative(sourceBaseDir, itemPath);
@@ -99,15 +99,9 @@ export async function startSession(this: EspressoDriver): Promise<void> {
99
99
  // launch espresso and wait till its online and we have a session
100
100
  await this.espresso.startSession(this.caps);
101
101
  if (this.caps.autoLaunch === false) {
102
- this.log.info(
103
- `Not waiting for the application activity to start because 'autoLaunch' is disabled`,
104
- );
102
+ this.log.info(`Not waiting for the application activity to start because 'autoLaunch' is disabled`);
105
103
  } else {
106
- await this.adb.waitForActivity(
107
- appWaitPackage,
108
- this.caps.appWaitActivity,
109
- this.opts.appWaitDuration,
110
- );
104
+ await this.adb.waitForActivity(appWaitPackage, this.caps.appWaitActivity, this.opts.appWaitDuration);
111
105
  }
112
106
  // if we want to immediately get into a webview, set our context
113
107
  // appropriately
@@ -39,11 +39,7 @@ export async function mobileStartService(
39
39
  * @throws {Error} If there was a failure while stopping the service
40
40
  * or required options are missing
41
41
  */
42
- export async function mobileStopService(
43
- this: EspressoDriver,
44
- intent: string,
45
- user?: string | number,
46
- ): Promise<string> {
42
+ export async function mobileStopService(this: EspressoDriver, intent: string, user?: string | number): Promise<string> {
47
43
  return (await this.espresso.jwproxy.command('/appium/execute_mobile/stop_service', 'POST', {
48
44
  intent,
49
45
  user,