How to use adb.setIME method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

android-common.js

Source:android-common.js Github

copy

Full Screen

...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 }...

Full Screen

Full Screen

driver-specs.js

Source:driver-specs.js Github

copy

Full Screen

1import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';3import log from '../../lib/logger';4import sinon from 'sinon';5import helpers from '../../lib/android-helpers';6import { withMocks } from 'appium-test-support';7import AndroidDriver from '../..';8import ADB from 'appium-adb';9import { errors } from 'appium-base-driver';10import { fs } from 'appium-support';11import { SharedPrefsBuilder } from 'shared-preferences-builder';12let driver;13let sandbox = sinon.sandbox.create();14let expect = chai.expect;15chai.should();16chai.use(chaiAsPromised);17describe('driver', () => {18 describe('constructor', () => {19 it('should call BaseDriver constructor with opts', () => {20 let driver = new AndroidDriver({foo: 'bar'});21 driver.should.exist;22 driver.opts.foo.should.equal('bar');23 });24 it('should have this.findElOrEls', () => {25 let driver = new AndroidDriver({foo: 'bar'});26 driver.findElOrEls.should.exist;27 driver.findElOrEls.should.be.a('function');28 });29 });30 describe('emulator methods', () => {31 describe('fingerprint', () => {32 it('should be rejected if isEmulator is false', () => {33 let driver = new AndroidDriver();34 sandbox.stub(driver, 'isEmulator').returns(false);35 driver.fingerprint(1111).should.eventually.be.rejectedWith("fingerprint method is only available for emulators");36 driver.isEmulator.calledOnce.should.be.true;37 });38 });39 describe('sendSMS', () => {40 it('sendSMS should be rejected if isEmulator is false', () => {41 let driver = new AndroidDriver();42 sandbox.stub(driver, 'isEmulator').returns(false);43 driver.sendSMS(4509, "Hello Appium").should.eventually.be.rejectedWith("sendSMS method is only available for emulators");44 driver.isEmulator.calledOnce.should.be.true;45 });46 });47 });48 describe('sharedPreferences', () => {49 driver = new AndroidDriver();50 let adb = new ADB();51 driver.adb = adb;52 let builder = new SharedPrefsBuilder();53 describe('should skip setting sharedPreferences', withMocks({driver}, (mocks) => {54 it('on undefined name', async () => {55 driver.opts.sharedPreferences = {};56 (await driver.setSharedPreferences()).should.be.false;57 mocks.driver.verify();58 });59 }));60 describe('should set sharedPreferences', withMocks({driver, adb, builder, fs}, (mocks) => {61 it('on defined sharedPreferences object', async () => {62 driver.opts.appPackage = 'io.appium.test';63 driver.opts.sharedPreferences = {64 name: 'com.appium.prefs',65 prefs: [{type: 'string', name: 'mystr', value:'appium rocks!'}]66 };67 mocks.driver.expects('getPrefsBuilder').once().returns(builder);68 mocks.builder.expects('build').once();69 mocks.builder.expects('toFile').once();70 mocks.adb.expects('shell').once()71 .withExactArgs(['mkdir', '-p', '/data/data/io.appium.test/shared_prefs']);72 mocks.adb.expects('push').once()73 .withExactArgs('/tmp/com.appium.prefs.xml', '/data/data/io.appium.test/shared_prefs/com.appium.prefs.xml');74 mocks.fs.expects('exists').once()75 .withExactArgs('/tmp/com.appium.prefs.xml')76 .returns(true);77 mocks.fs.expects('unlink').once()78 .withExactArgs('/tmp/com.appium.prefs.xml');79 await driver.setSharedPreferences();80 mocks.driver.verify();81 mocks.adb.verify();82 mocks.builder.verify();83 mocks.fs.verify();84 });85 }));86 });87 describe('createSession', () => {88 beforeEach(() => {89 driver = new AndroidDriver();90 sandbox.stub(driver, 'checkAppPresent');91 sandbox.stub(driver, 'checkPackagePresent');92 sandbox.stub(driver, 'startAndroidSession');93 sandbox.stub(ADB, 'createADB', async (opts) => {94 return {95 getDevicesWithRetry: async () => {96 return [97 {udid: 'emulator-1234'},98 {udid: 'rotalume-1337'}99 ];100 },101 getPortFromEmulatorString: () => {102 return 1234;103 },104 setDeviceId: () => {},105 setEmulatorPort: () => {},106 adbPort: opts.adbPort,107 networkSpeed: () => {}108 };109 });110 });111 afterEach(() => {112 sandbox.restore();113 });114 it('should verify device is an emulator', async () => {115 driver.opts.avd = "Nexus_5X_Api_23";116 driver.isEmulator().should.equal(true);117 driver.opts.avd = undefined;118 driver.opts.udid = "emulator-5554";119 driver.isEmulator().should.equal(true);120 driver.opts.udid = "01234567889";121 driver.isEmulator().should.equal(false);122 });123 it('should get java version if none is provided', async () => {124 await driver.createSession({platformName: 'Android', deviceName: 'device', app: '/path/to/some.apk'});125 driver.opts.javaVersion.should.exist;126 });127 it('should get browser package details if browserName is provided', async () => {128 sandbox.spy(helpers, 'getChromePkg');129 await driver.createSession({platformName: 'Android', deviceName: 'device', browserName: 'Chrome'});130 helpers.getChromePkg.calledOnce.should.be.true;131 });132 it('should check an app is present', async () => {133 await driver.createSession({platformName: 'Android', deviceName: 'device', app: '/path/to/some.apk'});134 driver.checkAppPresent.calledOnce.should.be.true;135 });136 it('should check a package is present', async () => {137 await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: 'some.app.package'});138 driver.checkPackagePresent.calledOnce.should.be.true;139 });140 it('should accept a package via the app capability', async () => {141 await driver.createSession({platformName: 'Android', deviceName: 'device', app: 'some.app.package'});142 driver.checkPackagePresent.calledOnce.should.be.true;143 });144 it('should add server details to caps', async () => {145 await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: 'some.app.package'});146 driver.caps.webStorageEnabled.should.exist;147 });148 it('should delete a session on failure', async () => {149 // Force an error to make sure deleteSession gets called150 sandbox.stub(helpers, 'getJavaVersion').throws();151 sandbox.stub(driver, 'deleteSession');152 try {153 await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: 'some.app.package'});154 } catch (ign) {}155 driver.deleteSession.calledOnce.should.be.true;156 });157 it('should pass along adbPort capability to ADB', async () => {158 await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: 'some.app.package', adbPort: 1111});159 driver.adb.adbPort.should.equal(1111);160 });161 it('should proxy screenshot if nativeWebScreenshot is off', async () => {162 await driver.createSession({platformName: 'Android', deviceName: 'device', browserName: 'chrome', nativeWebScreenshot: false});163 driver.getProxyAvoidList().should.have.length(8);164 });165 it('should not proxy screenshot if nativeWebScreenshot is on', async () => {166 await driver.createSession({platformName: 'Android', deviceName: 'device', browserName: 'chrome', nativeWebScreenshot: true});167 driver.getProxyAvoidList().should.have.length(9);168 });169 it('should set networkSpeed before launching app', async () => {170 sandbox.stub(driver, 'isEmulator').returns(true);171 sandbox.stub(helpers, 'ensureNetworkSpeed').returns('full');172 await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: 'some.app.package', networkSpeed: 'edge'});173 driver.isEmulator.calledOnce.should.be.true;174 helpers.ensureNetworkSpeed.calledOnce.should.be.true;175 });176 });177 describe('deleteSession', () => {178 beforeEach(async () => {179 driver = new AndroidDriver();180 driver.adb = new ADB();181 driver.bootstrap = new helpers.bootstrap(driver.adb);182 sandbox.stub(driver, 'stopChromedriverProxies');183 sandbox.stub(driver.adb, 'setIME');184 sandbox.stub(driver.adb, 'forceStop');185 sandbox.stub(driver.adb, 'goToHome');186 sandbox.stub(driver.adb, 'uninstallApk');187 sandbox.stub(driver.adb, 'stopLogcat');188 sandbox.stub(driver.bootstrap, 'shutdown');189 sandbox.spy(log, 'debug');190 });191 afterEach(() => {192 sandbox.restore();193 });194 it('should not do anything if Android Driver has already shut down', async () => {195 driver.bootstrap = null;196 await driver.deleteSession();197 log.debug.callCount.should.eql(3);198 driver.stopChromedriverProxies.called.should.be.false;199 driver.adb.stopLogcat.called.should.be.true;200 });201 it('should reset keyboard to default IME', async () => {202 driver.opts.unicodeKeyboard = true;203 driver.opts.resetKeyboard = true;204 driver.defaultIME = 'someDefaultIME';205 await driver.deleteSession();206 driver.adb.setIME.calledOnce.should.be.true;207 });208 it('should force stop non-Chrome sessions', async () => {209 await driver.deleteSession();210 driver.adb.forceStop.calledOnce.should.be.true;211 });212 it('should uninstall APK if required', async () => {213 driver.opts.fullReset = true;214 await driver.deleteSession();215 driver.adb.uninstallApk.calledOnce.should.be.true;216 });217 });218 describe('dismissChromeWelcome', () => {219 before(async () => {220 driver = new AndroidDriver();221 });222 it('should verify chromeOptions args', () => {223 driver.opts = {};224 driver.shouldDismissChromeWelcome().should.be.false;225 driver.opts = {chromeOptions: {}};226 driver.shouldDismissChromeWelcome().should.be.false;227 driver.opts = {chromeOptions: {args: []}};228 driver.shouldDismissChromeWelcome().should.be.false;229 driver.opts = {chromeOptions: {args: "--no-first-run"}};230 driver.shouldDismissChromeWelcome().should.be.false;231 driver.opts = {chromeOptions: {args: ["--disable-dinosaur-easter-egg"]}};232 driver.shouldDismissChromeWelcome().should.be.false;233 driver.opts = {chromeOptions: {args: ["--no-first-run"]}};234 driver.shouldDismissChromeWelcome().should.be.true;235 });236 });237 describe('initAUT', withMocks({helpers}, (mocks) => {238 beforeEach(async () => {239 driver = new AndroidDriver();240 driver.caps = {};241 });242 it('should throw error if run with full reset', async () => {243 driver.opts = {appPackage: "app.package", appActivity: "act", fullReset: true};244 await driver.initAUT().should.be.rejectedWith(/Full reset requires an app capability/);245 });246 it('should reset if run with fast reset', async () => {247 driver.opts = {appPackage: "app.package", appActivity: "act", fullReset: false, fastReset: true};248 driver.adb = "mock_adb";249 mocks.helpers.expects("resetApp").withExactArgs("mock_adb", undefined, "app.package", true);250 await driver.initAUT();251 mocks.helpers.verify();252 });253 it('should keep data if run without reset', async () => {254 driver.opts = {appPackage: "app.package", appActivity: "act", fullReset: false, fastReset: false};255 mocks.helpers.expects("resetApp").never();256 await driver.initAUT();257 mocks.helpers.verify();258 });259 }));260 describe('startAndroidSession', () => {261 beforeEach(async () => {262 driver = new AndroidDriver();263 driver.adb = new ADB();264 driver.bootstrap = new helpers.bootstrap(driver.adb);265 driver.settings = { update () {} };266 driver.caps = {};267 // create a fake bootstrap because we can't mock268 // driver.bootstrap.<whatever> in advance269 let fakeBootstrap = {start () {},270 onUnexpectedShutdown: {catch () {}}271 };272 sandbox.stub(helpers, 'initDevice');273 sandbox.stub(helpers, 'unlock');274 sandbox.stub(helpers, 'bootstrap').returns(fakeBootstrap);275 sandbox.stub(driver, 'initAUT');276 sandbox.stub(driver, 'startAUT');277 sandbox.stub(driver, 'defaultWebviewName');278 sandbox.stub(driver, 'setContext');279 sandbox.stub(driver, 'startChromeSession');280 sandbox.stub(driver, 'dismissChromeWelcome');281 sandbox.stub(driver.settings, 'update');282 sandbox.stub(driver.adb, 'getPlatformVersion');283 sandbox.stub(driver.adb, 'getScreenSize');284 sandbox.stub(driver.adb, 'getModel');285 sandbox.stub(driver.adb, 'getManufacturer');286 });287 afterEach(() => {288 sandbox.restore();289 });290 it('should set actual platform version', async () => {291 await driver.startAndroidSession();292 driver.adb.getPlatformVersion.calledOnce.should.be.true;293 });294 it('should auto launch app if it is on the device', async () => {295 driver.opts.autoLaunch = true;296 await driver.startAndroidSession();297 driver.initAUT.calledOnce.should.be.true;298 });299 it('should handle chrome sessions', async () => {300 driver.opts.browserName = 'Chrome';301 await driver.startAndroidSession();302 driver.startChromeSession.calledOnce.should.be.true;303 });304 it('should unlock the device', async () => {305 await driver.startAndroidSession();306 helpers.unlock.calledOnce.should.be.true;307 });308 it('should start AUT if auto lauching', async () => {309 driver.opts.autoLaunch = true;310 await driver.startAndroidSession();311 driver.initAUT.calledOnce.should.be.true;312 });313 it('should not start AUT if not auto lauching', async () => {314 driver.opts.autoLaunch = false;315 await driver.startAndroidSession();316 driver.initAUT.calledOnce.should.be.false;317 });318 it('should set the context if autoWebview is requested', async () => {319 driver.opts.autoWebview = true;320 await driver.startAndroidSession();321 driver.defaultWebviewName.calledOnce.should.be.true;322 driver.setContext.calledOnce.should.be.true;323 });324 it('should set the context if autoWebview is requested using timeout', async () => {325 driver.setContext.onCall(0).throws(errors.NoSuchContextError);326 driver.setContext.onCall(1).returns();327 driver.opts.autoWebview = true;328 driver.opts.autoWebviewTimeout = 5000;329 await driver.startAndroidSession();330 driver.defaultWebviewName.calledOnce.should.be.true;331 driver.setContext.calledTwice.should.be.true;332 });333 it('should respect timeout if autoWebview is requested', async function () {334 this.timeout(10000);335 driver.setContext.throws(new errors.NoSuchContextError());336 let begin = Date.now();337 driver.opts.autoWebview = true;338 driver.opts.autoWebviewTimeout = 5000;339 await driver.startAndroidSession().should.eventually.be.rejected;340 driver.defaultWebviewName.calledOnce.should.be.true;341 // we have a timeout of 5000ms, retrying on 500ms, so expect 10 times342 driver.setContext.callCount.should.equal(10);343 let end = Date.now();344 (end - begin).should.be.above(5000);345 });346 it('should not set the context if autoWebview is not requested', async () => {347 await driver.startAndroidSession();348 driver.defaultWebviewName.calledOnce.should.be.false;349 driver.setContext.calledOnce.should.be.false;350 });351 it('should set ignoreUnimportantViews cap', async () => {352 driver.opts.ignoreUnimportantViews = true;353 await driver.startAndroidSession();354 driver.settings.update.calledOnce.should.be.true;355 driver.settings.update.firstCall.args[0].ignoreUnimportantViews.should.be.true;356 });357 it('should not call dismissChromeWelcome on missing chromeOptions', async () => {358 driver.opts.browserName = 'Chrome';359 await driver.startAndroidSession();360 driver.dismissChromeWelcome.calledOnce.should.be.false;361 });362 it('should call dismissChromeWelcome', async () => {363 driver.opts.browserName = 'Chrome';364 driver.opts.chromeOptions = {365 "args" : ["--no-first-run"]366 };367 await driver.startAndroidSession();368 driver.dismissChromeWelcome.calledOnce.should.be.true;369 });370 });371 describe('validateDesiredCaps', () => {372 before(() => {373 driver = new AndroidDriver();374 });375 it('should throw an error if caps do not contain an app, package or valid browser', () => {376 expect(() => {377 driver.validateDesiredCaps({platformName: 'Android', deviceName: 'device'});378 }).to.throw(/must include/);379 expect(() => {380 driver.validateDesiredCaps({platformName: 'Android', deviceName: 'device', browserName: 'Netscape Navigator'});381 }).to.throw(/must include/);382 });383 it('should not throw an error if caps contain an app, package or valid browser', () => {384 expect(() => {385 driver.validateDesiredCaps({platformName: 'Android', deviceName: 'device', app: '/path/to/some.apk'});386 }).to.not.throw(Error);387 expect(() => {388 driver.validateDesiredCaps({platformName: 'Android', deviceName: 'device', browserName: 'Chrome'});389 }).to.not.throw(Error);390 expect(() => {391 driver.validateDesiredCaps({platformName: 'Android', deviceName: 'device', appPackage: 'some.app.package'});392 }).to.not.throw(/must include/);393 });394 it('should not be sensitive to platform name casing', () => {395 expect(() => {396 driver.validateDesiredCaps({platformName: 'AnDrOiD', deviceName: 'device', app: '/path/to/some.apk'});397 }).to.not.throw(Error);398 });399 it('should not throw an error if caps contain both an app and browser, for grid compatibility', () => {400 expect(() => {401 driver.validateDesiredCaps({platformName: 'Android', deviceName: 'device', app: '/path/to/some.apk', browserName: 'iPhone'});402 }).to.not.throw(Error);403 });404 it('should not throw an error if caps contain androidScreenshotPath capability', () => {405 expect(() => {406 driver.validateDesiredCaps({platformName: 'Android', deviceName: 'device', app: '/path/to/some.apk', androidScreenshotPath: '/path/to/screenshotdir'});407 }).to.not.throw(Error);408 });409 });410 describe('proxying', () => {411 before(() => {412 driver = new AndroidDriver();413 driver.sessionId = 'abc';414 });415 describe('#proxyActive', () => {416 it('should exist', () => {417 driver.proxyActive.should.be.an.instanceof(Function);418 });419 it('should return false', () => {420 driver.proxyActive('abc').should.be.false;421 });422 it('should throw an error if session id is wrong', () => {423 (() => { driver.proxyActive('aaa'); }).should.throw;424 });425 });426 describe('#getProxyAvoidList', () => {427 it('should exist', () => {428 driver.getProxyAvoidList.should.be.an.instanceof(Function);429 });430 it('should return jwpProxyAvoid array', () => {431 let avoidList = driver.getProxyAvoidList('abc');432 avoidList.should.be.an.instanceof(Array);433 avoidList.should.eql(driver.jwpProxyAvoid);434 });435 it('should throw an error if session id is wrong', () => {436 (() => { driver.getProxyAvoidList('aaa'); }).should.throw;437 });438 });439 describe('#canProxy', () => {440 it('should exist', () => {441 driver.canProxy.should.be.an.instanceof(Function);442 });443 it('should return false', () => {444 driver.canProxy('abc').should.be.false;445 });446 it('should throw an error if session id is wrong', () => {447 (() => { driver.canProxy('aaa'); }).should.throw;448 });449 });450 });...

Full Screen

Full Screen

selendroid.js

Source:selendroid.js Github

copy

Full Screen

...229Selendroid.prototype.stop = function (ocb) {230 var completeShutdown = function (cb) {231 if (this.args.unicodeKeyboard && this.args.resetKeyboard && this.defaultIME) {232 logger.debug('Resetting IME to \'' + this.defaultIME + '\'');233 this.adb.setIME(this.defaultIME, function (err) {234 if (err) {235 // simply warn on error here, because we don't want to stop the shutdown236 // process237 logger.warn(err);238 }239 logger.debug("Stopping selendroid server");240 this.deleteSession(cb);241 }.bind(this));242 } else {243 logger.debug("Stopping selendroid server");244 this.deleteSession(cb);245 }246 }.bind(this);247 completeShutdown(function (err) {...

Full Screen

Full Screen

android.js

Source:android.js Github

copy

Full Screen

...427 if (this.adb) {428 this.adb.endAndroidCoverage();429 if (this.args.unicodeKeyboard && this.args.resetKeyboard && this.defaultIME) {430 logger.debug('Resetting IME to \'' + this.defaultIME + '\'');431 this.adb.setIME(this.defaultIME, function (err) {432 if (err) {433 // simply warn on error here, because we don't want to stop the shutdown434 // process435 logger.warn(err);436 }437 if (this.adb) {438 this.adb.stopLogcat(function () {439 next();440 }.bind(this));441 }442 }.bind(this));443 } else {444 this.adb.stopLogcat(function () {445 next();...

Full Screen

Full Screen

driver.js

Source:driver.js Github

copy

Full Screen

...229 if (this.adb) {230 if (this.opts.unicodeKeyboard && this.opts.resetKeyboard &&231 this.defaultIME) {232 logger.debug(`Resetting IME to '${this.defaultIME}'`);233 await this.adb.setIME(this.defaultIME);234 }235 await this.adb.forceStop(this.opts.appPackage);236 await this.adb.stopLogcat();237 if (this.opts.reboot) {238 let avdName = this.opts.avd.replace('@', '');239 logger.debug(`closing emulator '${avdName}'`);240 await this.adb.killEmulator(avdName);241 }242 }243 await super.deleteSession();244 }245 async checkAppPresent () {246 logger.debug('Checking whether app is actually present');247 if (!(await fs.exists(this.opts.app))) {...

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

...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 adb = driver.adb;2adb.setIME("com.android.inputmethod.latin/.LatinIME");3var adb = driver.adb;4adb.getIMEs();5var adb = driver.adb;6adb.getConnectedEmulators();7var adb = driver.adb;8adb.getConnectedDevices();9var adb = driver.adb;10adb.getEmulatorPort("emulator-5554");11var adb = driver.adb;12adb.getRunningAVD();13var adb = driver.adb;14adb.getRunningAVDWithRetry();15var adb = driver.adb;16adb.getRunningAVDWithRetry();17var adb = driver.adb;18adb.getRunningAVDWithRetry();19var adb = driver.adb;20adb.getRunningAVDWithRetry();21var adb = driver.adb;22adb.getRunningAVDWithRetry();23var adb = driver.adb;24adb.getRunningAVDWithRetry();25var adb = driver.adb;26adb.getRunningAVDWithRetry();27var adb = driver.adb;28adb.getRunningAVDWithRetry();29var adb = driver.adb;30adb.getRunningAVDWithRetry();31var adb = driver.adb;32adb.getRunningAVDWithRetry();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .setIME('com.android.inputmethod.latin/.LatinIME')9 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var adb = require('appium-adb');2var driver = new adb.ADB();3driver.setIME('com.android.inputmethod.latin/.LatinIME');4driver.getIMEs().then(function(imes) {5 console.log(imes);6});7[ { engine: 'com.android.inputmethod.latin/.LatinIME',8 current: true },9 { engine: 'com.android.inputmethod.latin/.LatinIME',10 current: false },11 { engine: 'com.sec.android.inputmethod/.SamsungKeypad',12 current: false },13 { engine: 'com.sec.android.inputmethod/.Swype',14 current: false } ]

Full Screen

Using AI Code Generation

copy

Full Screen

1var Appium = require('appium');2var driver = Appium.AndroidDriver;3var adb = driver.adb;4adb.setIME('com.android.inputmethod.latin/.LatinIME');5console.log('IME set to: ' + adb.getIME());6{7 "dependencies": {8 }9}10{11 "appium": {12 }13}14{15}16{17 "dependencies": {18 }19}20var Appium = require('appium');21var driver = Appium.AndroidDriver;22var adb = driver.adb;23adb.setIME('com.android.inputmethod.latin/.LatinIME');24console.log('IME set to: ' + adb.getIME());25{26 "dependencies": {27 }28}29{30 "appium": {31 }32}33{34}35{36 "dependencies": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var path = require('path');4var desired = {5 app: path.resolve(__dirname, 'ApiDemos-debug.apk'),6};7var driver = wd.promiseChainRemote('localhost', 4723);8 .init(desired)9 .setIME('io.appium.android.ime/.UnicodeIME')10 .then(function () {11 })12 .click()13 .click()14 .click()15 .elementById('io.appium.android.apis:id/edit')16 .type('Hello')17 .sleep(3000)18 .back()19 .back()20 .back()21 .resetIME()22 .quit();

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