How to use adb.defaultIME method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

android-common.js

Source:android-common.js Github

copy

Full Screen

...797 if (this.args.unicodeKeyboard) {798 logger.debug('Enabling Unicode keyboard support');799 this.pushUnicodeIME(function (err) {800 if (err) return cb(err);801 this.adb.defaultIME(function (err, engine) {802 if (err) return cb(err);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 + '\'.'928 });929 }930 }.bind(this));931};932androidCommon.deactivateIMEEngine = function (cb) {933 logger.debug('Retrieving current default IME');934 this.adb.defaultIME(function (err, engine) {935 if (err) return cb(err);936 logger.debug('Attempting to deactivate \'' + engine + '\'');937 this.adb.disableIME(engine, function (err) {938 if (err) return cb(err);939 cb(null, {940 status: status.codes.Success.code,941 value: null942 });943 });944 }.bind(this));945};946androidCommon.hideKeyboard = function () {947 // parameters only used for iOS. Please ignore them for android.948 var args = new Args(arguments);...

Full Screen

Full Screen

android-controller.js

Source:android-controller.js Github

copy

Full Screen

...964 });965};966androidController.getActiveIMEEngine = function (cb) {967 logger.debug('Retrieving current default IME');968 this.adb.defaultIME(function (err, engine) {969 if (err) return cb(err);970 cb(null, {971 status: status.codes.Success.code,972 value: engine973 });974 });975};976androidController.activateIMEEngine = function (imeId, cb) {977 logger.debug('Attempting to activate IME \'' + imeId + '\'');978 this.adb.availableIMEs(function (err, engines) {979 if (err) return cb(err);980 if (engines.indexOf(imeId) !== -1) {981 logger.debug('Found installed IME, attempting to activate.');982 this.adb.enableIME(imeId, function (err) {983 if (err) return cb(err);984 this.adb.setIME(imeId, function (err) {985 if (err) return cb(err);986 return cb(null, {987 status: status.codes.Success.code,988 value: null989 });990 });991 }.bind(this));992 } else {993 logger.debug('IME not found, failing.');994 return cb(null, {995 status: status.codes.IMENotAvailable.code,996 message: 'Unable to find requested IME \'' + imeId + '\'.'997 });998 }999 }.bind(this));1000};1001androidController.deactivateIMEEngine = function (cb) {1002 logger.debug('Retrieving current default IME');1003 this.adb.defaultIME(function (err, engine) {1004 if (err) return cb(err);1005 logger.debug('Attempting to deactivate \'' + engine + '\'');1006 this.adb.disableIME(engine, function (err) {1007 if (err) return cb(err);1008 cb(null, {1009 status: status.codes.Success.code,1010 value: null1011 });1012 });1013 }.bind(this));1014};...

Full Screen

Full Screen

ah1.js

Source:ah1.js Github

copy

Full Screen

...361 await adb.uninstallApk(UNICODE_IME_PKG_ID);362 await adb.install(unicodeIMEPath, {replace: false});363 }364 // get the default IME so we can return back to it later if we want365 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 }...

Full Screen

Full Screen

android-helpers.js

Source:android-helpers.js Github

copy

Full Screen

...312 logger.debug('Enabling Unicode keyboard support');313 logger.debug("Pushing unicode ime to device...");314 // await adb.install(unicodeIMEPath, {replace: false});315 // get the default IME so we can return back to it later if we want316 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 }...

Full Screen

Full Screen

keyboard-e2e-specs.js

Source:keyboard-e2e-specs.js Github

copy

Full Screen

...232 let driver;233 before(async function () {234 // save the initial ime so we can make sure it is restored235 if (adb) {236 initialIME = await adb.defaultIME();237 initialIME.should.not.eql('io.appium.settings/.UnicodeIME');238 }239 driver = await initDriver(defaultUnicodeCaps);240 });241 after(async function () {242 await driver.quit();243 // make sure the IME has been restored244 if (adb) {245 let ime = await adb.defaultIME();246 ime.should.eql(initialIME);247 ime.should.not.eql('io.appium.settings/.UnicodeIME');248 }249 });250 beforeEach(async function () {251 await ensureUnlocked(driver);252 });253 describe('editing a text field', function () {254 beforeEach(async function () {255 await driver.startActivity({256 appPackage: defaultUnicodeCaps.appPackage,257 appActivity: defaultUnicodeCaps.appActivity,258 });259 });...

Full Screen

Full Screen

adb-commands-e2e-specs.js

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

copy

Full Screen

...35 it('enabledIMEs should get list of enabled IMEs', async () => {36 (await adb.enabledIMEs()).should.have.length.above(0);37 });38 it('defaultIME should get default IME', async () => {39 defaultIMEs.should.include(await adb.defaultIME());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 });...

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', function () {10 let driver;11 let sandbox = sinon.createSandbox();12 beforeEach(function () {13 driver = new AndroidDriver();14 driver.adb = new ADB();15 });16 afterEach(function () {17 sandbox.restore();18 });19 describe('isIMEActivated', function () {20 it('should allways return true', async function () {21 await driver.isIMEActivated().should.eventually.be.true;22 });23 });24 describe('availableIMEEngines', function () {25 it('should return available IMEEngines', async function () {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', function () {32 it('should return active IME engine', async function () {33 sandbox.stub(driver.adb, 'defaultIME').returns('default_ime_engine');34 await driver.getActiveIMEEngine().should.become('default_ime_engine');35 });36 });37 describe('activateIMEEngine', function () {38 it('should activate IME engine', async function () {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 function () {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', function () {53 it('should deactivate IME engine', async function () {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

...12 return engines;13};14commands.getActiveIMEEngine = async function getActiveIMEEngine () {15 log.debug('Retrieving current default IME');16 return await this.adb.defaultIME();17};18commands.activateIMEEngine = async function activateIMEEngine (imeId) {19 log.debug(`Attempting to activate IME ${imeId}`);20 let availableEngines = await this.adb.availableIMEs();21 if (availableEngines.indexOf(imeId) === -1) {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 deactivateIMEEngine () {30 let currentEngine = await this.getActiveIMEEngine();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 until = webdriver.until;3var driver = new webdriver.Builder()4 .forBrowser('chrome')5 .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnK')).click();8driver.wait(until.titleIs('webdriver - Google Search'), 1000);9driver.quit();10I am using the latest version of appium and node.js (v6.9.1)

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var androidDriver = require('appium-android-driver');3var adb = new androidDriver.ADB();4var driver = new webdriver.Builder()5 .forBrowser('chrome')6 .build();7adb.defaultIME().then(function(ime) {8 console.log(ime);9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var appium = require('appium');3var assert = require("assert");4var desiredCaps = {5};6var driver = wd.remote('localhost', 4723);7driver.init(desiredCaps, function(err) {8 if (err) throw err;9 driver.elementByTagName('button', function(err, el) {10 if (err) throw err;11 el.click(function(err) {12 if (err) throw err;13 driver.defaultIME(function(err, ime) {14 if (err) throw err;15 console.log("Default IME is: " + ime);16 driver.quit();17 });18 });19 });20});21import io.appium.java_client.android.AndroidDriver;22import io.appium.java_client.android.AndroidElement;23import java.net.MalformedURLException;24import java.net.URL;25import org.openqa.selenium.remote.DesiredCapabilities;26public class test {27 public static void main(String[] args) throws MalformedURLException {28 DesiredCapabilities capabilities = new DesiredCapabilities();29 capabilities.setCapability("device", "Android");30 capabilities.setCapability("platform", "Android");31 capabilities.setCapability("version", "4.2");32 capabilities.setCapability("name", "Appium Android Driver Test");33 capabilities.setCapability("appPackage", "com.example.android.apis");34 capabilities.setCapability("appActivity", ".ApiDemos");35 capabilities.setCapability("appium-version", "1.0");

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Appium Android Driver', function() {2 it('should set defaultIME', function(done) {3 var adb = new ADB();4 var defaultIME = adb.defaultIME();5 console.log(defaultIME);6 done();7 });8});9describe('Appium Android Driver', function() {10 it('should get IMEs', function(done) {11 var adb = new ADB();12 var IMEs = adb.IMEs();13 console.log(IMEs);14 done();15 });16});17describe('Appium Android Driver', function() {18 it('should set IME', function(done) {19 var adb = new ADB();20 var IME = adb.setIME();21 console.log(IME);22 done();23 });24});25describe('Appium Android Driver', function() {26 it('should reset IME', function(done) {27 var adb = new ADB();28 var IME = adb.resetIME();29 console.log(IME);30 done();31 });32});33describe('Appium Android Driver', function() {34 it('should check if IME is active', function(done) {35 var adb = new ADB();36 var IME = adb.isIMEActive();37 console.log(IME);38 done();39 });40});41describe('Appium Android Driver', function() {42 it('should get device language', function(done) {43 var adb = new ADB();44 var language = adb.getDeviceLanguage();45 console.log(language);46 done();47 });48});49describe('Appium Android Driver', function() {50 it('should get device country', function(done) {51 var adb = new ADB();52 var country = adb.getDeviceCountry();53 console.log(country);54 done();55 });56});57describe('Appium Android Driver', function() {58 it('should get display density', function(done

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('ADB', function () {2 this.timeout(240000);3 let driver;4 before(async function () {5 driver = await initDriver();6 });7 after(async function () {8 await driver.quit();9 });10 it('should set the default IME to io.selendroid.testapp:ime/UnicodeIME', async function () {11 await driver.defaultIME();12 let currentIME = await driver.getCurrentIME();13 currentIME.should.equal('io.selendroid.testapp:ime/UnicodeIME');14 });15});16async defaultIME () {17 await this.adb.defaultIME();18}19async defaultIME () {20 await this.setIME('io.selendroid.testapp/.UnicodeIME');21}22async setIME (imeId) {23 await this.shell(['ime', 'enable', imeId]);24 await this.shell(['ime', 'set', imeId]);25}26async shell (cmd, opts = {}) {27 if (!_.isArray(cmd)) {28 cmd = [cmd];29 }30 if (this.executable.defaultArgs) {31 cmd.unshift(...this.executable.defaultArgs);32 }33 log.debug(`Executing adb with args: ${cmd.join(' ')}`);34 return await exec(this.executable.path, cmd, opts);35}36async defaultIME () {37 await this.adb.defaultIME();38}

Full Screen

Using AI Code Generation

copy

Full Screen

1var defaultIME = driver.adb.defaultIME();2console.log("Default IME is: " + defaultIME);3var availableImes = driver.adb.IMEs();4console.log("Available IMEs are: " + availableImes);5var availableImes = driver.adb.IMEs();6console.log("Available IMEs are: " + availableImes);7var availableImes = driver.adb.IMEs();8console.log("Available IMEs are: " + availableImes);9var availableImes = driver.adb.IMEs();10console.log("Available IMEs are: " + availableImes);11var availableImes = driver.adb.IMEs();12console.log("Available IM

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