@limrun/appium-xcuitest-driver 10.11.0-lim.4 → 10.14.6-lim.1

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 (279) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/build/lib/commands/active-app-info.d.ts +4 -3
  3. package/build/lib/commands/active-app-info.d.ts.map +1 -1
  4. package/build/lib/commands/active-app-info.js +2 -3
  5. package/build/lib/commands/active-app-info.js.map +1 -1
  6. package/build/lib/commands/alert.d.ts +26 -31
  7. package/build/lib/commands/alert.d.ts.map +1 -1
  8. package/build/lib/commands/alert.js +20 -29
  9. package/build/lib/commands/alert.js.map +1 -1
  10. package/build/lib/commands/app-management.d.ts +99 -76
  11. package/build/lib/commands/app-management.d.ts.map +1 -1
  12. package/build/lib/commands/app-management.js +83 -73
  13. package/build/lib/commands/app-management.js.map +1 -1
  14. package/build/lib/commands/app-strings.d.ts +6 -7
  15. package/build/lib/commands/app-strings.d.ts.map +1 -1
  16. package/build/lib/commands/app-strings.js +3 -8
  17. package/build/lib/commands/app-strings.js.map +1 -1
  18. package/build/lib/commands/appearance.d.ts +7 -9
  19. package/build/lib/commands/appearance.d.ts.map +1 -1
  20. package/build/lib/commands/appearance.js +13 -19
  21. package/build/lib/commands/appearance.js.map +1 -1
  22. package/build/lib/commands/audit.d.ts +5 -33
  23. package/build/lib/commands/audit.d.ts.map +1 -1
  24. package/build/lib/commands/audit.js +3 -16
  25. package/build/lib/commands/audit.js.map +1 -1
  26. package/build/lib/commands/battery.d.ts +4 -4
  27. package/build/lib/commands/battery.d.ts.map +1 -1
  28. package/build/lib/commands/battery.js +3 -7
  29. package/build/lib/commands/battery.js.map +1 -1
  30. package/build/lib/commands/biometric.d.ts +12 -14
  31. package/build/lib/commands/biometric.d.ts.map +1 -1
  32. package/build/lib/commands/biometric.js +10 -19
  33. package/build/lib/commands/biometric.js.map +1 -1
  34. package/build/lib/commands/certificate.d.ts +14 -19
  35. package/build/lib/commands/certificate.d.ts.map +1 -1
  36. package/build/lib/commands/certificate.js +24 -31
  37. package/build/lib/commands/certificate.js.map +1 -1
  38. package/build/lib/commands/clipboard.d.ts +9 -11
  39. package/build/lib/commands/clipboard.d.ts.map +1 -1
  40. package/build/lib/commands/clipboard.js +8 -13
  41. package/build/lib/commands/clipboard.js.map +1 -1
  42. package/build/lib/commands/condition.d.ts +9 -72
  43. package/build/lib/commands/condition.d.ts.map +1 -1
  44. package/build/lib/commands/condition.js +5 -66
  45. package/build/lib/commands/condition.js.map +1 -1
  46. package/build/lib/commands/content-size.d.ts +16 -19
  47. package/build/lib/commands/content-size.d.ts.map +1 -1
  48. package/build/lib/commands/content-size.js +14 -22
  49. package/build/lib/commands/content-size.js.map +1 -1
  50. package/build/lib/commands/context.d.ts +130 -161
  51. package/build/lib/commands/context.d.ts.map +1 -1
  52. package/build/lib/commands/context.js +123 -108
  53. package/build/lib/commands/context.js.map +1 -1
  54. package/build/lib/commands/device-info.d.ts +13 -0
  55. package/build/lib/commands/device-info.d.ts.map +1 -0
  56. package/build/lib/commands/device-info.js +20 -0
  57. package/build/lib/commands/device-info.js.map +1 -0
  58. package/build/lib/commands/element.d.ts +83 -67
  59. package/build/lib/commands/element.d.ts.map +1 -1
  60. package/build/lib/commands/element.js +111 -134
  61. package/build/lib/commands/element.js.map +1 -1
  62. package/build/lib/commands/execute.d.ts +10 -22
  63. package/build/lib/commands/execute.d.ts.map +1 -1
  64. package/build/lib/commands/execute.js +13 -29
  65. package/build/lib/commands/execute.js.map +1 -1
  66. package/build/lib/commands/file-movement.d.ts +31 -42
  67. package/build/lib/commands/file-movement.d.ts.map +1 -1
  68. package/build/lib/commands/file-movement.js +146 -205
  69. package/build/lib/commands/file-movement.js.map +1 -1
  70. package/build/lib/commands/find.d.ts +20 -12
  71. package/build/lib/commands/find.d.ts.map +1 -1
  72. package/build/lib/commands/find.js +27 -65
  73. package/build/lib/commands/find.js.map +1 -1
  74. package/build/lib/commands/general.d.ts +84 -80
  75. package/build/lib/commands/general.d.ts.map +1 -1
  76. package/build/lib/commands/general.js +67 -54
  77. package/build/lib/commands/general.js.map +1 -1
  78. package/build/lib/commands/geolocation.d.ts +16 -36
  79. package/build/lib/commands/geolocation.d.ts.map +1 -1
  80. package/build/lib/commands/geolocation.js +8 -25
  81. package/build/lib/commands/geolocation.js.map +1 -1
  82. package/build/lib/commands/gesture.d.ts +103 -119
  83. package/build/lib/commands/gesture.d.ts.map +1 -1
  84. package/build/lib/commands/gesture.js +98 -138
  85. package/build/lib/commands/gesture.js.map +1 -1
  86. package/build/lib/commands/increase-contrast.d.ts +10 -13
  87. package/build/lib/commands/increase-contrast.d.ts.map +1 -1
  88. package/build/lib/commands/increase-contrast.js +8 -16
  89. package/build/lib/commands/increase-contrast.js.map +1 -1
  90. package/build/lib/commands/iohid.d.ts +6 -1359
  91. package/build/lib/commands/iohid.d.ts.map +1 -1
  92. package/build/lib/commands/iohid.js +5 -10
  93. package/build/lib/commands/iohid.js.map +1 -1
  94. package/build/lib/commands/keyboard.d.ts +16 -13
  95. package/build/lib/commands/keyboard.d.ts.map +1 -1
  96. package/build/lib/commands/keyboard.js +14 -18
  97. package/build/lib/commands/keyboard.js.map +1 -1
  98. package/build/lib/commands/keychains.d.ts +2 -2
  99. package/build/lib/commands/keychains.d.ts.map +1 -1
  100. package/build/lib/commands/keychains.js +1 -4
  101. package/build/lib/commands/keychains.js.map +1 -1
  102. package/build/lib/commands/localization.d.ts +7 -6
  103. package/build/lib/commands/localization.d.ts.map +1 -1
  104. package/build/lib/commands/localization.js +7 -8
  105. package/build/lib/commands/localization.js.map +1 -1
  106. package/build/lib/commands/location.d.ts +8 -11
  107. package/build/lib/commands/location.d.ts.map +1 -1
  108. package/build/lib/commands/location.js +7 -15
  109. package/build/lib/commands/location.js.map +1 -1
  110. package/build/lib/commands/lock.d.ts +6 -10
  111. package/build/lib/commands/lock.d.ts.map +1 -1
  112. package/build/lib/commands/lock.js +3 -10
  113. package/build/lib/commands/lock.js.map +1 -1
  114. package/build/lib/commands/log.d.ts +42 -44
  115. package/build/lib/commands/log.d.ts.map +1 -1
  116. package/build/lib/commands/log.js +32 -53
  117. package/build/lib/commands/log.js.map +1 -1
  118. package/build/lib/commands/memory.d.ts +4 -5
  119. package/build/lib/commands/memory.d.ts.map +1 -1
  120. package/build/lib/commands/memory.js +3 -8
  121. package/build/lib/commands/memory.js.map +1 -1
  122. package/build/lib/commands/navigation.d.ts +14 -26
  123. package/build/lib/commands/navigation.d.ts.map +1 -1
  124. package/build/lib/commands/navigation.js +22 -32
  125. package/build/lib/commands/navigation.js.map +1 -1
  126. package/build/lib/commands/notifications.d.ts +10 -10
  127. package/build/lib/commands/notifications.d.ts.map +1 -1
  128. package/build/lib/commands/notifications.js +8 -12
  129. package/build/lib/commands/notifications.js.map +1 -1
  130. package/build/lib/commands/pasteboard.d.ts +9 -10
  131. package/build/lib/commands/pasteboard.d.ts.map +1 -1
  132. package/build/lib/commands/pasteboard.js +8 -13
  133. package/build/lib/commands/pasteboard.js.map +1 -1
  134. package/build/lib/commands/pcap.d.ts +18 -38
  135. package/build/lib/commands/pcap.d.ts.map +1 -1
  136. package/build/lib/commands/pcap.js +9 -14
  137. package/build/lib/commands/pcap.js.map +1 -1
  138. package/build/lib/commands/performance.d.ts +36 -55
  139. package/build/lib/commands/performance.d.ts.map +1 -1
  140. package/build/lib/commands/performance.js +93 -86
  141. package/build/lib/commands/performance.js.map +1 -1
  142. package/build/lib/commands/permissions.d.ts +15 -17
  143. package/build/lib/commands/permissions.d.ts.map +1 -1
  144. package/build/lib/commands/permissions.js +12 -18
  145. package/build/lib/commands/permissions.js.map +1 -1
  146. package/build/lib/commands/proxy-helper.d.ts +11 -11
  147. package/build/lib/commands/proxy-helper.d.ts.map +1 -1
  148. package/build/lib/commands/proxy-helper.js +15 -24
  149. package/build/lib/commands/proxy-helper.js.map +1 -1
  150. package/build/lib/commands/record-audio.d.ts +25 -52
  151. package/build/lib/commands/record-audio.d.ts.map +1 -1
  152. package/build/lib/commands/record-audio.js +17 -19
  153. package/build/lib/commands/record-audio.js.map +1 -1
  154. package/build/lib/commands/recordscreen.d.ts +31 -62
  155. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  156. package/build/lib/commands/recordscreen.js +29 -28
  157. package/build/lib/commands/recordscreen.js.map +1 -1
  158. package/build/lib/commands/screenshots.d.ts +15 -9
  159. package/build/lib/commands/screenshots.d.ts.map +1 -1
  160. package/build/lib/commands/screenshots.js +16 -16
  161. package/build/lib/commands/screenshots.js.map +1 -1
  162. package/build/lib/commands/simctl.d.ts +16 -22
  163. package/build/lib/commands/simctl.d.ts.map +1 -1
  164. package/build/lib/commands/simctl.js +13 -17
  165. package/build/lib/commands/simctl.js.map +1 -1
  166. package/build/lib/commands/source.d.ts +10 -8
  167. package/build/lib/commands/source.d.ts.map +1 -1
  168. package/build/lib/commands/source.js +11 -14
  169. package/build/lib/commands/source.js.map +1 -1
  170. package/build/lib/commands/timeouts.d.ts +25 -32
  171. package/build/lib/commands/timeouts.d.ts.map +1 -1
  172. package/build/lib/commands/timeouts.js +19 -15
  173. package/build/lib/commands/timeouts.js.map +1 -1
  174. package/build/lib/commands/types.d.ts +80 -0
  175. package/build/lib/commands/types.d.ts.map +1 -1
  176. package/build/lib/commands/web.d.ts +199 -202
  177. package/build/lib/commands/web.d.ts.map +1 -1
  178. package/build/lib/commands/web.js +216 -175
  179. package/build/lib/commands/web.js.map +1 -1
  180. package/build/lib/commands/xctest-record-screen.d.ts +17 -47
  181. package/build/lib/commands/xctest-record-screen.d.ts.map +1 -1
  182. package/build/lib/commands/xctest-record-screen.js +28 -59
  183. package/build/lib/commands/xctest-record-screen.js.map +1 -1
  184. package/build/lib/commands/xctest.d.ts +37 -37
  185. package/build/lib/commands/xctest.d.ts.map +1 -1
  186. package/build/lib/commands/xctest.js +38 -50
  187. package/build/lib/commands/xctest.js.map +1 -1
  188. package/build/lib/desired-caps.js +1 -1
  189. package/build/lib/device/log/ios-simulator-log.d.ts.map +1 -1
  190. package/build/lib/device/log/ios-simulator-log.js +2 -0
  191. package/build/lib/device/log/ios-simulator-log.js.map +1 -1
  192. package/build/lib/device/simulator-management.d.ts.map +1 -1
  193. package/build/lib/device/simulator-management.js +0 -2
  194. package/build/lib/device/simulator-management.js.map +1 -1
  195. package/build/lib/doctor/optional-checks.d.ts +0 -9
  196. package/build/lib/doctor/optional-checks.d.ts.map +1 -1
  197. package/build/lib/doctor/optional-checks.js +1 -30
  198. package/build/lib/doctor/optional-checks.js.map +1 -1
  199. package/build/lib/driver.d.ts +6 -5
  200. package/build/lib/driver.d.ts.map +1 -1
  201. package/build/lib/driver.js +16 -14
  202. package/build/lib/driver.js.map +1 -1
  203. package/build/lib/execute-method-map.d.ts.map +1 -1
  204. package/build/lib/execute-method-map.js +0 -9
  205. package/build/lib/execute-method-map.js.map +1 -1
  206. package/lib/commands/active-app-info.ts +15 -0
  207. package/lib/commands/alert.ts +98 -0
  208. package/lib/commands/app-management.ts +414 -0
  209. package/lib/commands/{app-strings.js → app-strings.ts} +10 -9
  210. package/lib/commands/appearance.ts +70 -0
  211. package/lib/commands/audit.ts +25 -0
  212. package/lib/commands/{battery.js → battery.ts} +10 -12
  213. package/lib/commands/biometric.ts +52 -0
  214. package/lib/commands/{certificate.js → certificate.ts} +55 -50
  215. package/lib/commands/clipboard.ts +37 -0
  216. package/lib/commands/{condition.js → condition.ts} +21 -77
  217. package/lib/commands/content-size.ts +67 -0
  218. package/lib/commands/{context.js → context.ts} +174 -146
  219. package/lib/commands/device-info.ts +24 -0
  220. package/lib/commands/element.ts +419 -0
  221. package/lib/commands/{execute.js → execute.ts} +42 -38
  222. package/lib/commands/{file-movement.js → file-movement.ts} +212 -235
  223. package/lib/commands/find.ts +277 -0
  224. package/lib/commands/{general.js → general.ts} +102 -77
  225. package/lib/commands/geolocation.ts +55 -0
  226. package/lib/commands/{gesture.js → gesture.ts} +225 -183
  227. package/lib/commands/increase-contrast.ts +49 -0
  228. package/lib/commands/{iohid.js → iohid.ts} +15 -13
  229. package/lib/commands/keyboard.ts +70 -0
  230. package/lib/commands/keychains.ts +16 -0
  231. package/lib/commands/{localization.js → localization.ts} +22 -12
  232. package/lib/commands/{location.js → location.ts} +19 -22
  233. package/lib/commands/lock.ts +43 -0
  234. package/lib/commands/{log.js → log.ts} +68 -68
  235. package/lib/commands/{memory.js → memory.ts} +9 -9
  236. package/lib/commands/{navigation.js → navigation.ts} +42 -39
  237. package/lib/commands/{notifications.js → notifications.ts} +22 -14
  238. package/lib/commands/pasteboard.ts +44 -0
  239. package/lib/commands/{pcap.js → pcap.ts} +28 -28
  240. package/lib/commands/{performance.js → performance.ts} +133 -114
  241. package/lib/commands/permissions.ts +90 -0
  242. package/lib/commands/{proxy-helper.js → proxy-helper.ts} +26 -26
  243. package/lib/commands/{record-audio.js → record-audio.ts} +35 -33
  244. package/lib/commands/{recordscreen.js → recordscreen.ts} +78 -50
  245. package/lib/commands/{screenshots.js → screenshots.ts} +27 -21
  246. package/lib/commands/simctl.ts +82 -0
  247. package/lib/commands/{source.js → source.ts} +23 -20
  248. package/lib/commands/timeouts.ts +95 -0
  249. package/lib/commands/types.ts +86 -0
  250. package/lib/commands/{web.js → web.ts} +314 -264
  251. package/lib/commands/{xctest-record-screen.js → xctest-record-screen.ts} +54 -71
  252. package/lib/commands/{xctest.js → xctest.ts} +78 -71
  253. package/lib/desired-caps.ts +1 -1
  254. package/lib/device/log/ios-simulator-log.ts +2 -0
  255. package/lib/device/simulator-management.ts +0 -2
  256. package/lib/doctor/optional-checks.ts +0 -33
  257. package/lib/driver.ts +19 -17
  258. package/lib/execute-method-map.ts +0 -9
  259. package/package.json +6 -6
  260. package/lib/commands/active-app-info.js +0 -12
  261. package/lib/commands/alert.js +0 -88
  262. package/lib/commands/app-management.js +0 -346
  263. package/lib/commands/appearance.js +0 -71
  264. package/lib/commands/audit.js +0 -31
  265. package/lib/commands/biometric.js +0 -52
  266. package/lib/commands/clipboard.js +0 -35
  267. package/lib/commands/content-size.js +0 -68
  268. package/lib/commands/deviceInfo.js +0 -27
  269. package/lib/commands/element.js +0 -423
  270. package/lib/commands/find.js +0 -205
  271. package/lib/commands/geolocation.js +0 -56
  272. package/lib/commands/increase-contrast.js +0 -50
  273. package/lib/commands/keyboard.js +0 -62
  274. package/lib/commands/keychains.js +0 -17
  275. package/lib/commands/lock.js +0 -46
  276. package/lib/commands/pasteboard.js +0 -43
  277. package/lib/commands/permissions.js +0 -85
  278. package/lib/commands/simctl.js +0 -71
  279. package/lib/commands/timeouts.js +0 -68
@@ -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,16 @@
1
+ import {assertSimulator} from '../utils';
2
+ import type {XCUITestDriver} from '../driver';
3
+
4
+ /**
5
+ * Clears keychains on a simulated device.
6
+ *
7
+ * @throws {Error} If current device is not a Simulator or there was an error
8
+ * while clearing keychains.
9
+ * @group Simulator Only
10
+ */
11
+ export async function mobileClearKeychains(
12
+ this: XCUITestDriver,
13
+ ): Promise<void> {
14
+ await assertSimulator.call(this, 'Keychain modification').clearKeychains();
15
+ }
16
+
@@ -1,6 +1,6 @@
1
- import {assertSimulator as _assertSimulator} from '../utils';
2
-
3
- const assertSimulator = (driver) => _assertSimulator.call(driver, 'Localization configuration');
1
+ import {assertSimulator} from '../utils';
2
+ import type {XCUITestDriver} from '../driver';
3
+ import type {KeyboardOptions, LanguageOptions, LocaleOptions} from './types';
4
4
 
5
5
  /**
6
6
  * Change localization settings on the currently booted simulator
@@ -9,21 +9,31 @@ const assertSimulator = (driver) => _assertSimulator.call(driver, 'Localization
9
9
  * Currently running applications will be unchanged. This means, for example, that the keyboard should be hidden and shown again in order to observe the changed layout, and corresponding apps must be restarted in order to observe their interface using the newly set locale/language.
10
10
  *
11
11
  * The driver performs no strict checking of the arguments (such as locale names). Be aware that an incorrect or invalid string may cause unexpected behavior.
12
- * @param {import('./types').KeyboardOptions} [keyboard] - Keyboard options
13
- * @param {import('./types').LanguageOptions} [language] - Language options
14
- * @param {import('./types').LocaleOptions} [locale] - Locale options
12
+ * @param keyboard - Keyboard options
13
+ * @param language - Language options
14
+ * @param locale - Locale options
15
15
  * @throws {Error} If there was a failure while setting the preferences
16
- * @returns {Promise<boolean>} `true` if any of settings has been successfully changed
16
+ * @returns `true` if any of settings has been successfully changed
17
17
  * @group Simulator Only
18
- * @this {import('../driver').XCUITestDriver}
19
18
  */
20
- export async function mobileConfigureLocalization(keyboard, language, locale) {
21
- assertSimulator(this);
19
+ export async function mobileConfigureLocalization(
20
+ this: XCUITestDriver,
21
+ keyboard?: KeyboardOptions,
22
+ language?: LanguageOptions,
23
+ locale?: LocaleOptions,
24
+ ): Promise<boolean> {
25
+ ;
22
26
 
23
- const localizationOptions = {locale, keyboard};
27
+ const localizationOptions: {
28
+ locale?: LocaleOptions;
29
+ keyboard?: KeyboardOptions;
30
+ language?: LanguageOptions & {skipSyncUiDialogTranslation?: boolean};
31
+ } = {locale, keyboard};
24
32
  if (language) {
25
33
  // Assign skipSyncUiDialogTranslation: true option in order to avoid shutting down the WDA session
26
34
  localizationOptions.language = Object.assign(language, {skipSyncUiDialogTranslation: true});
27
35
  }
28
- return await /** @type {import('appium-ios-simulator').Simulator} */ (this.device).configureLocalization(localizationOptions);
36
+ return await assertSimulator.call(this, 'Localization configuration')
37
+ .configureLocalization(localizationOptions);
29
38
  }
39
+
@@ -3,6 +3,10 @@ import {errors} from 'appium/driver';
3
3
  import {util} from 'appium/support';
4
4
  import {AuthorizationStatus} from './enum';
5
5
  import { isIos17OrNewer } from '../utils';
6
+ import type {XCUITestDriver} from '../driver';
7
+ import type {Location} from '@appium/types';
8
+ import type {LocationWithAltitude, WDALocationInfo} from './types';
9
+ import type {Simulator} from 'appium-ios-simulator';
6
10
 
7
11
  /**
8
12
  * Returns location of the device under test.
@@ -17,12 +21,11 @@ import { isIos17OrNewer } from '../utils';
17
21
  * "mobile:getSimulatedLocation" if the simulated location has been previously set
18
22
  * "mobile:setSimulatedLocation" already.
19
23
  *
20
- * @returns {Promise<import('./types').LocationWithAltitude>}
24
+ * @returns Location with altitude
21
25
  * @throws {Error} If the device under test returns an error message.
22
26
  * i.e.: tvOS returns unsupported error
23
- * @this {XCUITestDriver}
24
27
  */
25
- export async function getGeoLocation() {
28
+ export async function getGeoLocation(this: XCUITestDriver): Promise<LocationWithAltitude> {
26
29
  // Currently we proxy the setGeoLocation to mobile:setSimulatedLocation for iOS 17+.
27
30
  // It would be helpful to address to use "mobile:getSimulatedLocation" for iOS 17+.
28
31
  if (isIos17OrNewer(this.opts)) {
@@ -41,9 +44,7 @@ export async function getGeoLocation() {
41
44
  // '/wda/device/location' returns current device location information,
42
45
  // but '/wda/simulatedLocation' returns `null` values until the WDA process
43
46
  // sets a simulated location. After setting the value, both returns the same values.
44
- const {authorizationStatus, latitude, longitude, altitude} = /** @type {WDALocationInfo} */ (
45
- await this.proxyCommand('/wda/device/location', 'GET')
46
- );
47
+ const {authorizationStatus, latitude, longitude, altitude} = await this.proxyCommand('/wda/device/location', 'GET') as WDALocationInfo;
47
48
 
48
49
  // '3' is 'Always' in the privacy
49
50
  // https://developer.apple.com/documentation/corelocation/clauthorizationstatus
@@ -66,19 +67,21 @@ export async function getGeoLocation() {
66
67
  * iOS 17+ real device environment will be via "mobile:setSimulatedLocation" as
67
68
  * setting simulated location for XCTest session.
68
69
  *
69
- * @param {Partial<Location>} location
70
- * @this {XCUITestDriver}
70
+ * @param location - Location with latitude and longitude
71
71
  */
72
- export async function setGeoLocation(location) {
73
- let {latitude, longitude} = location;
72
+ export async function setGeoLocation(
73
+ this: XCUITestDriver,
74
+ location: Partial<Location>,
75
+ ): Promise<Location> {
76
+ const {latitude, longitude} = location;
74
77
 
75
78
  if (!util.hasValue(latitude) || !util.hasValue(longitude)) {
76
79
  throw new errors.InvalidArgumentError(`Both latitude and longitude should be set`);
77
80
  }
78
81
 
79
82
  if (this.isSimulator()) {
80
- await /** @type {import('appium-ios-simulator').Simulator} */ (this.device).setGeolocation(`${latitude}`, `${longitude}`);
81
- return /** @type {Location} */ ({latitude, longitude, altitude: 0});
83
+ await (this.device as Simulator).setGeolocation(`${latitude}`, `${longitude}`);
84
+ return {latitude, longitude, altitude: 0};
82
85
  }
83
86
 
84
87
  if (isIos17OrNewer(this.opts)) {
@@ -88,7 +91,7 @@ export async function setGeoLocation(location) {
88
91
  const service = await services.startSimulateLocationService(this.opts.udid);
89
92
  try {
90
93
  service.setLocation(latitude, longitude);
91
- } catch (e) {
94
+ } catch (e: any) {
92
95
  throw this.log.errorWithException(
93
96
  `Can't set the location on device '${this.opts.udid}'. Original error: ${e.message}`,
94
97
  );
@@ -97,7 +100,7 @@ export async function setGeoLocation(location) {
97
100
  }
98
101
  }
99
102
 
100
- return /** @type {Location} */ ({latitude, longitude, altitude: 0});
103
+ return {latitude, longitude, altitude: 0};
101
104
  }
102
105
 
103
106
  /**
@@ -105,9 +108,8 @@ export async function setGeoLocation(location) {
105
108
  *
106
109
  * @throws {Error} If the device is simulator and iOS version is below 17,
107
110
  * or 'resetLocation' raises an error.
108
- * @this {XCUITestDriver}
109
111
  */
110
- export async function mobileResetLocationService() {
112
+ export async function mobileResetLocationService(this: XCUITestDriver): Promise<void> {
111
113
  if (isIos17OrNewer(this.opts)) {
112
114
  this.log.info(`Proxying to mobile:resetSimulatedLocation method for iOS 17+`);
113
115
  await this.mobileResetSimulatedLocation();
@@ -121,7 +123,7 @@ export async function mobileResetLocationService() {
121
123
  const service = await services.startSimulateLocationService(this.opts.udid);
122
124
  try {
123
125
  service.resetLocation();
124
- } catch (err) {
126
+ } catch (err: any) {
125
127
  throw this.log.errorWithException(
126
128
  `Failed to reset the location on the device on device '${this.opts.udid}'. ` +
127
129
  `Original error: ${err.message}`,
@@ -131,8 +133,3 @@ export async function mobileResetLocationService() {
131
133
  }
132
134
  }
133
135
 
134
- /**
135
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
136
- * @typedef {import('./types').WDALocationInfo} WDALocationInfo
137
- * @typedef {import('@appium/types').Location} Location
138
- */
@@ -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
+