appium-mac2-driver
Version:
XCTest-based Appium driver for macOS apps automation
138 lines • 9.7 kB
TypeScript
/**
* 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. Also, the Appium process must be allowed to access screen recording
* in System Preferences->Security & Privacy->Screen Recording.
* The resulting video uses H264 codec and is ready to be played by media players built-in into web browsers.
*
* @this {Mac2Driver}
* @param {string|number} deviceId Screen device index to use for the recording.
* The list of available devices could be retrieved using
* `ffmpeg -f avfoundation -list_devices true -i` command.
* @param {string|number} [timeLimit] The maximum recording time, in seconds. The default
* value is 600 seconds (10 minutes).
* @param {string} [videoFilter] The video filter spec to apply for ffmpeg.
* See https://trac.ffmpeg.org/wiki/FilteringGuide for more details on the possible values.
* Example: Set it to `scale=ifnot(gte(iw\,1024)\,iw\,1024):-2` in order to limit the video width
* to 1024px. The height will be adjusted automatically to match the actual ratio.
* @param {string|number} [fps] The count of frames per second in the resulting video.
* The greater fps it has the bigger file size is. 15 by default.
* @param {'ultrafast'|'superfast'|'veryfast'|'faster'|'fast'|'medium'|'slow'|'slower'|'veryslow'} [preset]
* One of the supported encoding presets. A preset is a collection of options that will provide a
* certain encoding speed to compression ratio.
* A slower preset will provide better compression (compression is quality per filesize).
* This means that, for example, if you target a certain file size or constant bit rate, you will
* achieve better quality with a slower preset. Read https://trac.ffmpeg.org/wiki/Encode/H.264 for more details.
* `veryfast` by default
* @param {boolean} [captureCursor] Whether to capture the mouse cursor while recording the screen.
* False by default
* @param {boolean} [captureClicks] Whether to capture mouse clicks while recording the screen.
* False by default.
* @param {boolean} [forceRestart=true] Whether to ignore the call if a screen recording is currently running
* (`false`) or to start a new recording immediately and terminate the existing one
* if running (`true`). The default value is `true`.
* @throws {Error} If screen recording has failed to start or is not supported on the device under test.
*/
export function startRecordingScreen(this: import("../driver").Mac2Driver, deviceId: string | number, timeLimit?: string | number, videoFilter?: string, fps?: string | number, preset?: "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow", captureCursor?: boolean, captureClicks?: boolean, forceRestart?: boolean): Promise<void>;
export class startRecordingScreen {
/**
* 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. Also, the Appium process must be allowed to access screen recording
* in System Preferences->Security & Privacy->Screen Recording.
* The resulting video uses H264 codec and is ready to be played by media players built-in into web browsers.
*
* @this {Mac2Driver}
* @param {string|number} deviceId Screen device index to use for the recording.
* The list of available devices could be retrieved using
* `ffmpeg -f avfoundation -list_devices true -i` command.
* @param {string|number} [timeLimit] The maximum recording time, in seconds. The default
* value is 600 seconds (10 minutes).
* @param {string} [videoFilter] The video filter spec to apply for ffmpeg.
* See https://trac.ffmpeg.org/wiki/FilteringGuide for more details on the possible values.
* Example: Set it to `scale=ifnot(gte(iw\,1024)\,iw\,1024):-2` in order to limit the video width
* to 1024px. The height will be adjusted automatically to match the actual ratio.
* @param {string|number} [fps] The count of frames per second in the resulting video.
* The greater fps it has the bigger file size is. 15 by default.
* @param {'ultrafast'|'superfast'|'veryfast'|'faster'|'fast'|'medium'|'slow'|'slower'|'veryslow'} [preset]
* One of the supported encoding presets. A preset is a collection of options that will provide a
* certain encoding speed to compression ratio.
* A slower preset will provide better compression (compression is quality per filesize).
* This means that, for example, if you target a certain file size or constant bit rate, you will
* achieve better quality with a slower preset. Read https://trac.ffmpeg.org/wiki/Encode/H.264 for more details.
* `veryfast` by default
* @param {boolean} [captureCursor] Whether to capture the mouse cursor while recording the screen.
* False by default
* @param {boolean} [captureClicks] Whether to capture mouse clicks while recording the screen.
* False by default.
* @param {boolean} [forceRestart=true] Whether to ignore the call if a screen recording is currently running
* (`false`) or to start a new recording immediately and terminate the existing one
* if running (`true`). The default value is `true`.
* @throws {Error} If screen recording has failed to start or is not supported on the device under test.
*/
constructor(this: import("../driver").Mac2Driver, deviceId: string | number, timeLimit?: string | number, videoFilter?: string, fps?: string | number, preset?: "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow", captureCursor?: boolean, captureClicks?: boolean, forceRestart?: boolean);
_screenRecorder: ScreenRecorder;
}
/**
* Stop recording the screen.
* If no screen recording has been started before then the method returns an empty string.
*
* @param {string} [remotePath] The path to the remote location, where the resulting video 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 encoded as Base64 and passed as the endpoint response value.
* An exception will be thrown if the generated media file is too big to
* fit into the available process memory.
* @param {string} [user] The name of the user for the remote authentication.
* @param {string} [pass] The password for the remote authentication.
* @param {string} [method] The http multipart upload method name. The 'PUT' one is used by default.
* @param {import('@appium/types').StringRecord|[string, any][]} [headers]
* Additional headers mapping for multipart http(s) uploads
* @param {string} [fileFieldName] The name of the form field, where the file content BLOB should
* be stored for http(s) uploads
* @param {import('@appium/types').StringRecord|[string, string][]} [formFields]
* Additional form fields for multipart http(s) uploads
* @returns {Promise<string>} Base64-encoded content of the recorded media file if 'remotePath'
* parameter is falsy or an empty string.
* @this {Mac2Driver}
* @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 function stopRecordingScreen(this: import("../driver").Mac2Driver, remotePath?: string, user?: string, pass?: string, method?: string, headers?: import("@appium/types").StringRecord | [string, any][], fileFieldName?: string, formFields?: import("@appium/types").StringRecord | [string, string][]): Promise<string>;
export type Mac2Driver = import("../driver").Mac2Driver;
export type ScreenRecorderOptions = {
fps?: number | undefined;
deviceId: string | number;
preset?: string | undefined;
captureCursor?: boolean | undefined;
captureClicks?: boolean | undefined;
videoFilter?: string | undefined;
timeLimit?: number | undefined;
};
declare class ScreenRecorder {
/**
*
* @param {string} videoPath
* @param {import('@appium/types').AppiumLogger} log
* @param {ScreenRecorderOptions} opts
*/
constructor(videoPath: string, log: import("@appium/types").AppiumLogger, opts: ScreenRecorderOptions);
_log: import("@appium/types").AppiumLogger;
_videoPath: string;
_process: any;
_fps: number;
_deviceId: string | number;
_captureCursor: boolean | undefined;
_captureClicks: boolean | undefined;
_preset: string;
_videoFilter: string | undefined;
_timeLimit: number;
getVideoPath(): Promise<string>;
isRunning(): boolean;
_enforceTermination(): Promise<string>;
start(): Promise<void>;
stop(force?: boolean): Promise<any>;
}
export {};
//# sourceMappingURL=record-screen.d.ts.map