UNPKG

appium-android-driver

Version:

Android UiAutomator and Chrome support for Appium

160 lines 5.05 kB
"use strict"; /* eslint-disable @typescript-eslint/no-unused-vars */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getAttribute = getAttribute; exports.click = click; exports.getText = getText; exports.getLocation = getLocation; exports.getSize = getSize; exports.getName = getName; exports.elementDisplayed = elementDisplayed; exports.elementEnabled = elementEnabled; exports.elementSelected = elementSelected; exports.setElementValue = setElementValue; exports.doSetElementValue = doSetElementValue; exports.setValue = setValue; exports.replaceValue = replaceValue; exports.setValueImmediate = setValueImmediate; exports.getLocationInView = getLocationInView; const driver_1 = require("appium/driver"); /** * @this {import('../driver').AndroidDriver} * @param {string} attribute * @param {string} elementId * @returns {Promise<string?>} */ async function getAttribute(attribute, elementId) { throw new driver_1.errors.NotImplementedError('Not implemented'); } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<void>} */ async function click(elementId) { throw new driver_1.errors.NotImplementedError('Not implemented'); } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<string>} */ async function getText(elementId) { throw new driver_1.errors.NotImplementedError('Not implemented'); } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<import('@appium/types').Position>} */ async function getLocation(elementId) { throw new driver_1.errors.NotImplementedError('Not implemented'); } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<import('@appium/types').Size>} */ async function getSize(elementId) { throw new driver_1.errors.NotImplementedError('Not implemented'); } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<string>} */ async function getName(elementId) { return /** @type {string} */ (await this.getAttribute('className', elementId)); } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<boolean>} */ async function elementDisplayed(elementId) { return (await this.getAttribute('displayed', elementId)) === 'true'; } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<boolean>} */ async function elementEnabled(elementId) { return (await this.getAttribute('enabled', elementId)) === 'true'; } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<boolean>} */ async function elementSelected(elementId) { return (await this.getAttribute('selected', elementId)) === 'true'; } /** * @this {import('../driver').AndroidDriver} * @param {string|string[]} keys * @param {string} elementId * @param {boolean} [replace=false] * @returns {Promise<void>} */ async function setElementValue(keys, elementId, replace = false) { const text = keys instanceof Array ? keys.join('') : keys; return await this.doSetElementValue({ elementId, text: String(text), replace, }); } /** * Reason for isolating doSetElementValue from setElementValue is for reusing setElementValue * across android-drivers (like appium-uiautomator2-driver) and to avoid code duplication. * Other android-drivers (like appium-uiautomator2-driver) need to override doSetElementValue * to facilitate setElementValue. * * @this {import('../driver').AndroidDriver} * @param {import('./types').DoSetElementValueOpts} params * @returns {Promise<void>} */ async function doSetElementValue(params) { throw new driver_1.errors.NotImplementedError('Not implemented'); } /** * @this {import('../driver').AndroidDriver} * @param {string|string[]} keys * @param {string} elementId * @returns {Promise<void>} */ async function setValue(keys, elementId) { return await this.setElementValue(keys, elementId, false); } /** * @this {import('../driver').AndroidDriver} * @param {string|string[]} keys * @param {string} elementId * @returns {Promise<void>} */ async function replaceValue(keys, elementId) { return await this.setElementValue(keys, elementId, true); } /** * @this {import('../driver').AndroidDriver} * @param {string|string[]} keys * @param {string} elementId * @returns {Promise<void>} */ async function setValueImmediate(keys, elementId) { const text = Array.isArray(keys) ? keys.join('') : keys; // first, make sure we are focused on the element await this.click(elementId); // then send through adb await this.adb.inputText(/** @type {string} */ (text)); } /** * @this {import('../driver').AndroidDriver} * @param {string} elementId * @returns {Promise<import('@appium/types').Position>} */ async function getLocationInView(elementId) { return await this.getLocation(elementId); } //# sourceMappingURL=element.js.map