appium-xcuitest-driver 7.7.1 → 7.8.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.
Files changed (134) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/lib/app-utils.d.ts.map +1 -1
  3. package/build/lib/app-utils.js +1 -2
  4. package/build/lib/app-utils.js.map +1 -1
  5. package/build/lib/commands/activeAppInfo.d.ts +1 -1
  6. package/build/lib/commands/activeAppInfo.d.ts.map +1 -1
  7. package/build/lib/commands/alert.d.ts +6 -6
  8. package/build/lib/commands/alert.d.ts.map +1 -1
  9. package/build/lib/commands/app-management.d.ts +13 -13
  10. package/build/lib/commands/app-management.d.ts.map +1 -1
  11. package/build/lib/commands/app-management.js +9 -6
  12. package/build/lib/commands/app-management.js.map +1 -1
  13. package/build/lib/commands/app-strings.d.ts +1 -1
  14. package/build/lib/commands/app-strings.d.ts.map +1 -1
  15. package/build/lib/commands/appearance.d.ts +2 -2
  16. package/build/lib/commands/appearance.d.ts.map +1 -1
  17. package/build/lib/commands/appearance.js +2 -4
  18. package/build/lib/commands/appearance.js.map +1 -1
  19. package/build/lib/commands/audit.d.ts +1 -1
  20. package/build/lib/commands/audit.d.ts.map +1 -1
  21. package/build/lib/commands/battery.d.ts +1 -1
  22. package/build/lib/commands/battery.d.ts.map +1 -1
  23. package/build/lib/commands/biometric.d.ts +3 -3
  24. package/build/lib/commands/biometric.d.ts.map +1 -1
  25. package/build/lib/commands/certificate.d.ts +2 -2
  26. package/build/lib/commands/certificate.d.ts.map +1 -1
  27. package/build/lib/commands/certificate.js +1 -2
  28. package/build/lib/commands/certificate.js.map +1 -1
  29. package/build/lib/commands/clipboard.d.ts +2 -2
  30. package/build/lib/commands/clipboard.d.ts.map +1 -1
  31. package/build/lib/commands/condition.d.ts +3 -3
  32. package/build/lib/commands/condition.d.ts.map +1 -1
  33. package/build/lib/commands/context.d.ts +20 -20
  34. package/build/lib/commands/context.d.ts.map +1 -1
  35. package/build/lib/commands/context.js +1 -2
  36. package/build/lib/commands/context.js.map +1 -1
  37. package/build/lib/commands/deviceInfo.d.ts +1 -1
  38. package/build/lib/commands/deviceInfo.d.ts.map +1 -1
  39. package/build/lib/commands/element.d.ts +18 -18
  40. package/build/lib/commands/element.d.ts.map +1 -1
  41. package/build/lib/commands/file-movement.d.ts +8 -8
  42. package/build/lib/commands/file-movement.d.ts.map +1 -1
  43. package/build/lib/commands/find.d.ts +4 -4
  44. package/build/lib/commands/find.d.ts.map +1 -1
  45. package/build/lib/commands/general.d.ts +19 -19
  46. package/build/lib/commands/general.d.ts.map +1 -1
  47. package/build/lib/commands/geolocation.d.ts +3 -3
  48. package/build/lib/commands/geolocation.d.ts.map +1 -1
  49. package/build/lib/commands/gesture.d.ts +19 -19
  50. package/build/lib/commands/gesture.d.ts.map +1 -1
  51. package/build/lib/commands/iohid.d.ts +1 -1
  52. package/build/lib/commands/keyboard.d.ts +4 -4
  53. package/build/lib/commands/keyboard.d.ts.map +1 -1
  54. package/build/lib/commands/keychains.d.ts +1 -1
  55. package/build/lib/commands/keychains.d.ts.map +1 -1
  56. package/build/lib/commands/localization.d.ts +1 -1
  57. package/build/lib/commands/localization.d.ts.map +1 -1
  58. package/build/lib/commands/location.d.ts +3 -3
  59. package/build/lib/commands/location.d.ts.map +1 -1
  60. package/build/lib/commands/lock.d.ts +3 -3
  61. package/build/lib/commands/lock.d.ts.map +1 -1
  62. package/build/lib/commands/log.d.ts +4 -4
  63. package/build/lib/commands/log.d.ts.map +1 -1
  64. package/build/lib/commands/memory.d.ts +1 -1
  65. package/build/lib/commands/memory.d.ts.map +1 -1
  66. package/build/lib/commands/memory.js +1 -2
  67. package/build/lib/commands/memory.js.map +1 -1
  68. package/build/lib/commands/navigation.d.ts +5 -5
  69. package/build/lib/commands/navigation.d.ts.map +1 -1
  70. package/build/lib/commands/notifications.d.ts +2 -2
  71. package/build/lib/commands/notifications.d.ts.map +1 -1
  72. package/build/lib/commands/pasteboard.d.ts +2 -2
  73. package/build/lib/commands/pasteboard.d.ts.map +1 -1
  74. package/build/lib/commands/pcap.d.ts +2 -2
  75. package/build/lib/commands/pcap.d.ts.map +1 -1
  76. package/build/lib/commands/performance.d.ts +2 -2
  77. package/build/lib/commands/performance.d.ts.map +1 -1
  78. package/build/lib/commands/permissions.d.ts +3 -3
  79. package/build/lib/commands/permissions.d.ts.map +1 -1
  80. package/build/lib/commands/proxy-helper.d.ts +1 -1
  81. package/build/lib/commands/proxy-helper.d.ts.map +1 -1
  82. package/build/lib/commands/record-audio.d.ts +2 -2
  83. package/build/lib/commands/record-audio.d.ts.map +1 -1
  84. package/build/lib/commands/recordscreen.d.ts +2 -2
  85. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  86. package/build/lib/commands/screenshots.d.ts +3 -3
  87. package/build/lib/commands/screenshots.d.ts.map +1 -1
  88. package/build/lib/commands/source.d.ts +2 -2
  89. package/build/lib/commands/source.d.ts.map +1 -1
  90. package/build/lib/commands/timeouts.d.ts +7 -7
  91. package/build/lib/commands/timeouts.d.ts.map +1 -1
  92. package/build/lib/commands/web.d.ts +32 -32
  93. package/build/lib/commands/web.d.ts.map +1 -1
  94. package/build/lib/commands/web.js +5 -10
  95. package/build/lib/commands/web.js.map +1 -1
  96. package/build/lib/commands/xctest-record-screen.d.ts +2 -2
  97. package/build/lib/commands/xctest-record-screen.d.ts.map +1 -1
  98. package/build/lib/commands/xctest.d.ts +4 -4
  99. package/build/lib/commands/xctest.d.ts.map +1 -1
  100. package/build/lib/css-converter.d.ts.map +1 -1
  101. package/build/lib/css-converter.js +5 -15
  102. package/build/lib/css-converter.js.map +1 -1
  103. package/build/lib/desired-caps.d.ts +8 -0
  104. package/build/lib/desired-caps.d.ts.map +1 -1
  105. package/build/lib/desired-caps.js +6 -0
  106. package/build/lib/desired-caps.js.map +1 -1
  107. package/build/lib/driver.d.ts +63 -65
  108. package/build/lib/driver.d.ts.map +1 -1
  109. package/build/lib/driver.js +48 -66
  110. package/build/lib/driver.js.map +1 -1
  111. package/build/lib/real-device-management.d.ts +4 -4
  112. package/build/lib/real-device-management.d.ts.map +1 -1
  113. package/build/lib/simulator-management.d.ts +8 -8
  114. package/build/lib/simulator-management.d.ts.map +1 -1
  115. package/build/lib/types.d.ts +0 -18
  116. package/build/lib/types.d.ts.map +1 -1
  117. package/build/lib/utils.d.ts +4 -1
  118. package/build/lib/utils.d.ts.map +1 -1
  119. package/build/lib/utils.js +4 -1
  120. package/build/lib/utils.js.map +1 -1
  121. package/lib/app-utils.js +1 -2
  122. package/lib/commands/app-management.js +9 -7
  123. package/lib/commands/appearance.js +2 -4
  124. package/lib/commands/certificate.js +1 -2
  125. package/lib/commands/context.js +2 -2
  126. package/lib/commands/memory.js +1 -2
  127. package/lib/commands/web.js +3 -7
  128. package/lib/css-converter.js +17 -15
  129. package/lib/desired-caps.js +6 -0
  130. package/lib/driver.js +57 -67
  131. package/lib/types.ts +0 -19
  132. package/lib/utils.js +4 -1
  133. package/npm-shrinkwrap.json +6 -6
  134. package/package.json +2 -2
@@ -390,8 +390,7 @@ export default {
390
390
  }
391
391
 
392
392
  let isCertAlreadyInstalled = false;
393
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
394
- if (util.compareVersions(this.opts.platformVersion, '>=', '12.2')) {
393
+ if (util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '>=', '12.2')) {
395
394
  if (await installPost122Certificate(this, cn)) {
396
395
  await clickElement(this, Settings.Profile);
397
396
  await trustCertificateInPreferences(this, cn);
@@ -49,9 +49,9 @@ const extensions = {
49
49
  * @this {XCUITestDriver}
50
50
  */
51
51
  useNewSafari() {
52
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
53
- return !this.isRealDevice() && this.opts.safari;
52
+ return this.isSimulator() && this.isSafari();
54
53
  },
54
+
55
55
  /**
56
56
  * @this {XCUITestDriver}
57
57
  */
@@ -1,6 +1,5 @@
1
1
  import _ from 'lodash';
2
2
  import { errors } from 'appium/driver';
3
- import RealDevice from '../real-device';
4
3
 
5
4
  export default {
6
5
  /**
@@ -16,7 +15,7 @@ export default {
16
15
  throw new Error('Memory warning simulation is only supported on real devices');
17
16
  }
18
17
 
19
- const device = /** @type {RealDevice} */ (this.device);
18
+ const device = /** @type {import('../real-device').RealDevice} */ (this.device);
20
19
 
21
20
  /** @type {import('../devicectl').AppInfo[]} */
22
21
  const appInfos = await device.devicectl.listApps(bundleId);
@@ -523,8 +523,7 @@ const extensions = {
523
523
  const {
524
524
  nativeWebTapTabBarVisibility,
525
525
  nativeWebTapSmartAppBannerVisibility,
526
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
527
- safariTabBarPosition = util.compareVersions(this.opts.platformVersion, '>=', '15.0') &&
526
+ safariTabBarPosition = util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '>=', '15.0') &&
528
527
  isIphone
529
528
  ? TAB_BAR_POSITION_BOTTOM
530
529
  : TAB_BAR_POSITION_TOP,
@@ -551,8 +550,7 @@ const extensions = {
551
550
  const orientation = realDims.h > realDims.w ? 'PORTRAIT' : 'LANDSCAPE';
552
551
 
553
552
  const notchOffset = isNotched
554
- ? // @ts-expect-error - do not assign arbitrary properties to `this.opts`
555
- util.compareVersions(this.opts.platformVersion, '=', '13.0')
553
+ ? util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '=', '13.0')
556
554
  ? IPHONE_X_NOTCH_OFFSET_IOS_13
557
555
  : IPHONE_X_NOTCH_OFFSET_IOS
558
556
  : 0;
@@ -945,9 +943,7 @@ const extensions = {
945
943
  // restore the previous url
946
944
  await this.setUrl(currentUrl);
947
945
  }
948
- /** @type {import('../types').CalibrationData} */
949
- // @ts-ignore this.webviewCalibrationResult is always defined here
950
- const result = this.webviewCalibrationResult;
946
+ const result = /** @type {import('../types').CalibrationData} */ (this.webviewCalibrationResult);
951
947
  return {
952
948
  ...result,
953
949
  offsetX: Math.round(result.offsetX),
@@ -210,18 +210,19 @@ function parseCssRule(cssRule) {
210
210
  }
211
211
 
212
212
  let iosClassChainSelector = '';
213
- /** @type {import('css-selector-parser').AstClassName[]} */
214
- // @ts-ignore This should work
215
- const astClassNames = cssRule.items.filter(({type}) => type === 'ClassName');
213
+ const astClassNames = /** @type {import('css-selector-parser').AstClassName[]} */ (
214
+ cssRule.items.filter(({type}) => type === 'ClassName')
215
+ );
216
216
  const classNames = astClassNames.map(({name}) => name);
217
217
  if (classNames.length) {
218
218
  throw new errors.InvalidSelectorError(`'${[cssRule || '', ...classNames].join('.')}'
219
219
  is not a valid ios class. Must be a single string (e.g.: XCUIElementTypeWindow) without
220
220
  dots separating them`);
221
221
  }
222
- /** @type {import('css-selector-parser').AstTagName|undefined} */
223
- // @ts-ignore This should work
224
- const astTag = cssRule.items.find(({type}) => type === 'TagName');
222
+
223
+ const astTag = /** @type {import('css-selector-parser').AstTagName|undefined} */ (
224
+ cssRule.items.find(({type}) => type === 'TagName')
225
+ );
225
226
  let tagName = astTag?.name ?? '';
226
227
  if (tagName && tagName !== '*' && !_.startsWith(_.toLower(tagName), 'xcuielementtype')) {
227
228
  const capitalizedTagName = tagName.charAt(0).toUpperCase() + tagName.slice(1);
@@ -231,22 +232,23 @@ function parseCssRule(cssRule) {
231
232
 
232
233
  /** @type {(string|{index: string|undefined}|undefined)[]} */
233
234
  const attrs = [];
234
- /** @type {import('css-selector-parser').AstId[]} */
235
- // @ts-ignore This should work
236
- const astIds = cssRule.items.filter(({type}) => type === 'Id');
235
+
236
+ const astIds = /** @type {import('css-selector-parser').AstId[]} */ (
237
+ cssRule.items.filter(({type}) => type === 'Id')
238
+ );
237
239
  const ids = astIds.map(({name}) => name);
238
240
  if (ids.length) {
239
241
  attrs.push(`name == "${ids[0]}"`);
240
242
  }
241
- /** @type {import('css-selector-parser').AstAttribute[]} */
242
- // @ts-ignore This should work
243
- const attributes = cssRule.items.filter(({type}) => type === 'Attribute');
243
+ const attributes = /** @type {import('css-selector-parser').AstAttribute[]} */ (
244
+ cssRule.items.filter(({type}) => type === 'Attribute')
245
+ );
244
246
  for (const attr of attributes) {
245
247
  attrs.push(parseAttr(attr));
246
248
  }
247
- /** @type {import('css-selector-parser').AstPseudoClass[]} */
248
- // @ts-ignore This should work
249
- const pseudoClasses = cssRule.items.filter(({type}) => type === 'PseudoClass');
249
+ const pseudoClasses = /** @type {import('css-selector-parser').AstPseudoClass[]} */ (
250
+ cssRule.items.filter(({type}) => type === 'PseudoClass')
251
+ );
250
252
  for (const pseudo of pseudoClasses) {
251
253
  attrs.push(parsePseudo(pseudo));
252
254
  }
@@ -364,6 +364,12 @@ const desiredCapConstraints = /** @type {const} */ ({
364
364
  skipSyncUiDialogTranslation: {
365
365
  isBoolean: true,
366
366
  },
367
+ forceSimulatorSoftwareKeyboardPresence: {
368
+ isBoolean: true,
369
+ },
370
+ appLaunchStateTimeoutSec: {
371
+ isNumber: true,
372
+ }
367
373
  });
368
374
 
369
375
  export {desiredCapConstraints, PLATFORM_NAME_IOS, PLATFORM_NAME_TVOS};
package/lib/driver.js CHANGED
@@ -181,7 +181,7 @@ const BUNDLE_VERSION_PATTERN = /CFBundleVersion\s+=\s+"?([^(;|")]+)/;
181
181
  * @privateRemarks **This class should be considered "final"**. It cannot be extended
182
182
  * due to use of public class field assignments. If extending this class becomes a hard requirement, refer to the implementation of `BaseDriver` on how to do so.
183
183
  */
184
- class XCUITestDriver extends BaseDriver {
184
+ export class XCUITestDriver extends BaseDriver {
185
185
  static newMethodMap = newMethodMap;
186
186
 
187
187
  static executeMethodMap = executeMethodMap;
@@ -256,6 +256,12 @@ class XCUITestDriver extends BaseDriver {
256
256
  /** @type {import('./commands/pcap').TrafficCapture|null} */
257
257
  _trafficCapture;
258
258
 
259
+ /** @type {Simulator|RealDevice} */
260
+ _device;
261
+
262
+ /** @type {string|null} */
263
+ _iosSdkVersion;
264
+
259
265
  /**
260
266
  *
261
267
  * @param {XCUITestDriverOpts} opts
@@ -323,8 +329,6 @@ class XCUITestDriver extends BaseDriver {
323
329
  resetIos() {
324
330
  this.opts = this.opts || {};
325
331
  this.wda = null;
326
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
327
- this.opts.device = null;
328
332
  this.jwpProxyActive = false;
329
333
  this.proxyReqRes = null;
330
334
  this.safari = false;
@@ -388,8 +392,7 @@ class XCUITestDriver extends BaseDriver {
388
392
  * @returns {Simulator|RealDevice}
389
393
  */
390
394
  get device() {
391
- // @ts-ignore This property should exist
392
- return this.opts?.device;
395
+ return this._device;
393
396
  }
394
397
 
395
398
  isXcodebuildNeeded() {
@@ -399,8 +402,6 @@ class XCUITestDriver extends BaseDriver {
399
402
  async createSession(w3cCaps1, w3cCaps2, w3cCaps3, driverData) {
400
403
  try {
401
404
  let [sessionId, caps] = await super.createSession(w3cCaps1, w3cCaps2, w3cCaps3, driverData);
402
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
403
- this.opts.sessionId = sessionId;
404
405
 
405
406
  // merge cli args to opts, and if we did merge any, revalidate opts to ensure the final set
406
407
  // is also consistent
@@ -432,20 +433,16 @@ class XCUITestDriver extends BaseDriver {
432
433
  elementResponseAttributes: DEFAULT_SETTINGS.elementResponseAttributes,
433
434
  shouldUseCompactResponses: DEFAULT_SETTINGS.shouldUseCompactResponses,
434
435
  };
435
- if (_.has(this.opts, 'elementResponseAttributes')) {
436
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
436
+ if ('elementResponseAttributes' in this.opts && _.isString(this.opts.elementResponseAttributes)) {
437
437
  wdaSettings.elementResponseAttributes = this.opts.elementResponseAttributes;
438
438
  }
439
- if (_.has(this.opts, 'shouldUseCompactResponses')) {
440
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
439
+ if ('shouldUseCompactResponses' in this.opts && _.isBoolean(this.opts.shouldUseCompactResponses)) {
441
440
  wdaSettings.shouldUseCompactResponses = this.opts.shouldUseCompactResponses;
442
441
  }
443
- if (_.has(this.opts, 'mjpegServerScreenshotQuality')) {
444
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
442
+ if ('mjpegServerScreenshotQuality' in this.opts && _.isNumber(this.opts.mjpegServerScreenshotQuality)) {
445
443
  wdaSettings.mjpegServerScreenshotQuality = this.opts.mjpegServerScreenshotQuality;
446
444
  }
447
- if (_.has(this.opts, 'mjpegServerFramerate')) {
448
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
445
+ if ('mjpegServerFramerate' in this.opts && _.isNumber(this.opts.mjpegServerFramerate)) {
449
446
  wdaSettings.mjpegServerFramerate = this.opts.mjpegServerFramerate;
450
447
  }
451
448
  if (_.has(this.opts, 'screenshotQuality')) {
@@ -486,18 +483,13 @@ class XCUITestDriver extends BaseDriver {
486
483
  this.opts.fullReset = !!this.opts.fullReset;
487
484
 
488
485
  await printUser();
489
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
490
- this.opts.iosSdkVersion = null; // For WDA and xcodebuild
486
+ this._iosSdkVersion = null; // For WDA and xcodebuild
491
487
  const {device, udid, realDevice} = await this.determineDevice();
492
488
  this.log.info(
493
489
  `Determining device to run tests on: udid: '${udid}', real device: ${realDevice}`,
494
490
  );
495
- // TODO: extract device out of opts to a separate driver property
496
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
497
- this.opts.device = device;
491
+ this._device = device;
498
492
  this.opts.udid = udid;
499
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
500
- this.opts.realDevice = realDevice;
501
493
 
502
494
  if (this.opts.simulatorDevicesSetPath) {
503
495
  if (realDevice) {
@@ -528,8 +520,7 @@ class XCUITestDriver extends BaseDriver {
528
520
  this.opts.platformVersion = normalizedVersion;
529
521
  }
530
522
 
531
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
532
- if (_.isEmpty(this.xcodeVersion) && (this.isXcodebuildNeeded() || !this.opts.realDevice)) {
523
+ if (_.isEmpty(this.xcodeVersion) && (this.isXcodebuildNeeded() || this.isSimulator())) {
533
524
  // no `webDriverAgentUrl`, or on a simulator, so we need an Xcode version
534
525
  this.xcodeVersion = await getAndCheckXcodeVersion();
535
526
  }
@@ -561,7 +552,12 @@ class XCUITestDriver extends BaseDriver {
561
552
 
562
553
  this.wda = new WebDriverAgent(
563
554
  /** @type {import('appium-xcode').XcodeVersion} */ (this.xcodeVersion),
564
- this.opts,
555
+ {
556
+ ...this.opts,
557
+ device: this.device,
558
+ realDevice: this.isRealDevice(),
559
+ iosSdkVersion: this._iosSdkVersion,
560
+ },
565
561
  this.log,
566
562
  );
567
563
  // Derived data path retrieval is an expensive operation
@@ -635,8 +631,7 @@ class XCUITestDriver extends BaseDriver {
635
631
  }
636
632
  }
637
633
 
638
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
639
- await this.startWda(this.opts.sessionId);
634
+ await this.startWda();
640
635
 
641
636
  if (_.isString(this.opts.orientation)) {
642
637
  await this.setInitialOrientation(this.opts.orientation);
@@ -715,9 +710,8 @@ class XCUITestDriver extends BaseDriver {
715
710
 
716
711
  /**
717
712
  * Start WebDriverAgentRunner
718
- * @param {string} sessionId - The id of the target session to launch WDA with.
719
713
  */
720
- async startWda(sessionId) {
714
+ async startWda() {
721
715
  // Don't cleanup the processes if webDriverAgentUrl is set
722
716
  if (!util.hasValue(this.wda.webDriverAgentUrl)) {
723
717
  await this.wda.cleanupObsoleteProcesses();
@@ -824,7 +818,7 @@ class XCUITestDriver extends BaseDriver {
824
818
  await this.preparePreinstalledWda();
825
819
  }
826
820
 
827
- this.cachedWdaStatus = await this.wda.launch(sessionId);
821
+ this.cachedWdaStatus = await this.wda.launch(/** @type {string} */ (this.sessionId));
828
822
  } catch (err) {
829
823
  this.logEvent('wdaStartFailed');
830
824
  this.log.debug(err.stack);
@@ -1170,16 +1164,14 @@ class XCUITestDriver extends BaseDriver {
1170
1164
  this.opts.deviceName = translateDeviceName(this.opts.platformVersion, this.opts.deviceName);
1171
1165
 
1172
1166
  const setupVersionCaps = async () => {
1173
- const iosSdkVersion = await getAndCheckIosSdkVersion();
1174
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
1175
- this.opts.iosSdkVersion = iosSdkVersion;
1176
- this.log.info(`iOS SDK Version set to '${iosSdkVersion}'`);
1177
- if (!this.opts.platformVersion && iosSdkVersion) {
1167
+ this._iosSdkVersion = await getAndCheckIosSdkVersion();
1168
+ this.log.info(`iOS SDK Version set to '${this._iosSdkVersion}'`);
1169
+ if (!this.opts.platformVersion && this._iosSdkVersion) {
1178
1170
  this.log.info(
1179
- `No platformVersion specified. Using the latest version Xcode supports: '${iosSdkVersion}'. ` +
1171
+ `No platformVersion specified. Using the latest version Xcode supports: '${this._iosSdkVersion}'. ` +
1180
1172
  `This may cause problems if a simulator does not exist for this platform version.`,
1181
1173
  );
1182
- this.opts.platformVersion = normalizePlatformVersion(iosSdkVersion);
1174
+ this.opts.platformVersion = normalizePlatformVersion(this._iosSdkVersion);
1183
1175
  }
1184
1176
  };
1185
1177
 
@@ -1355,9 +1347,9 @@ class XCUITestDriver extends BaseDriver {
1355
1347
  disableAutomaticScreenshots: this.opts.disableAutomaticScreenshots,
1356
1348
  shouldTerminateApp: this.opts.shouldTerminateApp ?? true,
1357
1349
  forceAppLaunch: this.opts.forceAppLaunch ?? true,
1350
+ appLaunchStateTimeoutSec: this.opts.appLaunchStateTimeoutSec,
1358
1351
  useNativeCachingStrategy: this.opts.useNativeCachingStrategy ?? true,
1359
1352
  forceSimulatorSoftwareKeyboardPresence:
1360
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
1361
1353
  this.opts.forceSimulatorSoftwareKeyboardPresence ??
1362
1354
  (this.opts.connectHardwareKeyboard === true ? false : true),
1363
1355
  });
@@ -1397,29 +1389,35 @@ class XCUITestDriver extends BaseDriver {
1397
1389
  return true;
1398
1390
  }
1399
1391
 
1392
+ /**
1393
+ * @returns {boolean}
1394
+ */
1400
1395
  isSafari() {
1401
1396
  return !!this.safari;
1402
1397
  }
1398
+
1403
1399
  /**
1404
- *
1405
1400
  * @returns {boolean}
1406
1401
  */
1407
1402
  isRealDevice() {
1408
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
1409
- return Boolean(this.opts.realDevice);
1403
+ return 'devicectl' in (this.device ?? {});
1410
1404
  }
1411
1405
 
1406
+ /**
1407
+ * @returns {boolean}
1408
+ */
1412
1409
  isSimulator() {
1413
- // @ts-expect-error - do not assign arbitrary properties to `this.opts`
1414
- return !this.opts.realDevice;
1410
+ return 'simctl' in (this.device ?? {});
1415
1411
  }
1416
1412
 
1413
+ /**
1414
+ * @param {string} strategy
1415
+ */
1417
1416
  validateLocatorStrategy(strategy) {
1418
1417
  super.validateLocatorStrategy(strategy, this.isWebContext());
1419
1418
  }
1420
1419
 
1421
1420
  /**
1422
- *
1423
1421
  * @param {any} caps
1424
1422
  * @returns {caps is import('@appium/types').DriverCaps<XCUITestDriverConstraints>}
1425
1423
  */
@@ -1556,22 +1554,6 @@ class XCUITestDriver extends BaseDriver {
1556
1554
  return true;
1557
1555
  }
1558
1556
 
1559
- /**
1560
- * @typedef {Object} AutInstallationStateOptions
1561
- * @property {Pick<XCUITestDriverOpts, "enforceAppInstall">} enforceAppInstall
1562
- * @property {Pick<XCUITestDriverOpts, "fullReset">} fullReset
1563
- * @property {Pick<XCUITestDriverOpts, "noReset">} noReset
1564
- * @property {Pick<XCUITestDriverOpts, "bundleId">} bundleId
1565
- * @property {Pick<XCUITestDriverOpts, "app">} app
1566
- * @property {Object} device - Real device object or simulator object
1567
- */
1568
-
1569
- /**
1570
- * @typedef {Object} AutInstallationState
1571
- * @property {boolean} install - If the given app should install, or not need to install.
1572
- * @property {boolean} skipUninstall - If the installed app should be uninstalled, or not.
1573
- * /
1574
-
1575
1557
  /**
1576
1558
  * Check if the given app can be installed, or should uninstall before installing it.
1577
1559
  *
@@ -1579,10 +1561,9 @@ class XCUITestDriver extends BaseDriver {
1579
1561
  * @returns {Promise<AutInstallationState>}
1580
1562
  */
1581
1563
  async checkAutInstallationState(opts) {
1582
- // @ts-expect-error - do not assign arbitrary properties to `opts`
1583
- const {enforceAppInstall, fullReset, noReset, bundleId, device, app} = opts ?? this.opts;
1564
+ const {enforceAppInstall, fullReset, noReset, bundleId, app} = opts ?? this.opts;
1584
1565
 
1585
- const wasAppInstalled = await device.isAppInstalled(bundleId);
1566
+ const wasAppInstalled = await this.device.isAppInstalled(bundleId);
1586
1567
  if (wasAppInstalled) {
1587
1568
  this.log.info(`App '${bundleId}' is already installed`);
1588
1569
  if (noReset) {
@@ -1613,8 +1594,8 @@ class XCUITestDriver extends BaseDriver {
1613
1594
  }
1614
1595
 
1615
1596
  const appBundleVersion = this.isRealDevice()
1616
- ? (await device.fetchAppInfo(bundleId))?.CFBundleVersion
1617
- : BUNDLE_VERSION_PATTERN.exec(await device.simctl.appInfo(bundleId))?.[1];
1597
+ ? (await /** @type {RealDevice} */ (this.device).fetchAppInfo(bundleId))?.CFBundleVersion
1598
+ : BUNDLE_VERSION_PATTERN.exec(await /** @type {Simulator} */ (this.device).simctl.appInfo(bundleId))?.[1];
1618
1599
  this.log.debug(`CFBundleVersion from installed app info: ${appBundleVersion}`);
1619
1600
  if (!appBundleVersion) {
1620
1601
  return {
@@ -2255,7 +2236,6 @@ function shouldSetInitialSafariUrl(opts) {
2255
2236
  }
2256
2237
 
2257
2238
  export default XCUITestDriver;
2258
- export {XCUITestDriver};
2259
2239
 
2260
2240
  /**
2261
2241
  * @template {import('@appium/types').Constraints} C
@@ -2263,6 +2243,16 @@ export {XCUITestDriver};
2263
2243
  * @typedef {import('@appium/types').ExternalDriver<C, Ctx>} ExternalDriver
2264
2244
  */
2265
2245
 
2246
+ /**
2247
+ * @typedef {Pick<XCUITestDriverOpts, 'enforceAppInstall' | 'fullReset' | 'noReset' | 'bundleId' | 'app'>} AutInstallationStateOptions
2248
+ */
2249
+
2250
+ /**
2251
+ * @typedef {Object} AutInstallationState
2252
+ * @property {boolean} install - If the given app should install, or not need to install.
2253
+ * @property {boolean} skipUninstall - If the installed app should be uninstalled, or not.
2254
+ */
2255
+
2266
2256
  /**
2267
2257
  * @typedef {typeof desiredCapConstraints} XCUITestDriverConstraints
2268
2258
  * @typedef {import('@appium/types').DriverOpts<XCUITestDriverConstraints>} XCUITestDriverOpts
@@ -2271,4 +2261,4 @@ export {XCUITestDriver};
2271
2261
  * @typedef {import('appium-xcode').XcodeVersion} XcodeVersion
2272
2262
  * @typedef {import('appium-ios-simulator').Simulator} Simulator
2273
2263
  * @typedef {import('./real-device').RealDevice} RealDevice
2274
- */
2264
+ */
package/lib/types.ts CHANGED
@@ -15,25 +15,6 @@ export interface LifecycleData {
15
15
  createSim?: boolean;
16
16
  }
17
17
 
18
- /**
19
- * All of these options are manually added to the `opts` property of the driver, which is strongly discouraged.
20
- *
21
- * Future versions of this driver should move these properties somewhere else.
22
- *
23
- * @todo If anyone knows anything about the types of these values, please fill them in.
24
- */
25
- export interface CustomOpts {
26
- device: any;
27
- realDevice: any;
28
- SimulatorWindowCenter: any;
29
- forceSimulatorSoftwareKeyboardPresence: any;
30
- iosSdkVersion: string;
31
- platformVersion: string;
32
- safari: any;
33
- sessionId: string | null;
34
- elementResponseAttributes: any;
35
- }
36
-
37
18
  export interface WDASettings {
38
19
  elementResponseAttributes: string;
39
20
  shouldUseCompactResponses: boolean;
package/lib/utils.js CHANGED
@@ -60,11 +60,14 @@ async function getAndCheckXcodeVersion() {
60
60
  return version;
61
61
  }
62
62
 
63
+ /**
64
+ * @returns {Promise<string|null>}
65
+ */
63
66
  async function getAndCheckIosSdkVersion() {
64
67
  try {
65
68
  return await xcode.getMaxIOSSDK();
66
69
  } catch (err) {
67
- log.errorAndThrow(`Could not determine iOS SDK version: ${err.message}`);
70
+ throw log.errorWithException(`Could not determine iOS SDK version: ${err.message}`);
68
71
  }
69
72
  }
70
73
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appium-xcuitest-driver",
3
- "version": "7.7.1",
3
+ "version": "7.8.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-xcuitest-driver",
9
- "version": "7.7.1",
9
+ "version": "7.8.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@colors/colors": "^1.6.0",
@@ -14,7 +14,7 @@
14
14
  "appium-ios-device": "^2.5.4",
15
15
  "appium-ios-simulator": "^6.1.2",
16
16
  "appium-remote-debugger": "^11.0.0",
17
- "appium-webdriveragent": "^8.1.0",
17
+ "appium-webdriveragent": "^8.2.1",
18
18
  "appium-xcode": "^5.1.4",
19
19
  "async-lock": "^1.4.0",
20
20
  "asyncbox": "^3.0.0",
@@ -999,9 +999,9 @@
999
999
  }
1000
1000
  },
1001
1001
  "node_modules/appium-webdriveragent": {
1002
- "version": "8.1.0",
1003
- "resolved": "https://registry.npmjs.org/appium-webdriveragent/-/appium-webdriveragent-8.1.0.tgz",
1004
- "integrity": "sha512-pexbyMiffrSBRQ3Ahr4GqbFHyw9xwySg9fvA8yIh6gfthXu4Q8MoGTbhYE9lZZq6mWqEGZQ7LoSShFL/NCzyPg==",
1002
+ "version": "8.2.1",
1003
+ "resolved": "https://registry.npmjs.org/appium-webdriveragent/-/appium-webdriveragent-8.2.1.tgz",
1004
+ "integrity": "sha512-Ai4I5YSyNOKlD6+oGbaRfuPAeGINcLGDB0+CwowvkG4FnReYKm3zfYR6VOquoqoNqOZkzTW8PbxSG0dRSUBxMQ==",
1005
1005
  "dependencies": {
1006
1006
  "@appium/base-driver": "^9.0.0",
1007
1007
  "@appium/strongbox": "^0.x",
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "xcuitest",
9
9
  "xctest"
10
10
  ],
11
- "version": "7.7.1",
11
+ "version": "7.8.0",
12
12
  "author": "Appium Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "repository": {
@@ -81,7 +81,7 @@
81
81
  "appium-ios-device": "^2.5.4",
82
82
  "appium-ios-simulator": "^6.1.2",
83
83
  "appium-remote-debugger": "^11.0.0",
84
- "appium-webdriveragent": "^8.1.0",
84
+ "appium-webdriveragent": "^8.2.1",
85
85
  "appium-xcode": "^5.1.4",
86
86
  "async-lock": "^1.4.0",
87
87
  "asyncbox": "^3.0.0",