appium-xcuitest-driver 10.14.2 → 10.14.4

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/alert.d.ts +26 -31
  3. package/build/lib/commands/alert.d.ts.map +1 -1
  4. package/build/lib/commands/alert.js +20 -29
  5. package/build/lib/commands/alert.js.map +1 -1
  6. package/build/lib/commands/appearance.d.ts +7 -9
  7. package/build/lib/commands/appearance.d.ts.map +1 -1
  8. package/build/lib/commands/appearance.js +13 -19
  9. package/build/lib/commands/appearance.js.map +1 -1
  10. package/build/lib/commands/biometric.d.ts +12 -14
  11. package/build/lib/commands/biometric.d.ts.map +1 -1
  12. package/build/lib/commands/biometric.js +10 -19
  13. package/build/lib/commands/biometric.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/iohid.d.ts +6 -1359
  23. package/build/lib/commands/iohid.d.ts.map +1 -1
  24. package/build/lib/commands/iohid.js +5 -10
  25. package/build/lib/commands/iohid.js.map +1 -1
  26. package/build/lib/commands/keyboard.d.ts +16 -13
  27. package/build/lib/commands/keyboard.d.ts.map +1 -1
  28. package/build/lib/commands/keyboard.js +14 -18
  29. package/build/lib/commands/keyboard.js.map +1 -1
  30. package/build/lib/commands/notifications.d.ts +10 -10
  31. package/build/lib/commands/notifications.d.ts.map +1 -1
  32. package/build/lib/commands/notifications.js +8 -12
  33. package/build/lib/commands/notifications.js.map +1 -1
  34. package/build/lib/commands/permissions.d.ts +15 -17
  35. package/build/lib/commands/permissions.d.ts.map +1 -1
  36. package/build/lib/commands/permissions.js +12 -18
  37. package/build/lib/commands/permissions.js.map +1 -1
  38. package/build/lib/commands/proxy-helper.d.ts +11 -11
  39. package/build/lib/commands/proxy-helper.d.ts.map +1 -1
  40. package/build/lib/commands/proxy-helper.js +15 -24
  41. package/build/lib/commands/proxy-helper.js.map +1 -1
  42. package/build/lib/commands/simctl.d.ts +16 -22
  43. package/build/lib/commands/simctl.d.ts.map +1 -1
  44. package/build/lib/commands/simctl.js +8 -17
  45. package/build/lib/commands/simctl.js.map +1 -1
  46. package/build/lib/commands/timeouts.d.ts +25 -32
  47. package/build/lib/commands/timeouts.d.ts.map +1 -1
  48. package/build/lib/commands/timeouts.js +18 -14
  49. package/build/lib/commands/timeouts.js.map +1 -1
  50. package/lib/commands/alert.ts +98 -0
  51. package/lib/commands/appearance.ts +70 -0
  52. package/lib/commands/biometric.ts +52 -0
  53. package/lib/commands/content-size.ts +67 -0
  54. package/lib/commands/geolocation.ts +55 -0
  55. package/lib/commands/{iohid.js → iohid.ts} +15 -13
  56. package/lib/commands/keyboard.ts +70 -0
  57. package/lib/commands/{notifications.js → notifications.ts} +22 -14
  58. package/lib/commands/permissions.ts +90 -0
  59. package/lib/commands/{proxy-helper.js → proxy-helper.ts} +26 -26
  60. package/lib/commands/{simctl.js → simctl.ts} +27 -21
  61. package/lib/commands/timeouts.ts +95 -0
  62. package/npm-shrinkwrap.json +5 -5
  63. package/package.json +1 -1
  64. package/lib/commands/alert.js +0 -88
  65. package/lib/commands/appearance.js +0 -71
  66. package/lib/commands/biometric.js +0 -52
  67. package/lib/commands/content-size.js +0 -68
  68. package/lib/commands/geolocation.js +0 -56
  69. package/lib/commands/keyboard.js +0 -62
  70. package/lib/commands/permissions.js +0 -85
  71. package/lib/commands/timeouts.js +0 -68
@@ -33,14 +33,14 @@ const SUBCOMMANDS_HAS_DEVICE = [
33
33
  /**
34
34
  * Run the given command with arguments as `xcrun simctl` subcommand.
35
35
  * This method works behind the 'simctl' security flag.
36
- * @this {XCUITestDriver}
37
- * @param {string} command Subcommand to run with `xcrun simctl`
38
- * @param {string[]} [args=[]] arguments for the subcommand. The arguments should be after <device> in the help.
39
- * @param {number|undefined} timeout - The maximum number of milliseconds
40
- * @returns {Promise<SimctlExecResponse>}
41
- * @throws {Error} If the simctl subcommand command returns non-zero return code, or the given subcommand was invalid.
36
+ *
37
+ * @param command - Subcommand to run with `xcrun simctl`. Must be one of the supported commands.
38
+ * @param args - Arguments for the subcommand. The arguments should be after <device> in the help.
39
+ * @param timeout - The maximum number of milliseconds
40
+ * @returns The execution result with stdout, stderr, and return code
41
+ * @throws If the simctl subcommand command returns non-zero return code, or the given subcommand was invalid.
42
42
  */
43
- async function mobileSimctl(command, args = [], timeout = undefined) {
43
+ async function mobileSimctl(command, args = [], timeout) {
44
44
  if (!this.isSimulator()) {
45
45
  throw new driver_1.errors.UnsupportedOperationError(`Only simulator is supported.`);
46
46
  }
@@ -51,20 +51,11 @@ async function mobileSimctl(command, args = [], timeout = undefined) {
51
51
  throw new driver_1.errors.InvalidArgumentError(`The given command '${command}' is not supported. ` +
52
52
  `Available subcommands are ${SUBCOMMANDS_HAS_DEVICE.join(',')}`);
53
53
  }
54
- const result = await /** @type {import('appium-ios-simulator').Simulator} */ (this.device).simctl.exec(command, { args: [this.opts.udid, ...args], timeout });
54
+ const result = await this.device.simctl.exec(command, { args: [this.opts.udid, ...args], timeout });
55
55
  return {
56
56
  stdout: result?.stdout ?? '',
57
57
  stderr: result?.stderr ?? '',
58
58
  code: result?.code ?? 0
59
59
  };
60
60
  }
61
- /**
62
- * @typedef {Object} SimctlExecResponse
63
- * @property {string} stdout The output of standard out.
64
- * @property {string} stderr The output of standard error.
65
- * @property {number} code Return code.
66
- */
67
- /**
68
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
69
- */
70
61
  //# sourceMappingURL=simctl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"simctl.js","sourceRoot":"","sources":["../../../lib/commands/simctl.js"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AG,MAAO,IAAI,CAAC,MAAoB,CAAC,MAAM,CAAC,IAAI,CACzD,OAAgD,EAChD,EAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,OAAO,EAAC,CAC3C,CAAC;IACF,OAAO;QACL,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;QAC5B,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;QAC5B,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC;KACxB,CAAC;AACJ,CAAC"}
@@ -1,53 +1,46 @@
1
+ import type { XCUITestDriver } from '../driver';
1
2
  /**
2
- * @this {XCUITestDriver}
3
+ * Sets the page load timeout using W3C protocol.
4
+ *
5
+ * @param ms - Timeout in milliseconds
3
6
  */
4
- export function pageLoadTimeoutW3C(this: import("../driver").XCUITestDriver, ms: any): Promise<void>;
7
+ export declare function pageLoadTimeoutW3C(this: XCUITestDriver, ms: number): Promise<void>;
5
8
  /**
6
- * @this {XCUITestDriver}
9
+ * Sets the page load timeout using MJSONWP protocol.
10
+ *
11
+ * @param ms - Timeout in milliseconds
7
12
  */
8
- export function pageLoadTimeoutMJSONWP(this: import("../driver").XCUITestDriver, ms: any): Promise<void>;
13
+ export declare function pageLoadTimeoutMJSONWP(this: XCUITestDriver, ms: number): Promise<void>;
9
14
  /**
10
- * @this {XCUITestDriver}
15
+ * Sets the async script timeout using W3C protocol.
16
+ *
17
+ * @param ms - Timeout in milliseconds
11
18
  */
12
- export function scriptTimeoutW3C(this: import("../driver").XCUITestDriver, ms: any): Promise<void>;
19
+ export declare function scriptTimeoutW3C(this: XCUITestDriver, ms: number): Promise<void>;
13
20
  /**
14
21
  * Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
15
22
  *
16
- * @param {number} ms - the timeout
17
- * @this {XCUITestDriver}
23
+ * @param ms - The timeout in milliseconds
18
24
  * @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
19
25
  */
20
- export function scriptTimeoutMJSONWP(this: import("../driver").XCUITestDriver, ms: number): Promise<void>;
26
+ export declare function scriptTimeoutMJSONWP(this: XCUITestDriver, ms: number): Promise<void>;
21
27
  /**
22
28
  * Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
23
29
  *
24
- * @param {number} ms - the timeout
25
- *
30
+ * @param ms - The timeout in milliseconds
26
31
  * @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
27
- * @this {XCUITestDriver}
28
32
  */
29
- export function asyncScriptTimeout(this: import("../driver").XCUITestDriver, ms: number): Promise<void>;
33
+ export declare function asyncScriptTimeout(this: XCUITestDriver, ms: number): Promise<void>;
30
34
  /**
31
- * @this {XCUITestDriver}
35
+ * Sets the page load timeout.
36
+ *
37
+ * @param ms - Timeout in milliseconds
32
38
  */
33
- export function setPageLoadTimeout(this: import("../driver").XCUITestDriver, ms: any): void;
34
- export class setPageLoadTimeout {
35
- /**
36
- * @this {XCUITestDriver}
37
- */
38
- constructor(this: import("../driver").XCUITestDriver, ms: any);
39
- pageLoadMs: any;
40
- }
39
+ export declare function setPageLoadTimeout(this: XCUITestDriver, ms: number): void;
41
40
  /**
42
- * @this {XCUITestDriver}
41
+ * Sets the async script timeout.
42
+ *
43
+ * @param ms - Timeout in milliseconds
43
44
  */
44
- export function setAsyncScriptTimeout(this: import("../driver").XCUITestDriver, ms: any): void;
45
- export class setAsyncScriptTimeout {
46
- /**
47
- * @this {XCUITestDriver}
48
- */
49
- constructor(this: import("../driver").XCUITestDriver, ms: any);
50
- asyncWaitMs: any;
51
- }
52
- export type XCUITestDriver = import("../driver").XCUITestDriver;
45
+ export declare function setAsyncScriptTimeout(this: XCUITestDriver, ms: number): void;
53
46
  //# sourceMappingURL=timeouts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeouts.d.ts","sourceRoot":"","sources":["../../../lib/commands/timeouts.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,qGAEC;AAED;;GAEG;AACH,yGAEC;AAED;;GAEG;AACH,mGAGC;AAED;;;;;;GAMG;AACH,mFAJW,MAAM,iBAMhB;AAED;;;;;;;GAOG;AACH,iFALW,MAAM,iBAOhB;AAED;;GAEG;AACH,4FAOC;;IAVD;;OAEG;IACH,+DAOC;IALC,gBAAoB;;AAOtB;;GAEG;AACH,+FAGC;;IAND;;OAEG;IACH,+DAGC;IAFC,iBAAqB;;6BAKV,OAAO,WAAW,EAAE,cAAc"}
1
+ {"version":3,"file":"timeouts.d.ts","sourceRoot":"","sources":["../../../lib/commands/timeouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,WAAW,CAAC;AAE9C;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,IAAI,CAGN"}
@@ -8,19 +8,25 @@ exports.asyncScriptTimeout = asyncScriptTimeout;
8
8
  exports.setPageLoadTimeout = setPageLoadTimeout;
9
9
  exports.setAsyncScriptTimeout = setAsyncScriptTimeout;
10
10
  /**
11
- * @this {XCUITestDriver}
11
+ * Sets the page load timeout using W3C protocol.
12
+ *
13
+ * @param ms - Timeout in milliseconds
12
14
  */
13
15
  async function pageLoadTimeoutW3C(ms) {
14
16
  await this.setPageLoadTimeout(this.parseTimeoutArgument(ms));
15
17
  }
16
18
  /**
17
- * @this {XCUITestDriver}
19
+ * Sets the page load timeout using MJSONWP protocol.
20
+ *
21
+ * @param ms - Timeout in milliseconds
18
22
  */
19
23
  async function pageLoadTimeoutMJSONWP(ms) {
20
24
  await this.setPageLoadTimeout(this.parseTimeoutArgument(ms));
21
25
  }
22
26
  /**
23
- * @this {XCUITestDriver}
27
+ * Sets the async script timeout using W3C protocol.
28
+ *
29
+ * @param ms - Timeout in milliseconds
24
30
  */
25
31
  async function scriptTimeoutW3C(ms) {
26
32
  // XXX: this is synchronous
@@ -29,8 +35,7 @@ async function scriptTimeoutW3C(ms) {
29
35
  /**
30
36
  * Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
31
37
  *
32
- * @param {number} ms - the timeout
33
- * @this {XCUITestDriver}
38
+ * @param ms - The timeout in milliseconds
34
39
  * @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
35
40
  */
36
41
  async function scriptTimeoutMJSONWP(ms) {
@@ -39,19 +44,19 @@ async function scriptTimeoutMJSONWP(ms) {
39
44
  /**
40
45
  * Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
41
46
  *
42
- * @param {number} ms - the timeout
43
- *
47
+ * @param ms - The timeout in milliseconds
44
48
  * @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
45
- * @this {XCUITestDriver}
46
49
  */
47
50
  async function asyncScriptTimeout(ms) {
48
51
  await this.scriptTimeoutW3C(ms);
49
52
  }
50
53
  /**
51
- * @this {XCUITestDriver}
54
+ * Sets the page load timeout.
55
+ *
56
+ * @param ms - Timeout in milliseconds
52
57
  */
53
58
  function setPageLoadTimeout(ms) {
54
- ms = parseInt(ms, 10);
59
+ ms = parseInt(String(ms), 10);
55
60
  this.pageLoadMs = ms;
56
61
  if (this._remote) {
57
62
  this.remote.pageLoadMs = ms;
@@ -59,13 +64,12 @@ function setPageLoadTimeout(ms) {
59
64
  this.log.debug(`Set page load timeout to ${ms}ms`);
60
65
  }
61
66
  /**
62
- * @this {XCUITestDriver}
67
+ * Sets the async script timeout.
68
+ *
69
+ * @param ms - Timeout in milliseconds
63
70
  */
64
71
  function setAsyncScriptTimeout(ms) {
65
72
  this.asyncWaitMs = ms;
66
73
  this.log.debug(`Set async script timeout to ${ms}ms`);
67
74
  }
68
- /**
69
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
70
- */
71
75
  //# sourceMappingURL=timeouts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeouts.js","sourceRoot":"","sources":["../../../lib/commands/timeouts.js"],"names":[],"mappings":";;AAGA,gDAEC;AAKD,wDAEC;AAKD,4CAGC;AASD,oDAEC;AAUD,gDAEC;AAKD,gDAOC;AAKD,sDAGC;AA/DD;;GAEG;AACI,KAAK,UAAU,kBAAkB,CAAC,EAAE;IACzC,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAAC,EAAE;IAC7C,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,EAAE;IACvC,2BAA2B;IAC3B,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAClE,CAA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CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,gBAAgB,CAEpC,EAAU;IAEV,2BAA2B;IAC3B,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CAExC,EAAU;IAEV,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,kBAAkB,CAEtC,EAAU;IAEV,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAEhC,EAAU;IAEV,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACrB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,EAAE,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAEnC,EAAU;IAEV,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACtB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,98 @@
1
+ import type {XCUITestDriver} from '../driver';
2
+
3
+ export type AlertAction = 'accept' | 'dismiss' | 'getButtons';
4
+
5
+ /**
6
+ * Gets the text of the currently displayed alert.
7
+ *
8
+ * @returns The alert text, or null if no alert is displayed
9
+ */
10
+ export async function getAlertText(this: XCUITestDriver): Promise<string | null> {
11
+ return await this.proxyCommand<any, string | null>('/alert/text', 'GET');
12
+ }
13
+
14
+ /**
15
+ * Sets the text in an alert input field.
16
+ *
17
+ * @param value - The text to set
18
+ */
19
+ export async function setAlertText(
20
+ this: XCUITestDriver,
21
+ value: string,
22
+ ): Promise<void> {
23
+ await this.proxyCommand('/alert/text', 'POST', {value});
24
+ }
25
+
26
+ /**
27
+ * Accepts the currently displayed alert.
28
+ *
29
+ * @param opts - Options including optional button label
30
+ */
31
+ export async function postAcceptAlert(
32
+ this: XCUITestDriver,
33
+ opts: AlertOptions = {},
34
+ ): Promise<void> {
35
+ await this.proxyCommand('/alert/accept', 'POST', toAlertParams(opts));
36
+ }
37
+
38
+ /**
39
+ * Dismisses the currently displayed alert.
40
+ *
41
+ * @param opts - Options including optional button label
42
+ */
43
+ export async function postDismissAlert(
44
+ this: XCUITestDriver,
45
+ opts: AlertOptions = {},
46
+ ): Promise<void> {
47
+ await this.proxyCommand('/alert/dismiss', 'POST', toAlertParams(opts));
48
+ }
49
+
50
+ /**
51
+ * Gets the list of button labels from the currently displayed alert.
52
+ *
53
+ * @returns The list of button labels
54
+ * @internal
55
+ */
56
+ export async function getAlertButtons(this: XCUITestDriver): Promise<string[]> {
57
+ return await this.proxyCommand<any, string[]>('/wda/alert/buttons', 'GET');
58
+ }
59
+
60
+ /**
61
+ * Tries to apply the given action to the currently visible alert.
62
+ *
63
+ * @param action - The actual action to apply
64
+ * @param buttonLabel - The name of the button used to perform the chosen alert action. Only makes sense if the action is `accept` or `dismiss`
65
+ * @returns If `action` is `getButtons`, a list of alert button labels; otherwise nothing
66
+ * @remarks This should really be separate commands.
67
+ */
68
+ export async function mobileHandleAlert(
69
+ this: XCUITestDriver,
70
+ action: AlertAction,
71
+ buttonLabel?: string,
72
+ ): Promise<string[] | void> {
73
+ switch (action) {
74
+ case 'accept':
75
+ return await this.postAcceptAlert({buttonLabel});
76
+ case 'dismiss':
77
+ return await this.postDismissAlert({buttonLabel});
78
+ case 'getButtons':
79
+ return await this.getAlertButtons();
80
+ default:
81
+ throw new Error(
82
+ `The 'action' value should be either 'accept', 'dismiss' or 'getButtons'. ` +
83
+ `'${action}' is provided instead.`,
84
+ );
85
+ }
86
+ }
87
+
88
+ function toAlertParams(opts: AlertOptions = {}): {name?: string} {
89
+ const params: {name?: string} = {};
90
+ if (opts.buttonLabel) {
91
+ params.name = opts.buttonLabel;
92
+ }
93
+ return params;
94
+ }
95
+
96
+ interface AlertOptions {
97
+ buttonLabel?: string;
98
+ }
@@ -0,0 +1,70 @@
1
+ import _ from 'lodash';
2
+ import {util} from 'appium/support';
3
+ import type {XCUITestDriver} from '../driver';
4
+ import type {Style} from './types';
5
+ import type {Simulator} from 'appium-ios-simulator';
6
+
7
+ /**
8
+ * Set the device's UI appearance style
9
+ *
10
+ * @since iOS 12.0
11
+ * @param style - The appearance style to set
12
+ * @throws If the current platform does not support UI appearance changes
13
+ */
14
+ export async function mobileSetAppearance(
15
+ this: XCUITestDriver,
16
+ style: 'dark' | 'light',
17
+ ): Promise<void> {
18
+ if (!['light', 'dark'].includes(_.toLower(style))) {
19
+ throw new Error(`The 'style' value is expected to equal either 'light' or 'dark'`);
20
+ }
21
+ if (util.compareVersions(this.opts.platformVersion as string, '<', '12.0')) {
22
+ throw new Error('Changing appearance is only supported since iOS 12');
23
+ }
24
+
25
+ if (this.isSimulator()) {
26
+ try {
27
+ await (this.device as Simulator).setAppearance(style);
28
+ return;
29
+ } catch (e: any) {
30
+ this.log.debug(e.stack);
31
+ }
32
+ }
33
+ try {
34
+ await this.proxyCommand('/wda/device/appearance', 'POST', {name: style}, false);
35
+ return;
36
+ } catch (e: any) {
37
+ this.log.debug(e.stack);
38
+ }
39
+ // Fall back to the ugly Siri workaround if the current SDK is too old
40
+ await this.mobileSiriCommand(`Turn ${_.toLower(style) === 'dark' ? 'on' : 'off'} dark mode`);
41
+ }
42
+
43
+ /**
44
+ * Get the device's UI appearance style.
45
+ *
46
+ * @since Xcode SDK 11
47
+ * @returns The current appearance style
48
+ */
49
+ export async function mobileGetAppearance(
50
+ this: XCUITestDriver,
51
+ ): Promise<{style: Style}> {
52
+ if (util.compareVersions(this.opts.platformVersion as string, '<', '12.0')) {
53
+ return {style: 'unsupported'};
54
+ }
55
+
56
+ let style: Style | undefined;
57
+ if (this.isSimulator()) {
58
+ try {
59
+ style = await (this.device as Simulator).getAppearance() as Style;
60
+ } catch {}
61
+ }
62
+ if (!style) {
63
+ const deviceInfo = await this.proxyCommand<any, {userInterfaceStyle?: string}>('/wda/device/info', 'GET');
64
+ style = (deviceInfo?.userInterfaceStyle ?? 'unknown') as Style;
65
+ }
66
+ return {
67
+ style: style as Style,
68
+ };
69
+ }
70
+
@@ -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,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
+
@@ -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
+