appium-xcuitest-driver 10.2.2 → 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.
- package/CHANGELOG.md +12 -0
- package/build/lib/commands/active-app-info.d.ts +9 -0
- package/build/lib/commands/active-app-info.d.ts.map +1 -0
- package/build/lib/commands/active-app-info.js +14 -0
- package/build/lib/commands/active-app-info.js.map +1 -0
- package/build/lib/commands/alert.d.ts +42 -45
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +66 -62
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +150 -153
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +300 -286
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/app-strings.d.ts +14 -17
- package/build/lib/commands/app-strings.d.ts.map +1 -1
- package/build/lib/commands/app-strings.js +23 -24
- package/build/lib/commands/app-strings.js.map +1 -1
- package/build/lib/commands/appearance.d.ts +19 -22
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js +56 -56
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/audit.d.ts +22 -17
- package/build/lib/commands/audit.d.ts.map +1 -1
- package/build/lib/commands/audit.js +17 -18
- package/build/lib/commands/audit.js.map +1 -1
- package/build/lib/commands/battery.d.ts +11 -14
- package/build/lib/commands/battery.d.ts.map +1 -1
- package/build/lib/commands/battery.js +36 -37
- package/build/lib/commands/battery.js.map +1 -1
- package/build/lib/commands/biometric.d.ts +30 -33
- package/build/lib/commands/biometric.d.ts.map +1 -1
- package/build/lib/commands/biometric.js +42 -41
- package/build/lib/commands/biometric.js.map +1 -1
- package/build/lib/commands/certificate.d.ts +48 -45
- package/build/lib/commands/certificate.d.ts.map +1 -1
- package/build/lib/commands/certificate.js +218 -205
- package/build/lib/commands/certificate.js.map +1 -1
- package/build/lib/commands/clipboard.d.ts +19 -22
- package/build/lib/commands/clipboard.d.ts.map +1 -1
- package/build/lib/commands/clipboard.js +30 -30
- package/build/lib/commands/clipboard.js.map +1 -1
- package/build/lib/commands/condition.d.ts +49 -26
- package/build/lib/commands/condition.d.ts.map +1 -1
- package/build/lib/commands/condition.js +87 -86
- package/build/lib/commands/condition.js.map +1 -1
- package/build/lib/commands/content-size.d.ts +26 -29
- package/build/lib/commands/content-size.d.ts.map +1 -1
- package/build/lib/commands/content-size.js +36 -36
- package/build/lib/commands/content-size.js.map +1 -1
- package/build/lib/commands/context.d.ts +161 -108
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +530 -517
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/deviceInfo.d.ts +9 -12
- package/build/lib/commands/deviceInfo.d.ts.map +1 -1
- package/build/lib/commands/deviceInfo.js +17 -18
- package/build/lib/commands/deviceInfo.js.map +1 -1
- package/build/lib/commands/element.d.ts +102 -105
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +337 -323
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts +24 -19
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +63 -62
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-movement.d.ts +77 -80
- package/build/lib/commands/file-movement.d.ts.map +1 -1
- package/build/lib/commands/file-movement.js +130 -124
- package/build/lib/commands/file-movement.js.map +1 -1
- package/build/lib/commands/find.d.ts +18 -21
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +158 -156
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +124 -116
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +248 -232
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/geolocation.d.ts +43 -46
- package/build/lib/commands/geolocation.d.ts.map +1 -1
- package/build/lib/commands/geolocation.js +10 -11
- package/build/lib/commands/geolocation.js.map +1 -1
- package/build/lib/commands/gesture.d.ts +273 -276
- package/build/lib/commands/gesture.d.ts.map +1 -1
- package/build/lib/commands/gesture.js +506 -492
- package/build/lib/commands/gesture.js.map +1 -1
- package/build/lib/commands/increase-contrast.d.ts +20 -23
- package/build/lib/commands/increase-contrast.d.ts.map +1 -1
- package/build/lib/commands/increase-contrast.js +30 -30
- package/build/lib/commands/increase-contrast.js.map +1 -1
- package/build/lib/commands/iohid.d.ts +1370 -1373
- package/build/lib/commands/iohid.d.ts.map +1 -1
- package/build/lib/commands/iohid.js +30 -31
- package/build/lib/commands/iohid.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +29 -32
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +53 -51
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/keychains.d.ts +9 -12
- package/build/lib/commands/keychains.d.ts.map +1 -1
- package/build/lib/commands/keychains.js +13 -14
- package/build/lib/commands/keychains.js.map +1 -1
- package/build/lib/commands/localization.d.ts +16 -19
- package/build/lib/commands/localization.d.ts.map +1 -1
- package/build/lib/commands/localization.js +25 -26
- package/build/lib/commands/localization.js.map +1 -1
- package/build/lib/commands/location.d.ts +36 -39
- package/build/lib/commands/location.d.ts.map +1 -1
- package/build/lib/commands/location.js +99 -98
- package/build/lib/commands/location.js.map +1 -1
- package/build/lib/commands/lock.d.ts +21 -24
- package/build/lib/commands/lock.d.ts.map +1 -1
- package/build/lib/commands/lock.js +39 -38
- package/build/lib/commands/lock.js.map +1 -1
- package/build/lib/commands/log.d.ts +43 -37
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +174 -171
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/memory.d.ts +9 -12
- package/build/lib/commands/memory.d.ts.map +1 -1
- package/build/lib/commands/memory.js +37 -39
- package/build/lib/commands/memory.js.map +1 -1
- package/build/lib/commands/navigation.d.ts +30 -33
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js +92 -92
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/notifications.d.ts +26 -29
- package/build/lib/commands/notifications.d.ts.map +1 -1
- package/build/lib/commands/notifications.js +53 -53
- package/build/lib/commands/notifications.js.map +1 -1
- package/build/lib/commands/pasteboard.d.ts +21 -24
- package/build/lib/commands/pasteboard.d.ts.map +1 -1
- package/build/lib/commands/pasteboard.js +37 -37
- package/build/lib/commands/pasteboard.js.map +1 -1
- package/build/lib/commands/pcap.d.ts +39 -26
- package/build/lib/commands/pcap.d.ts.map +1 -1
- package/build/lib/commands/pcap.js +81 -81
- package/build/lib/commands/pcap.js.map +1 -1
- package/build/lib/commands/performance.d.ts +63 -44
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +105 -105
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +33 -36
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +66 -65
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/proxy-helper.d.ts +12 -15
- package/build/lib/commands/proxy-helper.d.ts.map +1 -1
- package/build/lib/commands/proxy-helper.js +53 -54
- package/build/lib/commands/proxy-helper.js.map +1 -1
- package/build/lib/commands/record-audio.d.ts +49 -29
- package/build/lib/commands/record-audio.d.ts.map +1 -1
- package/build/lib/commands/record-audio.js +100 -104
- package/build/lib/commands/record-audio.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +54 -18
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +127 -129
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/screenshots.d.ts +14 -17
- package/build/lib/commands/screenshots.d.ts.map +1 -1
- package/build/lib/commands/screenshots.js +108 -107
- package/build/lib/commands/screenshots.js.map +1 -1
- package/build/lib/commands/simctl.d.ts +11 -14
- package/build/lib/commands/simctl.d.ts.map +1 -1
- package/build/lib/commands/simctl.js +23 -26
- package/build/lib/commands/simctl.js.map +1 -1
- package/build/lib/commands/source.d.ts +14 -17
- package/build/lib/commands/source.d.ts.map +1 -1
- package/build/lib/commands/source.js +40 -43
- package/build/lib/commands/source.js.map +1 -1
- package/build/lib/commands/timeouts.d.ts +44 -33
- package/build/lib/commands/timeouts.d.ts.map +1 -1
- package/build/lib/commands/timeouts.js +65 -63
- package/build/lib/commands/timeouts.js.map +1 -1
- package/build/lib/commands/web.d.ts +247 -197
- package/build/lib/commands/web.d.ts.map +1 -1
- package/build/lib/commands/web.js +815 -786
- package/build/lib/commands/web.js.map +1 -1
- package/build/lib/commands/xctest-record-screen.d.ts +63 -66
- package/build/lib/commands/xctest-record-screen.d.ts.map +1 -1
- package/build/lib/commands/xctest-record-screen.js +103 -102
- package/build/lib/commands/xctest-record-screen.js.map +1 -1
- package/build/lib/commands/xctest.d.ts +55 -51
- package/build/lib/commands/xctest.d.ts.map +1 -1
- package/build/lib/commands/xctest.js +116 -117
- package/build/lib/commands/xctest.js.map +1 -1
- package/build/lib/driver.d.ts +278 -1597
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +320 -236
- package/build/lib/driver.js.map +1 -1
- package/build/lib/execute-method-map.d.ts.map +1 -1
- package/build/lib/execute-method-map.js +9 -0
- package/build/lib/execute-method-map.js.map +1 -1
- package/build/lib/real-device.d.ts +1 -1
- package/build/lib/real-device.d.ts.map +1 -1
- package/build/lib/real-device.js +2 -2
- package/build/lib/real-device.js.map +1 -1
- package/lib/commands/active-app-info.js +12 -0
- package/lib/commands/alert.js +68 -65
- package/lib/commands/app-management.js +308 -301
- package/lib/commands/app-strings.js +24 -26
- package/lib/commands/appearance.js +54 -56
- package/lib/commands/audit.js +18 -20
- package/lib/commands/battery.js +35 -37
- package/lib/commands/biometric.js +44 -46
- package/lib/commands/certificate.js +226 -215
- package/lib/commands/clipboard.js +30 -32
- package/lib/commands/condition.js +98 -100
- package/lib/commands/content-size.js +36 -38
- package/lib/commands/context.js +495 -490
- package/lib/commands/deviceInfo.js +19 -20
- package/lib/commands/element.js +367 -357
- package/lib/commands/execute.js +72 -72
- package/lib/commands/file-movement.js +132 -134
- package/lib/commands/find.js +160 -159
- package/lib/commands/general.js +238 -231
- package/lib/commands/geolocation.js +6 -14
- package/lib/commands/gesture.js +525 -515
- package/lib/commands/increase-contrast.js +30 -32
- package/lib/commands/iohid.js +32 -34
- package/lib/commands/keyboard.js +49 -51
- package/lib/commands/keychains.js +12 -14
- package/lib/commands/localization.js +24 -26
- package/lib/commands/location.js +102 -104
- package/lib/commands/lock.js +38 -38
- package/lib/commands/log.js +197 -198
- package/lib/commands/memory.js +40 -43
- package/lib/commands/navigation.js +96 -100
- package/lib/commands/notifications.js +57 -59
- package/lib/commands/pasteboard.js +37 -39
- package/lib/commands/pcap.js +84 -86
- package/lib/commands/performance.js +132 -133
- package/lib/commands/permissions.js +67 -69
- package/lib/commands/proxy-helper.js +60 -61
- package/lib/commands/record-audio.js +115 -120
- package/lib/commands/recordscreen.js +145 -149
- package/lib/commands/screenshots.js +116 -116
- package/lib/commands/simctl.js +25 -29
- package/lib/commands/source.js +42 -46
- package/lib/commands/timeouts.js +59 -63
- package/lib/commands/web.js +878 -858
- package/lib/commands/xctest-record-screen.js +103 -105
- package/lib/commands/xctest.js +134 -139
- package/lib/driver.js +288 -236
- package/lib/execute-method-map.ts +9 -0
- package/lib/real-device.js +2 -2
- package/npm-shrinkwrap.json +440 -76
- package/package.json +2 -1
- package/build/lib/commands/activeAppInfo.d.ts +0 -12
- package/build/lib/commands/activeAppInfo.d.ts.map +0 -1
- package/build/lib/commands/activeAppInfo.js +0 -15
- package/build/lib/commands/activeAppInfo.js.map +0 -1
- package/build/lib/commands/index.d.ts +0 -96
- package/build/lib/commands/index.d.ts.map +0 -1
- package/build/lib/commands/index.js +0 -100
- package/build/lib/commands/index.js.map +0 -1
- package/build/lib/real-device-clients/devicectl.d.ts +0 -204
- package/build/lib/real-device-clients/devicectl.d.ts.map +0 -1
- package/build/lib/real-device-clients/devicectl.js +0 -264
- package/build/lib/real-device-clients/devicectl.js.map +0 -1
- package/lib/commands/activeAppInfo.js +0 -14
- package/lib/commands/index.js +0 -95
- package/lib/real-device-clients/devicectl.js +0 -291
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AudioRecorder = void 0;
|
|
4
|
+
exports.startAudioRecording = startAudioRecording;
|
|
5
|
+
exports.stopAudioRecording = stopAudioRecording;
|
|
4
6
|
const support_1 = require("appium/support");
|
|
5
7
|
const teen_process_1 = require("teen_process");
|
|
6
8
|
const utils_1 = require("../utils");
|
|
@@ -119,113 +121,107 @@ class AudioRecorder {
|
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
exports.AudioRecorder = AudioRecorder;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (this._audioRecorder?.isRecording()) {
|
|
156
|
-
this.log.info(`There is an active audio recording process`);
|
|
157
|
-
if (forceRestart) {
|
|
158
|
-
this.log.info(`Stopping it because 'forceRestart' option is set to true`);
|
|
159
|
-
await this._audioRecorder.interrupt(true);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
this.log.info(`Doing nothing. ` +
|
|
163
|
-
`Set 'forceRestart' option to true if you'd like to start a new audio recording session`);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (this._audioRecorder) {
|
|
168
|
-
await this._audioRecorder.cleanup();
|
|
169
|
-
this._audioRecorder = null;
|
|
170
|
-
}
|
|
171
|
-
const audioPath = await support_1.tempDir.path({
|
|
172
|
-
prefix: `appium_${support_1.util.uuidV4().substring(0, 8)}`,
|
|
173
|
-
suffix: DEFAULT_EXT,
|
|
174
|
-
});
|
|
175
|
-
const audioRecorder = new AudioRecorder(audioInput, this.log, audioPath, {
|
|
176
|
-
audioSource: DEFAULT_SOURCE,
|
|
177
|
-
audioCodec,
|
|
178
|
-
audioBitrate,
|
|
179
|
-
audioChannels,
|
|
180
|
-
audioRate,
|
|
181
|
-
});
|
|
182
|
-
const timeoutSeconds = parseInt(String(timeLimit), 10);
|
|
183
|
-
if (isNaN(timeoutSeconds) || timeoutSeconds > MAX_RECORDING_TIME_SEC || timeoutSeconds <= 0) {
|
|
184
|
-
throw this.log.errorWithException(`The timeLimit value must be in range [1, ${MAX_RECORDING_TIME_SEC}] seconds. ` +
|
|
185
|
-
`The value of '${timeLimit}' has been passed instead.`);
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
await audioRecorder.start(timeoutSeconds);
|
|
189
|
-
}
|
|
190
|
-
catch (e) {
|
|
191
|
-
await audioRecorder.interrupt(true);
|
|
192
|
-
await audioRecorder.cleanup();
|
|
193
|
-
throw e;
|
|
194
|
-
}
|
|
195
|
-
this._audioRecorder = audioRecorder;
|
|
196
|
-
},
|
|
197
|
-
/**
|
|
198
|
-
* Stop recording of the audio input. If no audio recording process is running then
|
|
199
|
-
* the endpoint will try to get the recently recorded file.
|
|
200
|
-
* If no previously recorded file is found and no active audio recording
|
|
201
|
-
* processes are running then the method returns an empty string.
|
|
202
|
-
*
|
|
203
|
-
* @returns {Promise<string>} Base64-encoded content of the recorded media file or an
|
|
204
|
-
* empty string if no audio recording has been started before.
|
|
205
|
-
* @throws {Error} If there was an error while getting the recorded file.
|
|
206
|
-
* @this {XCUITestDriver}
|
|
207
|
-
*/
|
|
208
|
-
async stopAudioRecording() {
|
|
209
|
-
if (!this._audioRecorder) {
|
|
210
|
-
this.log.info('Audio recording has not been started. There is nothing to stop');
|
|
211
|
-
return '';
|
|
124
|
+
/**
|
|
125
|
+
* Records the given hardware audio input and saves it into an `.mp4` file.
|
|
126
|
+
*
|
|
127
|
+
* **To use this command, the `audio_record` security feature must be enabled _and_ [FFMpeg](https://ffmpeg.org/) must be installed on the Appium server.**
|
|
128
|
+
*
|
|
129
|
+
* @param {string|number} audioInput - The name of the corresponding audio input device to use for the capture. The full list of capture devices could be shown by executing `ffmpeg -f avfoundation -list_devices true -i ""`
|
|
130
|
+
* @param {string|number} timeLimit - The maximum recording time, in seconds.
|
|
131
|
+
* @param {string} audioCodec - The name of the audio codec.
|
|
132
|
+
* @param {string} audioBitrate - The bitrate of the resulting audio stream.
|
|
133
|
+
* @param {string|number} audioChannels - The count of audio channels in the resulting stream. Setting it to `1` will create a single channel (mono) audio stream.
|
|
134
|
+
* @param {string|number} audioRate - The sampling rate of the resulting audio stream (in Hz).
|
|
135
|
+
* @param {boolean} forceRestart - Whether to restart audio capture process forcefully when `mobile: startRecordingAudio` is called (`true`) or ignore the call until the current audio recording is completed (`false`).
|
|
136
|
+
* @group Real Device Only
|
|
137
|
+
* @this {XCUITestDriver}
|
|
138
|
+
* @returns {Promise<void>}
|
|
139
|
+
* @privateRemarks Using string literals for the default parameters makes better documentation.
|
|
140
|
+
*/
|
|
141
|
+
async function startAudioRecording(audioInput, timeLimit = 180, audioCodec = 'aac', audioBitrate = '128k', audioChannels = 2, audioRate = 44100, forceRestart = false) {
|
|
142
|
+
if (!this.isFeatureEnabled(AUDIO_RECORD_FEAT_NAME)) {
|
|
143
|
+
throw this.log.errorWithException(`Audio capture feature must be enabled on the server side. ` +
|
|
144
|
+
`Please set '--relaxed-security' or '--allow-insecure' with '${AUDIO_RECORD_FEAT_NAME}' option. ` +
|
|
145
|
+
`Read https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/security.md for more details.`);
|
|
146
|
+
}
|
|
147
|
+
if (!audioInput) {
|
|
148
|
+
throw this.log.errorWithException(`The mandatory audioInput option is not provided. Please set it ` +
|
|
149
|
+
`to a correct value (e. g. ':1'). Use 'ffmpeg -f avfoundation -list_devices true -i ""' ` +
|
|
150
|
+
`command to list available input sources`);
|
|
151
|
+
}
|
|
152
|
+
if (this._audioRecorder?.isRecording()) {
|
|
153
|
+
this.log.info(`There is an active audio recording process`);
|
|
154
|
+
if (forceRestart) {
|
|
155
|
+
this.log.info(`Stopping it because 'forceRestart' option is set to true`);
|
|
156
|
+
await this._audioRecorder.interrupt(true);
|
|
212
157
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
throw this.log.errorWithException(`${FFMPEG_BINARY} has failed ` + `to store the actual audio recording at '${resultPath}'`);
|
|
218
|
-
}
|
|
158
|
+
else {
|
|
159
|
+
this.log.info(`Doing nothing. ` +
|
|
160
|
+
`Set 'forceRestart' option to true if you'd like to start a new audio recording session`);
|
|
161
|
+
return;
|
|
219
162
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
163
|
+
}
|
|
164
|
+
if (this._audioRecorder) {
|
|
165
|
+
await this._audioRecorder.cleanup();
|
|
166
|
+
this._audioRecorder = null;
|
|
167
|
+
}
|
|
168
|
+
const audioPath = await support_1.tempDir.path({
|
|
169
|
+
prefix: `appium_${support_1.util.uuidV4().substring(0, 8)}`,
|
|
170
|
+
suffix: DEFAULT_EXT,
|
|
171
|
+
});
|
|
172
|
+
const audioRecorder = new AudioRecorder(audioInput, this.log, audioPath, {
|
|
173
|
+
audioSource: DEFAULT_SOURCE,
|
|
174
|
+
audioCodec,
|
|
175
|
+
audioBitrate,
|
|
176
|
+
audioChannels,
|
|
177
|
+
audioRate,
|
|
178
|
+
});
|
|
179
|
+
const timeoutSeconds = parseInt(String(timeLimit), 10);
|
|
180
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds > MAX_RECORDING_TIME_SEC || timeoutSeconds <= 0) {
|
|
181
|
+
throw this.log.errorWithException(`The timeLimit value must be in range [1, ${MAX_RECORDING_TIME_SEC}] seconds. ` +
|
|
182
|
+
`The value of '${timeLimit}' has been passed instead.`);
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
await audioRecorder.start(timeoutSeconds);
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
await audioRecorder.interrupt(true);
|
|
189
|
+
await audioRecorder.cleanup();
|
|
190
|
+
throw e;
|
|
191
|
+
}
|
|
192
|
+
this._audioRecorder = audioRecorder;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Stop recording of the audio input. If no audio recording process is running then
|
|
196
|
+
* the endpoint will try to get the recently recorded file.
|
|
197
|
+
* If no previously recorded file is found and no active audio recording
|
|
198
|
+
* processes are running then the method returns an empty string.
|
|
199
|
+
*
|
|
200
|
+
* @returns {Promise<string>} Base64-encoded content of the recorded media file or an
|
|
201
|
+
* empty string if no audio recording has been started before.
|
|
202
|
+
* @throws {Error} If there was an error while getting the recorded file.
|
|
203
|
+
* @this {XCUITestDriver}
|
|
204
|
+
*/
|
|
205
|
+
async function stopAudioRecording() {
|
|
206
|
+
if (!this._audioRecorder) {
|
|
207
|
+
this.log.info('Audio recording has not been started. There is nothing to stop');
|
|
208
|
+
return '';
|
|
209
|
+
}
|
|
210
|
+
let resultPath;
|
|
211
|
+
try {
|
|
212
|
+
resultPath = await this._audioRecorder.finish();
|
|
213
|
+
if (!(await support_1.fs.exists(resultPath))) {
|
|
214
|
+
throw this.log.errorWithException(`${FFMPEG_BINARY} has failed ` + `to store the actual audio recording at '${resultPath}'`);
|
|
225
215
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
await this._audioRecorder.interrupt(true);
|
|
219
|
+
await this._audioRecorder.cleanup();
|
|
220
|
+
this._audioRecorder = null;
|
|
221
|
+
throw e;
|
|
222
|
+
}
|
|
223
|
+
return await (0, utils_1.encodeBase64OrUpload)(resultPath);
|
|
224
|
+
}
|
|
229
225
|
/**
|
|
230
226
|
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
231
227
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-audio.js","sourceRoot":"","sources":["../../../lib/commands/record-audio.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"record-audio.js","sourceRoot":"","sources":["../../../lib/commands/record-audio.js"],"names":[],"mappings":";;;AA0JA,kDAuEC;AAaD,gDAqBC;AAnQD,4CAAyD;AACzD,+CAAwC;AACxC,oCAA8C;AAC9C,uCAA0C;AAE1C,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,sBAAsB,GAAG,cAAc,CAAC;AAC9C,MAAM,cAAc,GAAG,cAAc,CAAC;AACtC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAExC,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,aAAa,GAAG,QAAQ,CAAC;AAC/B,MAAM,YAAY,GAAG,gBAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAErD,MAAa,aAAa;IACxB,YAAY,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,cAAc;QACxB,IAAI,CAAC;YACH,MAAM,YAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAChC,C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}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Direct Appium to start recording the device screen
|
|
3
|
+
*
|
|
4
|
+
* Record the display of devices running iOS Simulator since Xcode 9 or real devices since iOS 11
|
|
5
|
+
* (ffmpeg utility is required: 'brew install ffmpeg').
|
|
6
|
+
* It records screen activity to a MPEG-4 file. Audio is not recorded with the video file.
|
|
7
|
+
* If screen recording has been already started then the command will stop it forcefully and start a new one.
|
|
8
|
+
* The previously recorded video file will be deleted.
|
|
9
|
+
*
|
|
10
|
+
* @param {import('./types').StartRecordingScreenOptions} [options] - The available options.
|
|
11
|
+
* @returns {Promise<string>} Base64-encoded content of the recorded media file if
|
|
12
|
+
* any screen recording is currently running or an empty string.
|
|
13
|
+
* @throws {Error} If screen recording has failed to start.
|
|
14
|
+
* @this {XCUITestDriver}
|
|
15
|
+
*/
|
|
16
|
+
export function startRecordingScreen(this: import("../driver").XCUITestDriver, options?: import("./types").StartRecordingScreenOptions): Promise<string>;
|
|
17
|
+
export class startRecordingScreen {
|
|
16
18
|
/**
|
|
17
19
|
* Direct Appium to start recording the device screen
|
|
18
20
|
*
|
|
@@ -28,7 +30,28 @@ declare namespace _default {
|
|
|
28
30
|
* @throws {Error} If screen recording has failed to start.
|
|
29
31
|
* @this {XCUITestDriver}
|
|
30
32
|
*/
|
|
31
|
-
|
|
33
|
+
constructor(this: import("../driver").XCUITestDriver, options?: import("./types").StartRecordingScreenOptions);
|
|
34
|
+
_recentScreenRecorder: ScreenRecorder;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Direct Appium to stop screen recording and return the video
|
|
38
|
+
*
|
|
39
|
+
* If no screen recording process is running then the endpoint will try to get
|
|
40
|
+
* the recently recorded file. If no previously recorded file is found and no
|
|
41
|
+
* active screen recording processes are running then the method returns an
|
|
42
|
+
* empty string.
|
|
43
|
+
*
|
|
44
|
+
* @param {import('./types').StopRecordingScreenOptions} options - The available
|
|
45
|
+
* options.
|
|
46
|
+
* @returns {Promise<string?>} Base64-encoded content of the recorded media
|
|
47
|
+
* file if `remotePath` parameter is empty or null or an empty string.
|
|
48
|
+
* @throws {Error} If there was an error while getting the name of a media
|
|
49
|
+
* file or the file content cannot be uploaded to the remote
|
|
50
|
+
* location.
|
|
51
|
+
* @this {XCUITestDriver}
|
|
52
|
+
*/
|
|
53
|
+
export function stopRecordingScreen(this: import("../driver").XCUITestDriver, options?: import("./types").StopRecordingScreenOptions): Promise<string | null>;
|
|
54
|
+
export class stopRecordingScreen {
|
|
32
55
|
/**
|
|
33
56
|
* Direct Appium to stop screen recording and return the video
|
|
34
57
|
*
|
|
@@ -46,8 +69,21 @@ declare namespace _default {
|
|
|
46
69
|
* location.
|
|
47
70
|
* @this {XCUITestDriver}
|
|
48
71
|
*/
|
|
49
|
-
|
|
72
|
+
constructor(this: import("../driver").XCUITestDriver, options?: import("./types").StopRecordingScreenOptions);
|
|
73
|
+
_recentScreenRecorder: any;
|
|
74
|
+
}
|
|
75
|
+
export class ScreenRecorder {
|
|
76
|
+
constructor(udid: any, log: any, videoPath: any, opts?: {});
|
|
77
|
+
videoPath: any;
|
|
78
|
+
log: any;
|
|
79
|
+
opts: {};
|
|
80
|
+
udid: any;
|
|
81
|
+
mainProcess: any;
|
|
82
|
+
timeoutHandler: NodeJS.Timeout | null;
|
|
83
|
+
start(timeoutMs: any): Promise<void>;
|
|
84
|
+
interrupt(force?: boolean): Promise<boolean>;
|
|
85
|
+
finish(): Promise<any>;
|
|
86
|
+
cleanup(): Promise<void>;
|
|
50
87
|
}
|
|
51
|
-
export default _default;
|
|
52
88
|
export type XCUITestDriver = import("../driver").XCUITestDriver;
|
|
53
89
|
//# sourceMappingURL=recordscreen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordscreen.d.ts","sourceRoot":"","sources":["../../../lib/commands/recordscreen.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recordscreen.d.ts","sourceRoot":"","sources":["../../../lib/commands/recordscreen.js"],"names":[],"mappings":"AAoOA;;;;;;;;;;;;;;GAcG;AACH,yFANW,OAAO,SAAS,EAAE,2BAA2B,GAC3C,OAAO,CAAC,MAAM,CAAC,CA6G3B;;IAvHD;;;;;;;;;;;;;;OAcG;IACH,gEANW,OAAO,SAAS,EAAE,2BAA2B,EA8GvD;IA7DG,sCAAiC;;AA+DrC;;;;;;;;;;;;;;;;GAgBG;AACH,wFATW,OAAO,SAAS,EAAE,0BAA0B,GAE1C,OAAO,CAAC,MAAM,OAAC,CAAC,CA2B5B;;IArCD;;;;;;;;;;;;;;;;OAgBG;IACH,gEATW,OAAO,SAAS,EAAE,0BAA0B,EA6BtD;IAFG,2BAAiC;;AA3TrC;IACE,4DAOC;IANC,eAA0B;IAC1B,SAAc;IACd,SAAgB;IAChB,UAAgB;IAChB,iBAAuB;IACvB,sCAA0B;IAG5B,qCA8GC;IAED,6CAuBC;IAED,uBAGC;IAED,yBAIC;CACF;6BAmKY,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.ScreenRecorder = void 0;
|
|
7
|
+
exports.startRecordingScreen = startRecordingScreen;
|
|
8
|
+
exports.stopRecordingScreen = stopRecordingScreen;
|
|
7
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
10
|
const support_1 = require("appium/support");
|
|
9
11
|
const teen_process_1 = require("teen_process");
|
|
@@ -188,140 +190,136 @@ class ScreenRecorder {
|
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
exports.ScreenRecorder = ScreenRecorder;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
: QUALITY_MAPPING[lodash_1.default.toLower(String(videoQuality))];
|
|
250
|
-
if (!quality) {
|
|
251
|
-
throw new Error(`videoQuality value should be one of ${JSON.stringify(lodash_1.default.keys(QUALITY_MAPPING))} or a number in range 1..100. ` + `'${videoQuality}' is given instead`);
|
|
252
|
-
}
|
|
253
|
-
mjpegServerScreenshotQuality = mjpegServerScreenshotQuality !== quality ? quality : undefined;
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
mjpegServerScreenshotQuality = undefined;
|
|
257
|
-
}
|
|
258
|
-
if (videoFps) {
|
|
259
|
-
const fps = parseInt(String(videoFps), 10);
|
|
260
|
-
if (isNaN(fps)) {
|
|
261
|
-
throw new Error(`videoFps value should be a valid number in range 1..60. ` +
|
|
262
|
-
`'${videoFps}' is given instead`);
|
|
263
|
-
}
|
|
264
|
-
mjpegServerFramerate = mjpegServerFramerate !== fps ? fps : undefined;
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
mjpegServerFramerate = undefined;
|
|
268
|
-
}
|
|
269
|
-
if (support_1.util.hasValue(mjpegServerScreenshotQuality) || support_1.util.hasValue(mjpegServerFramerate)) {
|
|
270
|
-
await this.proxyCommand('/appium/settings', 'POST', {
|
|
271
|
-
settings: {
|
|
272
|
-
mjpegServerScreenshotQuality,
|
|
273
|
-
mjpegServerFramerate
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
try {
|
|
278
|
-
await screenRecorder.start(timeoutSeconds * 1000);
|
|
279
|
-
}
|
|
280
|
-
catch (e) {
|
|
281
|
-
await screenRecorder.interrupt(true);
|
|
282
|
-
await screenRecorder.cleanup();
|
|
283
|
-
throw e;
|
|
193
|
+
/**
|
|
194
|
+
* Direct Appium to start recording the device screen
|
|
195
|
+
*
|
|
196
|
+
* Record the display of devices running iOS Simulator since Xcode 9 or real devices since iOS 11
|
|
197
|
+
* (ffmpeg utility is required: 'brew install ffmpeg').
|
|
198
|
+
* It records screen activity to a MPEG-4 file. Audio is not recorded with the video file.
|
|
199
|
+
* If screen recording has been already started then the command will stop it forcefully and start a new one.
|
|
200
|
+
* The previously recorded video file will be deleted.
|
|
201
|
+
*
|
|
202
|
+
* @param {import('./types').StartRecordingScreenOptions} [options] - The available options.
|
|
203
|
+
* @returns {Promise<string>} Base64-encoded content of the recorded media file if
|
|
204
|
+
* any screen recording is currently running or an empty string.
|
|
205
|
+
* @throws {Error} If screen recording has failed to start.
|
|
206
|
+
* @this {XCUITestDriver}
|
|
207
|
+
*/
|
|
208
|
+
async function startRecordingScreen(options = {}) {
|
|
209
|
+
const { videoType = DEFAULT_VCODEC, timeLimit = DEFAULT_RECORDING_TIME_SEC, videoQuality = DEFAULT_QUALITY, videoFps = DEFAULT_FPS, videoFilters, videoScale, forceRestart, pixelFormat, hardwareAcceleration } = options;
|
|
210
|
+
let result = '';
|
|
211
|
+
if (!forceRestart) {
|
|
212
|
+
this.log.info(`Checking if there is/was a previous screen recording. ` +
|
|
213
|
+
`Set 'forceRestart' option to 'true' if you'd like to skip this step.`);
|
|
214
|
+
result = (await this.stopRecordingScreen(options)) ?? result;
|
|
215
|
+
}
|
|
216
|
+
const videoPath = await support_1.tempDir.path({
|
|
217
|
+
prefix: `appium_${Math.random().toString(16).substring(2, 8)}`,
|
|
218
|
+
suffix: MP4_EXT
|
|
219
|
+
});
|
|
220
|
+
const wdaBaseUrl = this.opts.wdaBaseUrl || appium_webdriveragent_1.WDA_BASE_URL;
|
|
221
|
+
const screenRecorder = new ScreenRecorder(this.device.udid, this.log, videoPath, {
|
|
222
|
+
remotePort: this.opts.mjpegServerPort || DEFAULT_MJPEG_SERVER_PORT,
|
|
223
|
+
remoteUrl: wdaBaseUrl,
|
|
224
|
+
videoType,
|
|
225
|
+
videoFilters,
|
|
226
|
+
videoScale,
|
|
227
|
+
videoFps,
|
|
228
|
+
pixelFormat,
|
|
229
|
+
hardwareAcceleration
|
|
230
|
+
});
|
|
231
|
+
if (!(await screenRecorder.interrupt(true))) {
|
|
232
|
+
throw this.log.errorWithException('Unable to stop screen recording process');
|
|
233
|
+
}
|
|
234
|
+
if (this._recentScreenRecorder) {
|
|
235
|
+
await this._recentScreenRecorder.cleanup();
|
|
236
|
+
this._recentScreenRecorder = null;
|
|
237
|
+
}
|
|
238
|
+
const timeoutSeconds = parseFloat(String(timeLimit));
|
|
239
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds > MAX_RECORDING_TIME_SEC || timeoutSeconds <= 0) {
|
|
240
|
+
throw this.log.errorWithException(`The timeLimit value must be in range [1, ${MAX_RECORDING_TIME_SEC}] seconds. ` +
|
|
241
|
+
`The value of '${timeLimit}' has been passed instead.`);
|
|
242
|
+
}
|
|
243
|
+
let { mjpegServerScreenshotQuality, mjpegServerFramerate } =
|
|
244
|
+
/** @type {import('appium-webdriveragent').WDASettings} */ (await this.proxyCommand('/appium/settings', 'GET'));
|
|
245
|
+
if (videoQuality) {
|
|
246
|
+
const quality = lodash_1.default.isInteger(videoQuality)
|
|
247
|
+
? videoQuality
|
|
248
|
+
: QUALITY_MAPPING[lodash_1.default.toLower(String(videoQuality))];
|
|
249
|
+
if (!quality) {
|
|
250
|
+
throw new Error(`videoQuality value should be one of ${JSON.stringify(lodash_1.default.keys(QUALITY_MAPPING))} or a number in range 1..100. ` + `'${videoQuality}' is given instead`);
|
|
284
251
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
*
|
|
296
|
-
* @param {import('./types').StopRecordingScreenOptions} options - The available
|
|
297
|
-
* options.
|
|
298
|
-
* @returns {Promise<string?>} Base64-encoded content of the recorded media
|
|
299
|
-
* file if `remotePath` parameter is empty or null or an empty string.
|
|
300
|
-
* @throws {Error} If there was an error while getting the name of a media
|
|
301
|
-
* file or the file content cannot be uploaded to the remote
|
|
302
|
-
* location.
|
|
303
|
-
* @this {XCUITestDriver}
|
|
304
|
-
*/
|
|
305
|
-
async stopRecordingScreen(options = {}) {
|
|
306
|
-
if (!this._recentScreenRecorder) {
|
|
307
|
-
this.log.info('Screen recording is not running. There is nothing to stop.');
|
|
308
|
-
return '';
|
|
252
|
+
mjpegServerScreenshotQuality = mjpegServerScreenshotQuality !== quality ? quality : undefined;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
mjpegServerScreenshotQuality = undefined;
|
|
256
|
+
}
|
|
257
|
+
if (videoFps) {
|
|
258
|
+
const fps = parseInt(String(videoFps), 10);
|
|
259
|
+
if (isNaN(fps)) {
|
|
260
|
+
throw new Error(`videoFps value should be a valid number in range 1..60. ` +
|
|
261
|
+
`'${videoFps}' is given instead`);
|
|
309
262
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
263
|
+
mjpegServerFramerate = mjpegServerFramerate !== fps ? fps : undefined;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
mjpegServerFramerate = undefined;
|
|
267
|
+
}
|
|
268
|
+
if (support_1.util.hasValue(mjpegServerScreenshotQuality) || support_1.util.hasValue(mjpegServerFramerate)) {
|
|
269
|
+
await this.proxyCommand('/appium/settings', 'POST', {
|
|
270
|
+
settings: {
|
|
271
|
+
mjpegServerScreenshotQuality,
|
|
272
|
+
mjpegServerFramerate
|
|
315
273
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
await screenRecorder.start(timeoutSeconds * 1000);
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
await screenRecorder.interrupt(true);
|
|
281
|
+
await screenRecorder.cleanup();
|
|
282
|
+
throw e;
|
|
283
|
+
}
|
|
284
|
+
this._recentScreenRecorder = screenRecorder;
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Direct Appium to stop screen recording and return the video
|
|
289
|
+
*
|
|
290
|
+
* If no screen recording process is running then the endpoint will try to get
|
|
291
|
+
* the recently recorded file. If no previously recorded file is found and no
|
|
292
|
+
* active screen recording processes are running then the method returns an
|
|
293
|
+
* empty string.
|
|
294
|
+
*
|
|
295
|
+
* @param {import('./types').StopRecordingScreenOptions} options - The available
|
|
296
|
+
* options.
|
|
297
|
+
* @returns {Promise<string?>} Base64-encoded content of the recorded media
|
|
298
|
+
* file if `remotePath` parameter is empty or null or an empty string.
|
|
299
|
+
* @throws {Error} If there was an error while getting the name of a media
|
|
300
|
+
* file or the file content cannot be uploaded to the remote
|
|
301
|
+
* location.
|
|
302
|
+
* @this {XCUITestDriver}
|
|
303
|
+
*/
|
|
304
|
+
async function stopRecordingScreen(options = {}) {
|
|
305
|
+
if (!this._recentScreenRecorder) {
|
|
306
|
+
this.log.info('Screen recording is not running. There is nothing to stop.');
|
|
307
|
+
return '';
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
const videoPath = await this._recentScreenRecorder.finish();
|
|
311
|
+
if (!(await support_1.fs.exists(videoPath))) {
|
|
312
|
+
throw this.log.errorWithException(`The screen recorder utility has failed ` +
|
|
313
|
+
`to store the actual screen recording at '${videoPath}'`);
|
|
322
314
|
}
|
|
315
|
+
return await (0, utils_1.encodeBase64OrUpload)(videoPath, options.remotePath, options);
|
|
323
316
|
}
|
|
324
|
-
|
|
317
|
+
finally {
|
|
318
|
+
await this._recentScreenRecorder.interrupt(true);
|
|
319
|
+
await this._recentScreenRecorder.cleanup();
|
|
320
|
+
this._recentScreenRecorder = null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
325
323
|
/**
|
|
326
324
|
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
327
325
|
*/
|