Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 93 additions & 2 deletions lib/commands/record-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export class ScreenRecorder {
* (`false`) or to start a new recording immediately and terminate the existing one if running (`true`).
* @throws {Error} If screen recording has failed to start or is not supported on the device under test.
*/
export async function startRecordingScreen (
export async function windowsStartRecordingScreen (
timeLimit,
videoFilter,
fps,
Expand Down Expand Up @@ -301,7 +301,7 @@ export async function startRecordingScreen (
* or the file content cannot be uploaded to the remote location
* or screen recording is not supported on the device under test.
*/
export async function stopRecordingScreen (
export async function windowsStopRecordingScreen (
remotePath,
user,
pass,
Expand Down Expand Up @@ -335,6 +335,97 @@ export async function stopRecordingScreen (
});
}

/**
Comment thread
mykola-mokhnach marked this conversation as resolved.
Outdated
* Record the display in background while the automated test is running.
* This method requires FFMPEG (https://www.ffmpeg.org/download.html) to be installed
* and present in PATH.
* The resulting video uses H264 codec and is ready to be played by media players built-in into web browsers.
*
* @param {StartRecordingOptions} [options] - The available options.
* @this {import('../driver').WindowsDriver}
* @throws {Error} If screen recording has failed to start or is not supported on the device under test.
*/
export async function startRecordingScreen(options = {}) {
const {
timeLimit,
videoFilter,
fps,
preset,
captureCursor,
captureClicks,
audioInput,
forceRestart = true,
} = options;

await this.windowsStartRecordingScreen(
timeLimit,
videoFilter,
fps,
preset,
captureCursor,
captureClicks,
audioInput,
forceRestart
);
}

/**
* Stop recording the screen.
* If no screen recording has been started before then the method returns an empty string.
*
* @param {StopRecordingOptions} [options] - The available options.
* @returns {Promise<string>} Base64-encoded content of the recorded media file if 'remotePath'
* parameter is falsy or an empty string.
* @this {import('../driver').WindowsDriver}
* @throws {Error} If there was an error while getting the name of a media file
* or the file content cannot be uploaded to the remote location
* or screen recording is not supported on the device under test.
*/
export async function stopRecordingScreen(options = {}) {
const {remotePath, user, pass, method, headers, fileFieldName, formFields} = options;

return await this.windowsStopRecordingScreen(
remotePath,
user,
pass,
method,
headers,
fileFieldName,
formFields
);
}

/**
* @typedef {import('../driver').WindowsDriver} WindowsDriver
*/

/**
* For detailed explanations of each property,
* please refer to the parameters of the `windowsStartRecordingScreen` function.
Comment thread
mykola-mokhnach marked this conversation as resolved.
Outdated
*
* @typedef {Object} StartRecordingOptions
*
* @property {string} [videoFilter]
* @property {number|string} [fps=15]
* @property {string} [preset='veryfast']
* @property {boolean} [captureCursor=false]
* @property {boolean} [captureClicks=false]
* @property {string} [audioInput]
* @property {string|number} [timeLimit=600]
* @property {boolean} [forceRestart=true]
*/

/**
* For detailed explanations of each property,
* please refer to the parameters of the `windowsStopRecordingScreen` function.
*
* @typedef {Object} StopRecordingOptions
*
* @property {string} [remotePath]
* @property {string} [user]
* @property {string} [pass]
* @property {string} [method]
* @property {Object} [headers]
* @property {string} [fileFieldName='file']
* @property {Object[]|[string, string][]} [formFields]
*/
2 changes: 2 additions & 0 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ export class WindowsDriver extends BaseDriver {

execPowerShell = powershellCommands.execPowerShell;

windowsStartRecordingScreen = recordScreenCommands.windowsStartRecordingScreen;
windowsStopRecordingScreen = recordScreenCommands.windowsStopRecordingScreen;
startRecordingScreen = recordScreenCommands.startRecordingScreen;
stopRecordingScreen = recordScreenCommands.stopRecordingScreen;

Expand Down
5 changes: 3 additions & 2 deletions lib/execute-method-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { ExecuteMethodMap } from '@appium/types';

export const executeMethodMap = {
'windows: startRecordingScreen': {
command: 'startRecordingScreen',
command: 'windowsStartRecordingScreen',
params: {
optional: [
'timeLimit',
'videoFilter',
'fps',
'preset',
'captureCursor',
Expand All @@ -16,7 +17,7 @@ export const executeMethodMap = {
},
},
'windows: stopRecordingScreen': {
command: 'stopRecordingScreen',
command: 'windowsStopRecordingScreen',
params: {
optional: [
'remotePath',
Expand Down