appium-android-driver
Version:
Android UiAutomator and Chrome support for Appium
38 lines • 1.34 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mobileNfc = mobileNfc;
const driver_1 = require("appium/driver");
const lodash_1 = __importDefault(require("lodash"));
const SUPPORTED_ACTIONS = /** @type {const} */ ({
ENABLE: 'enable',
DISABLE: 'disable',
});
/**
* Performs the requested action on the default NFC adapter
*
* @this {AndroidDriver}
* @param { 'enable' | 'disable'} action
* @returns {Promise<void>}
* @throws {Error} if the device under test has no default NFC adapter
* or there was a failure while performing the action.
*/
async function mobileNfc(action) {
switch (action) {
case SUPPORTED_ACTIONS.ENABLE:
await this.adb.setNfcOn(true);
break;
case SUPPORTED_ACTIONS.DISABLE:
await this.adb.setNfcOn(false);
break;
default:
throw new driver_1.errors.InvalidArgumentError(`You must provide a valid 'action' argument. Supported actions are: ${lodash_1.default.values(SUPPORTED_ACTIONS)}`);
}
}
/**
* @typedef {import('appium-adb').ADB} ADB
* @typedef {import('../driver').AndroidDriver} AndroidDriver
*/
//# sourceMappingURL=nfc.js.map
;