appium-xcuitest-driver 10.3.0 → 10.4.0

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 (252) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/lib/commands/active-app-info.d.ts +9 -0
  3. package/build/lib/commands/active-app-info.d.ts.map +1 -0
  4. package/build/lib/commands/active-app-info.js +14 -0
  5. package/build/lib/commands/active-app-info.js.map +1 -0
  6. package/build/lib/commands/alert.d.ts +42 -45
  7. package/build/lib/commands/alert.d.ts.map +1 -1
  8. package/build/lib/commands/alert.js +66 -62
  9. package/build/lib/commands/alert.js.map +1 -1
  10. package/build/lib/commands/app-management.d.ts +150 -153
  11. package/build/lib/commands/app-management.d.ts.map +1 -1
  12. package/build/lib/commands/app-management.js +300 -286
  13. package/build/lib/commands/app-management.js.map +1 -1
  14. package/build/lib/commands/app-strings.d.ts +14 -17
  15. package/build/lib/commands/app-strings.d.ts.map +1 -1
  16. package/build/lib/commands/app-strings.js +23 -24
  17. package/build/lib/commands/app-strings.js.map +1 -1
  18. package/build/lib/commands/appearance.d.ts +19 -22
  19. package/build/lib/commands/appearance.d.ts.map +1 -1
  20. package/build/lib/commands/appearance.js +56 -56
  21. package/build/lib/commands/appearance.js.map +1 -1
  22. package/build/lib/commands/audit.d.ts +22 -17
  23. package/build/lib/commands/audit.d.ts.map +1 -1
  24. package/build/lib/commands/audit.js +17 -18
  25. package/build/lib/commands/audit.js.map +1 -1
  26. package/build/lib/commands/battery.d.ts +11 -14
  27. package/build/lib/commands/battery.d.ts.map +1 -1
  28. package/build/lib/commands/battery.js +36 -37
  29. package/build/lib/commands/battery.js.map +1 -1
  30. package/build/lib/commands/biometric.d.ts +30 -33
  31. package/build/lib/commands/biometric.d.ts.map +1 -1
  32. package/build/lib/commands/biometric.js +42 -41
  33. package/build/lib/commands/biometric.js.map +1 -1
  34. package/build/lib/commands/certificate.d.ts +48 -45
  35. package/build/lib/commands/certificate.d.ts.map +1 -1
  36. package/build/lib/commands/certificate.js +218 -205
  37. package/build/lib/commands/certificate.js.map +1 -1
  38. package/build/lib/commands/clipboard.d.ts +19 -22
  39. package/build/lib/commands/clipboard.d.ts.map +1 -1
  40. package/build/lib/commands/clipboard.js +30 -30
  41. package/build/lib/commands/clipboard.js.map +1 -1
  42. package/build/lib/commands/condition.d.ts +49 -26
  43. package/build/lib/commands/condition.d.ts.map +1 -1
  44. package/build/lib/commands/condition.js +87 -86
  45. package/build/lib/commands/condition.js.map +1 -1
  46. package/build/lib/commands/content-size.d.ts +26 -29
  47. package/build/lib/commands/content-size.d.ts.map +1 -1
  48. package/build/lib/commands/content-size.js +36 -36
  49. package/build/lib/commands/content-size.js.map +1 -1
  50. package/build/lib/commands/context.d.ts +161 -108
  51. package/build/lib/commands/context.d.ts.map +1 -1
  52. package/build/lib/commands/context.js +530 -517
  53. package/build/lib/commands/context.js.map +1 -1
  54. package/build/lib/commands/deviceInfo.d.ts +9 -12
  55. package/build/lib/commands/deviceInfo.d.ts.map +1 -1
  56. package/build/lib/commands/deviceInfo.js +17 -18
  57. package/build/lib/commands/deviceInfo.js.map +1 -1
  58. package/build/lib/commands/element.d.ts +102 -105
  59. package/build/lib/commands/element.d.ts.map +1 -1
  60. package/build/lib/commands/element.js +337 -323
  61. package/build/lib/commands/element.js.map +1 -1
  62. package/build/lib/commands/execute.d.ts +24 -19
  63. package/build/lib/commands/execute.d.ts.map +1 -1
  64. package/build/lib/commands/execute.js +63 -62
  65. package/build/lib/commands/execute.js.map +1 -1
  66. package/build/lib/commands/file-movement.d.ts +77 -80
  67. package/build/lib/commands/file-movement.d.ts.map +1 -1
  68. package/build/lib/commands/file-movement.js +130 -124
  69. package/build/lib/commands/file-movement.js.map +1 -1
  70. package/build/lib/commands/find.d.ts +18 -21
  71. package/build/lib/commands/find.d.ts.map +1 -1
  72. package/build/lib/commands/find.js +158 -156
  73. package/build/lib/commands/find.js.map +1 -1
  74. package/build/lib/commands/general.d.ts +124 -116
  75. package/build/lib/commands/general.d.ts.map +1 -1
  76. package/build/lib/commands/general.js +248 -232
  77. package/build/lib/commands/general.js.map +1 -1
  78. package/build/lib/commands/geolocation.d.ts +43 -46
  79. package/build/lib/commands/geolocation.d.ts.map +1 -1
  80. package/build/lib/commands/geolocation.js +10 -11
  81. package/build/lib/commands/geolocation.js.map +1 -1
  82. package/build/lib/commands/gesture.d.ts +273 -276
  83. package/build/lib/commands/gesture.d.ts.map +1 -1
  84. package/build/lib/commands/gesture.js +506 -492
  85. package/build/lib/commands/gesture.js.map +1 -1
  86. package/build/lib/commands/increase-contrast.d.ts +20 -23
  87. package/build/lib/commands/increase-contrast.d.ts.map +1 -1
  88. package/build/lib/commands/increase-contrast.js +30 -30
  89. package/build/lib/commands/increase-contrast.js.map +1 -1
  90. package/build/lib/commands/iohid.d.ts +1370 -1373
  91. package/build/lib/commands/iohid.d.ts.map +1 -1
  92. package/build/lib/commands/iohid.js +30 -31
  93. package/build/lib/commands/iohid.js.map +1 -1
  94. package/build/lib/commands/keyboard.d.ts +29 -32
  95. package/build/lib/commands/keyboard.d.ts.map +1 -1
  96. package/build/lib/commands/keyboard.js +53 -51
  97. package/build/lib/commands/keyboard.js.map +1 -1
  98. package/build/lib/commands/keychains.d.ts +9 -12
  99. package/build/lib/commands/keychains.d.ts.map +1 -1
  100. package/build/lib/commands/keychains.js +13 -14
  101. package/build/lib/commands/keychains.js.map +1 -1
  102. package/build/lib/commands/localization.d.ts +16 -19
  103. package/build/lib/commands/localization.d.ts.map +1 -1
  104. package/build/lib/commands/localization.js +25 -26
  105. package/build/lib/commands/localization.js.map +1 -1
  106. package/build/lib/commands/location.d.ts +36 -39
  107. package/build/lib/commands/location.d.ts.map +1 -1
  108. package/build/lib/commands/location.js +99 -98
  109. package/build/lib/commands/location.js.map +1 -1
  110. package/build/lib/commands/lock.d.ts +21 -24
  111. package/build/lib/commands/lock.d.ts.map +1 -1
  112. package/build/lib/commands/lock.js +39 -38
  113. package/build/lib/commands/lock.js.map +1 -1
  114. package/build/lib/commands/log.d.ts +43 -37
  115. package/build/lib/commands/log.d.ts.map +1 -1
  116. package/build/lib/commands/log.js +174 -171
  117. package/build/lib/commands/log.js.map +1 -1
  118. package/build/lib/commands/memory.d.ts +9 -12
  119. package/build/lib/commands/memory.d.ts.map +1 -1
  120. package/build/lib/commands/memory.js +37 -38
  121. package/build/lib/commands/memory.js.map +1 -1
  122. package/build/lib/commands/navigation.d.ts +30 -33
  123. package/build/lib/commands/navigation.d.ts.map +1 -1
  124. package/build/lib/commands/navigation.js +92 -92
  125. package/build/lib/commands/navigation.js.map +1 -1
  126. package/build/lib/commands/notifications.d.ts +26 -29
  127. package/build/lib/commands/notifications.d.ts.map +1 -1
  128. package/build/lib/commands/notifications.js +53 -53
  129. package/build/lib/commands/notifications.js.map +1 -1
  130. package/build/lib/commands/pasteboard.d.ts +21 -24
  131. package/build/lib/commands/pasteboard.d.ts.map +1 -1
  132. package/build/lib/commands/pasteboard.js +37 -37
  133. package/build/lib/commands/pasteboard.js.map +1 -1
  134. package/build/lib/commands/pcap.d.ts +39 -26
  135. package/build/lib/commands/pcap.d.ts.map +1 -1
  136. package/build/lib/commands/pcap.js +81 -81
  137. package/build/lib/commands/pcap.js.map +1 -1
  138. package/build/lib/commands/performance.d.ts +63 -44
  139. package/build/lib/commands/performance.d.ts.map +1 -1
  140. package/build/lib/commands/performance.js +105 -105
  141. package/build/lib/commands/performance.js.map +1 -1
  142. package/build/lib/commands/permissions.d.ts +33 -36
  143. package/build/lib/commands/permissions.d.ts.map +1 -1
  144. package/build/lib/commands/permissions.js +66 -65
  145. package/build/lib/commands/permissions.js.map +1 -1
  146. package/build/lib/commands/proxy-helper.d.ts +12 -15
  147. package/build/lib/commands/proxy-helper.d.ts.map +1 -1
  148. package/build/lib/commands/proxy-helper.js +53 -54
  149. package/build/lib/commands/proxy-helper.js.map +1 -1
  150. package/build/lib/commands/record-audio.d.ts +49 -29
  151. package/build/lib/commands/record-audio.d.ts.map +1 -1
  152. package/build/lib/commands/record-audio.js +100 -104
  153. package/build/lib/commands/record-audio.js.map +1 -1
  154. package/build/lib/commands/recordscreen.d.ts +54 -18
  155. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  156. package/build/lib/commands/recordscreen.js +127 -129
  157. package/build/lib/commands/recordscreen.js.map +1 -1
  158. package/build/lib/commands/screenshots.d.ts +14 -17
  159. package/build/lib/commands/screenshots.d.ts.map +1 -1
  160. package/build/lib/commands/screenshots.js +108 -107
  161. package/build/lib/commands/screenshots.js.map +1 -1
  162. package/build/lib/commands/simctl.d.ts +11 -14
  163. package/build/lib/commands/simctl.d.ts.map +1 -1
  164. package/build/lib/commands/simctl.js +23 -26
  165. package/build/lib/commands/simctl.js.map +1 -1
  166. package/build/lib/commands/source.d.ts +14 -17
  167. package/build/lib/commands/source.d.ts.map +1 -1
  168. package/build/lib/commands/source.js +40 -43
  169. package/build/lib/commands/source.js.map +1 -1
  170. package/build/lib/commands/timeouts.d.ts +44 -33
  171. package/build/lib/commands/timeouts.d.ts.map +1 -1
  172. package/build/lib/commands/timeouts.js +65 -63
  173. package/build/lib/commands/timeouts.js.map +1 -1
  174. package/build/lib/commands/web.d.ts +247 -197
  175. package/build/lib/commands/web.d.ts.map +1 -1
  176. package/build/lib/commands/web.js +815 -786
  177. package/build/lib/commands/web.js.map +1 -1
  178. package/build/lib/commands/xctest-record-screen.d.ts +63 -66
  179. package/build/lib/commands/xctest-record-screen.d.ts.map +1 -1
  180. package/build/lib/commands/xctest-record-screen.js +103 -102
  181. package/build/lib/commands/xctest-record-screen.js.map +1 -1
  182. package/build/lib/commands/xctest.d.ts +55 -51
  183. package/build/lib/commands/xctest.d.ts.map +1 -1
  184. package/build/lib/commands/xctest.js +116 -117
  185. package/build/lib/commands/xctest.js.map +1 -1
  186. package/build/lib/driver.d.ts +278 -1597
  187. package/build/lib/driver.d.ts.map +1 -1
  188. package/build/lib/driver.js +319 -235
  189. package/build/lib/driver.js.map +1 -1
  190. package/build/lib/execute-method-map.d.ts.map +1 -1
  191. package/build/lib/execute-method-map.js +9 -0
  192. package/build/lib/execute-method-map.js.map +1 -1
  193. package/lib/commands/active-app-info.js +12 -0
  194. package/lib/commands/alert.js +68 -65
  195. package/lib/commands/app-management.js +308 -301
  196. package/lib/commands/app-strings.js +24 -26
  197. package/lib/commands/appearance.js +54 -56
  198. package/lib/commands/audit.js +18 -20
  199. package/lib/commands/battery.js +35 -37
  200. package/lib/commands/biometric.js +44 -46
  201. package/lib/commands/certificate.js +226 -215
  202. package/lib/commands/clipboard.js +30 -32
  203. package/lib/commands/condition.js +98 -100
  204. package/lib/commands/content-size.js +36 -38
  205. package/lib/commands/context.js +495 -490
  206. package/lib/commands/deviceInfo.js +19 -20
  207. package/lib/commands/element.js +367 -357
  208. package/lib/commands/execute.js +72 -72
  209. package/lib/commands/file-movement.js +132 -134
  210. package/lib/commands/find.js +160 -159
  211. package/lib/commands/general.js +238 -231
  212. package/lib/commands/geolocation.js +6 -14
  213. package/lib/commands/gesture.js +525 -515
  214. package/lib/commands/increase-contrast.js +30 -32
  215. package/lib/commands/iohid.js +32 -34
  216. package/lib/commands/keyboard.js +49 -51
  217. package/lib/commands/keychains.js +12 -14
  218. package/lib/commands/localization.js +24 -26
  219. package/lib/commands/location.js +102 -104
  220. package/lib/commands/lock.js +38 -38
  221. package/lib/commands/log.js +197 -198
  222. package/lib/commands/memory.js +40 -42
  223. package/lib/commands/navigation.js +96 -100
  224. package/lib/commands/notifications.js +57 -59
  225. package/lib/commands/pasteboard.js +37 -39
  226. package/lib/commands/pcap.js +84 -86
  227. package/lib/commands/performance.js +132 -133
  228. package/lib/commands/permissions.js +67 -69
  229. package/lib/commands/proxy-helper.js +60 -61
  230. package/lib/commands/record-audio.js +115 -120
  231. package/lib/commands/recordscreen.js +145 -149
  232. package/lib/commands/screenshots.js +116 -116
  233. package/lib/commands/simctl.js +25 -29
  234. package/lib/commands/source.js +42 -46
  235. package/lib/commands/timeouts.js +59 -63
  236. package/lib/commands/web.js +878 -858
  237. package/lib/commands/xctest-record-screen.js +103 -105
  238. package/lib/commands/xctest.js +134 -139
  239. package/lib/driver.js +287 -235
  240. package/lib/execute-method-map.ts +9 -0
  241. package/npm-shrinkwrap.json +2 -2
  242. package/package.json +1 -1
  243. package/build/lib/commands/activeAppInfo.d.ts +0 -12
  244. package/build/lib/commands/activeAppInfo.d.ts.map +0 -1
  245. package/build/lib/commands/activeAppInfo.js +0 -15
  246. package/build/lib/commands/activeAppInfo.js.map +0 -1
  247. package/build/lib/commands/index.d.ts +0 -96
  248. package/build/lib/commands/index.d.ts.map +0 -1
  249. package/build/lib/commands/index.js +0 -100
  250. package/build/lib/commands/index.js.map +0 -1
  251. package/lib/commands/activeAppInfo.js +0 -14
  252. package/lib/commands/index.js +0 -95
@@ -1,3 +1,42 @@
1
+ /**
2
+ * Records the given network traffic capture into a .pcap file.
3
+ *
4
+ * @param {number} timeLimitSec - The maximum recording time, in seconds. The maximum value is `43200` (12 hours).
5
+ * @param {boolean} forceRestart - Whether to restart traffic capture process forcefully when startPcap is called (`true`) or ignore the call until the current traffic capture is completed (`false`, the default value).
6
+ * @throws {Error} If network traffic capture has failed to start.
7
+ * @returns {Promise<void>}
8
+ * @this {XCUITestDriver}
9
+ */
10
+ export function mobileStartPcap(this: import("../driver").XCUITestDriver, timeLimitSec?: number, forceRestart?: boolean): Promise<void>;
11
+ export class mobileStartPcap {
12
+ /**
13
+ * Records the given network traffic capture into a .pcap file.
14
+ *
15
+ * @param {number} timeLimitSec - The maximum recording time, in seconds. The maximum value is `43200` (12 hours).
16
+ * @param {boolean} forceRestart - Whether to restart traffic capture process forcefully when startPcap is called (`true`) or ignore the call until the current traffic capture is completed (`false`, the default value).
17
+ * @throws {Error} If network traffic capture has failed to start.
18
+ * @returns {Promise<void>}
19
+ * @this {XCUITestDriver}
20
+ */
21
+ constructor(this: import("../driver").XCUITestDriver, timeLimitSec?: number, forceRestart?: boolean);
22
+ _trafficCapture: TrafficCapture;
23
+ }
24
+ /**
25
+ * Stops network traffic capture.
26
+ *
27
+ * If no traffic capture process is running, then the endpoint will try to get the recently recorded file.
28
+ *
29
+ * If no previously recorded file is found and no active traffic capture processes are running, then the method returns an empty string.
30
+ *
31
+ * @remarks Network capture files can be viewed in [Wireshark](https://www.wireshark.org/) and other similar applications.
32
+ * @returns {Promise<string>} Base64-encoded content of the recorded pcap file or an empty string if no traffic capture has been started before.
33
+ * @throws {Error} If there was an error while getting the capture file.
34
+ * @this {XCUITestDriver}
35
+ */
36
+ export function mobileStopPcap(this: import("../driver").XCUITestDriver): Promise<string>;
37
+ export class mobileStopPcap {
38
+ _trafficCapture: any;
39
+ }
1
40
  export class TrafficCapture {
2
41
  constructor(udid: any, log: any, resultPath: any);
3
42
  /** @type {import('teen_process').SubProcess|null} */
@@ -11,31 +50,5 @@ export class TrafficCapture {
11
50
  finish(): Promise<any>;
12
51
  cleanup(): Promise<void>;
13
52
  }
14
- declare namespace _default {
15
- /**
16
- * Records the given network traffic capture into a .pcap file.
17
- *
18
- * @param {number} timeLimitSec - The maximum recording time, in seconds. The maximum value is `43200` (12 hours).
19
- * @param {boolean} forceRestart - Whether to restart traffic capture process forcefully when startPcap is called (`true`) or ignore the call until the current traffic capture is completed (`false`, the default value).
20
- * @throws {Error} If network traffic capture has failed to start.
21
- * @returns {Promise<void>}
22
- * @this {XCUITestDriver}
23
- */
24
- function mobileStartPcap(this: import("../driver").XCUITestDriver, timeLimitSec?: number, forceRestart?: boolean): Promise<void>;
25
- /**
26
- * Stops network traffic capture.
27
- *
28
- * If no traffic capture process is running, then the endpoint will try to get the recently recorded file.
29
- *
30
- * If no previously recorded file is found and no active traffic capture processes are running, then the method returns an empty string.
31
- *
32
- * @remarks Network capture files can be viewed in [Wireshark](https://www.wireshark.org/) and other similar applications.
33
- * @returns {Promise<string>} Base64-encoded content of the recorded pcap file or an empty string if no traffic capture has been started before.
34
- * @throws {Error} If there was an error while getting the capture file.
35
- * @this {XCUITestDriver}
36
- */
37
- function mobileStopPcap(this: import("../driver").XCUITestDriver): Promise<string>;
38
- }
39
- export default _default;
40
53
  export type XCUITestDriver = import("../driver").XCUITestDriver;
41
54
  //# sourceMappingURL=pcap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pcap.d.ts","sourceRoot":"","sources":["../../../lib/commands/pcap.js"],"names":[],"mappings":"AAQA;IAGE,kDAKC;IAPD,qDAAqD;IACrD,aADW,GAAiC,GAAC,IAAI,CACrC;IAEV,UAAgB;IAChB,SAAc;IACd,gBAA4B;IAI9B,0CAmBC;IAED,uBAEC;IAED,6CAgBC;IAED,uBAGC;IAED,yBAIC;CACF;;IAGC;;;;;;;;OAQG;IACH,kFANW,MAAM,iBACN,OAAO,GAEL,OAAO,CAAC,IAAI,CAAC,CAgDzB;IAED;;;;;;;;;;;OAWG;IACH,mEAJa,OAAO,CAAC,MAAM,CAAC,CA0B3B;;;6BAIU,OAAO,WAAW,EAAE,cAAc"}
1
+ {"version":3,"file":"pcap.d.ts","sourceRoot":"","sources":["../../../lib/commands/pcap.js"],"names":[],"mappings":"AAyEA;;;;;;;;GAQG;AACH,yFANW,MAAM,iBACN,OAAO,GAEL,OAAO,CAAC,IAAI,CAAC,CAgDzB;;IAtDD;;;;;;;;OAQG;IACH,qEANW,MAAM,iBACN,OAAO,EAkDjB;IAzBG,gCAA2B;;AA2B/B;;;;;;;;;;;GAWG;AACH,0EAJa,OAAO,CAAC,MAAM,CAAC,CA0B3B;;IAJG,qBAA2B;;AAvJ/B;IAGE,kDAKC;IAPD,qDAAqD;IACrD,aADW,GAAiC,GAAC,IAAI,CACrC;IAEV,UAAgB;IAChB,SAAc;IACd,gBAA4B;IAI9B,0CAmBC;IAED,uBAEC;IAED,6CAgBC;IAED,uBAGC;IAED,yBAIC;CACF;6BA+FY,OAAO,WAAW,EAAE,cAAc"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TrafficCapture = void 0;
4
+ exports.mobileStartPcap = mobileStartPcap;
5
+ exports.mobileStopPcap = mobileStopPcap;
4
6
  const py_ios_device_client_1 = require("../real-device-clients/py-ios-device-client");
5
7
  const support_1 = require("appium/support");
6
8
  const utils_1 = require("../utils");
@@ -59,90 +61,88 @@ class TrafficCapture {
59
61
  }
60
62
  }
61
63
  exports.TrafficCapture = TrafficCapture;
62
- exports.default = {
63
- /**
64
- * Records the given network traffic capture into a .pcap file.
65
- *
66
- * @param {number} timeLimitSec - The maximum recording time, in seconds. The maximum value is `43200` (12 hours).
67
- * @param {boolean} forceRestart - Whether to restart traffic capture process forcefully when startPcap is called (`true`) or ignore the call until the current traffic capture is completed (`false`, the default value).
68
- * @throws {Error} If network traffic capture has failed to start.
69
- * @returns {Promise<void>}
70
- * @this {XCUITestDriver}
71
- */
72
- async mobileStartPcap(timeLimitSec = 180, forceRestart = false) {
73
- if (this.isSimulator()) {
74
- throw this.log.errorWithException('Network traffic capture only works on real devices');
75
- }
76
- if (this._trafficCapture?.isCapturing()) {
77
- this.log.info(`There is an active traffic capture process`);
78
- if (forceRestart) {
79
- this.log.info(`Stopping it because 'forceRestart' option is set to true`);
80
- await this._trafficCapture.interrupt(true);
81
- }
82
- else {
83
- this.log.info(`Doing nothing. ` +
84
- `Set 'forceRestart' option to true if you'd like to start a new traffic capture session`);
85
- return;
86
- }
87
- }
88
- if (this._trafficCapture) {
89
- await this._trafficCapture.cleanup();
90
- this._trafficCapture = null;
91
- }
92
- const resultPath = await support_1.tempDir.path({
93
- prefix: `appium_${support_1.util.uuidV4().substring(0, 8)}`,
94
- suffix: DEFAULT_EXT,
95
- });
96
- const trafficCollector = new TrafficCapture(this.device.udid, this.log, resultPath);
97
- const timeoutSeconds = parseInt(String(timeLimitSec), 10);
98
- if (isNaN(timeoutSeconds) || timeoutSeconds > MAX_CAPTURE_TIME_SEC || timeoutSeconds <= 0) {
99
- throw new driver_1.errors.InvalidArgumentError(`The timeLimitSec value must be in range [1, ${MAX_CAPTURE_TIME_SEC}] seconds. ` +
100
- `The value of '${timeLimitSec}' has been passed instead.`);
101
- }
102
- try {
103
- await trafficCollector.start(timeoutSeconds);
104
- }
105
- catch (e) {
106
- await trafficCollector.interrupt(true);
107
- await trafficCollector.cleanup();
108
- throw e;
109
- }
110
- this._trafficCapture = trafficCollector;
111
- },
112
- /**
113
- * Stops network traffic capture.
114
- *
115
- * If no traffic capture process is running, then the endpoint will try to get the recently recorded file.
116
- *
117
- * If no previously recorded file is found and no active traffic capture processes are running, then the method returns an empty string.
118
- *
119
- * @remarks Network capture files can be viewed in [Wireshark](https://www.wireshark.org/) and other similar applications.
120
- * @returns {Promise<string>} Base64-encoded content of the recorded pcap file or an empty string if no traffic capture has been started before.
121
- * @throws {Error} If there was an error while getting the capture file.
122
- * @this {XCUITestDriver}
123
- */
124
- async mobileStopPcap() {
125
- if (!this._trafficCapture) {
126
- this.log.info('Network traffic collector has not been started. There is nothing to stop');
127
- return '';
64
+ /**
65
+ * Records the given network traffic capture into a .pcap file.
66
+ *
67
+ * @param {number} timeLimitSec - The maximum recording time, in seconds. The maximum value is `43200` (12 hours).
68
+ * @param {boolean} forceRestart - Whether to restart traffic capture process forcefully when startPcap is called (`true`) or ignore the call until the current traffic capture is completed (`false`, the default value).
69
+ * @throws {Error} If network traffic capture has failed to start.
70
+ * @returns {Promise<void>}
71
+ * @this {XCUITestDriver}
72
+ */
73
+ async function mobileStartPcap(timeLimitSec = 180, forceRestart = false) {
74
+ if (this.isSimulator()) {
75
+ throw this.log.errorWithException('Network traffic capture only works on real devices');
76
+ }
77
+ if (this._trafficCapture?.isCapturing()) {
78
+ this.log.info(`There is an active traffic capture process`);
79
+ if (forceRestart) {
80
+ this.log.info(`Stopping it because 'forceRestart' option is set to true`);
81
+ await this._trafficCapture.interrupt(true);
128
82
  }
129
- let resultPath;
130
- try {
131
- resultPath = await this._trafficCapture.finish();
132
- if (!(await support_1.fs.exists(resultPath))) {
133
- throw this.log.errorWithException(`The network traffic capture utility has failed ` +
134
- `to store the actual traffic capture at '${resultPath}'`);
135
- }
83
+ else {
84
+ this.log.info(`Doing nothing. ` +
85
+ `Set 'forceRestart' option to true if you'd like to start a new traffic capture session`);
86
+ return;
136
87
  }
137
- catch (e) {
138
- await this._trafficCapture.interrupt(true);
139
- await this._trafficCapture.cleanup();
140
- this._trafficCapture = null;
141
- throw e;
88
+ }
89
+ if (this._trafficCapture) {
90
+ await this._trafficCapture.cleanup();
91
+ this._trafficCapture = null;
92
+ }
93
+ const resultPath = await support_1.tempDir.path({
94
+ prefix: `appium_${support_1.util.uuidV4().substring(0, 8)}`,
95
+ suffix: DEFAULT_EXT,
96
+ });
97
+ const trafficCollector = new TrafficCapture(this.device.udid, this.log, resultPath);
98
+ const timeoutSeconds = parseInt(String(timeLimitSec), 10);
99
+ if (isNaN(timeoutSeconds) || timeoutSeconds > MAX_CAPTURE_TIME_SEC || timeoutSeconds <= 0) {
100
+ throw new driver_1.errors.InvalidArgumentError(`The timeLimitSec value must be in range [1, ${MAX_CAPTURE_TIME_SEC}] seconds. ` +
101
+ `The value of '${timeLimitSec}' has been passed instead.`);
102
+ }
103
+ try {
104
+ await trafficCollector.start(timeoutSeconds);
105
+ }
106
+ catch (e) {
107
+ await trafficCollector.interrupt(true);
108
+ await trafficCollector.cleanup();
109
+ throw e;
110
+ }
111
+ this._trafficCapture = trafficCollector;
112
+ }
113
+ /**
114
+ * Stops network traffic capture.
115
+ *
116
+ * If no traffic capture process is running, then the endpoint will try to get the recently recorded file.
117
+ *
118
+ * If no previously recorded file is found and no active traffic capture processes are running, then the method returns an empty string.
119
+ *
120
+ * @remarks Network capture files can be viewed in [Wireshark](https://www.wireshark.org/) and other similar applications.
121
+ * @returns {Promise<string>} Base64-encoded content of the recorded pcap file or an empty string if no traffic capture has been started before.
122
+ * @throws {Error} If there was an error while getting the capture file.
123
+ * @this {XCUITestDriver}
124
+ */
125
+ async function mobileStopPcap() {
126
+ if (!this._trafficCapture) {
127
+ this.log.info('Network traffic collector has not been started. There is nothing to stop');
128
+ return '';
129
+ }
130
+ let resultPath;
131
+ try {
132
+ resultPath = await this._trafficCapture.finish();
133
+ if (!(await support_1.fs.exists(resultPath))) {
134
+ throw this.log.errorWithException(`The network traffic capture utility has failed ` +
135
+ `to store the actual traffic capture at '${resultPath}'`);
142
136
  }
143
- return await (0, utils_1.encodeBase64OrUpload)(resultPath);
144
- },
145
- };
137
+ }
138
+ catch (e) {
139
+ await this._trafficCapture.interrupt(true);
140
+ await this._trafficCapture.cleanup();
141
+ this._trafficCapture = null;
142
+ throw e;
143
+ }
144
+ return await (0, utils_1.encodeBase64OrUpload)(resultPath);
145
+ }
146
146
  /**
147
147
  * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
148
148
  */
@@ -1 +1 @@
1
- {"version":3,"file":"pcap.js","sourceRoot":"","sources":["../../../lib/commands/pcap.js"],"names":[],"mappings":";;;AAAA,sFAAwE;AACxE,4CAAiD;AACjD,oCAA8C;AAC9C,0CAAqC;AAErC,MAAM,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1C,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,MAAa,cAAc;IACzB,qDAAqD;IACrD,WAAW,CAAC;IACZ,YAAY,IAAI,EAAE,GAAG,EAAE,UAAU;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,cAAc;QACxB,IAAI,CAAC,WAAW,GAAG,gDAAgD,CAAC,CAClE,MAAM,IAAI,gCAAS,CAAC;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAChC,CAAC;QACF,IAAI,CAAC,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AAI,CAAC,CAAC,MAAM,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAC/B,iDAAiD;gBAC/C,2CAA2C,UAAU,GAAG,CAC3D,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,MAAM,CAAC,CAAC;IACV,CAAC;IACD,OAAO,MAAM,IAAA,4BAAoB,EAAC,UAAU,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG"}
@@ -1,3 +1,66 @@
1
+ /**
2
+ * Starts performance profiling for the device under test.
3
+ *
4
+ * Relaxing security is mandatory for simulators. It can always work for real devices.
5
+ *
6
+ * Since XCode 12 the method tries to use `xctrace` tool to record performance stats.
7
+ *
8
+ * The `instruments` developer utility is used as a fallback for this purpose if `xctrace` is not available.
9
+ *
10
+ * It is possible to record multiple profiles at the same time.
11
+ *
12
+ * Read [Recording, Pausing, and Stopping Traces](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Recording,Pausing,andStoppingTraces.html) for more details.
13
+ *
14
+ * @param {number} timeout - The maximum count of milliseconds to record the profiling information.
15
+ * @param {string} profileName - The name of existing performance profile to apply. Can also contain the full path to the chosen template on the server file system. Note: not all profiles are supported on mobile devices.
16
+ * @param {number|'current'} [pid] - The ID of the process to measure the performance for. Set it to `current` in order to measure the performance of the process, which belongs to the currently active application. All processes running on the device are measured if `pid` is unset (the default setting).
17
+ * @this {XCUITestDriver}
18
+ */
19
+ export function mobileStartPerfRecord(this: import("../driver").XCUITestDriver, timeout?: number, profileName?: string, pid?: number | "current"): Promise<void>;
20
+ export class mobileStartPerfRecord {
21
+ /**
22
+ * Starts performance profiling for the device under test.
23
+ *
24
+ * Relaxing security is mandatory for simulators. It can always work for real devices.
25
+ *
26
+ * Since XCode 12 the method tries to use `xctrace` tool to record performance stats.
27
+ *
28
+ * The `instruments` developer utility is used as a fallback for this purpose if `xctrace` is not available.
29
+ *
30
+ * It is possible to record multiple profiles at the same time.
31
+ *
32
+ * Read [Recording, Pausing, and Stopping Traces](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Recording,Pausing,andStoppingTraces.html) for more details.
33
+ *
34
+ * @param {number} timeout - The maximum count of milliseconds to record the profiling information.
35
+ * @param {string} profileName - The name of existing performance profile to apply. Can also contain the full path to the chosen template on the server file system. Note: not all profiles are supported on mobile devices.
36
+ * @param {number|'current'} [pid] - The ID of the process to measure the performance for. Set it to `current` in order to measure the performance of the process, which belongs to the currently active application. All processes running on the device are measured if `pid` is unset (the default setting).
37
+ * @this {XCUITestDriver}
38
+ */
39
+ constructor(this: import("../driver").XCUITestDriver, timeout?: number, profileName?: string, pid?: number | "current");
40
+ _perfRecorders: PerfRecorder[] | undefined;
41
+ }
42
+ /**
43
+ * Stops performance recording operation previously started by {@linkcode XCUITestDriver.mobileStartPerfRecord mobile: startPerfRecord}.
44
+ *
45
+ * If the previous call has already been completed due to the timeout, then its result is returned immediately. An error is thrown if the performance recording failed to start.
46
+ *
47
+ * The resulting file in `.trace` format can be either returned directly as base64-encoded zip archive or uploaded to a remote location (such files can be pretty large). Afterwards it is possible to unarchive and open such files with Xcode Dev Tools.
48
+ *
49
+ * @param {string} [remotePath] - The path to the remote location, where the resulting zipped `.trace` file should be uploaded. The following protocols are supported: `http`, `https`, `ftp`. Null or empty string value (the default setting) means the content of resulting file should be zipped, encoded as Base64 and passed as the endpoint response value. An exception will be thrown if the generated file is too big to fit into the available process memory.
50
+ * @param {string} [user] - The name of the user for the remote authentication. Only works if `remotePath` is provided.
51
+ * @param {string} [pass] - The password for the remote authentication. Only works if `remotePath` is provided.
52
+ * @param {import('axios').Method} [method] - The http multipart upload method name. Only works if `remotePath` is provided. Defaults to `PUT`
53
+ * @param {string} profileName - The name of existing performance profile to stop the recording for. Multiple recorders for different profile names could be executed at the same time.
54
+ * @param {Record<string,any>} [headers] - Additional headers mapping for multipart http(s) uploads
55
+ * @param {string} [fileFieldName] - The name of the form field, where the file content BLOB should be stored for http(s) uploads. Defaults to `file`
56
+ * @param {Record<string,any>|([string, any])[]} [formFields] - Additional form fields for multipart http(s) uploads
57
+ *
58
+ * @returns {Promise<string>} The resulting file in `.trace` format. This file can either be returned directly as base64-encoded `.zip` archive or uploaded to a remote location (note that such files may be large), _depending on the `remotePath` argument value._ Thereafter, the file may be unarchived and opened with Xcode Developer Tools.
59
+ * @throws {Error} If no performance recording with given profile name/device udid combination
60
+ * has been started before or the resulting .trace file has not been generated properly.
61
+ * @this {XCUITestDriver}
62
+ */
63
+ export function mobileStopPerfRecord(this: import("../driver").XCUITestDriver, remotePath?: string, user?: string, pass?: string, method?: import("axios").Method, profileName?: string, headers?: Record<string, any>, fileFieldName?: string, formFields?: Record<string, any> | ([string, any])[]): Promise<string>;
1
64
  export class PerfRecorder {
2
65
  constructor(reportRoot: any, udid: any, opts?: {});
3
66
  /** @type {import('teen_process').SubProcess|null} */
@@ -18,49 +81,5 @@ export class PerfRecorder {
18
81
  start(): Promise<void>;
19
82
  stop(force?: boolean): Promise<string>;
20
83
  }
21
- declare namespace _default {
22
- /**
23
- * Starts performance profiling for the device under test.
24
- *
25
- * Relaxing security is mandatory for simulators. It can always work for real devices.
26
- *
27
- * Since XCode 12 the method tries to use `xctrace` tool to record performance stats.
28
- *
29
- * The `instruments` developer utility is used as a fallback for this purpose if `xctrace` is not available.
30
- *
31
- * It is possible to record multiple profiles at the same time.
32
- *
33
- * Read [Recording, Pausing, and Stopping Traces](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Recording,Pausing,andStoppingTraces.html) for more details.
34
- *
35
- * @param {number} timeout - The maximum count of milliseconds to record the profiling information.
36
- * @param {string} profileName - The name of existing performance profile to apply. Can also contain the full path to the chosen template on the server file system. Note: not all profiles are supported on mobile devices.
37
- * @param {number|'current'} [pid] - The ID of the process to measure the performance for. Set it to `current` in order to measure the performance of the process, which belongs to the currently active application. All processes running on the device are measured if `pid` is unset (the default setting).
38
- * @this {XCUITestDriver}
39
- */
40
- function mobileStartPerfRecord(this: import("../driver").XCUITestDriver, timeout?: number, profileName?: string, pid?: number | "current"): Promise<void>;
41
- /**
42
- * Stops performance recording operation previously started by {@linkcode XCUITestDriver.mobileStartPerfRecord mobile: startPerfRecord}.
43
- *
44
- * If the previous call has already been completed due to the timeout, then its result is returned immediately. An error is thrown if the performance recording failed to start.
45
- *
46
- * The resulting file in `.trace` format can be either returned directly as base64-encoded zip archive or uploaded to a remote location (such files can be pretty large). Afterwards it is possible to unarchive and open such files with Xcode Dev Tools.
47
- *
48
- * @param {string} [remotePath] - The path to the remote location, where the resulting zipped `.trace` file should be uploaded. The following protocols are supported: `http`, `https`, `ftp`. Null or empty string value (the default setting) means the content of resulting file should be zipped, encoded as Base64 and passed as the endpoint response value. An exception will be thrown if the generated file is too big to fit into the available process memory.
49
- * @param {string} [user] - The name of the user for the remote authentication. Only works if `remotePath` is provided.
50
- * @param {string} [pass] - The password for the remote authentication. Only works if `remotePath` is provided.
51
- * @param {import('axios').Method} [method] - The http multipart upload method name. Only works if `remotePath` is provided. Defaults to `PUT`
52
- * @param {string} profileName - The name of existing performance profile to stop the recording for. Multiple recorders for different profile names could be executed at the same time.
53
- * @param {Record<string,any>} [headers] - Additional headers mapping for multipart http(s) uploads
54
- * @param {string} [fileFieldName] - The name of the form field, where the file content BLOB should be stored for http(s) uploads. Defaults to `file`
55
- * @param {Record<string,any>|([string, any])[]} [formFields] - Additional form fields for multipart http(s) uploads
56
- *
57
- * @returns {Promise<string>} The resulting file in `.trace` format. This file can either be returned directly as base64-encoded `.zip` archive or uploaded to a remote location (note that such files may be large), _depending on the `remotePath` argument value._ Thereafter, the file may be unarchived and opened with Xcode Developer Tools.
58
- * @throws {Error} If no performance recording with given profile name/device udid combination
59
- * has been started before or the resulting .trace file has not been generated properly.
60
- * @this {XCUITestDriver}
61
- */
62
- function mobileStopPerfRecord(this: import("../driver").XCUITestDriver, remotePath?: string, user?: string, pass?: string, method?: import("axios").Method, profileName?: string, headers?: Record<string, any>, fileFieldName?: string, formFields?: Record<string, any> | ([string, any])[]): Promise<string>;
63
- }
64
- export default _default;
65
84
  export type XCUITestDriver = import("../driver").XCUITestDriver;
66
85
  //# sourceMappingURL=performance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../../lib/commands/performance.js"],"names":[],"mappings":"AA+CA;IAGE,mDAeC;IAjBD,qDAAqD;IACrD,UADW,GAAiC,GAAC,IAAI,CACxC;IAGP,0BAA2B;IAC3B,cAAoF;IACpF,kBAA4D;IAC5D,oBAGC;IACD,UAAoB;IACpB,WAAiB;IACjB,8CAEC;IACD,wCAA2B;IAG7B,uBAEC;IAED,yCAEC;IAED,uCAsBC;IAED,qBAEC;IAED,uCAgCC;IAED,uBAiGC;IAED,uCAkBC;CACF;;IAGC;;;;;;;;;;;;;;;;;OAiBG;IACH,mFALW,MAAM,gBACN,MAAM,QACN,MAAM,GAAC,SAAS,iBA4C1B;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,qFAdW,MAAM,SACN,MAAM,SACN,MAAM,WACN,OAAO,OAAO,EAAE,MAAM,gBACtB,MAAM,YACN,MAAM,CAAC,MAAM,EAAC,GAAG,CAAC,kBAClB,MAAM,eACN,MAAM,CAAC,MAAM,EAAC,GAAG,CAAC,GAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,GAElC,OAAO,CAAC,MAAM,CAAC,CAoD3B;;;6BAIU,OAAO,WAAW,EAAE,cAAc"}
1
+ {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../../lib/commands/performance.js"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;;;;;;GAiBG;AACH,0FALW,MAAM,gBACN,MAAM,QACN,MAAM,GAAC,SAAS,iBA4C1B;;IA3DD;;;;;;;;;;;;;;;;;OAiBG;IACH,gEALW,MAAM,gBACN,MAAM,QACN,MAAM,GAAC,SAAS,EA4C1B;IADC,2CAAgE;;AAGlE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,4FAdW,MAAM,SACN,MAAM,SACN,MAAM,WACN,OAAO,OAAO,EAAE,MAAM,gBACtB,MAAM,YACN,MAAM,CAAC,MAAM,EAAC,GAAG,CAAC,kBAClB,MAAM,eACN,MAAM,CAAC,MAAM,EAAC,GAAG,CAAC,GAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,GAElC,OAAO,CAAC,MAAM,CAAC,CAoD3B;AA2BD;IAGE,mDAeC;IAjBD,qDAAqD;IACrD,UADW,GAAiC,GAAC,IAAI,CACxC;IAGP,0BAA2B;IAC3B,cAAoF;IACpF,kBAA4D;IAC5D,oBAGC;IACD,UAAoB;IACpB,WAAiB;IACjB,8CAEC;IACD,wCAA2B;IAG7B,uBAEC;IAED,yCAEC;IAED,uCAsBC;IAED,qBAEC;IAED,uCAgCC;IAED,uBAiGC;IAED,uCAkBC;CACF;6BAGY,OAAO,WAAW,EAAE,cAAc"}
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PerfRecorder = void 0;
7
+ exports.mobileStartPerfRecord = mobileStartPerfRecord;
8
+ exports.mobileStopPerfRecord = mobileStopPerfRecord;
7
9
  const lodash_1 = __importDefault(require("lodash"));
8
10
  const path_1 = __importDefault(require("path"));
9
11
  const support_1 = require("appium/support");
@@ -24,6 +26,109 @@ const DEFAULT_EXT = '.trace';
24
26
  const DEFAULT_PID = 'current';
25
27
  const INSTRUMENTS = 'instruments';
26
28
  const XCTRACE = 'xctrace';
29
+ /**
30
+ * Starts performance profiling for the device under test.
31
+ *
32
+ * Relaxing security is mandatory for simulators. It can always work for real devices.
33
+ *
34
+ * Since XCode 12 the method tries to use `xctrace` tool to record performance stats.
35
+ *
36
+ * The `instruments` developer utility is used as a fallback for this purpose if `xctrace` is not available.
37
+ *
38
+ * It is possible to record multiple profiles at the same time.
39
+ *
40
+ * Read [Recording, Pausing, and Stopping Traces](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Recording,Pausing,andStoppingTraces.html) for more details.
41
+ *
42
+ * @param {number} timeout - The maximum count of milliseconds to record the profiling information.
43
+ * @param {string} profileName - The name of existing performance profile to apply. Can also contain the full path to the chosen template on the server file system. Note: not all profiles are supported on mobile devices.
44
+ * @param {number|'current'} [pid] - The ID of the process to measure the performance for. Set it to `current` in order to measure the performance of the process, which belongs to the currently active application. All processes running on the device are measured if `pid` is unset (the default setting).
45
+ * @this {XCUITestDriver}
46
+ */
47
+ async function mobileStartPerfRecord(timeout = DEFAULT_TIMEOUT_MS, profileName = DEFAULT_PROFILE_NAME, pid) {
48
+ if (!this.isFeatureEnabled(PERF_RECORD_FEAT_NAME) && !this.isRealDevice()) {
49
+ throw this.log.errorWithException(PERF_RECORD_SECURITY_MESSAGE);
50
+ }
51
+ if (!lodash_1.default.isEmpty(this._perfRecorders)) {
52
+ for (const recorder of this._perfRecorders.filter((x) => x.profileName === profileName)) {
53
+ if (recorder.isRunning()) {
54
+ this.log.debug(`Performance recorder for '${profileName}' on device '${this.device.udid}' ` +
55
+ ` is already running. Doing nothing`);
56
+ return;
57
+ }
58
+ lodash_1.default.pull(this._perfRecorders, recorder);
59
+ await recorder.stop(true);
60
+ }
61
+ }
62
+ let realPid;
63
+ if (pid) {
64
+ if (lodash_1.default.toLower(String(pid)) === DEFAULT_PID) {
65
+ const appInfo = /** @type {import('./types').ActiveAppInfo} */ (await this.proxyCommand('/wda/activeAppInfo', 'GET'));
66
+ realPid = appInfo.pid;
67
+ }
68
+ else {
69
+ realPid = pid;
70
+ }
71
+ }
72
+ const recorder = new PerfRecorder(await support_1.tempDir.openDir(), this.device.udid, {
73
+ timeout: parseInt(String(timeout), 10),
74
+ profileName,
75
+ pid: parseInt(String(realPid), 10),
76
+ });
77
+ await recorder.start();
78
+ this._perfRecorders = [...(this._perfRecorders || []), recorder];
79
+ }
80
+ /**
81
+ * Stops performance recording operation previously started by {@linkcode XCUITestDriver.mobileStartPerfRecord mobile: startPerfRecord}.
82
+ *
83
+ * If the previous call has already been completed due to the timeout, then its result is returned immediately. An error is thrown if the performance recording failed to start.
84
+ *
85
+ * The resulting file in `.trace` format can be either returned directly as base64-encoded zip archive or uploaded to a remote location (such files can be pretty large). Afterwards it is possible to unarchive and open such files with Xcode Dev Tools.
86
+ *
87
+ * @param {string} [remotePath] - The path to the remote location, where the resulting zipped `.trace` file should be uploaded. The following protocols are supported: `http`, `https`, `ftp`. Null or empty string value (the default setting) means the content of resulting file should be zipped, encoded as Base64 and passed as the endpoint response value. An exception will be thrown if the generated file is too big to fit into the available process memory.
88
+ * @param {string} [user] - The name of the user for the remote authentication. Only works if `remotePath` is provided.
89
+ * @param {string} [pass] - The password for the remote authentication. Only works if `remotePath` is provided.
90
+ * @param {import('axios').Method} [method] - The http multipart upload method name. Only works if `remotePath` is provided. Defaults to `PUT`
91
+ * @param {string} profileName - The name of existing performance profile to stop the recording for. Multiple recorders for different profile names could be executed at the same time.
92
+ * @param {Record<string,any>} [headers] - Additional headers mapping for multipart http(s) uploads
93
+ * @param {string} [fileFieldName] - The name of the form field, where the file content BLOB should be stored for http(s) uploads. Defaults to `file`
94
+ * @param {Record<string,any>|([string, any])[]} [formFields] - Additional form fields for multipart http(s) uploads
95
+ *
96
+ * @returns {Promise<string>} The resulting file in `.trace` format. This file can either be returned directly as base64-encoded `.zip` archive or uploaded to a remote location (note that such files may be large), _depending on the `remotePath` argument value._ Thereafter, the file may be unarchived and opened with Xcode Developer Tools.
97
+ * @throws {Error} If no performance recording with given profile name/device udid combination
98
+ * has been started before or the resulting .trace file has not been generated properly.
99
+ * @this {XCUITestDriver}
100
+ */
101
+ async function mobileStopPerfRecord(remotePath, user, pass, method, profileName = DEFAULT_PROFILE_NAME, headers, fileFieldName, formFields) {
102
+ if (!this.isFeatureEnabled(PERF_RECORD_FEAT_NAME) && !this.isRealDevice()) {
103
+ throw this.log.errorWithException(PERF_RECORD_SECURITY_MESSAGE);
104
+ }
105
+ if (lodash_1.default.isEmpty(this._perfRecorders)) {
106
+ this.log.info('No performance recorders have been started. Doing nothing');
107
+ return '';
108
+ }
109
+ const recorders = this._perfRecorders.filter((x) => x.profileName === profileName);
110
+ if (lodash_1.default.isEmpty(recorders)) {
111
+ throw this.log.errorWithException(`There are no records for performance profile '${profileName}' ` +
112
+ `and device ${this.device.udid}. Have you started the profiling before?`);
113
+ }
114
+ const recorder = lodash_1.default.first(recorders);
115
+ const resultPath = await /** @type {PerfRecorder} */ (recorder).stop();
116
+ if (!(await support_1.fs.exists(resultPath))) {
117
+ throw this.log.errorWithException(`There is no ${DEFAULT_EXT} file found for performance profile '${profileName}' ` +
118
+ `and device ${this.device.udid}. Make sure the selected profile is supported on this device`);
119
+ }
120
+ const result = await (0, utils_1.encodeBase64OrUpload)(resultPath, remotePath, {
121
+ user,
122
+ pass,
123
+ method,
124
+ headers,
125
+ fileFieldName,
126
+ formFields,
127
+ });
128
+ lodash_1.default.pull(this._perfRecorders, recorder);
129
+ await support_1.fs.rimraf(resultPath);
130
+ return result;
131
+ }
27
132
  async function requireXctrace() {
28
133
  const xcrunPath = await (0, xcrun_1.requireXcrun)();
29
134
  try {
@@ -220,111 +325,6 @@ class PerfRecorder {
220
325
  }
221
326
  }
222
327
  exports.PerfRecorder = PerfRecorder;
223
- exports.default = {
224
- /**
225
- * Starts performance profiling for the device under test.
226
- *
227
- * Relaxing security is mandatory for simulators. It can always work for real devices.
228
- *
229
- * Since XCode 12 the method tries to use `xctrace` tool to record performance stats.
230
- *
231
- * The `instruments` developer utility is used as a fallback for this purpose if `xctrace` is not available.
232
- *
233
- * It is possible to record multiple profiles at the same time.
234
- *
235
- * Read [Recording, Pausing, and Stopping Traces](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Recording,Pausing,andStoppingTraces.html) for more details.
236
- *
237
- * @param {number} timeout - The maximum count of milliseconds to record the profiling information.
238
- * @param {string} profileName - The name of existing performance profile to apply. Can also contain the full path to the chosen template on the server file system. Note: not all profiles are supported on mobile devices.
239
- * @param {number|'current'} [pid] - The ID of the process to measure the performance for. Set it to `current` in order to measure the performance of the process, which belongs to the currently active application. All processes running on the device are measured if `pid` is unset (the default setting).
240
- * @this {XCUITestDriver}
241
- */
242
- async mobileStartPerfRecord(timeout = DEFAULT_TIMEOUT_MS, profileName = DEFAULT_PROFILE_NAME, pid) {
243
- if (!this.isFeatureEnabled(PERF_RECORD_FEAT_NAME) && !this.isRealDevice()) {
244
- throw this.log.errorWithException(PERF_RECORD_SECURITY_MESSAGE);
245
- }
246
- if (!lodash_1.default.isEmpty(this._perfRecorders)) {
247
- for (const recorder of this._perfRecorders.filter((x) => x.profileName === profileName)) {
248
- if (recorder.isRunning()) {
249
- this.log.debug(`Performance recorder for '${profileName}' on device '${this.device.udid}' ` +
250
- ` is already running. Doing nothing`);
251
- return;
252
- }
253
- lodash_1.default.pull(this._perfRecorders, recorder);
254
- await recorder.stop(true);
255
- }
256
- }
257
- let realPid;
258
- if (pid) {
259
- if (lodash_1.default.toLower(String(pid)) === DEFAULT_PID) {
260
- const appInfo = /** @type {import('./types').ActiveAppInfo} */ (await this.proxyCommand('/wda/activeAppInfo', 'GET'));
261
- realPid = appInfo.pid;
262
- }
263
- else {
264
- realPid = pid;
265
- }
266
- }
267
- const recorder = new PerfRecorder(await support_1.tempDir.openDir(), this.device.udid, {
268
- timeout: parseInt(String(timeout), 10),
269
- profileName,
270
- pid: parseInt(String(realPid), 10),
271
- });
272
- await recorder.start();
273
- this._perfRecorders = [...(this._perfRecorders || []), recorder];
274
- },
275
- /**
276
- * Stops performance recording operation previously started by {@linkcode XCUITestDriver.mobileStartPerfRecord mobile: startPerfRecord}.
277
- *
278
- * If the previous call has already been completed due to the timeout, then its result is returned immediately. An error is thrown if the performance recording failed to start.
279
- *
280
- * The resulting file in `.trace` format can be either returned directly as base64-encoded zip archive or uploaded to a remote location (such files can be pretty large). Afterwards it is possible to unarchive and open such files with Xcode Dev Tools.
281
- *
282
- * @param {string} [remotePath] - The path to the remote location, where the resulting zipped `.trace` file should be uploaded. The following protocols are supported: `http`, `https`, `ftp`. Null or empty string value (the default setting) means the content of resulting file should be zipped, encoded as Base64 and passed as the endpoint response value. An exception will be thrown if the generated file is too big to fit into the available process memory.
283
- * @param {string} [user] - The name of the user for the remote authentication. Only works if `remotePath` is provided.
284
- * @param {string} [pass] - The password for the remote authentication. Only works if `remotePath` is provided.
285
- * @param {import('axios').Method} [method] - The http multipart upload method name. Only works if `remotePath` is provided. Defaults to `PUT`
286
- * @param {string} profileName - The name of existing performance profile to stop the recording for. Multiple recorders for different profile names could be executed at the same time.
287
- * @param {Record<string,any>} [headers] - Additional headers mapping for multipart http(s) uploads
288
- * @param {string} [fileFieldName] - The name of the form field, where the file content BLOB should be stored for http(s) uploads. Defaults to `file`
289
- * @param {Record<string,any>|([string, any])[]} [formFields] - Additional form fields for multipart http(s) uploads
290
- *
291
- * @returns {Promise<string>} The resulting file in `.trace` format. This file can either be returned directly as base64-encoded `.zip` archive or uploaded to a remote location (note that such files may be large), _depending on the `remotePath` argument value._ Thereafter, the file may be unarchived and opened with Xcode Developer Tools.
292
- * @throws {Error} If no performance recording with given profile name/device udid combination
293
- * has been started before or the resulting .trace file has not been generated properly.
294
- * @this {XCUITestDriver}
295
- */
296
- async mobileStopPerfRecord(remotePath, user, pass, method, profileName = DEFAULT_PROFILE_NAME, headers, fileFieldName, formFields) {
297
- if (!this.isFeatureEnabled(PERF_RECORD_FEAT_NAME) && !this.isRealDevice()) {
298
- throw this.log.errorWithException(PERF_RECORD_SECURITY_MESSAGE);
299
- }
300
- if (lodash_1.default.isEmpty(this._perfRecorders)) {
301
- this.log.info('No performance recorders have been started. Doing nothing');
302
- return '';
303
- }
304
- const recorders = this._perfRecorders.filter((x) => x.profileName === profileName);
305
- if (lodash_1.default.isEmpty(recorders)) {
306
- throw this.log.errorWithException(`There are no records for performance profile '${profileName}' ` +
307
- `and device ${this.device.udid}. Have you started the profiling before?`);
308
- }
309
- const recorder = lodash_1.default.first(recorders);
310
- const resultPath = await /** @type {PerfRecorder} */ (recorder).stop();
311
- if (!(await support_1.fs.exists(resultPath))) {
312
- throw this.log.errorWithException(`There is no ${DEFAULT_EXT} file found for performance profile '${profileName}' ` +
313
- `and device ${this.device.udid}. Make sure the selected profile is supported on this device`);
314
- }
315
- const result = await (0, utils_1.encodeBase64OrUpload)(resultPath, remotePath, {
316
- user,
317
- pass,
318
- method,
319
- headers,
320
- fileFieldName,
321
- formFields,
322
- });
323
- lodash_1.default.pull(this._perfRecorders, recorder);
324
- await support_1.fs.rimraf(resultPath);
325
- return result;
326
- },
327
- };
328
328
  /**
329
329
  * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
330
330
  */