@limrun/appium-xcuitest-driver 10.4.3-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 (444) hide show
  1. package/CHANGELOG.md +2600 -0
  2. package/LICENSE +201 -0
  3. package/README.md +55 -0
  4. package/build/index.d.ts +5 -0
  5. package/build/index.js +41 -0
  6. package/build/lib/app-infos-cache.d.ts +62 -0
  7. package/build/lib/app-infos-cache.d.ts.map +1 -0
  8. package/build/lib/app-infos-cache.js +180 -0
  9. package/build/lib/app-infos-cache.js.map +1 -0
  10. package/build/lib/app-utils.d.ts +89 -0
  11. package/build/lib/app-utils.d.ts.map +1 -0
  12. package/build/lib/app-utils.js +657 -0
  13. package/build/lib/app-utils.js.map +1 -0
  14. package/build/lib/commands/active-app-info.d.ts +9 -0
  15. package/build/lib/commands/active-app-info.d.ts.map +1 -0
  16. package/build/lib/commands/active-app-info.js +14 -0
  17. package/build/lib/commands/active-app-info.js.map +1 -0
  18. package/build/lib/commands/advanced-battery-types.d.ts +444 -0
  19. package/build/lib/commands/advanced-battery-types.d.ts.map +1 -0
  20. package/build/lib/commands/advanced-battery-types.js +8 -0
  21. package/build/lib/commands/advanced-battery-types.js.map +1 -0
  22. package/build/lib/commands/alert.d.ts +45 -0
  23. package/build/lib/commands/alert.d.ts.map +1 -0
  24. package/build/lib/commands/alert.js +87 -0
  25. package/build/lib/commands/alert.js.map +1 -0
  26. package/build/lib/commands/app-management.d.ts +153 -0
  27. package/build/lib/commands/app-management.d.ts.map +1 -0
  28. package/build/lib/commands/app-management.js +323 -0
  29. package/build/lib/commands/app-management.js.map +1 -0
  30. package/build/lib/commands/app-strings.d.ts +16 -0
  31. package/build/lib/commands/app-strings.d.ts.map +1 -0
  32. package/build/lib/commands/app-strings.js +30 -0
  33. package/build/lib/commands/app-strings.js.map +1 -0
  34. package/build/lib/commands/appearance.d.ts +22 -0
  35. package/build/lib/commands/appearance.d.ts.map +1 -0
  36. package/build/lib/commands/appearance.js +74 -0
  37. package/build/lib/commands/appearance.js.map +1 -0
  38. package/build/lib/commands/audit.d.ts +43 -0
  39. package/build/lib/commands/audit.d.ts.map +1 -0
  40. package/build/lib/commands/audit.js +31 -0
  41. package/build/lib/commands/audit.js.map +1 -0
  42. package/build/lib/commands/battery.d.ts +13 -0
  43. package/build/lib/commands/battery.d.ts.map +1 -0
  44. package/build/lib/commands/battery.js +49 -0
  45. package/build/lib/commands/battery.js.map +1 -0
  46. package/build/lib/commands/bidi/constants.d.ts +6 -0
  47. package/build/lib/commands/bidi/constants.d.ts.map +1 -0
  48. package/build/lib/commands/bidi/constants.js +10 -0
  49. package/build/lib/commands/bidi/constants.js.map +1 -0
  50. package/build/lib/commands/bidi/models.d.ts +9 -0
  51. package/build/lib/commands/bidi/models.d.ts.map +1 -0
  52. package/build/lib/commands/bidi/models.js +54 -0
  53. package/build/lib/commands/bidi/models.js.map +1 -0
  54. package/build/lib/commands/bidi/types.d.ts +26 -0
  55. package/build/lib/commands/bidi/types.d.ts.map +1 -0
  56. package/build/lib/commands/bidi/types.js +4 -0
  57. package/build/lib/commands/bidi/types.js.map +1 -0
  58. package/build/lib/commands/biometric.d.ts +32 -0
  59. package/build/lib/commands/biometric.d.ts.map +1 -0
  60. package/build/lib/commands/biometric.js +54 -0
  61. package/build/lib/commands/biometric.js.map +1 -0
  62. package/build/lib/commands/certificate.d.ts +50 -0
  63. package/build/lib/commands/certificate.d.ts.map +1 -0
  64. package/build/lib/commands/certificate.js +454 -0
  65. package/build/lib/commands/certificate.js.map +1 -0
  66. package/build/lib/commands/clipboard.d.ts +21 -0
  67. package/build/lib/commands/clipboard.d.ts.map +1 -0
  68. package/build/lib/commands/clipboard.js +36 -0
  69. package/build/lib/commands/clipboard.js.map +1 -0
  70. package/build/lib/commands/condition.d.ts +102 -0
  71. package/build/lib/commands/condition.d.ts.map +1 -0
  72. package/build/lib/commands/condition.js +146 -0
  73. package/build/lib/commands/condition.js.map +1 -0
  74. package/build/lib/commands/content-size.d.ts +30 -0
  75. package/build/lib/commands/content-size.d.ts.map +1 -0
  76. package/build/lib/commands/content-size.js +67 -0
  77. package/build/lib/commands/content-size.js.map +1 -0
  78. package/build/lib/commands/context.d.ts +191 -0
  79. package/build/lib/commands/context.d.ts.map +1 -0
  80. package/build/lib/commands/context.js +625 -0
  81. package/build/lib/commands/context.js.map +1 -0
  82. package/build/lib/commands/deviceInfo.d.ts +12 -0
  83. package/build/lib/commands/deviceInfo.d.ts.map +1 -0
  84. package/build/lib/commands/deviceInfo.js +25 -0
  85. package/build/lib/commands/deviceInfo.js.map +1 -0
  86. package/build/lib/commands/element.d.ts +108 -0
  87. package/build/lib/commands/element.d.ts.map +1 -0
  88. package/build/lib/commands/element.js +395 -0
  89. package/build/lib/commands/element.js.map +1 -0
  90. package/build/lib/commands/enum.d.ts +105 -0
  91. package/build/lib/commands/enum.d.ts.map +1 -0
  92. package/build/lib/commands/enum.js +113 -0
  93. package/build/lib/commands/enum.js.map +1 -0
  94. package/build/lib/commands/execute.d.ts +33 -0
  95. package/build/lib/commands/execute.d.ts.map +1 -0
  96. package/build/lib/commands/execute.js +142 -0
  97. package/build/lib/commands/execute.js.map +1 -0
  98. package/build/lib/commands/file-movement.d.ts +90 -0
  99. package/build/lib/commands/file-movement.d.ts.map +1 -0
  100. package/build/lib/commands/file-movement.js +477 -0
  101. package/build/lib/commands/file-movement.js.map +1 -0
  102. package/build/lib/commands/find.d.ts +21 -0
  103. package/build/lib/commands/find.d.ts.map +1 -0
  104. package/build/lib/commands/find.js +199 -0
  105. package/build/lib/commands/find.js.map +1 -0
  106. package/build/lib/commands/general.d.ts +137 -0
  107. package/build/lib/commands/general.d.ts.map +1 -0
  108. package/build/lib/commands/general.js +270 -0
  109. package/build/lib/commands/general.js.map +1 -0
  110. package/build/lib/commands/geolocation.d.ts +57 -0
  111. package/build/lib/commands/geolocation.d.ts.map +1 -0
  112. package/build/lib/commands/geolocation.js +58 -0
  113. package/build/lib/commands/geolocation.js.map +1 -0
  114. package/build/lib/commands/gesture.d.ts +283 -0
  115. package/build/lib/commands/gesture.d.ts.map +1 -0
  116. package/build/lib/commands/gesture.js +565 -0
  117. package/build/lib/commands/gesture.js.map +1 -0
  118. package/build/lib/commands/hid-event.d.ts +2773 -0
  119. package/build/lib/commands/hid-event.d.ts.map +1 -0
  120. package/build/lib/commands/hid-event.js +1633 -0
  121. package/build/lib/commands/hid-event.js.map +1 -0
  122. package/build/lib/commands/increase-contrast.d.ts +24 -0
  123. package/build/lib/commands/increase-contrast.d.ts.map +1 -0
  124. package/build/lib/commands/increase-contrast.js +49 -0
  125. package/build/lib/commands/increase-contrast.js.map +1 -0
  126. package/build/lib/commands/iohid.d.ts +1372 -0
  127. package/build/lib/commands/iohid.d.ts.map +1 -0
  128. package/build/lib/commands/iohid.js +63 -0
  129. package/build/lib/commands/iohid.js.map +1 -0
  130. package/build/lib/commands/keyboard.d.ts +32 -0
  131. package/build/lib/commands/keyboard.d.ts.map +1 -0
  132. package/build/lib/commands/keyboard.js +67 -0
  133. package/build/lib/commands/keyboard.js.map +1 -0
  134. package/build/lib/commands/keychains.d.ts +10 -0
  135. package/build/lib/commands/keychains.d.ts.map +1 -0
  136. package/build/lib/commands/keychains.js +22 -0
  137. package/build/lib/commands/keychains.js.map +1 -0
  138. package/build/lib/commands/localization.d.ts +17 -0
  139. package/build/lib/commands/localization.d.ts.map +1 -0
  140. package/build/lib/commands/localization.js +34 -0
  141. package/build/lib/commands/localization.js.map +1 -0
  142. package/build/lib/commands/location.d.ts +40 -0
  143. package/build/lib/commands/location.d.ts.map +1 -0
  144. package/build/lib/commands/location.js +121 -0
  145. package/build/lib/commands/location.js.map +1 -0
  146. package/build/lib/commands/lock.d.ts +23 -0
  147. package/build/lib/commands/lock.d.ts.map +1 -0
  148. package/build/lib/commands/lock.js +49 -0
  149. package/build/lib/commands/lock.js.map +1 -0
  150. package/build/lib/commands/log.d.ts +68 -0
  151. package/build/lib/commands/log.d.ts.map +1 -0
  152. package/build/lib/commands/log.js +287 -0
  153. package/build/lib/commands/log.js.map +1 -0
  154. package/build/lib/commands/memory.d.ts +11 -0
  155. package/build/lib/commands/memory.d.ts.map +1 -0
  156. package/build/lib/commands/memory.js +49 -0
  157. package/build/lib/commands/memory.js.map +1 -0
  158. package/build/lib/commands/navigation.d.ts +44 -0
  159. package/build/lib/commands/navigation.d.ts.map +1 -0
  160. package/build/lib/commands/navigation.js +121 -0
  161. package/build/lib/commands/navigation.js.map +1 -0
  162. package/build/lib/commands/notifications.d.ts +28 -0
  163. package/build/lib/commands/notifications.d.ts.map +1 -0
  164. package/build/lib/commands/notifications.js +64 -0
  165. package/build/lib/commands/notifications.js.map +1 -0
  166. package/build/lib/commands/pasteboard.d.ts +23 -0
  167. package/build/lib/commands/pasteboard.d.ts.map +1 -0
  168. package/build/lib/commands/pasteboard.js +43 -0
  169. package/build/lib/commands/pasteboard.js.map +1 -0
  170. package/build/lib/commands/pcap.d.ts +54 -0
  171. package/build/lib/commands/pcap.d.ts.map +1 -0
  172. package/build/lib/commands/pcap.js +149 -0
  173. package/build/lib/commands/pcap.js.map +1 -0
  174. package/build/lib/commands/performance.d.ts +85 -0
  175. package/build/lib/commands/performance.d.ts.map +1 -0
  176. package/build/lib/commands/performance.js +331 -0
  177. package/build/lib/commands/performance.js.map +1 -0
  178. package/build/lib/commands/permissions.d.ts +36 -0
  179. package/build/lib/commands/permissions.d.ts.map +1 -0
  180. package/build/lib/commands/permissions.js +80 -0
  181. package/build/lib/commands/permissions.js.map +1 -0
  182. package/build/lib/commands/proxy-helper.d.ts +15 -0
  183. package/build/lib/commands/proxy-helper.d.ts.map +1 -0
  184. package/build/lib/commands/proxy-helper.js +117 -0
  185. package/build/lib/commands/proxy-helper.js.map +1 -0
  186. package/build/lib/commands/record-audio.d.ts +69 -0
  187. package/build/lib/commands/record-audio.d.ts.map +1 -0
  188. package/build/lib/commands/record-audio.js +228 -0
  189. package/build/lib/commands/record-audio.js.map +1 -0
  190. package/build/lib/commands/recordscreen.d.ts +89 -0
  191. package/build/lib/commands/recordscreen.d.ts.map +1 -0
  192. package/build/lib/commands/recordscreen.js +326 -0
  193. package/build/lib/commands/recordscreen.js.map +1 -0
  194. package/build/lib/commands/screenshots.d.ts +16 -0
  195. package/build/lib/commands/screenshots.d.ts.map +1 -0
  196. package/build/lib/commands/screenshots.js +129 -0
  197. package/build/lib/commands/screenshots.js.map +1 -0
  198. package/build/lib/commands/simctl.d.ts +27 -0
  199. package/build/lib/commands/simctl.d.ts.map +1 -0
  200. package/build/lib/commands/simctl.js +65 -0
  201. package/build/lib/commands/simctl.js.map +1 -0
  202. package/build/lib/commands/source.d.ts +16 -0
  203. package/build/lib/commands/source.d.ts.map +1 -0
  204. package/build/lib/commands/source.js +128 -0
  205. package/build/lib/commands/source.js.map +1 -0
  206. package/build/lib/commands/timeouts.d.ts +53 -0
  207. package/build/lib/commands/timeouts.d.ts.map +1 -0
  208. package/build/lib/commands/timeouts.js +71 -0
  209. package/build/lib/commands/timeouts.js.map +1 -0
  210. package/build/lib/commands/types.d.ts +539 -0
  211. package/build/lib/commands/types.d.ts.map +1 -0
  212. package/build/lib/commands/types.js +3 -0
  213. package/build/lib/commands/types.js.map +1 -0
  214. package/build/lib/commands/web.d.ts +297 -0
  215. package/build/lib/commands/web.d.ts.map +1 -0
  216. package/build/lib/commands/web.js +1029 -0
  217. package/build/lib/commands/web.js.map +1 -0
  218. package/build/lib/commands/xctest-record-screen.d.ts +92 -0
  219. package/build/lib/commands/xctest-record-screen.d.ts.map +1 -0
  220. package/build/lib/commands/xctest-record-screen.js +193 -0
  221. package/build/lib/commands/xctest-record-screen.js.map +1 -0
  222. package/build/lib/commands/xctest.d.ts +71 -0
  223. package/build/lib/commands/xctest.d.ts.map +1 -0
  224. package/build/lib/commands/xctest.js +257 -0
  225. package/build/lib/commands/xctest.js.map +1 -0
  226. package/build/lib/css-converter.d.ts +10 -0
  227. package/build/lib/css-converter.d.ts.map +1 -0
  228. package/build/lib/css-converter.js +258 -0
  229. package/build/lib/css-converter.js.map +1 -0
  230. package/build/lib/desired-caps.d.ts +506 -0
  231. package/build/lib/desired-caps.d.ts.map +1 -0
  232. package/build/lib/desired-caps.js +400 -0
  233. package/build/lib/desired-caps.js.map +1 -0
  234. package/build/lib/device-connections-factory.d.ts +13 -0
  235. package/build/lib/device-connections-factory.d.ts.map +1 -0
  236. package/build/lib/device-connections-factory.js +244 -0
  237. package/build/lib/device-connections-factory.js.map +1 -0
  238. package/build/lib/device-log/helpers.d.ts +10 -0
  239. package/build/lib/device-log/helpers.d.ts.map +1 -0
  240. package/build/lib/device-log/helpers.js +37 -0
  241. package/build/lib/device-log/helpers.js.map +1 -0
  242. package/build/lib/device-log/ios-crash-log.d.ts +34 -0
  243. package/build/lib/device-log/ios-crash-log.d.ts.map +1 -0
  244. package/build/lib/device-log/ios-crash-log.js +141 -0
  245. package/build/lib/device-log/ios-crash-log.js.map +1 -0
  246. package/build/lib/device-log/ios-device-log.d.ts +19 -0
  247. package/build/lib/device-log/ios-device-log.d.ts.map +1 -0
  248. package/build/lib/device-log/ios-device-log.js +42 -0
  249. package/build/lib/device-log/ios-device-log.js.map +1 -0
  250. package/build/lib/device-log/ios-log.d.ts +24 -0
  251. package/build/lib/device-log/ios-log.d.ts.map +1 -0
  252. package/build/lib/device-log/ios-log.js +50 -0
  253. package/build/lib/device-log/ios-log.js.map +1 -0
  254. package/build/lib/device-log/ios-performance-log.d.ts +18 -0
  255. package/build/lib/device-log/ios-performance-log.d.ts.map +1 -0
  256. package/build/lib/device-log/ios-performance-log.js +43 -0
  257. package/build/lib/device-log/ios-performance-log.js.map +1 -0
  258. package/build/lib/device-log/ios-simulator-log.d.ts +38 -0
  259. package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -0
  260. package/build/lib/device-log/ios-simulator-log.js +184 -0
  261. package/build/lib/device-log/ios-simulator-log.js.map +1 -0
  262. package/build/lib/device-log/line-consuming-log.d.ts +9 -0
  263. package/build/lib/device-log/line-consuming-log.d.ts.map +1 -0
  264. package/build/lib/device-log/line-consuming-log.js +16 -0
  265. package/build/lib/device-log/line-consuming-log.js.map +1 -0
  266. package/build/lib/device-log/safari-console-log.d.ts +67 -0
  267. package/build/lib/device-log/safari-console-log.d.ts.map +1 -0
  268. package/build/lib/device-log/safari-console-log.js +81 -0
  269. package/build/lib/device-log/safari-console-log.js.map +1 -0
  270. package/build/lib/device-log/safari-network-log.d.ts +75 -0
  271. package/build/lib/device-log/safari-network-log.d.ts.map +1 -0
  272. package/build/lib/device-log/safari-network-log.js +47 -0
  273. package/build/lib/device-log/safari-network-log.js.map +1 -0
  274. package/build/lib/doctor/checks.d.ts +3 -0
  275. package/build/lib/doctor/checks.d.ts.map +1 -0
  276. package/build/lib/doctor/checks.js +39 -0
  277. package/build/lib/doctor/checks.js.map +1 -0
  278. package/build/lib/doctor/optional-checks.d.ts +46 -0
  279. package/build/lib/doctor/optional-checks.d.ts.map +1 -0
  280. package/build/lib/doctor/optional-checks.js +129 -0
  281. package/build/lib/doctor/optional-checks.js.map +1 -0
  282. package/build/lib/doctor/required-checks.d.ts +42 -0
  283. package/build/lib/doctor/required-checks.d.ts.map +1 -0
  284. package/build/lib/doctor/required-checks.js +94 -0
  285. package/build/lib/doctor/required-checks.js.map +1 -0
  286. package/build/lib/doctor/utils.d.ts +8 -0
  287. package/build/lib/doctor/utils.d.ts.map +1 -0
  288. package/build/lib/doctor/utils.js +21 -0
  289. package/build/lib/doctor/utils.js.map +1 -0
  290. package/build/lib/driver.d.ts +2429 -0
  291. package/build/lib/driver.d.ts.map +1 -0
  292. package/build/lib/driver.js +1967 -0
  293. package/build/lib/driver.js.map +1 -0
  294. package/build/lib/execute-method-map.d.ts +552 -0
  295. package/build/lib/execute-method-map.d.ts.map +1 -0
  296. package/build/lib/execute-method-map.js +586 -0
  297. package/build/lib/execute-method-map.js.map +1 -0
  298. package/build/lib/ios-fs-helpers.d.ts +75 -0
  299. package/build/lib/ios-fs-helpers.d.ts.map +1 -0
  300. package/build/lib/ios-fs-helpers.js +370 -0
  301. package/build/lib/ios-fs-helpers.js.map +1 -0
  302. package/build/lib/ios-generic-simulators.d.ts +6 -0
  303. package/build/lib/ios-generic-simulators.d.ts.map +1 -0
  304. package/build/lib/ios-generic-simulators.js +14 -0
  305. package/build/lib/ios-generic-simulators.js.map +1 -0
  306. package/build/lib/logger.d.ts +3 -0
  307. package/build/lib/logger.d.ts.map +1 -0
  308. package/build/lib/logger.js +6 -0
  309. package/build/lib/logger.js.map +1 -0
  310. package/build/lib/method-map.d.ts +229 -0
  311. package/build/lib/method-map.d.ts.map +1 -0
  312. package/build/lib/method-map.js +200 -0
  313. package/build/lib/method-map.js.map +1 -0
  314. package/build/lib/real-device-clients/base-device-client.d.ts +22 -0
  315. package/build/lib/real-device-clients/base-device-client.d.ts.map +1 -0
  316. package/build/lib/real-device-clients/base-device-client.js +14 -0
  317. package/build/lib/real-device-clients/base-device-client.js.map +1 -0
  318. package/build/lib/real-device-clients/py-ios-device-client.d.ts +21 -0
  319. package/build/lib/real-device-clients/py-ios-device-client.d.ts.map +1 -0
  320. package/build/lib/real-device-clients/py-ios-device-client.js +125 -0
  321. package/build/lib/real-device-clients/py-ios-device-client.js.map +1 -0
  322. package/build/lib/real-device-management.d.ts +53 -0
  323. package/build/lib/real-device-management.d.ts.map +1 -0
  324. package/build/lib/real-device-management.js +128 -0
  325. package/build/lib/real-device-management.js.map +1 -0
  326. package/build/lib/real-device.d.ts +112 -0
  327. package/build/lib/real-device.d.ts.map +1 -0
  328. package/build/lib/real-device.js +352 -0
  329. package/build/lib/real-device.js.map +1 -0
  330. package/build/lib/simulator-management.d.ts +96 -0
  331. package/build/lib/simulator-management.d.ts.map +1 -0
  332. package/build/lib/simulator-management.js +278 -0
  333. package/build/lib/simulator-management.js.map +1 -0
  334. package/build/lib/stubs.d.ts +3 -0
  335. package/build/lib/stubs.d.ts.map +1 -0
  336. package/build/lib/stubs.js +3 -0
  337. package/build/lib/stubs.js.map +1 -0
  338. package/build/lib/types.d.ts +31 -0
  339. package/build/lib/types.d.ts.map +1 -0
  340. package/build/lib/types.js +3 -0
  341. package/build/lib/types.js.map +1 -0
  342. package/build/lib/utils.d.ts +191 -0
  343. package/build/lib/utils.d.ts.map +1 -0
  344. package/build/lib/utils.js +549 -0
  345. package/build/lib/utils.js.map +1 -0
  346. package/build/lib/xcrun.d.ts +3 -0
  347. package/build/lib/xcrun.d.ts.map +1 -0
  348. package/build/lib/xcrun.js +17 -0
  349. package/build/lib/xcrun.js.map +1 -0
  350. package/index.js +7 -0
  351. package/lib/app-infos-cache.js +187 -0
  352. package/lib/app-utils.js +710 -0
  353. package/lib/commands/active-app-info.js +12 -0
  354. package/lib/commands/advanced-battery-types.ts +454 -0
  355. package/lib/commands/alert.js +88 -0
  356. package/lib/commands/app-management.js +346 -0
  357. package/lib/commands/app-strings.js +30 -0
  358. package/lib/commands/appearance.js +71 -0
  359. package/lib/commands/audit.js +31 -0
  360. package/lib/commands/battery.js +45 -0
  361. package/lib/commands/bidi/constants.ts +6 -0
  362. package/lib/commands/bidi/models.ts +55 -0
  363. package/lib/commands/bidi/types.ts +31 -0
  364. package/lib/commands/biometric.js +53 -0
  365. package/lib/commands/certificate.js +497 -0
  366. package/lib/commands/clipboard.js +35 -0
  367. package/lib/commands/condition.js +155 -0
  368. package/lib/commands/content-size.js +68 -0
  369. package/lib/commands/context.js +705 -0
  370. package/lib/commands/deviceInfo.js +27 -0
  371. package/lib/commands/element.js +423 -0
  372. package/lib/commands/enum.ts +108 -0
  373. package/lib/commands/execute.js +153 -0
  374. package/lib/commands/file-movement.js +510 -0
  375. package/lib/commands/find.js +205 -0
  376. package/lib/commands/general.js +278 -0
  377. package/lib/commands/geolocation.js +56 -0
  378. package/lib/commands/gesture.js +596 -0
  379. package/lib/commands/hid-event.ts +1634 -0
  380. package/lib/commands/increase-contrast.js +50 -0
  381. package/lib/commands/iohid.js +64 -0
  382. package/lib/commands/keyboard.js +62 -0
  383. package/lib/commands/keychains.js +18 -0
  384. package/lib/commands/localization.js +30 -0
  385. package/lib/commands/location.js +131 -0
  386. package/lib/commands/lock.js +46 -0
  387. package/lib/commands/log.js +327 -0
  388. package/lib/commands/memory.js +51 -0
  389. package/lib/commands/navigation.js +125 -0
  390. package/lib/commands/notifications.js +66 -0
  391. package/lib/commands/pasteboard.js +42 -0
  392. package/lib/commands/pcap.js +168 -0
  393. package/lib/commands/performance.js +392 -0
  394. package/lib/commands/permissions.js +85 -0
  395. package/lib/commands/proxy-helper.js +122 -0
  396. package/lib/commands/record-audio.js +264 -0
  397. package/lib/commands/recordscreen.js +391 -0
  398. package/lib/commands/screenshots.js +137 -0
  399. package/lib/commands/simctl.js +71 -0
  400. package/lib/commands/source.js +131 -0
  401. package/lib/commands/timeouts.js +68 -0
  402. package/lib/commands/types.ts +648 -0
  403. package/lib/commands/web.js +1113 -0
  404. package/lib/commands/xctest-record-screen.js +204 -0
  405. package/lib/commands/xctest.js +285 -0
  406. package/lib/css-converter.js +311 -0
  407. package/lib/desired-caps.js +396 -0
  408. package/lib/device-connections-factory.js +269 -0
  409. package/lib/device-log/helpers.ts +40 -0
  410. package/lib/device-log/ios-crash-log.ts +166 -0
  411. package/lib/device-log/ios-device-log.ts +51 -0
  412. package/lib/device-log/ios-log.ts +70 -0
  413. package/lib/device-log/ios-performance-log.ts +50 -0
  414. package/lib/device-log/ios-simulator-log.ts +202 -0
  415. package/lib/device-log/line-consuming-log.ts +16 -0
  416. package/lib/device-log/safari-console-log.ts +117 -0
  417. package/lib/device-log/safari-network-log.ts +120 -0
  418. package/lib/doctor/checks.ts +3 -0
  419. package/lib/doctor/optional-checks.ts +173 -0
  420. package/lib/doctor/required-checks.ts +120 -0
  421. package/lib/doctor/utils.ts +18 -0
  422. package/lib/driver.js +2316 -0
  423. package/lib/execute-method-map.ts +585 -0
  424. package/lib/ios-fs-helpers.js +355 -0
  425. package/lib/ios-generic-simulators.js +11 -0
  426. package/lib/logger.js +5 -0
  427. package/lib/method-map.js +196 -0
  428. package/lib/real-device-clients/base-device-client.ts +34 -0
  429. package/lib/real-device-clients/py-ios-device-client.ts +149 -0
  430. package/lib/real-device-management.js +133 -0
  431. package/lib/real-device.js +347 -0
  432. package/lib/simulator-management.js +324 -0
  433. package/lib/stubs.ts +3 -0
  434. package/lib/types.ts +33 -0
  435. package/lib/utils.js +551 -0
  436. package/lib/xcrun.js +16 -0
  437. package/package.json +175 -0
  438. package/scripts/build-docs.js +56 -0
  439. package/scripts/build-wda.js +42 -0
  440. package/scripts/download-wda-sim.mjs +68 -0
  441. package/scripts/image-mounter.mjs +239 -0
  442. package/scripts/open-wda.mjs +15 -0
  443. package/scripts/tunnel-creation.mjs +359 -0
  444. package/scripts/utils.js +16 -0
@@ -0,0 +1,497 @@
1
+ import _ from 'lodash';
2
+ import {fs, plist, tempDir, util} from 'appium/support';
3
+ import {retryInterval, retry, waitForCondition} from 'asyncbox';
4
+ import B from 'bluebird';
5
+ import os from 'os';
6
+ import path from 'path';
7
+ import http from 'http';
8
+ import {exec} from 'teen_process';
9
+ import {findAPortNotInUse, checkPortStatus} from 'portscanner';
10
+ import {Pyidevice} from '../real-device-clients/py-ios-device-client';
11
+ import {errors} from 'appium/driver';
12
+
13
+ const CONFIG_EXTENSION = 'mobileconfig';
14
+ const HOST_PORT_RANGE = [38200, 38299];
15
+ const TMPSERVER_STARTUP_TIMEOUT = 5000;
16
+ const Settings = /** @type {const} */ ({
17
+ General: {
18
+ type: 'accessibility id',
19
+ value: 'General',
20
+ },
21
+ Profile: {
22
+ type: '-ios predicate string',
23
+ value: `name BEGINSWITH 'Profile'`,
24
+ },
25
+ About: {
26
+ type: 'accessibility id',
27
+ value: 'About',
28
+ },
29
+ Certificate_Trust_Settings: {
30
+ type: 'accessibility id',
31
+ value: 'Certificate Trust Settings',
32
+ },
33
+ });
34
+ const Button = /** @type {const} */ ({
35
+ Install: {
36
+ type: 'accessibility id',
37
+ value: 'Install',
38
+ },
39
+ Allow: {
40
+ type: 'accessibility id',
41
+ value: 'Allow',
42
+ },
43
+ Done: {
44
+ type: 'accessibility id',
45
+ value: 'Done',
46
+ },
47
+ Return_to_Settings: {
48
+ type: 'accessibility id',
49
+ value: 'Return to Settings',
50
+ },
51
+ });
52
+ const Alert = /** @type {const} */ ({
53
+ Install: {
54
+ type: '-ios class chain',
55
+ value:
56
+ "**/XCUIElementTypeAny[`type == 'XCUIElementTypeAlert' OR type == 'XCUIElementTypeSheet'`]/**/XCUIElementTypeButton[`label == 'Install'`]",
57
+ },
58
+ });
59
+
60
+ const LIBRE_SSL_PATTERN = /\/CN=([^\/]+)/; // eslint-disable-line no-useless-escape
61
+ const OPEN_SSL_PATTERN = /,\sCN\s=\s([^,]+)/;
62
+
63
+ /**
64
+ * 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
+ */
69
+ export function parseCommonName(stringCertificate) {
70
+ const result = [LIBRE_SSL_PATTERN, OPEN_SSL_PATTERN].reduce((acc, r) => {
71
+ if (acc) {
72
+ return acc;
73
+ }
74
+ const match = r.exec(stringCertificate);
75
+ return match?.[1];
76
+ }, null);
77
+ if (!result) {
78
+ throw new Error(`There is no common name value in '${stringCertificate}' output`);
79
+ }
80
+ return result;
81
+ }
82
+
83
+ /**
84
+ * Installs a custom certificate onto the device.
85
+ *
86
+ * Since Xcode SDK 11.4, Apple has added a dedicated `simctl` subcommand to quickly handle
87
+ * certificates on Simulator over CLI.
88
+ *
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
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
+ */
97
+ export async function mobileInstallCertificate(content, commonName, isRoot = true) {
98
+ if (_.isEmpty(content)) {
99
+ throw new Error('Certificate content should not be empty');
100
+ }
101
+
102
+ if (this.isSimulator()) {
103
+ try {
104
+ const methodName = isRoot ? 'addRootCertificate' : 'addCertificate';
105
+ await /** @type {import('../driver').Simulator} */ (this.device).simctl[methodName](Buffer.from(content, 'base64').toString(), {
106
+ raw: true,
107
+ });
108
+ return;
109
+ } catch (e) {
110
+ this.log.debug(e);
111
+ this.log.info(
112
+ `The certificate cannot be installed via CLI. ` + `Falling back to UI-based deployment`,
113
+ );
114
+ }
115
+ } else {
116
+ const client = new Pyidevice({
117
+ udid: this.opts.udid,
118
+ log: this.log,
119
+ });
120
+ if (await client.assertExists(false)) {
121
+ await client.installProfile({payload: Buffer.from(content, 'base64')});
122
+ return;
123
+ } else {
124
+ this.log.info(
125
+ 'pyidevice is not installed on your system. ' +
126
+ 'Falling back to the (slow) UI-based installation',
127
+ );
128
+ }
129
+ }
130
+
131
+ const tmpRoot = await tempDir.openDir();
132
+ const tmpPort = await findAPortNotInUse(HOST_PORT_RANGE[0], HOST_PORT_RANGE[1]);
133
+ const configName = `appium.${CONFIG_EXTENSION}`;
134
+ const configPath = path.resolve(tmpRoot, configName);
135
+ const tmpServer = http.createServer(async function (_, res) {
136
+ const configFile = await fs.readFile(configPath);
137
+ res.end(configFile);
138
+ });
139
+ try {
140
+ const certBuffer = Buffer.from(content, 'base64');
141
+ const cn = commonName || (await extractCommonName(certBuffer));
142
+ const mobileConfig = toMobileConfig(certBuffer, cn);
143
+ try {
144
+ await plist.updatePlistFile(configPath, mobileConfig, false, false);
145
+ } catch (err) {
146
+ throw new Error(
147
+ `Cannot store the generated config as '${configPath}'. ` +
148
+ `Original error: ${err.message}`,
149
+ );
150
+ }
151
+
152
+ try {
153
+ const host = os.hostname();
154
+ const certUrl = `http://${host}:${tmpPort}/${configName}`;
155
+ await tmpServer.listen(tmpPort);
156
+ try {
157
+ await waitForCondition(
158
+ async () => {
159
+ try {
160
+ return (await checkPortStatus(tmpPort, host)) === 'open';
161
+ } catch {
162
+ return false;
163
+ }
164
+ },
165
+ {
166
+ waitMs: TMPSERVER_STARTUP_TIMEOUT,
167
+ intervalMs: 300,
168
+ },
169
+ );
170
+ this.log.debug(`The temporary web server is running at http://${host}:${tmpPort}`);
171
+ } catch {
172
+ throw new Error(
173
+ `The temporary web server cannot be started at http://${host}:${tmpPort}.`,
174
+ );
175
+ }
176
+ if (this.isRealDevice()) {
177
+ try {
178
+ await this.proxyCommand('/url', 'POST', {url: certUrl});
179
+ } catch (err) {
180
+ if (this.isWebContext()) {
181
+ // The command above does not always work on real devices
182
+ await this.setUrl(certUrl);
183
+ } else {
184
+ throw err;
185
+ }
186
+ }
187
+ } else {
188
+ await /** @type {import('../driver').Simulator} */ (this.device).openUrl(certUrl);
189
+ }
190
+
191
+ let isCertAlreadyInstalled = false;
192
+ if (util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '>=', '12.2')) {
193
+ if (await installPost122Certificate(this, cn)) {
194
+ await clickElement(this, Settings.Profile);
195
+ await trustCertificateInPreferences(this, cn);
196
+ } else {
197
+ isCertAlreadyInstalled = true;
198
+ }
199
+ } else {
200
+ if (await installPre122Certificate(this)) {
201
+ await clickElement(this, Button.Return_to_Settings);
202
+ await trustCertificateInPreferences(this, cn);
203
+ } else {
204
+ isCertAlreadyInstalled = true;
205
+ }
206
+ }
207
+ if (isCertAlreadyInstalled) {
208
+ this.log.info(
209
+ `It looks like the '${cn}' certificate has been already added to the CA root`,
210
+ );
211
+ }
212
+ } finally {
213
+ if (this.opts.bundleId) {
214
+ try {
215
+ await this.activateApp(this.opts.bundleId);
216
+ } catch (e) {
217
+ this.log.warn(
218
+ `Cannot restore the application '${this.opts.bundleId}'. Original error: ${e.message}`,
219
+ );
220
+ }
221
+ }
222
+ }
223
+
224
+ return (await util.toInMemoryBase64(configPath)).toString();
225
+ } finally {
226
+ await tmpServer.close();
227
+ await fs.rimraf(tmpRoot);
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Removes installed certificates.
233
+ *
234
+ * This only works _if and only if_ `py-ios-device` is installed on the same machine Appium is running on.
235
+ *
236
+ * @see https://github.com/YueChen-C/py-ios-device
237
+ * @since 4.19.2
238
+ * @param {string} name - Name of the profile
239
+ * @returns {Promise<string>} Returns status acknowledgment status if
240
+ * tht certificate is successfully removed or 'None' (basically just
241
+ * forwards the original pyidevice output)
242
+ * @throws {Error} If attempting to remove certificates for a simulated device or if `py-ios-device` is not installed
243
+ * @group Real Device Only
244
+ */
245
+ export async function mobileRemoveCertificate(name) {
246
+ if (!this.isRealDevice()) {
247
+ throw new errors.NotImplementedError('This extension is only supported on real devices');
248
+ }
249
+ const client = new Pyidevice({
250
+ udid: this.opts.udid,
251
+ log: this.log,
252
+ });
253
+ await client.assertExists(true);
254
+ return await client.removeProfile(name);
255
+ }
256
+
257
+ /**
258
+ * Returns map of certificates installed on the real device.
259
+ *
260
+ * This only works _if and only if_ `py-ios-device` is installed on the same machine Appium is running on.
261
+ * @since 4.10.0
262
+ * @see https://github.com/YueChen-C/py-ios-device
263
+ * @returns {Promise<import('./types').CertificateList>} An object describing the certificates installed on the real device.
264
+ * @throws {Error} If attempting to list certificates for a simulated device or if `py-ios-device` is not installed
265
+ * @this {XCUITestDriver}
266
+ */
267
+ export async function mobileListCertificates() {
268
+ if (!this.isRealDevice()) {
269
+ throw new errors.NotImplementedError('This extension is only supported on real devices');
270
+ }
271
+ const client = new Pyidevice({
272
+ udid: this.opts.udid,
273
+ log: this.log,
274
+ });
275
+ await client.assertExists(true);
276
+ return await client.listProfiles();
277
+ }
278
+
279
+
280
+ /**
281
+ * Extracts the common name of the certificate from the given buffer.
282
+ *
283
+ * @param {Buffer} certBuffer
284
+ * @returns {Promise<string>} The common name of the certificate
285
+ */
286
+ async function extractCommonName(certBuffer) {
287
+ const tempCert = await tempDir.open({
288
+ prefix: 'cert',
289
+ suffix: '.cer',
290
+ });
291
+ try {
292
+ await fs.writeFile(tempCert.path, certBuffer);
293
+ const {stdout} = await exec('openssl', ['x509', '-noout', '-subject', '-in', tempCert.path]);
294
+ return parseCommonName(stdout);
295
+ } catch (err) {
296
+ throw new Error(
297
+ `Cannot parse common name value from the certificate. Is it valid and base64-encoded? ` +
298
+ `Original error: ${err.message}`,
299
+ );
300
+ } finally {
301
+ await fs.rimraf(tempCert.path);
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Generates Apple's over-the-air configuration profile
307
+ * for certificate deployment based on the given PEM certificate content.
308
+ * Read https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/iPhoneOTAConfiguration/Introduction/Introduction.html
309
+ * for more details on such profiles.
310
+ *
311
+ * @param {Buffer} certBuffer - The actual content of PEM certificate encoded into NodeJS buffer
312
+ * @param {string} commonName - Certificate's common name
313
+ * @returns {Object} The encoded structure of the given certificate, which is ready to be passed
314
+ * as an argument to plist builder
315
+ * @throws {Error} If the given certificate cannot be parsed
316
+ */
317
+ function toMobileConfig(certBuffer, commonName) {
318
+ const getUUID = () => util.uuidV4().toUpperCase();
319
+ const contentUuid = getUUID();
320
+ return {
321
+ PayloadContent: [
322
+ {
323
+ PayloadCertificateFileName: `${commonName}.cer`,
324
+ PayloadContent: certBuffer,
325
+ PayloadDescription: 'Adds a CA root certificate',
326
+ PayloadDisplayName: commonName,
327
+ PayloadIdentifier: `com.apple.security.root.${contentUuid}`,
328
+ PayloadType: 'com.apple.security.root',
329
+ PayloadUUID: contentUuid,
330
+ PayloadVersion: 1,
331
+ },
332
+ ],
333
+ PayloadDisplayName: commonName,
334
+ PayloadIdentifier: `${os.hostname().split('.')[0]}.${getUUID()}`,
335
+ PayloadRemovalDisallowed: false,
336
+ PayloadType: 'Configuration',
337
+ PayloadUUID: getUUID(),
338
+ PayloadVersion: 1,
339
+ };
340
+ }
341
+
342
+ async function clickElement(driver, locator, options = {}) {
343
+ let element = null;
344
+ const {timeout = 5000, skipIfInvisible = false} = options;
345
+ const lookupDelay = 500;
346
+ try {
347
+ element = await retryInterval(
348
+ timeout < lookupDelay ? 1 : timeout / lookupDelay,
349
+ lookupDelay,
350
+ () => driver.findNativeElementOrElements(locator.type, locator.value, false),
351
+ );
352
+ } catch {
353
+ if (skipIfInvisible) {
354
+ return false;
355
+ }
356
+ throw new Error(`Cannot find ${JSON.stringify(locator)} within ${timeout}ms timeout`);
357
+ }
358
+ await driver.nativeClick(element);
359
+ return true;
360
+ }
361
+
362
+ async function installPre122Certificate(driver) {
363
+ // Accept Safari alert
364
+ await clickElement(driver, Button.Allow, {
365
+ // certificate load might take some time on slow machines
366
+ timeout: 15000,
367
+ });
368
+ // Wait until Preferences are opened
369
+ await B.delay(2000);
370
+
371
+ // Go through Preferences wizard
372
+ if (
373
+ !(await clickElement(driver, Button.Install, {
374
+ skipIfInvisible: true,
375
+ }))
376
+ ) {
377
+ return false;
378
+ }
379
+ // We need to click Install button on two different tabs
380
+ // The second one confirms the previous
381
+ await B.delay(1500);
382
+ await clickElement(driver, Button.Install);
383
+ // Accept alert
384
+ await clickElement(driver, Alert.Install);
385
+ // Finish adding certificate
386
+ await clickElement(driver, Button.Done);
387
+ return true;
388
+ }
389
+
390
+ async function trustCertificateInPreferences(driver, name) {
391
+ await clickElement(driver, Settings.General);
392
+ await clickElement(driver, Settings.About);
393
+ const switchLocator = {
394
+ type: '-ios class chain',
395
+ value: `**/XCUIElementTypeCell[\`label == '${name}'\`]/**/XCUIElementTypeSwitch`,
396
+ };
397
+ await retry(5, async () => {
398
+ await driver.mobileSwipe({
399
+ element: await driver.findNativeElementOrElements(
400
+ 'class name',
401
+ 'XCUIElementTypeTable',
402
+ false,
403
+ ),
404
+ direction: 'up',
405
+ });
406
+ await clickElement(driver, Settings.Certificate_Trust_Settings, {
407
+ timeout: 500,
408
+ });
409
+
410
+ await driver.findNativeElementOrElements(switchLocator.type, switchLocator.value, false);
411
+ });
412
+ // Only click the switch if it is set to Off
413
+ if (
414
+ await clickElement(
415
+ driver,
416
+ {
417
+ type: switchLocator.type,
418
+ value: `${switchLocator.value}[\`value == '0'\`]`,
419
+ },
420
+ {
421
+ timeout: 1000,
422
+ skipIfInvisible: true,
423
+ },
424
+ )
425
+ ) {
426
+ await driver.postAcceptAlert();
427
+ }
428
+ }
429
+
430
+ async function installPost122Certificate(driver, name) {
431
+ // Accept Safari alert
432
+ await clickElement(driver, Button.Allow, {
433
+ // certificate load might take some time on slow machines
434
+ timeout: 15000,
435
+ });
436
+ // Wait for the second alert
437
+ await B.delay(2000);
438
+
439
+ await driver.postAcceptAlert();
440
+ await driver.activateApp('com.apple.Preferences');
441
+ await clickElement(driver, Settings.General);
442
+ await clickElement(driver, Settings.Profile);
443
+ // Select the target cert
444
+ let isCertFound = false;
445
+ for (let swipeNum = 0; swipeNum < 5; ++swipeNum) {
446
+ if (
447
+ await clickElement(
448
+ driver,
449
+ {
450
+ type: '-ios class chain',
451
+ value: `**/XCUIElementTypeCell[\`label == '${name}'\`]`,
452
+ },
453
+ {
454
+ timeout: 500,
455
+ skipIfInvisible: true,
456
+ },
457
+ )
458
+ ) {
459
+ isCertFound = true;
460
+ break;
461
+ }
462
+
463
+ await driver.mobileSwipe({
464
+ element: await driver.findNativeElementOrElements(
465
+ 'class name',
466
+ 'XCUIElementTypeTable',
467
+ false,
468
+ ),
469
+ direction: 'up',
470
+ });
471
+ }
472
+ if (!isCertFound) {
473
+ throw new Error(`'${name}' cannot be found in the certificates list`);
474
+ }
475
+
476
+ // Install option is only visible if the cert is not installed yet
477
+ if (
478
+ !(await clickElement(driver, Button.Install, {
479
+ skipIfInvisible: true,
480
+ }))
481
+ ) {
482
+ return false;
483
+ }
484
+ await B.delay(1500);
485
+ // Confirm untrusted cert install
486
+ await clickElement(driver, Button.Install);
487
+ // Accept alert
488
+ await clickElement(driver, Alert.Install);
489
+ // Finish adding certificate
490
+ await clickElement(driver, Button.Done);
491
+
492
+ return true;
493
+ }
494
+
495
+ /**
496
+ * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
497
+ */
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Sets the primary clipboard's content on the device under test.
3
+ *
4
+ * @param {string} content - The content to be set as base64 encoded string.
5
+ * @param {string} [contentType=plaintext] - The type of the content to set.
6
+ * Only `plaintext`, 'image and 'url' are supported.
7
+ * @this {XCUITestDriver}
8
+ */
9
+ export async function setClipboard(content, contentType) {
10
+ await this.proxyCommand('/wda/setPasteboard', 'POST', {
11
+ content,
12
+ contentType,
13
+ });
14
+ }
15
+
16
+ /**
17
+ * Gets the content of the primary clipboard on the device under test.
18
+ *
19
+ * @param {string} [contentType=plaintext] - The type of the content to get.
20
+ * Only `plaintext`, 'image and 'url' are supported.
21
+ * @returns {Promise<string>} The actual clipboard content encoded into base64 string.
22
+ * An empty string is returned if the clipboard contains no data.
23
+ * @this {XCUITestDriver}
24
+ */
25
+ export async function getClipboard(contentType) {
26
+ return /** @type {string} */ (
27
+ await this.proxyCommand('/wda/getPasteboard', 'POST', {
28
+ contentType,
29
+ })
30
+ );
31
+ }
32
+
33
+ /**
34
+ * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
35
+ */
@@ -0,0 +1,155 @@
1
+ import {INSTRUMENT_CHANNEL, services} from 'appium-ios-device';
2
+ import _ from 'lodash';
3
+
4
+ /**
5
+ * Get all available ConditionInducer configuration information, which can be used with
6
+ * {@linkcode XCUITestDriver.enableConditionInducer}
7
+ * @returns {Promise<Condition[]>}
8
+ * @since 4.9.0
9
+ * @see {@link https://help.apple.com/xcode/mac/current/#/dev308429d42}
10
+ * @this {XCUITestDriver}
11
+ */
12
+ export async function listConditionInducers() {
13
+ requireConditionInducerCompatibleDevice.bind(this);
14
+ const conditionInducerService = await services.startInstrumentService(this.device.udid);
15
+ try {
16
+ const ret = await conditionInducerService.callChannel(
17
+ INSTRUMENT_CHANNEL.CONDITION_INDUCER,
18
+ 'availableConditionInducers',
19
+ );
20
+ return ret.selector;
21
+ } finally {
22
+ conditionInducerService.close();
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Enable a "condition inducer". You can create a condition on a connected device to test your app under adverse conditions,
28
+ * such as poor network connectivity or thermal constraints. When you start a device condition,
29
+ * the operating system on the device behaves as if its environment has changed. The device
30
+ * condition remains active until you stop the device condition or disconnect the device. For
31
+ * example, you can start a device condition, run your app, monitor your app's energy usage, and
32
+ * then stop the condition.
33
+ *
34
+ * (Note: the socket needs to remain connected during operation)
35
+ * (Note: Device conditions are available only for real devices running iOS 13.0 and later.)
36
+ *
37
+ * @param {string} conditionID - Determine which condition IDs are available with the {@linkcode XCUITestDriver.listConditionInducers} command
38
+ * @param {string} profileID - Determine which profile IDs are available with the {@linkcode XCUITestDriver.listConditionInducers} command
39
+ * @returns {Promise<boolean>} `true` if enabling the condition succeeded
40
+ * @throws {Error} If you try to start another Condition and the previous Condition has not stopped
41
+ * @since 4.9.0
42
+ * @see {@link https://help.apple.com/xcode/mac/current/#/dev308429d42}
43
+ * @this {XCUITestDriver}
44
+ */
45
+ export async function enableConditionInducer(conditionID, profileID) {
46
+ requireConditionInducerCompatibleDevice.bind(this);
47
+ if (this._conditionInducerService && !this._conditionInducerService._socketClient.destroyed) {
48
+ throw this.log.errorWithException(
49
+ `Condition inducer has been started. A condition is already active.`
50
+ );
51
+ }
52
+ this._conditionInducerService = await services.startInstrumentService(this.device.udid);
53
+ const ret = await this._conditionInducerService.callChannel(
54
+ INSTRUMENT_CHANNEL.CONDITION_INDUCER,
55
+ 'enableConditionWithIdentifier:profileIdentifier:',
56
+ conditionID,
57
+ profileID,
58
+ );
59
+ if (!_.isBoolean(ret.selector)) {
60
+ this._conditionInducerService.close();
61
+ this._conditionInducerService = null;
62
+ throw this.log.errorWithException(`Enable condition inducer error: '${JSON.stringify(ret.selector)}'`);
63
+ }
64
+ return ret.selector;
65
+ }
66
+
67
+ /**
68
+ * Disable a condition inducer enabled with {@linkcode XCUITestDriver.enableConditionInducer} Usually
69
+ * a persistent connection is maintained after the condition inducer is enabled, and this method
70
+ * is only valid for the currently enabled connection. If the connection is disconnected, the
71
+ * condition inducer will be automatically disabled
72
+ *
73
+ * (Note: this is also automatically called upon session cleanup)
74
+ * @returns {Promise<boolean>} `true` if disable the condition succeeded
75
+ * @since 4.9.0
76
+ * @see {@link https://help.apple.com/xcode/mac/current/#/dev308429d42}
77
+ * @this {XCUITestDriver}
78
+ */
79
+ export async function disableConditionInducer() {
80
+ if (!this._conditionInducerService) {
81
+ this.log.warn('Condition inducer server is not started');
82
+ return false;
83
+ }
84
+ try {
85
+ const ret = await this._conditionInducerService.callChannel(
86
+ INSTRUMENT_CHANNEL.CONDITION_INDUCER,
87
+ 'disableActiveCondition',
88
+ );
89
+ if (!_.isBoolean(ret.selector)) {
90
+ this.log.warn(`Disable condition inducer error: '${JSON.stringify(ret.selector)}'`);
91
+ return false;
92
+ }
93
+ return ret.selector;
94
+ } finally {
95
+ if (this._conditionInducerService) {
96
+ this._conditionInducerService.close();
97
+ this._conditionInducerService = null;
98
+ }
99
+ }
100
+ }
101
+
102
+ /**
103
+ * @this {XCUITestDriver}
104
+ * @returns {void}
105
+ */
106
+ function requireConditionInducerCompatibleDevice() {
107
+ if (this.isSimulator()) {
108
+ throw this.log.errorWithException('Condition inducer only works on real devices');
109
+ }
110
+ }
111
+
112
+ /**
113
+ * @typedef {Object} Profile
114
+ * @property {string} name
115
+ * @property {string} identifier the property is profileID used in {@linkcode XCUITestDriver.enableConditionInducer}
116
+ * @property {string} description Configuration details
117
+ */
118
+
119
+ /**
120
+ * We can use the returned data to determine whether the Condition is enabled and the currently enabled configuration information
121
+ * @typedef {Object} Condition
122
+ * @property {Profile[]} profiles
123
+ * @property {string} identifier the property is conditionID used in {@linkcode XCUITestDriver.enableConditionInducer}
124
+ * @property {boolean} profilesSorted
125
+ * @property {boolean} isDestructive
126
+ * @property {boolean} isInternal
127
+ * @property {boolean} isActive `true` if this condition identifier is enabled
128
+ * @property {string} activeProfile enabled profiles identifier
129
+ * @example {
130
+ * "profiles": [
131
+ * {
132
+ * "name": "100% packet loss",
133
+ * "identifier": "SlowNetwork100PctLoss", // MobileEnableConditionInducer profileID
134
+ * "description": "Name: 100% Loss Scenario\n
135
+ * Downlink Bandwidth: 0 Mbps\n
136
+ * Downlink Latency:0 ms\n
137
+ * Downlink Packet Loss Ratio: 100%\n
138
+ * Uplink Bandwidth: 0 Mbps\n
139
+ * Uplink Latency: 0 ms\n
140
+ * Uplink Packet Loss Ratio: 100%"
141
+ * }
142
+ * ],
143
+ * "profilesSorted": true,
144
+ * "identifier": "SlowNetworkCondition", // MobileEnableConditionInducer conditionID
145
+ * "isDestructive": false,
146
+ * "isInternal": false,
147
+ * "activeProfile": "",
148
+ * "name": "Network Link",
149
+ * "isActive": false
150
+ * }
151
+ */
152
+
153
+ /**
154
+ * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
155
+ */