@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,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
+
@@ -9,6 +9,9 @@ import {exec} from 'teen_process';
9
9
  import {findAPortNotInUse, checkPortStatus} from 'portscanner';
10
10
  import {Pyidevice} from '../device/clients/py-ios-device-client';
11
11
  import {errors} from 'appium/driver';
12
+ import type {Simulator} from 'appium-ios-simulator';
13
+ import type {XCUITestDriver} from '../driver';
14
+ import type {CertificateList} from './types';
12
15
 
13
16
  const CONFIG_EXTENSION = 'mobileconfig';
14
17
  const HOST_PORT_RANGE = [38200, 38299];
@@ -62,11 +65,8 @@ const OPEN_SSL_PATTERN = /,\sCN\s=\s([^,]+)/;
62
65
 
63
66
  /**
64
67
  * Parses the common name of the certificate from the given string.
65
- *
66
- * @param {string} stringCertificate
67
- * @returns {string} The common name of the certificate
68
68
  */
69
- export function parseCommonName(stringCertificate) {
69
+ export function parseCommonName(stringCertificate: string): string {
70
70
  const result = [LIBRE_SSL_PATTERN, OPEN_SSL_PATTERN].reduce((acc, r) => {
71
71
  if (acc) {
72
72
  return acc;
@@ -87,22 +87,28 @@ export function parseCommonName(stringCertificate) {
87
87
  * certificates on Simulator over CLI.
88
88
  *
89
89
  * On real devices (or simulators before Xcode SDK 11.4), Apple provides no "official" way to do this via the command line. In such a case (and also as a fallback if CLI setup fails), this method tries to wrap the certificate into `.mobileconfig` format, then deploys the wrapped file to the internal HTTP server so that it can be opened via mobile Safari. This command then goes through the profile installation procedure by clicking the necessary buttons using WebDriverAgent.
90
- * @param {string} content - Base64-encoded content of the public certificate in [PEM](https://knowledge.digicert.com/quovadis/ssl-certificates/ssl-general-topics/what-is-pem-format.html) format
91
- * @param {string} [commonName] - Common name of the certificate. If this is not set, the command will try to parse it from the provided `content`.
92
- * @param {boolean} isRoot - Defines where the certificate should be installed; either the Trusted Root Store (`true`) or the Keychain (`false`). On environments other than Xcode 11.4+ Simulator, this option is ignored.
93
- * @returns {Promise<string|void>} The content of the generated `.mobileconfig` file as
90
+ * @param content - Base64-encoded content of the public certificate in [PEM](https://knowledge.digicert.com/quovadis/ssl-certificates/ssl-general-topics/what-is-pem-format.html) format
91
+ * @param commonName - Common name of the certificate. If this is not set, the command will try to parse it from the provided `content`.
92
+ * @param isRoot - Defines where the certificate should be installed; either the Trusted Root Store (`true`) or the Keychain (`false`). On environments other than Xcode 11.4+ Simulator, this option is ignored.
93
+ * @returns The content of the generated `.mobileconfig` file as
94
94
  * a base64-encoded string. This config might be useful for debugging purposes. If the certificate has been successfully set via CLI, then nothing is returned.
95
- * @this {XCUITestDriver}
96
95
  */
97
- export async function mobileInstallCertificate(content, commonName, isRoot = true) {
96
+ export async function mobileInstallCertificate(
97
+ this: XCUITestDriver,
98
+ content: string,
99
+ commonName?: string,
100
+ isRoot = true,
101
+ ): Promise<string | void> {
98
102
  if (_.isEmpty(content)) {
99
103
  throw new Error('Certificate content should not be empty');
100
104
  }
101
105
 
102
106
  if (this.isSimulator()) {
103
107
  try {
104
- const methodName = isRoot ? 'addRootCertificate' : 'addCertificate';
105
- await /** @type {import('appium-ios-simulator').Simulator} */ (this.device).simctl[methodName](Buffer.from(content, 'base64').toString(), {
108
+ const methodName: 'addRootCertificate' | 'addCertificate' = isRoot
109
+ ? 'addRootCertificate'
110
+ : 'addCertificate';
111
+ await (this.device as Simulator).simctl[methodName](Buffer.from(content, 'base64').toString(), {
106
112
  raw: true,
107
113
  });
108
114
  return;
@@ -188,11 +194,12 @@ export async function mobileInstallCertificate(content, commonName, isRoot = tru
188
194
  }
189
195
  }
190
196
  } else {
191
- await /** @type {import('appium-ios-simulator').Simulator} */ (this.device).openUrl(certUrl);
197
+ await (this.device as Simulator).openUrl(certUrl);
192
198
  }
193
199
 
194
200
  let isCertAlreadyInstalled = false;
195
- if (util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '>=', '12.2')) {
201
+ const platformVersion = this.opts.platformVersion ?? '';
202
+ if (util.compareVersions(platformVersion, '>=', '12.2')) {
196
203
  if (await installPost122Certificate(this, cn)) {
197
204
  await clickElement(this, Settings.Profile);
198
205
  await trustCertificateInPreferences(this, cn);
@@ -238,17 +245,19 @@ export async function mobileInstallCertificate(content, commonName, isRoot = tru
238
245
  *
239
246
  * @see https://github.com/YueChen-C/py-ios-device
240
247
  * @since 4.19.2
241
- * @param {string} name - Name of the profile
242
- * @returns {Promise<string>} Returns status acknowledgment status if
243
- * tht certificate is successfully removed or 'None' (basically just
244
- * forwards the original pyidevice output)
248
+ * @param name - Name of the profile
249
+ * @returns Status acknowledgment if
250
+ * the certificate is successfully removed or 'None' (forwards pyidevice output)
245
251
  * @throws {Error} If attempting to remove certificates for a simulated device or if `py-ios-device` is not installed
246
252
  * @group Real Device Only
247
253
  */
248
- export async function mobileRemoveCertificate(name) {
254
+ export async function mobileRemoveCertificate(this: XCUITestDriver, name: string): Promise<string> {
249
255
  if (!this.isRealDevice()) {
250
256
  throw new errors.NotImplementedError('This extension is only supported on real devices');
251
257
  }
258
+ if (!this.opts.udid) {
259
+ throw new Error('udid capability is required');
260
+ }
252
261
  const client = new Pyidevice({
253
262
  udid: this.opts.udid,
254
263
  log: this.log,
@@ -263,11 +272,10 @@ export async function mobileRemoveCertificate(name) {
263
272
  * This only works _if and only if_ `py-ios-device` is installed on the same machine Appium is running on.
264
273
  * @since 4.10.0
265
274
  * @see https://github.com/YueChen-C/py-ios-device
266
- * @returns {Promise<import('./types').CertificateList>} An object describing the certificates installed on the real device.
275
+ * @returns An object describing the certificates installed on the real device.
267
276
  * @throws {Error} If attempting to list certificates for a simulated device or if `py-ios-device` is not installed
268
- * @this {XCUITestDriver}
269
277
  */
270
- export async function mobileListCertificates() {
278
+ export async function mobileListCertificates(this: XCUITestDriver): Promise<CertificateList> {
271
279
  if (!this.isRealDevice()) {
272
280
  throw new errors.NotImplementedError('This extension is only supported on real devices');
273
281
  }
@@ -287,9 +295,9 @@ export async function mobileListCertificates() {
287
295
  * Extracts the common name of the certificate from the given buffer.
288
296
  *
289
297
  * @param {Buffer} certBuffer
290
- * @returns {Promise<string>} The common name of the certificate
298
+ * @returns The common name of the certificate
291
299
  */
292
- async function extractCommonName(certBuffer) {
300
+ async function extractCommonName(certBuffer: Buffer): Promise<string> {
293
301
  const tempCert = await tempDir.open({
294
302
  prefix: 'cert',
295
303
  suffix: '.cer',
@@ -315,12 +323,12 @@ async function extractCommonName(certBuffer) {
315
323
  * for more details on such profiles.
316
324
  *
317
325
  * @param {Buffer} certBuffer - The actual content of PEM certificate encoded into NodeJS buffer
318
- * @param {string} commonName - Certificate's common name
326
+ * @param commonName - Certificate's common name
319
327
  * @returns {Object} The encoded structure of the given certificate, which is ready to be passed
320
328
  * as an argument to plist builder
321
329
  * @throws {Error} If the given certificate cannot be parsed
322
330
  */
323
- function toMobileConfig(certBuffer, commonName) {
331
+ function toMobileConfig(certBuffer: Buffer, commonName: string): Record<string, any> {
324
332
  const getUUID = () => util.uuidV4().toUpperCase();
325
333
  const contentUuid = getUUID();
326
334
  return {
@@ -345,8 +353,12 @@ function toMobileConfig(certBuffer, commonName) {
345
353
  };
346
354
  }
347
355
 
348
- async function clickElement(driver, locator, options = {}) {
349
- let element = null;
356
+ async function clickElement(
357
+ driver: XCUITestDriver,
358
+ locator: {type: string; value: string},
359
+ options: {timeout?: number; skipIfInvisible?: boolean} = {},
360
+ ): Promise<boolean> {
361
+ let element: any = null;
350
362
  const {timeout = 5000, skipIfInvisible = false} = options;
351
363
  const lookupDelay = 500;
352
364
  try {
@@ -365,7 +377,7 @@ async function clickElement(driver, locator, options = {}) {
365
377
  return true;
366
378
  }
367
379
 
368
- async function installPre122Certificate(driver) {
380
+ async function installPre122Certificate(driver: XCUITestDriver): Promise<boolean> {
369
381
  // Accept Safari alert
370
382
  await clickElement(driver, Button.Allow, {
371
383
  // certificate load might take some time on slow machines
@@ -393,7 +405,7 @@ async function installPre122Certificate(driver) {
393
405
  return true;
394
406
  }
395
407
 
396
- async function trustCertificateInPreferences(driver, name) {
408
+ async function trustCertificateInPreferences(driver: XCUITestDriver, name: string): Promise<void> {
397
409
  await clickElement(driver, Settings.General);
398
410
  await clickElement(driver, Settings.About);
399
411
  const switchLocator = {
@@ -401,14 +413,12 @@ async function trustCertificateInPreferences(driver, name) {
401
413
  value: `**/XCUIElementTypeCell[\`label == '${name}'\`]/**/XCUIElementTypeSwitch`,
402
414
  };
403
415
  await retry(5, async () => {
404
- await driver.mobileSwipe({
405
- element: await driver.findNativeElementOrElements(
406
- 'class name',
407
- 'XCUIElementTypeTable',
408
- false,
409
- ),
410
- direction: 'up',
411
- });
416
+ const tableEl = await driver.findNativeElementOrElements(
417
+ 'class name',
418
+ 'XCUIElementTypeTable',
419
+ false,
420
+ );
421
+ await driver.mobileSwipe('up', undefined, tableEl);
412
422
  await clickElement(driver, Settings.Certificate_Trust_Settings, {
413
423
  timeout: 500,
414
424
  });
@@ -433,7 +443,7 @@ async function trustCertificateInPreferences(driver, name) {
433
443
  }
434
444
  }
435
445
 
436
- async function installPost122Certificate(driver, name) {
446
+ async function installPost122Certificate(driver: XCUITestDriver, name: string): Promise<boolean> {
437
447
  // Accept Safari alert
438
448
  await clickElement(driver, Button.Allow, {
439
449
  // certificate load might take some time on slow machines
@@ -466,14 +476,12 @@ async function installPost122Certificate(driver, name) {
466
476
  break;
467
477
  }
468
478
 
469
- await driver.mobileSwipe({
470
- element: await driver.findNativeElementOrElements(
471
- 'class name',
472
- 'XCUIElementTypeTable',
473
- false,
474
- ),
475
- direction: 'up',
476
- });
479
+ const tableEl = await driver.findNativeElementOrElements(
480
+ 'class name',
481
+ 'XCUIElementTypeTable',
482
+ false,
483
+ );
484
+ await driver.mobileSwipe('up', undefined, tableEl);
477
485
  }
478
486
  if (!isCertFound) {
479
487
  throw new Error(`'${name}' cannot be found in the certificates list`);
@@ -498,6 +506,3 @@ async function installPost122Certificate(driver, name) {
498
506
  return true;
499
507
  }
500
508
 
501
- /**
502
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
503
- */
@@ -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
+
@@ -1,24 +1,25 @@
1
1
  import {INSTRUMENT_CHANNEL, services} from 'appium-ios-device';
2
2
  import _ from 'lodash';
3
3
  import { isIos18OrNewer } from '../utils';
4
+ import type {XCUITestDriver} from '../driver';
5
+ import type {DVTServiceWithConnection} from 'appium-ios-remotexpc';
6
+ import type {Condition} from './types';
4
7
 
5
8
  /**
6
9
  * Get all available ConditionInducer configuration information, which can be used with
7
10
  * {@linkcode XCUITestDriver.enableConditionInducer}
8
- * @returns {Promise<Condition[]>}
9
11
  * @since 4.9.0
10
12
  * @see {@link https://help.apple.com/xcode/mac/current/#/dev308429d42}
11
- * @this {XCUITestDriver}
12
13
  */
13
- export async function listConditionInducers() {
14
+ export async function listConditionInducers(this: XCUITestDriver): Promise<Condition[]> {
14
15
  requireConditionInducerCompatibleDevice.call(this);
15
16
 
16
17
  if (isIos18OrNewer(this.opts)) {
17
18
  const dvtConnection = await startRemoteXPC(this.device.udid);
18
19
  try {
19
20
  const result = await dvtConnection.conditionInducer.list();
20
- return /** @type {Condition[]} */ (result);
21
- } catch (err) {
21
+ return result as Condition[];
22
+ } catch (err: any) {
22
23
  this.log.error(`Failed to list condition inducers via RemoteXPC: ${err.message}`);
23
24
  throw err;
24
25
  } finally {
@@ -50,15 +51,18 @@ export async function listConditionInducers() {
50
51
  * (Note: the socket needs to remain connected during operation)
51
52
  * (Note: Device conditions are available only for real devices running iOS 13.0 and later.)
52
53
  *
53
- * @param {string} conditionID - Determine which condition IDs are available with the {@linkcode XCUITestDriver.listConditionInducers} command
54
- * @param {string} profileID - Determine which profile IDs are available with the {@linkcode XCUITestDriver.listConditionInducers} command
55
- * @returns {Promise<boolean>} `true` if enabling the condition succeeded
54
+ * @param conditionID - Determine which condition IDs are available with the {@linkcode XCUITestDriver.listConditionInducers} command
55
+ * @param profileID - Determine which profile IDs are available with the {@linkcode XCUITestDriver.listConditionInducers} command
56
+ * @returns `true` if enabling the condition succeeded
56
57
  * @throws {Error} If you try to start another Condition and the previous Condition has not stopped
57
58
  * @since 4.9.0
58
59
  * @see {@link https://help.apple.com/xcode/mac/current/#/dev308429d42}
59
- * @this {XCUITestDriver}
60
60
  */
61
- export async function enableConditionInducer(conditionID, profileID) {
61
+ export async function enableConditionInducer(
62
+ this: XCUITestDriver,
63
+ conditionID: string,
64
+ profileID: string,
65
+ ): Promise<boolean> {
62
66
  requireConditionInducerCompatibleDevice.call(this);
63
67
 
64
68
  if (isIos18OrNewer(this.opts)) {
@@ -76,7 +80,7 @@ export async function enableConditionInducer(conditionID, profileID) {
76
80
 
77
81
  this.log.info(`Successfully enabled condition profile: ${profileID}`);
78
82
  return true;
79
- } catch (err) {
83
+ } catch (err: any) {
80
84
  await closeRemoteXPC.call(this);
81
85
  throw this.log.errorWithException(`Condition inducer '${profileID}' cannot be enabled: '${err.message}'`);
82
86
  }
@@ -109,12 +113,11 @@ export async function enableConditionInducer(conditionID, profileID) {
109
113
  * condition inducer will be automatically disabled
110
114
  *
111
115
  * (Note: this is also automatically called upon session cleanup)
112
- * @returns {Promise<boolean>} `true` if disable the condition succeeded
116
+ * @returns `true` if disable the condition succeeded
113
117
  * @since 4.9.0
114
118
  * @see {@link https://help.apple.com/xcode/mac/current/#/dev308429d42}
115
- * @this {XCUITestDriver}
116
119
  */
117
- export async function disableConditionInducer() {
120
+ export async function disableConditionInducer(this: XCUITestDriver): Promise<boolean> {
118
121
  requireConditionInducerCompatibleDevice.call(this);
119
122
 
120
123
  if (isIos18OrNewer(this.opts)) {
@@ -127,7 +130,7 @@ export async function disableConditionInducer() {
127
130
  await this._remoteXPCConditionInducerConnection.conditionInducer.disable();
128
131
  this.log.info('Successfully disabled condition inducer');
129
132
  return true;
130
- } catch (err) {
133
+ } catch (err: any) {
131
134
  this.log.warn(`Failed to disable condition inducer via RemoteXPC: ${err.message}`);
132
135
  return false;
133
136
  } finally {
@@ -158,81 +161,22 @@ export async function disableConditionInducer() {
158
161
  }
159
162
  }
160
163
 
161
- /**
162
- * @this {XCUITestDriver}
163
- * @returns {void}
164
- */
165
- function requireConditionInducerCompatibleDevice() {
164
+ function requireConditionInducerCompatibleDevice(this: XCUITestDriver): void {
166
165
  if (this.isSimulator()) {
167
166
  throw this.log.errorWithException('Condition inducer only works on real devices');
168
167
  }
169
168
  }
170
169
 
171
- /**
172
- * @param {string} udid
173
- * @returns {Promise<DVTServiceWithConnection>}
174
- */
175
- async function startRemoteXPC(udid) {
170
+ async function startRemoteXPC(udid: string): Promise<DVTServiceWithConnection> {
176
171
  const {Services} = await import('appium-ios-remotexpc');
177
172
  return Services.startDVTService(udid);
178
173
  }
179
174
 
180
- /**
181
- * @this {XCUITestDriver}
182
- * @returns {Promise<void>}
183
- */
184
- async function closeRemoteXPC() {
175
+ async function closeRemoteXPC(this: XCUITestDriver): Promise<void> {
185
176
  if (this._remoteXPCConditionInducerConnection) {
186
177
  await this._remoteXPCConditionInducerConnection.remoteXPC.close();
187
178
  this._remoteXPCConditionInducerConnection = null;
188
179
  }
189
180
  }
190
181
 
191
- /**
192
- * @typedef {import('appium-ios-remotexpc', {with: {'resolution-mode': 'import'}}).DVTServiceWithConnection} DVTServiceWithConnection
193
- */
194
-
195
- /**
196
- * @typedef {Object} Profile
197
- * @property {string} name
198
- * @property {string} identifier the property is profileID used in {@linkcode XCUITestDriver.enableConditionInducer}
199
- * @property {string} description Configuration details
200
- */
201
-
202
- /**
203
- * We can use the returned data to determine whether the Condition is enabled and the currently enabled configuration information
204
- * @typedef {Object} Condition
205
- * @property {Profile[]} profiles
206
- * @property {string} identifier the property is conditionID used in {@linkcode XCUITestDriver.enableConditionInducer}
207
- * @property {boolean} profilesSorted
208
- * @property {boolean} isDestructive
209
- * @property {boolean} isInternal
210
- * @property {boolean} isActive `true` if this condition identifier is enabled
211
- * @property {string} activeProfile enabled profiles identifier
212
- * @example {
213
- * "profiles": [
214
- * {
215
- * "name": "100% packet loss",
216
- * "identifier": "SlowNetwork100PctLoss", // MobileEnableConditionInducer profileID
217
- * "description": "Name: 100% Loss Scenario\n
218
- * Downlink Bandwidth: 0 Mbps\n
219
- * Downlink Latency:0 ms\n
220
- * Downlink Packet Loss Ratio: 100%\n
221
- * Uplink Bandwidth: 0 Mbps\n
222
- * Uplink Latency: 0 ms\n
223
- * Uplink Packet Loss Ratio: 100%"
224
- * }
225
- * ],
226
- * "profilesSorted": true,
227
- * "identifier": "SlowNetworkCondition", // MobileEnableConditionInducer conditionID
228
- * "isDestructive": false,
229
- * "isInternal": false,
230
- * "activeProfile": "",
231
- * "name": "Network Link",
232
- * "isActive": false
233
- * }
234
- */
235
182
 
236
- /**
237
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
238
- */
@@ -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
+