How to use this.adb.getApiLevel method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

driver.js

Source:driver.js Github

copy

Full Screen

...227 this.opts.emPort = emPort;228 // now that we know our java version and device info, we can create our229 // ADB instance230 this.adb = await androidHelpers.createADB(this.opts);231 if (await this.adb.getApiLevel() < 21) {232 logger.errorAndThrow('UIAutomation2 is only supported since Android 5.0 (Lollipop). ' +233 'You could still use other supported backends in order to automate older Android versions.');234 }235 // get appPackage et al from manifest if necessary236 let appInfo = await helpers.getLaunchInfo(this.adb, this.opts);237 // and get it onto our 'opts' object so we use it from now on238 Object.assign(this.opts, appInfo);239 // set actual device name, udid, platform version, screen size, screen density, model and manufacturer details240 this.caps.deviceName = this.adb.curDeviceId;241 this.caps.deviceUDID = this.opts.udid;242 this.caps.platformVersion = await this.adb.getPlatformVersion();243 this.caps.deviceScreenSize = await this.adb.getScreenSize();244 this.caps.deviceScreenDensity = await this.adb.getScreenDensity();245 this.caps.deviceModel = await this.adb.getModel();246 this.caps.deviceManufacturer = await this.adb.getManufacturer();247 this.caps.deviceApiLevel = await this.adb.getApiLevel();248 // set up the modified UiAutomator2 server etc249 await this.initUiAutomator2Server();250 // start an avd, set the language/locale, pick an emulator, etc...251 // TODO with multiple devices we'll need to parameterize this252 this.defaultIME = await helpers.initDevice(this.adb, this.opts);253 // Further prepare the device by forwarding the UiAutomator2 port254 logger.debug(`Forwarding UiAutomator2 Server port ${DEVICE_PORT} to ${this.opts.systemPort}`);255 await this.adb.forwardPort(this.opts.systemPort, DEVICE_PORT);256 // If the user sets autoLaunch to false, they are responsible for initAUT() and startAUT()257 if (this.opts.autoLaunch) {258 // set up app under test259 // prepare our actual AUT, get it on the device, etc...260 await this.initAUT();261 }...

Full Screen

Full Screen

android.js

Source:android.js Github

copy

Full Screen

...255 });256 return relaunch;257};258Android.prototype.checkApiLevel = function (cb) {259 this.adb.getApiLevel(function (err, apiLevel) {260 if (err) return cb(err);261 logger.info('Device API level is:', parseInt(apiLevel, 10));262 if (parseInt(apiLevel) < 17) {263 var msg = "Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.";264 logger.error(msg); // logs the error when we encounter it265 return cb(new Error(msg)); // send the error up the chain266 }267 cb();268 });269};270Android.prototype.decorateChromeOptions = function (caps) {271 // add options from appium session caps272 if (this.args.chromeOptions) {273 _.each(this.args.chromeOptions, function (val, option) {...

Full Screen

Full Screen

performance.js

Source:performance.js Github

copy

Full Screen

...93 nativePrivateDirty, nativePss, nativeHeapSize, nativeHeapAllocatedSize,94 dalvikPrivateDirty, dalvikPss,95 eglPrivateDirty, eglPss,96 glPrivateDirty, glPss;97 let apilevel = await this.adb.getApiLevel();98 for (let line of data.split('\n')) {99 let entries = line.trim().split(' ').filter(Boolean);100 // entries will have the values101 // ['<System Type>', '<Memory Type>', <pss total>, <private dirty>, <private clean>, <swapPss dirty>, <heap size>, <heap alloc>, <heap free>]102 // except 'TOTAL', which skips the second type name103 //104 // and on API level 18 and below105 // ['<System Type', '<pps>', '<shared dirty>', '<private dirty>', '<heap size>', '<heap alloc>', '<heap free>']106 if (apilevel > 18) {107 let type = entries[0];108 let subType = entries[1];109 if (type === 'Native' && subType === 'Heap') {110 // native heap111 nativePss = entries[2];...

Full Screen

Full Screen

actions.js

Source:actions.js Github

copy

Full Screen

...288 }289 return await jimp.read(stdout);290};291commands.getScreenshot = async function () {292 const apiLevel = await this.adb.getApiLevel();293 let image = null;294 if (apiLevel > 20) {295 try {296 // This screenshoting approach is way faster, since it requires less external commands297 // to be executed. Unfortunately, exec-out option is only supported by newer Android/SDK versions (5.0 and later)298 image = await this.getScreenshotDataWithAdbExecOut(this.adb);299 } catch (e) {300 log.info(`Cannot get screenshot data with 'adb exec-out' because of '${e.message}'. ` +301 `Defaulting to 'adb shell' call`);302 }303 }304 if (!image) {305 try {306 image = await this.getScreenshotDataWithAdbShell(this.adb, this.opts);...

Full Screen

Full Screen

touch.js

Source:touch.js Github

copy

Full Screen

...48 let {x, y} = await this.getLocationInView(moveTo.options.element);49 endX += x || 0;50 endY += y || 0;51 }52 let apiLevel = await this.adb.getApiLevel();53 // lollipop takes a little longer to get things rolling54 let duration = apiLevel >= 5 ? 2 : 1;55 // make sure that if the long press has a duration, we use it.56 if (longPress.options && longPress.options.duration) {57 duration = Math.max(longPress.options.duration / 1000, duration);58 }59 // `drag` will take care of whether there is an element or not at that level60 return await this.drag(startX, startY, endX, endY, duration, 1, longPress.options.element, moveTo.options.element);61};62// Release gesture needs element or co-ordinates to release it from that position63// or else release gesture is performed from center of the screen, so to fix it64// This method sets co-ordinates/element to release gesture if it has no options set already.65helpers.fixRelease = async function (gestures) {66 let release = _.last(gestures);...

Full Screen

Full Screen

network.js

Source:network.js Github

copy

Full Screen

...82 return await this.adb.setGeoLocation(location, this.isEmulator());83};84commands.toggleLocationServices = async function () {85 log.info("Toggling location services");86 let api = await this.adb.getApiLevel();87 if (this.isEmulator()) {88 let providers = await this.adb.getLocationProviders();89 let isGpsEnabled = providers.indexOf('gps') !== -1;90 await this.adb.toggleGPSLocationProvider(!isGpsEnabled);91 return;92 }93 if (api > 15) {94 let seq = [19, 19]; // up, up95 if (api === 16) {96 // This version of Android has a "parent" button in its action bar97 seq.push(20); // down98 } else if (api >= 19) {99 // Newer versions of Android have the toggle in the Action bar100 seq = [22, 22, 19]; // right, right, up...

Full Screen

Full Screen

recordscreen.js

Source:recordscreen.js Github

copy

Full Screen

...26 if (this.isEmulator()) {27 throw new Error('Screen recording does not work on emulators');28 }29 // this function is suppported on the device running android 4.4(api level 19)30 let apiLevel = await this.adb.getApiLevel();31 if (apiLevel < 19) {32 throw new Error(`Screen recording not available on API Level ${apiLevel}. Minimum API Level is 19.`);33 }34 //if there's same file in the path, then thorws error35 if (await this.adb.fileExists(filePath)) {36 throw new Error(`Screen recording failed: '${filePath}' already exists.`);37 }38 //make adb command39 let cmd = ['screenrecord', filePath];40 if (util.hasValue(videoSize)) {41 cmd.push('--size', videoSize);42 }43 if (util.hasValue(timeLimit)) {44 cmd.push('--time-limit', timeLimit);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var AppiumDriver = require('appium-android-driver');3var driver = new AppiumDriver();4driver.adb.getApiLevel().then(function(apiLevel) {5 console.log('API level is ' + apiLevel);6});7var webdriver = require('selenium-webdriver');8var AppiumDriver = require('appium-android-driver');9var driver = new AppiumDriver();10driver.adb.getApiLevel().then(function(apiLevel) {11 console.log('API level is ' + apiLevel);12});13var webdriver = require('selenium-webdriver');14var AppiumDriver = require('appium-android-driver');15var driver = new AppiumDriver();16driver.adb.getApiLevel().then(function(apiLevel) {17 console.log('API level is ' + apiLevel);18});19var webdriver = require('selenium-webdriver');20var AppiumDriver = require('appium-android-driver');21var driver = new AppiumDriver();22driver.adb.getApiLevel().then(function(apiLevel) {23 console.log('API level is ' + apiLevel);24});25var webdriver = require('selenium-webdriver');26var AppiumDriver = require('appium-android-driver');27var driver = new AppiumDriver();28driver.adb.getApiLevel().then(function(apiLevel) {29 console.log('API level is ' + apiLevel);30});31var webdriver = require('selenium-webdriver');32var AppiumDriver = require('appium-android-driver');33var driver = new AppiumDriver();34driver.adb.getApiLevel().then(function(apiLevel) {35 console.log('API level is ' + apiLevel);36});37var webdriver = require('selenium-webdriver');38var AppiumDriver = require('appium-android-driver');

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 android = require('appium').Android,3 driver = new webdriver.Builder()4 .forBrowser('chrome')5 .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnG')).click();8driver.wait(until.titleIs('webdriver - Google Search'), 1000);9var adb = new android.ADB();10var apiLevel = adb.getApiLevel();11console.log(apiLevel);12driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { AndroidDriver } = require('appium-android-driver');2const driver = new AndroidDriver();3driver.adb.getApiLevel().then((apiLevel) => {4 console.log(apiLevel);5});6const { ADB } = require('appium-adb');7const adb = new ADB();8adb.getApiLevel().then((apiLevel) => {9 console.log(apiLevel);10});11const { AndroidHelpers } = require('appium-android-driver');12const androidHelpers = new AndroidHelpers();13androidHelpers.getApiLevel().then((apiLevel) => {14 console.log(apiLevel);15});16const { ADB } = require('appium-adb');17const adb = new ADB();18adb.getApiLevel().then((apiLevel) => {19 console.log(apiLevel);20});21const { AndroidHelpers } = require('appium-android-driver');22const androidHelpers = new AndroidHelpers();23androidHelpers.getApiLevel().then((apiLevel) => {24 console.log(apiLevel);25});26const { ADB } = require('appium-adb');27const adb = new ADB();28adb.getApiLevel().then((apiLevel) => {29 console.log(apiLevel);30});31const { AndroidHelpers } = require('appium-android-driver');32const androidHelpers = new AndroidHelpers();33androidHelpers.getApiLevel().then((apiLevel) => {34 console.log(apiLevel);35});36const { ADB } = require('appium-adb');37const adb = new ADB();38adb.getApiLevel().then((apiLevel) => {39 console.log(apiLevel);40});41const { AndroidHelpers } = require('appium-android-driver');

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = new AndroidDriver({2});3driver.getApiLevel().then(function(apiLevel) {4 console.log('The device under test is on Android API level', apiLevel);5});6driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var AndroidDriver = require('appium-android-driver');4var driver = new AndroidDriver();5var desiredCaps = {6};7driver.createSession(desiredCaps).then(function () {8 driver.adb.getApiLevel().then(function (apiLevel) {9 console.log('Android API Level is: ' + apiLevel);10 });11});12driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desiredCaps = {};4desiredCaps['appium-version'] = '1.0';5desiredCaps.platformName = 'Android';6desiredCaps.platformVersion = '7.1.1';7desiredCaps.deviceName = 'Android Emulator';

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, 'app-debug.apk')6};7var driver = wd.promiseChainRemote('localhost', 4723);8 .init(desired)9 .then(function() {10 return driver.adb.getApiLevel();11 })12 .then(function(apiLevel) {13 console.log("Android API Level: " + apiLevel);14 })15 .finally(function() {16 return driver.quit();17 })18 .done();19var wd = require('wd');20var assert = require('assert');21var path = require('path');22var desired = {23 app: path.resolve(__dirname, 'app-debug.apk')24};25var driver = wd.promiseChainRemote('localhost', 4723);26 .init(desired)27 .then(function() {28 return driver.adb.getAndroidVersion();29 })30 .then(function(androidVersion) {31 console.log("Android Version:

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