appium-xcuitest-driver 10.14.3 → 10.14.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 (71) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/commands/battery.d.ts +4 -4
  3. package/build/lib/commands/battery.d.ts.map +1 -1
  4. package/build/lib/commands/battery.js +3 -7
  5. package/build/lib/commands/battery.js.map +1 -1
  6. package/build/lib/commands/biometric.d.ts +12 -14
  7. package/build/lib/commands/biometric.d.ts.map +1 -1
  8. package/build/lib/commands/biometric.js +10 -19
  9. package/build/lib/commands/biometric.js.map +1 -1
  10. package/build/lib/commands/clipboard.d.ts +9 -11
  11. package/build/lib/commands/clipboard.d.ts.map +1 -1
  12. package/build/lib/commands/clipboard.js +8 -13
  13. package/build/lib/commands/clipboard.js.map +1 -1
  14. package/build/lib/commands/content-size.d.ts +16 -19
  15. package/build/lib/commands/content-size.d.ts.map +1 -1
  16. package/build/lib/commands/content-size.js +14 -22
  17. package/build/lib/commands/content-size.js.map +1 -1
  18. package/build/lib/commands/geolocation.d.ts +16 -36
  19. package/build/lib/commands/geolocation.d.ts.map +1 -1
  20. package/build/lib/commands/geolocation.js +8 -25
  21. package/build/lib/commands/geolocation.js.map +1 -1
  22. package/build/lib/commands/increase-contrast.d.ts +10 -13
  23. package/build/lib/commands/increase-contrast.d.ts.map +1 -1
  24. package/build/lib/commands/increase-contrast.js +8 -16
  25. package/build/lib/commands/increase-contrast.js.map +1 -1
  26. package/build/lib/commands/iohid.d.ts +6 -1359
  27. package/build/lib/commands/iohid.d.ts.map +1 -1
  28. package/build/lib/commands/iohid.js +5 -10
  29. package/build/lib/commands/iohid.js.map +1 -1
  30. package/build/lib/commands/keyboard.d.ts +16 -13
  31. package/build/lib/commands/keyboard.d.ts.map +1 -1
  32. package/build/lib/commands/keyboard.js +14 -18
  33. package/build/lib/commands/keyboard.js.map +1 -1
  34. package/build/lib/commands/lock.d.ts +6 -10
  35. package/build/lib/commands/lock.d.ts.map +1 -1
  36. package/build/lib/commands/lock.js +3 -10
  37. package/build/lib/commands/lock.js.map +1 -1
  38. package/build/lib/commands/memory.d.ts +4 -5
  39. package/build/lib/commands/memory.d.ts.map +1 -1
  40. package/build/lib/commands/memory.js +3 -8
  41. package/build/lib/commands/memory.js.map +1 -1
  42. package/build/lib/commands/notifications.d.ts +10 -10
  43. package/build/lib/commands/notifications.d.ts.map +1 -1
  44. package/build/lib/commands/notifications.js +8 -12
  45. package/build/lib/commands/notifications.js.map +1 -1
  46. package/build/lib/commands/pasteboard.d.ts +9 -10
  47. package/build/lib/commands/pasteboard.d.ts.map +1 -1
  48. package/build/lib/commands/pasteboard.js +8 -13
  49. package/build/lib/commands/pasteboard.js.map +1 -1
  50. package/lib/commands/{battery.js → battery.ts} +10 -12
  51. package/lib/commands/biometric.ts +52 -0
  52. package/lib/commands/clipboard.ts +37 -0
  53. package/lib/commands/content-size.ts +67 -0
  54. package/lib/commands/geolocation.ts +55 -0
  55. package/lib/commands/increase-contrast.ts +49 -0
  56. package/lib/commands/{iohid.js → iohid.ts} +15 -13
  57. package/lib/commands/keyboard.ts +70 -0
  58. package/lib/commands/lock.ts +43 -0
  59. package/lib/commands/{memory.js → memory.ts} +9 -9
  60. package/lib/commands/{notifications.js → notifications.ts} +22 -14
  61. package/lib/commands/pasteboard.ts +44 -0
  62. package/npm-shrinkwrap.json +29 -8
  63. package/package.json +1 -1
  64. package/lib/commands/biometric.js +0 -52
  65. package/lib/commands/clipboard.js +0 -35
  66. package/lib/commands/content-size.js +0 -68
  67. package/lib/commands/geolocation.js +0 -56
  68. package/lib/commands/increase-contrast.js +0 -50
  69. package/lib/commands/keyboard.js +0 -62
  70. package/lib/commands/lock.js +0 -46
  71. package/lib/commands/pasteboard.js +0 -43
@@ -0,0 +1,52 @@
1
+ import {assertSimulator as _assertSimulator} from '../utils';
2
+ import type {XCUITestDriver} from '../driver';
3
+ import type {BiometricFeature} from './types';
4
+ import type {Simulator} from 'appium-ios-simulator';
5
+
6
+ const assertSimulator = (driver: XCUITestDriver): Simulator => _assertSimulator.call(driver, 'Biometric enrollment');
7
+
8
+ /**
9
+ * Enrolls biometric authentication on a simulated device.
10
+ *
11
+ * @param isEnabled - Whether to enable/disable biometric enrollment.
12
+ * @throws If enrollment fails or the device is not a Simulator.
13
+ * @group Simulator Only
14
+ */
15
+ export async function mobileEnrollBiometric(
16
+ this: XCUITestDriver,
17
+ isEnabled: boolean = true,
18
+ ): Promise<void> {
19
+ await assertSimulator(this).enrollBiometric(isEnabled);
20
+ }
21
+
22
+ /**
23
+ * Emulates biometric match or non-match event on a simulated device.
24
+ *
25
+ * The biometric feature is expected to be already enrolled via {@linkcode mobileEnrollBiometric|mobile: enrollBiometric} before executing this.
26
+ *
27
+ * @param type - The biometric feature name.
28
+ * @param match - If `true`, simulate biometric match. If `false`, simulate biometric non-match.
29
+ * @throws If matching fails or the device is not a Simulator.
30
+ * @group Simulator Only
31
+ */
32
+ export async function mobileSendBiometricMatch(
33
+ this: XCUITestDriver,
34
+ type: BiometricFeature = 'touchId',
35
+ match: boolean = true,
36
+ ): Promise<void> {
37
+ await assertSimulator(this).sendBiometricMatch(match, type);
38
+ }
39
+
40
+ /**
41
+ * Checks whether the biometric feature is currently enrolled on a simulated device.
42
+ *
43
+ * @returns `true` if biometric is enrolled.
44
+ * @throws If the detection fails or the device is not a Simulator.
45
+ * @group Simulator Only
46
+ */
47
+ export async function mobileIsBiometricEnrolled(
48
+ this: XCUITestDriver,
49
+ ): Promise<boolean> {
50
+ return await assertSimulator(this).isBiometricEnrolled();
51
+ }
52
+
@@ -0,0 +1,37 @@
1
+ import type {XCUITestDriver} from '../driver';
2
+
3
+ /**
4
+ * Sets the primary clipboard's content on the device under test.
5
+ *
6
+ * @param content - The content to be set as base64 encoded string.
7
+ * @param contentType - The type of the content to set.
8
+ * Only `plaintext`, 'image' and 'url' are supported.
9
+ */
10
+ export async function setClipboard(
11
+ this: XCUITestDriver,
12
+ content: string,
13
+ contentType?: string,
14
+ ): Promise<void> {
15
+ await this.proxyCommand('/wda/setPasteboard', 'POST', {
16
+ content,
17
+ contentType,
18
+ });
19
+ }
20
+
21
+ /**
22
+ * Gets the content of the primary clipboard on the device under test.
23
+ *
24
+ * @param contentType - The type of the content to get.
25
+ * Only `plaintext`, 'image' and 'url' are supported.
26
+ * @returns The actual clipboard content encoded into base64 string.
27
+ * An empty string is returned if the clipboard contains no data.
28
+ */
29
+ export async function getClipboard(
30
+ this: XCUITestDriver,
31
+ contentType?: string,
32
+ ): Promise<string> {
33
+ return await this.proxyCommand<any, string>('/wda/getPasteboard', 'POST', {
34
+ contentType,
35
+ });
36
+ }
37
+
@@ -0,0 +1,67 @@
1
+ import _ from 'lodash';
2
+ import {assertSimulator as _assertSimulator} from '../utils';
3
+ import { errors } from 'appium/driver';
4
+ import type {XCUITestDriver} from '../driver';
5
+ import type {ContentSizeAction, ContentSizeResult} from './types';
6
+ import type {Simulator} from 'appium-ios-simulator';
7
+
8
+ const assertSimulator = (driver: XCUITestDriver): Simulator => _assertSimulator.call(driver, 'Content size ui command');
9
+
10
+ const CONTENT_SIZE = [
11
+ 'extra-small',
12
+ 'small',
13
+ 'medium',
14
+ 'large',
15
+ 'extra-large',
16
+ 'extra-extra-large',
17
+ 'extra-extra-extra-large',
18
+ 'accessibility-medium',
19
+ 'accessibility-large',
20
+ 'accessibility-extra-large',
21
+ 'accessibility-extra-extra-large',
22
+ 'accessibility-extra-extra-extra-large',
23
+ 'increment',
24
+ 'decrement'
25
+ ] as const;
26
+
27
+ /**
28
+ * Sets content size for the given simulator.
29
+ *
30
+ * @since Xcode 15 (but lower xcode could have this command)
31
+ * @param size - The content size action to set. Acceptable value is
32
+ * extra-small, small, medium, large, extra-large, extra-extra-large,
33
+ * extra-extra-extra-large, accessibility-medium, accessibility-large,
34
+ * accessibility-extra-large, accessibility-extra-extra-large,
35
+ * accessibility-extra-extra-extra-large with Xcode 16.2.
36
+ * @throws If the current platform does not support content size appearance changes
37
+ */
38
+ export async function mobileSetContentSize(
39
+ this: XCUITestDriver,
40
+ size: ContentSizeAction,
41
+ ): Promise<void> {
42
+ if (!(CONTENT_SIZE as readonly string[]).includes(_.lowerCase(size))) {
43
+ throw new errors.InvalidArgumentError(
44
+ `The 'size' value is expected to be one of ${CONTENT_SIZE.join(',')}`
45
+ );
46
+ }
47
+
48
+ await assertSimulator(this).setContentSize(size);
49
+ }
50
+
51
+ /**
52
+ * Retrieves the current content size value from the given simulator.
53
+ *
54
+ * @since Xcode 15 (but lower xcode could have this command)
55
+ * @returns The content size value. Possible return value is
56
+ * extra-small, small, medium, large, extra-large, extra-extra-large,
57
+ * extra-extra-extra-large, accessibility-medium, accessibility-large,
58
+ * accessibility-extra-large, accessibility-extra-extra-large,
59
+ * accessibility-extra-extra-extra-large,
60
+ * unknown or unsupported with Xcode 16.2.
61
+ */
62
+ export async function mobileGetContentSize(
63
+ this: XCUITestDriver,
64
+ ): Promise<ContentSizeResult> {
65
+ return await assertSimulator(this).getContentSize() as ContentSizeResult;
66
+ }
67
+
@@ -0,0 +1,55 @@
1
+ import type {XCUITestDriver} from '../driver';
2
+
3
+ export interface GeolocationInfo {
4
+ /** Measurement of distance north or south of the Equator, or `null` if {@linkcode XCUITestDriver.mobileSetSimulatedLocation} has not been called or {@linkcode mobileResetSimulatedLocation} has been called. */
5
+ latitude: number | null;
6
+ /** Measurement of distance east or west of the prime meridian, or `null` if {@linkcode XCUITestDriver.mobileSetSimulatedLocation} has not been called or {@linkcode mobileResetSimulatedLocation} has been called. */
7
+ longitude: number | null;
8
+ }
9
+
10
+ /**
11
+ * Retrieves the simulated geolocation value.
12
+ * Only works since Xcode 14.3/iOS 16.4
13
+ *
14
+ * @returns The current simulated geolocation
15
+ * @throws If the device under test does not support geolocation simulation.
16
+ * @since 4.18
17
+ */
18
+ export async function mobileGetSimulatedLocation(
19
+ this: XCUITestDriver,
20
+ ): Promise<GeolocationInfo> {
21
+ return await this.proxyCommand<any, GeolocationInfo>('/wda/simulatedLocation', 'GET');
22
+ }
23
+
24
+ /**
25
+ * Sets simulated geolocation value.
26
+ * Only works since Xcode 14.3/iOS 16.4
27
+ *
28
+ * @param latitude - Latitude value
29
+ * @param longitude - Longitude value
30
+ * @throws If the device under test does not support geolocation simulation.
31
+ * @since 4.18
32
+ */
33
+ export async function mobileSetSimulatedLocation(
34
+ this: XCUITestDriver,
35
+ latitude: number,
36
+ longitude: number,
37
+ ): Promise<void> {
38
+ await this.proxyCommand('/wda/simulatedLocation', 'POST', {latitude, longitude});
39
+ }
40
+
41
+ /**
42
+ * Resets simulated geolocation value.
43
+ * Only works since Xcode 14.3/iOS 16.4.
44
+ * ! Do not forget to reset the simulated geolocation value after your automated test is finished.
45
+ * ! If the value is not reset explicitly then the simulated one will remain until the next device restart.
46
+ *
47
+ * @throws If the device under test does not support geolocation simulation.
48
+ * @since 4.18
49
+ */
50
+ export async function mobileResetSimulatedLocation(
51
+ this: XCUITestDriver,
52
+ ): Promise<void> {
53
+ await this.proxyCommand('/wda/simulatedLocation', 'DELETE');
54
+ }
55
+
@@ -0,0 +1,49 @@
1
+ import _ from 'lodash';
2
+ import {assertSimulator as _assertSimulator} from '../utils';
3
+ import { errors } from 'appium/driver';
4
+ import type {XCUITestDriver} from '../driver';
5
+ import type {IncreaseContrastAction, IncreaseContrastResult} from './types';
6
+ import type {Simulator} from 'appium-ios-simulator';
7
+
8
+ const assertSimulator = (driver: XCUITestDriver): Simulator => _assertSimulator.call(driver, 'Content size ui command');
9
+
10
+ const INCREASE_CONTRAST_CONFIG = [
11
+ 'enabled',
12
+ 'disabled',
13
+ ] as const;
14
+
15
+ /**
16
+ * Sets the increase contrast configuration for the given simulator.
17
+ *
18
+ * @since Xcode 15 (but lower xcode could have this command)
19
+ * @param increaseContrast - Valid increase contrast configuration value.
20
+ * Acceptable value is 'enabled' or 'disabled' with Xcode 16.2.
21
+ * @throws If the current platform does not support content size appearance changes
22
+ */
23
+ export async function mobileSetIncreaseContrast(
24
+ this: XCUITestDriver,
25
+ increaseContrast: IncreaseContrastAction,
26
+ ): Promise<void> {
27
+ if (!(INCREASE_CONTRAST_CONFIG as readonly string[]).includes(_.lowerCase(increaseContrast))) {
28
+ throw new errors.InvalidArgumentError(
29
+ `The 'increaseContrast' value is expected to be one of ${INCREASE_CONTRAST_CONFIG.join(',')}`
30
+ );
31
+ }
32
+
33
+ await assertSimulator(this).setIncreaseContrast(increaseContrast);
34
+ }
35
+
36
+ /**
37
+ * Retrieves the current increase contrast configuration value from the given simulator.
38
+ *
39
+ * @since Xcode 15 (but lower xcode could have this command)
40
+ * @returns The contrast configuration value.
41
+ * Possible return value is 'enabled', 'disabled',
42
+ * 'unsupported' or 'unknown' with Xcode 16.2.
43
+ */
44
+ export async function mobileGetIncreaseContrast(
45
+ this: XCUITestDriver,
46
+ ): Promise<IncreaseContrastResult> {
47
+ return await assertSimulator(this).getIncreaseContrast() as IncreaseContrastResult;
48
+ }
49
+
@@ -1,5 +1,6 @@
1
1
  import {errors} from 'appium/driver';
2
2
  import {HIDUsageEvent, HIDPageEvent} from './hid-event';
3
+ import type {XCUITestDriver} from '../driver';
3
4
 
4
5
  /**
5
6
  * Emulates triggering of the given low-level IO HID device event.
@@ -12,12 +13,16 @@ import {HIDUsageEvent, HIDPageEvent} from './hid-event';
12
13
  * - `kHIDUsage_Csmr_Power` = `0x30` (Power)
13
14
  * - `kHIDUsage_Csmr_Snapshot` = `0x65` (Power + Home)
14
15
  *
15
- * @param {HIDPageEvent} page - The event page identifier
16
- * @param {HIDUsageEvent} usage - The event usage identifier (usages are defined per-page)
17
- * @param {number|string} durationSeconds - The event duration in float seconds (XCTest uses `0.005` for a single press event)
18
- * @this {import('../driver').XCUITestDriver}
16
+ * @param page - The event page identifier
17
+ * @param usage - The event usage identifier (usages are defined per-page)
18
+ * @param durationSeconds - The event duration in float seconds (XCTest uses `0.005` for a single press event)
19
19
  */
20
- export async function mobilePerformIoHidEvent(page, usage, durationSeconds) {
20
+ export async function mobilePerformIoHidEvent(
21
+ this: XCUITestDriver,
22
+ page: HIDPageEvent,
23
+ usage: number,
24
+ durationSeconds: number | string,
25
+ ): Promise<void> {
21
26
  if (!isHIDPageEvent(page)) {
22
27
  throw new errors.InvalidArgumentError(
23
28
  `'page' argument must be a valid HIDPageEvent identifier`,
@@ -30,15 +35,13 @@ export async function mobilePerformIoHidEvent(page, usage, durationSeconds) {
30
35
  if (Number.isNaN(duration)) {
31
36
  throw new errors.InvalidArgumentError(`'durationSeconds' argument must be a valid number`);
32
37
  }
33
- return await this.proxyCommand('/wda/performIoHidEvent', 'POST', {page, usage, duration});
38
+ await this.proxyCommand('/wda/performIoHidEvent', 'POST', {page, usage, duration});
34
39
  }
35
40
 
36
41
  /**
37
42
  * Type guard for {@linkcode HIDUsageEvent}
38
- * @param {any} value
39
- * @returns {value is HIDUsageEvent}
40
43
  */
41
- function isHIDUsageEvent(value) {
44
+ function isHIDUsageEvent(value: any): value is keyof typeof HIDUsageEvent {
42
45
  if (typeof value === 'string') {
43
46
  value = parseInt(value, 10);
44
47
  }
@@ -50,10 +53,8 @@ function isHIDUsageEvent(value) {
50
53
 
51
54
  /**
52
55
  * Type guard for {@linkcode HIDPageEvent}
53
- * @param {any} value
54
- * @returns {value is HIDPageEvent}
55
- **/
56
- function isHIDPageEvent(value) {
56
+ */
57
+ function isHIDPageEvent(value: any): value is HIDPageEvent {
57
58
  if (typeof value === 'string') {
58
59
  value = parseInt(value, 10);
59
60
  }
@@ -62,3 +63,4 @@ function isHIDPageEvent(value) {
62
63
  }
63
64
  return value in HIDPageEvent;
64
65
  }
66
+
@@ -0,0 +1,70 @@
1
+ import _ from 'lodash';
2
+ import type {XCUITestDriver} from '../driver';
3
+ import type {KeyboardKey} from './types';
4
+
5
+ /**
6
+ * Hides the keyboard.
7
+ *
8
+ * @deprecated
9
+ */
10
+ export async function hideKeyboard(
11
+ this: XCUITestDriver,
12
+ strategy?: string,
13
+ ...possibleKeys: string[]
14
+ ): Promise<boolean> {
15
+ // last parameter is the session id
16
+ const keyNames = _.compact(possibleKeys.slice(0, -1)).map((x) => `${x}`);
17
+ await this.mobileHideKeyboard(keyNames);
18
+ return true;
19
+ }
20
+
21
+ /**
22
+ * Hides the keyboard using the specified key names.
23
+ *
24
+ * @param keys - Array of key names to use for dismissing the keyboard
25
+ */
26
+ export async function mobileHideKeyboard(
27
+ this: XCUITestDriver,
28
+ keys: string[] = [],
29
+ ): Promise<void> {
30
+ await this.proxyCommand('/wda/keyboard/dismiss', 'POST', {
31
+ keyNames: keys.includes('done') ? keys : [...keys, 'done'],
32
+ });
33
+ }
34
+
35
+ /**
36
+ * Checks whether the keyboard is currently shown.
37
+ *
38
+ * @returns `true` if the keyboard is shown, `false` otherwise
39
+ */
40
+ export async function isKeyboardShown(this: XCUITestDriver): Promise<boolean> {
41
+ try {
42
+ await this.findNativeElementOrElements('class name', 'XCUIElementTypeKeyboard', false);
43
+ return true;
44
+ } catch {
45
+ return false;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Send keys to the given element or to the application under test.
51
+ * This API is not supported on tvOS
52
+ *
53
+ * @since Xcode 15/iOS 17
54
+ * @param keys - Array of keys to type.
55
+ * Each item could either be a string, that represents a key itself (see
56
+ * https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey?language=objc
57
+ * and https://developer.apple.com/documentation/xctest/xcuikeyboardkey?language=objc)
58
+ * or a dictionary, if the key should also be entered with modifiers.
59
+ * @param elementId - UUID of the element to send keys to.
60
+ * If the element is not provided then the keys will be sent to the current application.
61
+ */
62
+ export async function mobileKeys(
63
+ this: XCUITestDriver,
64
+ keys: (KeyboardKey | string)[],
65
+ elementId: string | null = null,
66
+ ): Promise<void> {
67
+ const url = `/wda/element/${elementId || 0}/keyboardInput`;
68
+ await this.proxyCommand(url, 'POST', { keys });
69
+ }
70
+
@@ -0,0 +1,43 @@
1
+ import B from 'bluebird';
2
+ import type {XCUITestDriver} from '../driver';
3
+
4
+ /**
5
+ * Lock the device (and optionally unlock the device after a certain amount of time)
6
+ *
7
+ * @param seconds - The number of seconds after which to unlock the device. Set to `0` or leave empty to require manual unlock (do not automatically unlock).
8
+ * @defaultValue 0
9
+ */
10
+ export async function lock(
11
+ this: XCUITestDriver,
12
+ seconds?: number | string,
13
+ ): Promise<void> {
14
+ await this.proxyCommand('/wda/lock', 'POST');
15
+ if (isNaN(Number(seconds))) {
16
+ return;
17
+ }
18
+
19
+ const floatSeconds = parseFloat(String(seconds));
20
+ if (floatSeconds <= 0) {
21
+ return;
22
+ }
23
+
24
+ await B.delay(floatSeconds * 1000);
25
+ await this.proxyCommand('/wda/unlock', 'POST');
26
+ }
27
+
28
+ /**
29
+ * Unlock the device
30
+ */
31
+ export async function unlock(this: XCUITestDriver): Promise<void> {
32
+ await this.proxyCommand('/wda/unlock', 'POST');
33
+ }
34
+
35
+ /**
36
+ * Determine whether the device is locked
37
+ *
38
+ * @returns `true` if the device is locked, `false` otherwise
39
+ */
40
+ export async function isLocked(this: XCUITestDriver): Promise<boolean> {
41
+ return await this.proxyCommand<any, boolean>('/wda/locked', 'GET');
42
+ }
43
+
@@ -1,20 +1,24 @@
1
1
  import _ from 'lodash';
2
2
  import { errors } from 'appium/driver';
3
+ import type {XCUITestDriver} from '../driver';
4
+ import type {RealDevice} from '../device/real-device-management';
3
5
 
4
6
  /**
5
7
  * Simulates Low Memory warning on the given application
6
8
  *
7
9
  * @since Xcode 15
8
- * @param {string} bundleId - The bundle identifier of the target app. The app must be running
9
- * @this {XCUITestDriver}
10
- * @throws {Error} if the app is not running or is not installed
10
+ * @param bundleId - The bundle identifier of the target app. The app must be running
11
+ * @throws If the app is not running or is not installed
11
12
  */
12
- export async function mobileSendMemoryWarning(bundleId) {
13
+ export async function mobileSendMemoryWarning(
14
+ this: XCUITestDriver,
15
+ bundleId: string,
16
+ ): Promise<void> {
13
17
  if (!this.isRealDevice()) {
14
18
  throw new Error('Memory warning simulation is only supported on real devices');
15
19
  }
16
20
 
17
- const device = /** @type {import('../device/real-device-management').RealDevice} */ (this.device);
21
+ const device = this.device as RealDevice;
18
22
 
19
23
  const appInfos = await device.devicectl.listApps(bundleId);
20
24
  if (_.isEmpty(appInfos)) {
@@ -33,7 +37,6 @@ export async function mobileSendMemoryWarning(bundleId) {
33
37
  // Unfortunately devicectl does not provide more info which would
34
38
  // allow to connect a bundle id to a process id.
35
39
  const pattern = new RegExp(`^${_.escapeRegExp(appInfos[0].url)}[^/]+$`);
36
- /** @type {number[]} */
37
40
  const pids = (await device.devicectl.listProcesses())
38
41
  .filter(({executable}) => pattern.test(executable))
39
42
  .map(({processIdentifier}) => processIdentifier);
@@ -46,6 +49,3 @@ export async function mobileSendMemoryWarning(bundleId) {
46
49
  await device.devicectl.sendMemoryWarning(pids[0]);
47
50
  }
48
51
 
49
- /**
50
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
51
- */
@@ -1,5 +1,8 @@
1
1
  import {errors} from 'appium/driver';
2
2
  import _ from 'lodash';
3
+ import type {XCUITestDriver} from '../driver';
4
+ import type {PushPayload, NotificationType} from './types';
5
+ import type {Simulator} from 'appium-ios-simulator';
3
6
 
4
7
  /**
5
8
  * Simulates push notification delivery to a simulated device.
@@ -7,12 +10,16 @@ import _ from 'lodash';
7
10
  * **Only "remote" push notifications are supported.** VoIP, Complication, File Provider, and other types are unsupported.
8
11
  *
9
12
  * Supported in Xcode SDK 11.4+.
10
- * @param {string} bundleId - The bundle identifier of the target application
11
- * @param {import('./types').PushPayload} payload - Valid push payload.
13
+ *
14
+ * @param bundleId - The bundle identifier of the target application
15
+ * @param payload - Valid push payload.
12
16
  * @group Simulator Only
13
- * @this {XCUITestDriver}
14
17
  */
15
- export async function mobilePushNotification(bundleId, payload) {
18
+ export async function mobilePushNotification(
19
+ this: XCUITestDriver,
20
+ bundleId: string,
21
+ payload: PushPayload,
22
+ ): Promise<void> {
16
23
  if (!this.isSimulator()) {
17
24
  throw new Error('This extension only works on Simulator');
18
25
  }
@@ -34,7 +41,7 @@ export async function mobilePushNotification(bundleId, payload) {
34
41
  `Got ${JSON.stringify(payload.aps)} instead`,
35
42
  );
36
43
  }
37
- return await /** @type {import('appium-ios-simulator').Simulator} */ (this.device).pushNotification({
44
+ await (this.device as Simulator).pushNotification({
38
45
  ...payload,
39
46
  'Simulator Target Bundle': bundleId,
40
47
  });
@@ -47,20 +54,21 @@ export async function mobilePushNotification(bundleId, payload) {
47
54
  * [`XCTNSNotificationExpectation`](https://developer.apple.com/documentation/xctest/xctnsnotificationexpectation?language=objc) and
48
55
  * [`XCTDarwinNotificationExpectation`](https://developer.apple.com/documentation/xctest/xctdarwinnotificationexpectation?language=objc) entities.
49
56
  *
50
- * @param {string} name - The name of the notification to expect
51
- * @param {import('./types').NotificationType} type - Which notification type to expect.
52
- * @param {number} timeoutSeconds - For how long to wait until the notification is delivered (in float seconds).
57
+ * @param name - The name of the notification to expect
58
+ * @param type - Which notification type to expect.
59
+ * @param timeoutSeconds - For how long to wait until the notification is delivered (in float seconds).
53
60
  * @throws A [`TimeoutError`](https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/error_exports_TimeoutError.html) if the expected notification has not been delivered within the given timeout.
54
- * @this {XCUITestDriver}
55
61
  */
56
- export async function mobileExpectNotification(name, type = 'plain', timeoutSeconds = 60) {
57
- return await this.proxyCommand('/wda/expectNotification', 'POST', {
62
+ export async function mobileExpectNotification(
63
+ this: XCUITestDriver,
64
+ name: string,
65
+ type: NotificationType = 'plain',
66
+ timeoutSeconds: number = 60,
67
+ ): Promise<void> {
68
+ await this.proxyCommand('/wda/expectNotification', 'POST', {
58
69
  name,
59
70
  type,
60
71
  timeout: timeoutSeconds,
61
72
  });
62
73
  }
63
74
 
64
- /**
65
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
66
- */
@@ -0,0 +1,44 @@
1
+ import _ from 'lodash';
2
+ import { assertSimulator } from '../utils';
3
+ import type {XCUITestDriver} from '../driver';
4
+ import type {Simulator} from 'appium-ios-simulator';
5
+
6
+ /**
7
+ * Sets the Simulator's pasteboard content to the given value.
8
+ *
9
+ * Does not work for real devices.
10
+ *
11
+ * @param content - The content to set
12
+ * @param encoding - The content's encoding
13
+ * @group Simulator Only
14
+ */
15
+ export async function mobileSetPasteboard(
16
+ this: XCUITestDriver,
17
+ content: string,
18
+ encoding: BufferEncoding = 'utf8',
19
+ ): Promise<void> {
20
+ assertSimulator.call(this, 'Setting pasteboard content');
21
+ if (!_.isString(content)) {
22
+ // can be empty string
23
+ throw new Error('Pasteboard content is mandatory to set');
24
+ }
25
+ await (this.device as Simulator).simctl.setPasteboard(content, encoding);
26
+ }
27
+
28
+ /**
29
+ * Gets the Simulator's pasteboard content.
30
+ *
31
+ * Does not work for real devices.
32
+ *
33
+ * @param encoding - Expected encoding of returned string
34
+ * @group Simulator Only
35
+ * @returns The pasteboard content string
36
+ */
37
+ export async function mobileGetPasteboard(
38
+ this: XCUITestDriver,
39
+ encoding: BufferEncoding = 'utf8',
40
+ ): Promise<string> {
41
+ assertSimulator.call(this, 'Getting pasteboard content');
42
+ return await (this.device as Simulator).simctl.getPasteboard(encoding);
43
+ }
44
+
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appium-xcuitest-driver",
3
- "version": "10.14.3",
3
+ "version": "10.14.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-xcuitest-driver",
9
- "version": "10.14.3",
9
+ "version": "10.14.5",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@appium/strongbox": "^1.0.0-rc.1",
@@ -692,9 +692,9 @@
692
692
  }
693
693
  },
694
694
  "node_modules/appium-ios-remotexpc": {
695
- "version": "0.24.1",
696
- "resolved": "https://registry.npmjs.org/appium-ios-remotexpc/-/appium-ios-remotexpc-0.24.1.tgz",
697
- "integrity": "sha512-LJ83A/cHx+CFOX9yGLoG+bsfgYiJdN1PSBDDe7FkZ/C6DGTi+5zvDxOwaBSLmhgEh6uae40EGK8/FbFiKwR4Kg==",
695
+ "version": "0.24.2",
696
+ "resolved": "https://registry.npmjs.org/appium-ios-remotexpc/-/appium-ios-remotexpc-0.24.2.tgz",
697
+ "integrity": "sha512-bZBVG5eo/TC9PJJIu/kpGy5YprMn9vcVMKCarNM8rTTtNNUgOE80LPJ5e1UxWj2AnIAXyoJochN996mmiaWvnA==",
698
698
  "license": "Apache-2.0",
699
699
  "optional": true,
700
700
  "dependencies": {
@@ -880,6 +880,27 @@
880
880
  "node": ">= 12.0.0"
881
881
  }
882
882
  },
883
+ "node_modules/appium/node_modules/ws": {
884
+ "version": "8.18.3",
885
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
886
+ "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
887
+ "license": "MIT",
888
+ "engines": {
889
+ "node": ">=10.0.0"
890
+ },
891
+ "peerDependencies": {
892
+ "bufferutil": "^4.0.1",
893
+ "utf-8-validate": ">=5.0.2"
894
+ },
895
+ "peerDependenciesMeta": {
896
+ "bufferutil": {
897
+ "optional": true
898
+ },
899
+ "utf-8-validate": {
900
+ "optional": true
901
+ }
902
+ }
903
+ },
883
904
  "node_modules/archiver": {
884
905
  "version": "7.0.1",
885
906
  "resolved": "https://registry.npmjs.org/archiver/-/archiver-7.0.1.tgz",
@@ -4697,9 +4718,9 @@
4697
4718
  "license": "ISC"
4698
4719
  },
4699
4720
  "node_modules/ws": {
4700
- "version": "8.18.3",
4701
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
4702
- "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
4721
+ "version": "8.19.0",
4722
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz",
4723
+ "integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==",
4703
4724
  "license": "MIT",
4704
4725
  "engines": {
4705
4726
  "node": ">=10.0.0"
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "xcuitest",
9
9
  "xctest"
10
10
  ],
11
- "version": "10.14.3",
11
+ "version": "10.14.5",
12
12
  "author": "Appium Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "repository": {