How to use adb.enableIME method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

adb-commands-specs.js

Source:adb-commands-specs.js Github

copy

Full Screen

...248 it('should call shell with correct args', async () => {249 mocks.adb.expects("shell")250 .once().withExactArgs(['ime', 'enable', IME])251 .returns("");252 await adb.enableIME(IME);253 mocks.adb.verify();254 });255 }));256 describe('keyevent', withMocks({adb}, (mocks) => {257 it('should call shell with correct args', async () => {258 let keycode = '29';259 let code = parseInt(keycode, 10);260 mocks.adb.expects("shell")261 .once().withExactArgs(['input', 'keyevent', code])262 .returns("");263 await adb.keyevent(keycode);264 mocks.adb.verify();265 });266 }));...

Full Screen

Full Screen

android-common.js

Source:android-common.js Github

copy

Full Screen

...803 // save the previously set IME804 this.defaultIME = engine;805 logger.debug('Unsetting IME \'' + this.defaultIME + '\'');806 logger.debug('Setting IME to \'io.appium.android.ime/.UnicodeIME\'');807 this.adb.enableIME('io.appium.android.ime/.UnicodeIME', function (err) {808 if (err) return cb(err);809 this.adb.setIME('io.appium.android.ime/.UnicodeIME', cb);810 }.bind(this));811 }.bind(this));812 }.bind(this));813 } else {814 cb();815 }816};817androidCommon.getNetworkConnection = function (cb) {818 logger.info('Getting network connection');819 this.adb.isAirplaneModeOn(function (err, airplaneModeOn) {820 if (err) return cb(err);821 var connection = airplaneModeOn ? 1 : 0;822 if (airplaneModeOn) {823 // airplane mode on implies wifi and data off824 return cb(null, {825 status: status.codes.Success.code,826 value: connection827 });828 }829 this.adb.isWifiOn(function (err, wifiOn) {830 if (err) return cb(err);831 connection += (wifiOn ? 2 : 0);832 this.adb.isDataOn(function (err, dataOn) {833 if (err) return cb(err);834 connection += (dataOn ? 4 : 0);835 cb(null, {836 status: status.codes.Success.code,837 value: connection838 });839 }.bind(this));840 }.bind(this));841 }.bind(this));842};843androidCommon.setNetworkConnection = function (type, ocb) {844 logger.info('Setting network connection');845 // decode the input846 var airplaneMode = type % 2;847 type >>= 1;848 var wifi = type % 2;849 type >>= 1;850 var data = type % 2;851 var series = [];852 // do airplane mode stuff first, since it will change the other statuses853 series.push(function (cb) {854 this.wrapActionAndHandleADBDisconnect(function (ncb) {855 this.adb.setAirplaneMode(airplaneMode, ncb);856 }.bind(this), cb);857 }.bind(this));858 series.push(function (cb) {859 this.wrapActionAndHandleADBDisconnect(function (ncb) {860 this.adb.broadcastAirplaneMode(airplaneMode, ncb);861 }.bind(this), cb);862 }.bind(this));863 // no need to do anything else if we are in or going into airplane mode864 if (airplaneMode === 0) {865 series.push(function (cb) {866 this.wrapActionAndHandleADBDisconnect(function (ncb) {867 this.adb.setWifiAndData({868 wifi: wifi,869 data: data870 }, ncb);871 }.bind(this), cb);872 }.bind(this));873 }874 async.series(series, function (err) {875 if (err) return ocb(err);876 return this.getNetworkConnection(ocb);877 }.bind(this));878};879androidCommon.isIMEActivated = function (cb) {880 // IME is always activated on Android devices881 cb(null, {882 status: status.codes.Success.code,883 value: true884 });885};886androidCommon.availableIMEEngines = function (cb) {887 logger.debug('Retrieving available IMEs');888 this.adb.availableIMEs(function (err, engines) {889 if (err) return cb(err);890 logger.debug('Engines: ' + JSON.stringify(engines));891 cb(null, {892 status: status.codes.Success.code,893 value: engines894 });895 });896};897androidCommon.getActiveIMEEngine = function (cb) {898 logger.debug('Retrieving current default IME');899 this.adb.defaultIME(function (err, engine) {900 if (err) return cb(err);901 cb(null, {902 status: status.codes.Success.code,903 value: engine904 });905 });906};907androidCommon.activateIMEEngine = function (imeId, cb) {908 logger.debug('Attempting to activate IME \'' + imeId + '\'');909 this.adb.availableIMEs(function (err, engines) {910 if (err) return cb(err);911 if (engines.indexOf(imeId) !== -1) {912 logger.debug('Found installed IME, attempting to activate.');913 this.adb.enableIME(imeId, function (err) {914 if (err) return cb(err);915 this.adb.setIME(imeId, function (err) {916 if (err) return cb(err);917 return cb(null, {918 status: status.codes.Success.code,919 value: null920 });921 });922 }.bind(this));923 } else {924 logger.debug('IME not found, failing.');925 return cb(null, {926 status: status.codes.IMENotAvailable.code,927 message: 'Unable to find requested IME \'' + imeId + '\'.'...

Full Screen

Full Screen

ah1.js

Source:ah1.js Github

copy

Full Screen

...365 let defaultIME = await adb.defaultIME();366 logger.debug(`Unsetting previous IME ${defaultIME}`);367 const appiumIME = `${UNICODE_IME_PKG_ID}/.UnicodeIME`;368 logger.debug(`Setting IME to '${appiumIME}'`);369 await adb.enableIME(appiumIME);370 await adb.setIME(appiumIME);371 return defaultIME;372};373helpers.setMockLocationApp = async function (adb, app) {374 try {375 if (await adb.getApiLevel() < 23) {376 await adb.shell(['settings', 'put', 'secure', 'mock_location', '1']);377 } else {378 await adb.shell(['appops', 'set', app, 'android:mock_location', 'allow']);379 }380 } catch (err) {381 logger.warn(`Unable to set mock location for app '${app}': ${err.message}`);382 }383};...

Full Screen

Full Screen

android-helpers.js

Source:android-helpers.js Github

copy

Full Screen

...316 let defaultIME = await adb.defaultIME();317 logger.debug(`Unsetting previous IME ${defaultIME}`);318 const appiumIME = 'io.appium.android.ime/.UnicodeIME';319 logger.debug(`Setting IME to '${appiumIME}'`);320 await adb.enableIME(appiumIME);321 await adb.setIME(appiumIME);322 return defaultIME;323};324helpers.setMockLocationApp = async function (adb, app) {325 try {326 if (await adb.getApiLevel() < 23) {327 await adb.shell(['settings', 'put', 'secure', 'mock_location', '1']);328 } else {329 await adb.shell(['appops', 'set', app, 'android:mock_location', 'allow']);330 }331 } catch (err) {332 logger.warn(`Unable to set mock location for app '${app}': ${err.message}`);333 }334};...

Full Screen

Full Screen

adb-commands-e2e-specs.js

Source:adb-commands-e2e-specs.js Github

copy

Full Screen

...40 });41 it('enableIME and disableIME should enable and disble IME', async () => {42 await adb.disableIME(IME);43 (await adb.enabledIMEs()).should.not.include(IME);44 await adb.enableIME(IME);45 (await adb.enabledIMEs()).should.include(IME);46 await adb.enabledIMEs();47 });48 it('processExists should be able to find ui process', async () => {49 (await adb.processExists('com.android.systemui')).should.be.true;50 });51 it('ping should return true', async () => {52 (await adb.ping()).should.be.true;53 });54 it('getPIDsByName should return pids', async () => {55 (await adb.getPIDsByName('m.android.phone')).should.have.length.above(0);56 });57 it('killProcessesByName should kill process', async () => {58 await adb.install(contactManagerPath);...

Full Screen

Full Screen

ime-specs.js

Source:ime-specs.js Github

copy

Full Screen

1import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';3import sinon from 'sinon';4import AndroidDriver from '../../..';5import ADB from 'appium-adb';6import { errors } from 'appium-base-driver';7chai.should();8chai.use(chaiAsPromised);9describe('IME', () => {10 let driver;11 let sandbox = sinon.sandbox.create();12 beforeEach(() => {13 driver = new AndroidDriver();14 driver.adb = new ADB();15 });16 afterEach(() => {17 sandbox.restore();18 });19 describe('isIMEActivated', () => {20 it('should allways return true', async () => {21 await driver.isIMEActivated().should.eventually.be.true;22 });23 });24 describe('availableIMEEngines', () => {25 it('should return available IMEEngines', async () => {26 sandbox.stub(driver.adb, 'availableIMEs').returns(['IME1', 'IME2']);27 await driver.availableIMEEngines()28 .should.eventually.be.deep.equal(['IME1', 'IME2']);29 });30 });31 describe('getActiveIMEEngine', () => {32 it('should return active IME engine', async () => {33 sandbox.stub(driver.adb, 'defaultIME').returns('default_ime_engine');34 await driver.getActiveIMEEngine().should.become('default_ime_engine');35 });36 });37 describe('activateIMEEngine', () => {38 it('should activate IME engine', async () => {39 sandbox.stub(driver.adb, 'availableIMEs').returns(['IME1', 'IME2']);40 sandbox.stub(driver.adb, 'enableIME');41 sandbox.stub(driver.adb, 'setIME');42 await driver.activateIMEEngine('IME2').should.be.fulfilled;43 driver.adb.enableIME.calledWithExactly('IME2').should.be.true;44 driver.adb.setIME.calledWithExactly('IME2').should.be.true;45 });46 it('should throws error if IME not found', async () => {47 sandbox.stub(driver.adb, 'availableIMEs').returns(['IME1', 'IME2']);48 await driver.activateIMEEngine ('IME3')49 .should.be.rejectedWith(errors.IMENotAvailableError);50 });51 });52 describe('deactivateIMEEngine', () => {53 it('should deactivate IME engine', async () => {54 sandbox.stub(driver, 'getActiveIMEEngine').returns('active_ime_engine');55 sandbox.stub(driver.adb, 'disableIME');56 await driver.deactivateIMEEngine().should.be.fulfilled;57 driver.adb.disableIME.calledWithExactly('active_ime_engine');58 });59 });...

Full Screen

Full Screen

ime.js

Source:ime.js Github

copy

Full Screen

...22 log.debug("IME not found, failing");23 throw new errors.IMENotAvailableError();24 }25 log.debug("Found installed IME, attempting to activate");26 await this.adb.enableIME(imeId);27 await this.adb.setIME(imeId);28};29commands.deactivateIMEEngine = async function () {30 let currentEngine = await this.getActiveIMEEngine();31 log.debug(`Attempting to deactivate ${currentEngine}`);32 await this.adb.disableIME(currentEngine);33};34Object.assign(extensions, commands, helpers);35export { commands, helpers };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6 return driver.getTitle().then(function(title) {7 return title === 'webdriver - Google Search';8 });9}, 1000);10driver.quit();11var webdriver = require('selenium-webdriver');12var driver = new webdriver.Builder().forBrowser('chrome').build();13driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');14driver.findElement(webdriver.By.name('btnG')).click();15driver.wait(function() {16 return driver.getTitle().then(function(title) {17 return title === 'webdriver - Google Search';18 });19}, 1000);20driver.quit();21var webdriver = require('selenium-webdriver');22var driver = new webdriver.Builder().forBrowser('chrome').build();23driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');24driver.findElement(webdriver.By.name('btnG')).click();25driver.wait(function() {26 return driver.getTitle().then(function(title) {27 return title === 'webdriver - Google Search';28 });29}, 1000);30driver.quit();31var webdriver = require('selenium-webdriver');32var driver = new webdriver.Builder().forBrowser('chrome').build();33driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');34driver.findElement(webdriver.By.name('btnG')).click();35driver.wait(function() {

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var By = webdriver.By;3var until = webdriver.until;4var driver = new webdriver.Builder()5 .forBrowser('chrome')6 .build();7driver.findElement(By.name('q')).sendKeys('webdriver');8driver.findElement(By.name('btnK')).click();9driver.wait(until.titleIs('webdriver - Google Search'), 1000);10driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var adb = require('appium-adb');2var driver = new adb.ADB();3driver.enableIME();4var adb = require('appium-adb');5var driver = new adb.ADB();6driver.disableIME();7var adb = require('appium-adb');8var driver = new adb.ADB();9driver.isIMEEnabled();10var adb = require('appium-adb');11var driver = new adb.ADB();12driver.getIMEs();13var adb = require('appium-adb');14var driver = new adb.ADB();15driver.setIME();16var adb = require('appium-adb');17var driver = new adb.ADB();18driver.getConnectedEmulators();19var adb = require('appium-adb');20var driver = new adb.ADB();21driver.getRunningAVD();22var adb = require('appium-adb');23var driver = new adb.ADB();24driver.getRunningAVDWithRetry();25var adb = require('appium-adb');26var driver = new adb.ADB();27driver.isDeviceConnected();28var adb = require('appium-adb');29var driver = new adb.ADB();30driver.isEmulatorConnected();31var adb = require('appium-adb');32var driver = new adb.ADB();33driver.getConnectedDevices();34var adb = require('appium-adb');35var driver = new adb.ADB();36driver.getRunningAVDWithRetry();37var adb = require('appium-adb');38var driver = new adb.ADB();39driver.getConnectedDevicesWithRetry();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var AndroidDriver = require('appium-android-driver');3var AppiumDriver = require('appium-base-driver').Driver;4var ADB = require('appium-adb').ADB;5var adb = new ADB();6var driver = new AppiumDriver();7var androidDriver = new AndroidDriver();8var desiredCapabilities = {9};10var driver = new webdriver.Builder()11 .forBrowser('chrome')12 .withCapabilities(desiredCapabilities)13 .build();14androidDriver.createSession(desiredCapabilities).then(function () {15 adb.enableIME();16});17var webdriver = require('selenium-webdriver');18var AndroidDriver = require('appium-android-driver');19var AppiumDriver = require('appium-base-driver').Driver;20var ADB = require('appium-adb').ADB;21var adb = new ADB();22var driver = new AppiumDriver();23var androidDriver = new AndroidDriver();24var desiredCapabilities = {25};26var driver = new webdriver.Builder()27 .forBrowser('chrome')28 .withCapabilities(desiredCapabilities)29 .build();30androidDriver.createSession(desiredCapabilities).then(function () {31 adb.disableIME();32});33var webdriver = require('selenium-webdriver');34var AndroidDriver = require('appium-android-driver');35var AppiumDriver = require('appium-base-driver').Driver;36var ADB = require('appium-adb').ADB;37var adb = new ADB();38var driver = new AppiumDriver();39var androidDriver = new AndroidDriver();40var desiredCapabilities = {41};42var driver = new webdriver.Builder()43 .forBrowser('chrome')44 .withCapabilities(desiredCapabilities)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var path = require('path');4var test = require('selenium-webdriver/testing');5var chai = require('chai');6var chaiAsPromised = require('chai-as-promised');7chai.use(chaiAsPromised);8chai.should();9var caps = {10 app: path.resolve(__dirname, 'ApiDemos-debug.apk')11};12var driver = wd.promiseChainRemote('localhost', 4723);13test.describe('Android', function() {14 this.timeout(300000);15 test.before(function() {16 var desired = caps;17 return driver.init(desired);18 });19 test.after(function() {20 return driver.quit();21 });22 test.it('should enable IME', function() {23 .enableIME()24 .should.eventually.be.true;25 });26});27var wd = require('wd');28var assert = require('assert');29var path = require('path');30var test = require('selenium-webdriver/testing');31var chai = require('chai');32var chaiAsPromised = require('chai-as-promised');33chai.use(chaiAsPromised);34chai.should();35var caps = {36 app: path.resolve(__dirname, 'ApiDemos-debug.apk')37};38var driver = wd.promiseChainRemote('localhost', 4723);39test.describe('Android', function() {40 this.timeout(300000);41 test.before(function() {42 var desired = caps;43 return driver.init(desired);44 });45 test.after(function() {46 return driver.quit();47 });48 test.it('should disable IME', function() {49 .disableIME()50 .should.eventually.be.true;51 });52});53var wd = require('wd');54var assert = require('assert');55var path = require('path');56var test = require('selenium-webdriver/testing');57var chai = require('chai');58var chaiAsPromised = require('chai-as-promised');59chai.use(chaiAsPromised);60chai.should();61var caps = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var androidDriver = require('appium-android-driver');3var driver = new androidDriver.AndroidDriver();4var adb = new androidDriver.ADB();5var assert = require('assert');6var appiumServerJar = 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\build\\lib\\main.js';7var appPath = 'C:\\Users\\user\\Desktop\\Appium\\ApiDemos-debug.apk';8var desiredCaps = {9};10 build();11driver.createSession(desiredCaps);12var ime = 'com.android.inputmethod.latin/.LatinIME';13adb.enableIME(ime);14appiumServer.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var driver = wd.promiseChainRemote('localhost', 4723);3var desiredCapabilities = {4};5 .init(desiredCapabilities)6 .then(function() {7 return driver.setImplicitWaitTimeout(10000);8 })9 .then(function() {10 return driver.elementById('com.android.settings:id/action_bar');11 })12 .then(function() {13 return driver.elementById('com.android.settings:id/search');14 })15 .then(function() {16 return driver.click();17 })18 .then(function() {19 return driver.elementById('android:id/search_src_text');20 })21 .then(function() {22 return driver.setValue("test");23 })24 .then(function() {25 return driver.elementById('com.android.settings:id/search');26 })27 .then(function() {28 return driver.click();29 })30 .then(function() {31 return driver.elementById('android:id/search_src_text');32 })33 .then(function() {34 return driver.setValue("test");35 })36 .then(function() {37 return driver.elementById('com.android.settings:id/search');38 })39 .then(function() {40 return driver.click();41 })42 .then(function() {43 return driver.elementById('android:id/search_src_text');44 })45 .then(function() {46 return driver.setValue("test");47 })48 .then(function() {49 return driver.elementById('com.android.settings:id/search');50 })51 .then(function() {52 return driver.click();53 })54 .then(function() {55 return driver.elementById('android:id/search_src_text');56 })57 .then(function() {58 return driver.setValue("test");59 })60 .then(function() {61 return driver.elementById('com.android.settings:id/search');62 })63 .then(function() {64 return driver.click();65 })66 .then(function() {67 return driver.elementById('android:id/search_src_text');68 })69 .then(function() {70 return driver.setValue("test");71 })

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Android Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful