UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

61 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mobileSimctl = mobileSimctl; const driver_1 = require("appium/driver"); /** * List of subcommands for `simctl` we provide as mobile simctl command. * They accept 'device' target. */ const SUBCOMMANDS_HAS_DEVICE = [ 'boot', 'get_app_container', 'getenv', 'icloud_sync', 'install', 'install_app_data', 'io', 'keychain', 'launch', 'location', 'logverbose', 'openurl', 'pbcopy', 'pbpaste', 'privacy', 'push', 'shutdown', 'spawn', 'status_bar', 'terminate', 'ui', 'uninstall' ]; /** * Run the given command with arguments as `xcrun simctl` subcommand. * This method works behind the 'simctl' security flag. * * @param command - Subcommand to run with `xcrun simctl`. Must be one of the supported commands. * @param args - Arguments for the subcommand. The arguments should be after <device> in the help. * @param timeout - The maximum number of milliseconds * @returns The execution result with stdout, stderr, and return code * @throws If the simctl subcommand command returns non-zero return code, or the given subcommand was invalid. */ async function mobileSimctl(command, args = [], timeout) { if (!this.isSimulator()) { throw new driver_1.errors.UnsupportedOperationError(`Only simulator is supported.`); } if (!this.opts.udid) { throw new driver_1.errors.InvalidArgumentError(`Unknown device or simulator UDID: '${this.opts.udid}'`); } if (!SUBCOMMANDS_HAS_DEVICE.includes(command)) { throw new driver_1.errors.InvalidArgumentError(`The given command '${command}' is not supported. ` + `Available subcommands are ${SUBCOMMANDS_HAS_DEVICE.join(',')}`); } const result = await this.device.simctl.exec(command, { args: [this.opts.udid, ...args], timeout }); return { stdout: result?.stdout ?? '', stderr: result?.stderr ?? '', code: result?.code ?? 0 }; } //# sourceMappingURL=simctl.js.map