appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
63 lines • 2.25 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.hideKeyboard = hideKeyboard;
exports.mobileHideKeyboard = mobileHideKeyboard;
exports.isKeyboardShown = isKeyboardShown;
exports.mobileKeys = mobileKeys;
const lodash_1 = __importDefault(require("lodash"));
/**
* Hides the keyboard.
*
* @deprecated
*/
async function hideKeyboard(strategy, ...possibleKeys) {
// last parameter is the session id
const keyNames = lodash_1.default.compact(possibleKeys.slice(0, -1)).map((x) => `${x}`);
await this.mobileHideKeyboard(keyNames);
return true;
}
/**
* Hides the keyboard using the specified key names.
*
* @param keys - Array of key names to use for dismissing the keyboard
*/
async function mobileHideKeyboard(keys = []) {
await this.proxyCommand('/wda/keyboard/dismiss', 'POST', {
keyNames: keys.includes('done') ? keys : [...keys, 'done'],
});
}
/**
* Checks whether the keyboard is currently shown.
*
* @returns `true` if the keyboard is shown, `false` otherwise
*/
async function isKeyboardShown() {
try {
await this.findNativeElementOrElements('class name', 'XCUIElementTypeKeyboard', false);
return true;
}
catch {
return false;
}
}
/**
* Send keys to the given element or to the application under test.
* This API is not supported on tvOS
*
* @since Xcode 15/iOS 17
* @param keys - Array of keys to type.
* Each item could either be a string, that represents a key itself (see
* https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey?language=objc
* and https://developer.apple.com/documentation/xctest/xcuikeyboardkey?language=objc)
* or a dictionary, if the key should also be entered with modifiers.
* @param elementId - UUID of the element to send keys to.
* If the element is not provided then the keys will be sent to the current application.
*/
async function mobileKeys(keys, elementId = null) {
const url = `/wda/element/${elementId || 0}/keyboardInput`;
await this.proxyCommand(url, 'POST', { keys });
}
//# sourceMappingURL=keyboard.js.map