appium-uiautomator2-driver 3.9.5 → 3.9.7

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.
@@ -76,7 +76,6 @@ export async function performActions(actions) {
76
76
  * @this {AndroidUiautomator2Driver}
77
77
  * @returns {Promise<void>}
78
78
  */
79
- // eslint-disable-next-line require-await
80
79
  export async function releaseActions() {
81
80
  this.log.info('On this platform, releaseActions is a no-op');
82
81
  }
package/lib/driver.ts CHANGED
@@ -10,7 +10,7 @@ import type {
10
10
  StringRecord,
11
11
  } from '@appium/types';
12
12
  import {DEFAULT_ADB_PORT} from 'appium-adb';
13
- import AndroidDriver, {utils} from 'appium-android-driver';
13
+ import {AndroidDriver, utils} from 'appium-android-driver';
14
14
  import {SETTINGS_HELPER_ID} from 'io.appium.settings';
15
15
  import {BaseDriver, DeviceSettings} from 'appium/driver';
16
16
  import {fs, mjpeg, util} from 'appium/support';
@@ -481,7 +481,7 @@ class AndroidUiautomator2Driver
481
481
  const [startPort, endPort] = DEVICE_PORT_RANGE;
482
482
  try {
483
483
  this.systemPort = await findAPortNotInUse(startPort, endPort);
484
- } catch (e) {
484
+ } catch {
485
485
  throw this.log.errorWithException(
486
486
  `Cannot find any free port in range ${startPort}..${endPort}}. ` +
487
487
  `Please set the available port number by providing the systemPort capability or ` +
@@ -671,9 +671,13 @@ class AndroidUiautomator2Driver
671
671
  ...caps,
672
672
  ...sessionInfo,
673
673
  };
674
- // Adding AUT package name in the capabilities if package name not exist in caps
675
- if (!capsWithSessionInfo.appPackage && appInfo) {
676
- capsWithSessionInfo.appPackage = appInfo.appPackage;
674
+ // Adding AUT info in the capabilities if it does not exist in caps
675
+ if (appInfo) {
676
+ for (const capName of ['appPackage', 'appActivity']) {
677
+ if (!capsWithSessionInfo[capName] && appInfo[capName]) {
678
+ capsWithSessionInfo[capName] = appInfo[capName];
679
+ }
680
+ }
677
681
  }
678
682
 
679
683
  await this.performSessionExecution(capsWithSessionInfo);
@@ -874,7 +878,7 @@ class AndroidUiautomator2Driver
874
878
  (async () => {
875
879
  try {
876
880
  await task();
877
- } catch (ign) {}
881
+ } catch {}
878
882
  })();
879
883
  })
880
884
  );
package/lib/helpers.js CHANGED
@@ -16,7 +16,7 @@ export async function isWriteable(filePath) {
16
16
  await fs.close(await fs.open(filePath, 'r+'));
17
17
  }
18
18
  return true;
19
- } catch (ign) {
19
+ } catch {
20
20
  return false;
21
21
  }
22
22
  }
@@ -226,7 +226,6 @@ class UiAutomator2Server {
226
226
  } else if (pmOutput.includes(INSTRUMENTATION_TARGET)) {
227
227
  pmOutput = ''; // remove output, so it is not printed below
228
228
  this.log.debug(`Instrumentation target '${INSTRUMENTATION_TARGET}' is available`);
229
- // eslint-disable-next-line require-atomic-updates
230
229
  isPmServiceAvailable = true;
231
230
  } else if (!pmError) {
232
231
  pmError = new Error('The instrumentation target is not listed by Package Manager');
@@ -237,7 +236,7 @@ class UiAutomator2Server {
237
236
  waitMs: SERVICES_LAUNCH_TIMEOUT,
238
237
  intervalMs: 1000,
239
238
  });
240
- } catch (err) {
239
+ } catch {
241
240
  // @ts-ignore It is ok if the attribute does not exist
242
241
  this.log.error(`Unable to find instrumentation target '${INSTRUMENTATION_TARGET}': ${(pmError || {}).message}`);
243
242
  if (pmOutput) {
@@ -268,7 +267,7 @@ class UiAutomator2Server {
268
267
  this.jwproxy.didInstrumentationExit = false;
269
268
  try {
270
269
  await this.stopInstrumentationProcess();
271
- } catch (ign) {}
270
+ } catch {}
272
271
  await this.startInstrumentationProcess();
273
272
  if (!this.jwproxy.didInstrumentationExit) {
274
273
  try {
@@ -276,7 +275,7 @@ class UiAutomator2Server {
276
275
  try {
277
276
  await this.jwproxy.command('/status', 'GET');
278
277
  return true;
279
- } catch (err) {
278
+ } catch {
280
279
  // short circuit to retry or fail fast
281
280
  return this.jwproxy.didInstrumentationExit;
282
281
  }
@@ -284,7 +283,7 @@ class UiAutomator2Server {
284
283
  waitMs: timeout,
285
284
  intervalMs: 1000,
286
285
  });
287
- } catch (err) {
286
+ } catch {
288
287
  throw this.log.errorWithException(
289
288
  `The instrumentation process cannot be initialized within ${timeout}ms timeout. `
290
289
  + 'Make sure the application under test does not crash and investigate the logcat output. '
@@ -391,14 +390,14 @@ class UiAutomator2Server {
391
390
  url: `http://${this.host}:${this.systemPort}/status`,
392
391
  timeout: axiosTimeout,
393
392
  });
394
- } catch (err) {
393
+ } catch {
395
394
  return true;
396
395
  }
397
396
  }, {
398
397
  waitMs: timeout,
399
398
  intervalMs: 100,
400
399
  });
401
- } catch (err) {
400
+ } catch {
402
401
  this.log.warn(`The ${SERVER_TEST_PACKAGE_ID} process might fail to stop within ${timeout}ms timeout.`);
403
402
  }
404
403
  };
@@ -429,12 +428,12 @@ class UiAutomator2Server {
429
428
  this.adb.forceStop(SERVER_PACKAGE_ID),
430
429
  this.adb.forceStop(SERVER_TEST_PACKAGE_ID)
431
430
  ]);
432
- } catch (ignore) {}
431
+ } catch {}
433
432
  if (strictCleanup) {
434
433
  // https://github.com/appium/appium/issues/10749
435
434
  try {
436
435
  await this.adb.killProcessesByName('uiautomator');
437
- } catch (ignore) {}
436
+ } catch {}
438
437
  }
439
438
  await waitStop();
440
439
  }