UNPKG

appium-mac2-driver

Version:

XCTest-based Appium driver for macOS apps automation

96 lines 5.87 kB
import type { Mac2Driver } from '../driver'; import type { AppiumLogger, StringRecord } from '@appium/types'; type Preset = 'ultrafast' | 'superfast' | 'veryfast' | 'faster' | 'fast' | 'medium' | 'slow' | 'slower' | 'veryslow'; interface ScreenRecorderOptions { fps?: number; deviceId: string | number; preset?: Preset; captureCursor?: boolean; captureClicks?: boolean; videoFilter?: string; timeLimit?: number; } export declare class ScreenRecorder { private readonly _log; private readonly _videoPath; private _process; private readonly _fps; private readonly _deviceId; private readonly _captureCursor?; private readonly _captureClicks?; private readonly _preset; private readonly _videoFilter?; private readonly _timeLimit; /** * * @param videoPath - Path to the video file * @param log - Logger instance * @param opts - Screen recorder options */ constructor(videoPath: string, log: AppiumLogger, opts: ScreenRecorderOptions); getVideoPath(): Promise<string>; isRunning(): boolean; start(): Promise<void>; stop(force?: boolean): Promise<string>; private _enforceTermination; } /** * 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. * * @param 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 timeLimit - The maximum recording time, in seconds. The default * value is 600 seconds (10 minutes). * @param 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 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 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 captureCursor - Whether to capture the mouse cursor while recording the screen. * False by default * @param captureClicks - Whether to capture mouse clicks while recording the screen. * False by default. * @param forceRestart - 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 declare function startRecordingScreen(this: Mac2Driver, deviceId: string | number, timeLimit?: string | number, videoFilter?: string, fps?: string | number, preset?: Preset, captureCursor?: boolean, captureClicks?: boolean, forceRestart?: boolean): Promise<void>; /** * Stop recording the screen. * If no screen recording has been started before then the method returns an empty string. * * @param 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 user - The name of the user for the remote authentication. * @param pass - The password for the remote authentication. * @param method - The http multipart upload method name. The 'PUT' one is used by default. * @param headers - Additional headers mapping for multipart http(s) uploads * @param fileFieldName - The name of the form field, where the file content BLOB should * be stored for http(s) uploads * @param formFields - Additional form fields for multipart http(s) uploads * @returns Base64-encoded content of the recorded media file if 'remotePath' * parameter is falsy or an empty string. * @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 declare function stopRecordingScreen(this: Mac2Driver, remotePath?: string | null, user?: string, pass?: string, method?: string, headers?: StringRecord | [string, any][], fileFieldName?: string, formFields?: StringRecord | [string, string][]): Promise<string>; export {}; //# sourceMappingURL=record-screen.d.ts.map