io.appium.settings
Version:
App for dealing with Android settings
45 lines • 1.96 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.performEditorAction = performEditorAction;
exports.typeUnicode = typeUnicode;
const lodash_1 = __importDefault(require("lodash"));
const constants_1 = require("../constants");
const utf7_1 = require("./utf7");
const logger_1 = require("../logger");
/**
* Performs the given editor action on the focused input field.
* This method requires Appium Settings helper to be installed on the device.
* No exception is thrown if there was a failure while performing the action.
* You must investigate the logcat output if something did not work as expected.
*
* @param action - Either action code or name. The following action names are supported:
* `normal, unspecified, none, go, search, send, next, done, previous`
*/
async function performEditorAction(action) {
this.log.debug(logger_1.LOG_PREFIX, `Performing editor action: ${action}`);
await this.adb.runInImeContext(constants_1.APPIUM_IME, async () => await this.adb.shell(['input', 'text', `/${action}/`]));
}
/**
* Types the given Unicode string.
* It is expected that the focus is already put
* to the destination input field before this method is called.
*
* @param text The string to type
* @returns `true` if the input text has been successfully sent to adb
*/
async function typeUnicode(text) {
if (lodash_1.default.isNil(text)) {
return false;
}
const textStr = `${text}`;
this.log.debug(logger_1.LOG_PREFIX, `Typing ${textStr.length} character${textStr.length === 1 ? '' : 's'}`);
if (!textStr) {
return false;
}
await this.adb.runInImeContext(constants_1.UNICODE_IME, async () => await this.adb.inputText(utf7_1.imap.encode(textStr)));
return true;
}
//# sourceMappingURL=typing.js.map