Skip to content

Commit 3fc1e96

Browse files
authored
fix: executeMethodMap of startRecordingScreen (#303)
1 parent 30652af commit 3fc1e96

File tree

3 files changed

+98
-4
lines changed

3 files changed

+98
-4
lines changed

lib/commands/record-screen.js

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export class ScreenRecorder {
234234
* (`false`) or to start a new recording immediately and terminate the existing one if running (`true`).
235235
* @throws {Error} If screen recording has failed to start or is not supported on the device under test.
236236
*/
237-
export async function startRecordingScreen (
237+
export async function windowsStartRecordingScreen (
238238
timeLimit,
239239
videoFilter,
240240
fps,
@@ -304,7 +304,7 @@ export async function startRecordingScreen (
304304
* or the file content cannot be uploaded to the remote location
305305
* or screen recording is not supported on the device under test.
306306
*/
307-
export async function stopRecordingScreen (
307+
export async function windowsStopRecordingScreen (
308308
remotePath,
309309
user,
310310
pass,
@@ -338,6 +338,97 @@ export async function stopRecordingScreen (
338338
});
339339
}
340340

341+
/**
342+
* Record the display in background while the automated test is running.
343+
* This method requires FFMPEG (https://www.ffmpeg.org/download.html) to be installed
344+
* and present in PATH.
345+
* The resulting video uses H264 codec and is ready to be played by media players built-in into web browsers.
346+
*
347+
* @param {StartRecordingOptions} [options] - The available options.
348+
* @this {import('../driver').WindowsDriver}
349+
* @throws {Error} If screen recording has failed to start or is not supported on the device under test.
350+
*/
351+
export async function startRecordingScreen(options = {}) {
352+
const {
353+
timeLimit,
354+
videoFilter,
355+
fps,
356+
preset,
357+
captureCursor,
358+
captureClicks,
359+
audioInput,
360+
forceRestart = true,
361+
} = options;
362+
363+
await this.windowsStartRecordingScreen(
364+
timeLimit,
365+
videoFilter,
366+
fps,
367+
preset,
368+
captureCursor,
369+
captureClicks,
370+
audioInput,
371+
forceRestart
372+
);
373+
}
374+
375+
/**
376+
* Stop recording the screen.
377+
* If no screen recording has been started before then the method returns an empty string.
378+
*
379+
* @param {StopRecordingOptions} [options] - The available options.
380+
* @returns {Promise<string>} Base64-encoded content of the recorded media file if 'remotePath'
381+
* parameter is falsy or an empty string.
382+
* @this {import('../driver').WindowsDriver}
383+
* @throws {Error} If there was an error while getting the name of a media file
384+
* or the file content cannot be uploaded to the remote location
385+
* or screen recording is not supported on the device under test.
386+
*/
387+
export async function stopRecordingScreen(options = {}) {
388+
const {remotePath, user, pass, method, headers, fileFieldName, formFields} = options;
389+
390+
return await this.windowsStopRecordingScreen(
391+
remotePath,
392+
user,
393+
pass,
394+
method,
395+
headers,
396+
fileFieldName,
397+
formFields
398+
);
399+
}
400+
341401
/**
342402
* @typedef {import('../driver').WindowsDriver} WindowsDriver
343403
*/
404+
405+
/**
406+
* For detailed explanations of each property,
407+
* please refer to the parameters of the {@linkcode windowsStartRecordingScreen} function.
408+
*
409+
* @typedef {Object} StartRecordingOptions
410+
*
411+
* @property {string} [videoFilter]
412+
* @property {number|string} [fps=15]
413+
* @property {string} [preset='veryfast']
414+
* @property {boolean} [captureCursor=false]
415+
* @property {boolean} [captureClicks=false]
416+
* @property {string} [audioInput]
417+
* @property {string|number} [timeLimit=600]
418+
* @property {boolean} [forceRestart=true]
419+
*/
420+
421+
/**
422+
* For detailed explanations of each property,
423+
* please refer to the parameters of the {@linkcode windowsStopRecordingScreen} function.
424+
*
425+
* @typedef {Object} StopRecordingOptions
426+
*
427+
* @property {string} [remotePath]
428+
* @property {string} [user]
429+
* @property {string} [pass]
430+
* @property {string} [method]
431+
* @property {Object} [headers]
432+
* @property {string} [fileFieldName='file']
433+
* @property {Object[]|[string, string][]} [formFields]
434+
*/

lib/driver.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ export class WindowsDriver extends BaseDriver {
204204

205205
execPowerShell = powershellCommands.execPowerShell;
206206

207+
windowsStartRecordingScreen = recordScreenCommands.windowsStartRecordingScreen;
208+
windowsStopRecordingScreen = recordScreenCommands.windowsStopRecordingScreen;
207209
startRecordingScreen = recordScreenCommands.startRecordingScreen;
208210
stopRecordingScreen = recordScreenCommands.stopRecordingScreen;
209211

lib/execute-method-map.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { ExecuteMethodMap } from '@appium/types';
22

33
export const executeMethodMap = {
44
'windows: startRecordingScreen': {
5-
command: 'startRecordingScreen',
5+
command: 'windowsStartRecordingScreen',
66
params: {
77
optional: [
88
'timeLimit',
9+
'videoFilter',
910
'fps',
1011
'preset',
1112
'captureCursor',
@@ -16,7 +17,7 @@ export const executeMethodMap = {
1617
},
1718
},
1819
'windows: stopRecordingScreen': {
19-
command: 'stopRecordingScreen',
20+
command: 'windowsStopRecordingScreen',
2021
params: {
2122
optional: [
2223
'remotePath',

0 commit comments

Comments
 (0)