UNPKG

appium-uiautomator2-driver

Version:
78 lines 3.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pressKeyCode = pressKeyCode; exports.longPressKeyCode = longPressKeyCode; exports.mobilePressKey = mobilePressKey; exports.mobileType = mobileType; exports.doSendKeys = doSendKeys; exports.keyevent = keyevent; /** * Presses a key code with optional metastate and flags. * @param keycode - Android key code to press. * @param metastate - Optional meta state modifier keys. * @param flags - Optional flags for the key event. */ async function pressKeyCode(keycode, metastate, flags) { await this.uiautomator2.jwproxy.command('/appium/device/press_keycode', 'POST', { keycode, metastate, flags, }); } /** * Long presses a key code with optional metastate and flags. * @param keycode - Android key code to long press. * @param metastate - Meta state modifier keys. * @param flags - Optional flags for the key event. */ async function longPressKeyCode(keycode, metastate, flags) { await this.uiautomator2.jwproxy.command('/appium/device/long_press_keycode', 'POST', { keycode, metastate, flags, }); } /** * Presses a key code with optional metastate, flags, source, and long press support. * @param keycode - Android key code to press. * @param metastate - Optional meta state modifier keys. * @param flags - Optional flags for the key event. * @param isLongPress - Whether to perform a long press. Defaults to false. * @param source - Optional input device source. One or more InputDevice.SOURCE_* values (default is SOURCE_KEYBOARD). * Multiple source values can be combined using the logical OR operator. * See https://developer.android.com/reference/android/view/InputDevice for details. */ async function mobilePressKey(keycode, metastate, flags, isLongPress = false, source) { await this.uiautomator2.jwproxy.command(`/appium/device/${isLongPress ? 'long_' : ''}press_keycode`, 'POST', { keycode, metastate, flags, source, }); } /** * Types the given Unicode string. The focus should already be on the destination input field. * @param text - Text to type. Can be a string, number, or boolean. * @returns True if the input text has been successfully sent to adb. * @throws {errors.InvalidArgumentError} If the text argument is not provided. */ async function mobileType(text) { return await this.settingsApp.typeUnicode(String(text)); } /** * Sends keys to the current element. * @param params - Options containing the text to send and optional replace flag. */ async function doSendKeys(params) { await this.uiautomator2.jwproxy.command('/keys', 'POST', params); } /** * Sends a key event to the device. * @param keycode - Android key code to send. * @param metastate - Optional meta state (ignored in this implementation). */ async function keyevent(keycode, metastate) { this.log.debug(`Ignoring metastate ${metastate}`); await this.adb.keyevent(keycode); } //# sourceMappingURL=keyboard.js.map