How to use adb.fingerprint method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

index.js

Source:index.js Github

copy

Full Screen

1var Promise = require('bluebird')2var logger = require('../../util/logger')3var wire = require('../../wire')4var wirerouter = require('../../wire/router')5var wireutil = require('../../wire/util')6var dbapi = require('../../db/api')7var lifecycle = require('../../util/lifecycle')8var srv = require('../../util/srv')9var zmqutil = require('../../util/zmqutil')10module.exports = function(options) {11 var log = logger.createLogger('processor')12 if (options.name) {13 logger.setGlobalIdentifier(options.name)14 }15 // App side16 var appDealer = zmqutil.socket('dealer')17 Promise.map(options.endpoints.appDealer, function(endpoint) {18 return srv.resolve(endpoint).then(function(records) {19 return srv.attempt(records, function(record) {20 log.info('App dealer connected to "%s"', record.url)21 appDealer.connect(record.url)22 return Promise.resolve(true)23 })24 })25 })26 .catch(function(err) {27 log.fatal('Unable to connect to app dealer endpoint', err)28 lifecycle.fatal()29 })30 appDealer.on('message', function(channel, data) {31 devDealer.send([channel, data])32 })33 // Device side34 var devDealer = zmqutil.socket('dealer')35 Promise.map(options.endpoints.devDealer, function(endpoint) {36 return srv.resolve(endpoint).then(function(records) {37 return srv.attempt(records, function(record) {38 log.info('Device dealer connected to "%s"', record.url)39 devDealer.connect(record.url)40 return Promise.resolve(true)41 })42 })43 })44 .catch(function(err) {45 log.fatal('Unable to connect to dev dealer endpoint', err)46 lifecycle.fatal()47 })48 devDealer.on('message', wirerouter()49 // Initial device message50 .on(wire.DeviceIntroductionMessage, function(channel, message, data) {51 dbapi.saveDeviceInitialState(message.serial, message)52 .then(function() {53 devDealer.send([54 message.provider.channel55 , wireutil.envelope(new wire.DeviceRegisteredMessage(56 message.serial57 ))58 ])59 appDealer.send([channel, data])60 })61 })62 // Workerless messages63 .on(wire.DevicePresentMessage, function(channel, message, data) {64 dbapi.setDevicePresent(message.serial)65 appDealer.send([channel, data])66 })67 .on(wire.DeviceAbsentMessage, function(channel, message, data) {68 dbapi.setDeviceAbsent(message.serial)69 appDealer.send([channel, data])70 })71 .on(wire.DeviceStatusMessage, function(channel, message, data) {72 dbapi.saveDeviceStatus(message.serial, message.status)73 appDealer.send([channel, data])74 })75 .on(wire.DeviceHeartbeatMessage, function(channel, message, data) {76 appDealer.send([channel, data])77 })78 // Worker initialized79 .on(wire.DeviceReadyMessage, function(channel, message, data) {80 dbapi.setDeviceReady(message.serial, message.channel)81 .then(function() {82 devDealer.send([83 message.channel84 , wireutil.envelope(new wire.ProbeMessage())85 ])86 appDealer.send([channel, data])87 })88 })89 // Worker messages90 .on(wire.JoinGroupByAdbFingerprintMessage, function(channel, message) {91 dbapi.lookupUserByAdbFingerprint(message.fingerprint)92 .then(function(user) {93 if (user) {94 devDealer.send([95 channel96 , wireutil.envelope(new wire.AutoGroupMessage(97 new wire.OwnerMessage(98 user.email99 , user.name100 , user.group101 )102 , message.fingerprint103 ))104 ])105 }106 else if (message.currentGroup) {107 appDealer.send([108 message.currentGroup109 , wireutil.envelope(new wire.JoinGroupByAdbFingerprintMessage(110 message.serial111 , message.fingerprint112 , message.comment113 ))114 ])115 }116 })117 .catch(function(err) {118 log.error(119 'Unable to lookup user by ADB fingerprint "%s"'120 , message.fingerprint121 , err.stack122 )123 })124 })125 .on(wire.JoinGroupByVncAuthResponseMessage, function(channel, message) {126 dbapi.lookupUserByVncAuthResponse(message.response, message.serial)127 .then(function(user) {128 if (user) {129 devDealer.send([130 channel131 , wireutil.envelope(new wire.AutoGroupMessage(132 new wire.OwnerMessage(133 user.email134 , user.name135 , user.group136 )137 , message.response138 ))139 ])140 }141 else if (message.currentGroup) {142 appDealer.send([143 message.currentGroup144 , wireutil.envelope(new wire.JoinGroupByVncAuthResponseMessage(145 message.serial146 , message.response147 ))148 ])149 }150 })151 .catch(function(err) {152 log.error(153 'Unable to lookup user by VNC auth response "%s"'154 , message.response155 , err.stack156 )157 })158 })159 .on(wire.JoinGroupMessage, function(channel, message, data) {160 dbapi.setDeviceOwner(message.serial, message.owner)161 appDealer.send([channel, data])162 })163 .on(wire.LeaveGroupMessage, function(channel, message, data) {164 dbapi.unsetDeviceOwner(message.serial, message.owner)165 appDealer.send([channel, data])166 })167 .on(wire.DeviceLogMessage, function(channel, message, data) {168 appDealer.send([channel, data])169 })170 .on(wire.DeviceIdentityMessage, function(channel, message, data) {171 dbapi.saveDeviceIdentity(message.serial, message)172 appDealer.send([channel, data])173 })174 .on(wire.TransactionProgressMessage, function(channel, message, data) {175 appDealer.send([channel, data])176 })177 .on(wire.TransactionDoneMessage, function(channel, message, data) {178 appDealer.send([channel, data])179 })180 .on(wire.DeviceLogcatEntryMessage, function(channel, message, data) {181 appDealer.send([channel, data])182 })183 .on(wire.AirplaneModeEvent, function(channel, message, data) {184 dbapi.setDeviceAirplaneMode(message.serial, message.enabled)185 appDealer.send([channel, data])186 })187 .on(wire.BatteryEvent, function(channel, message, data) {188 dbapi.setDeviceBattery(message.serial, message)189 appDealer.send([channel, data])190 })191 .on(wire.DeviceBrowserMessage, function(channel, message, data) {192 dbapi.setDeviceBrowser(message.serial, message)193 appDealer.send([channel, data])194 })195 .on(wire.ConnectivityEvent, function(channel, message, data) {196 dbapi.setDeviceConnectivity(message.serial, message)197 appDealer.send([channel, data])198 })199 .on(wire.PhoneStateEvent, function(channel, message, data) {200 dbapi.setDevicePhoneState(message.serial, message)201 appDealer.send([channel, data])202 })203 .on(wire.RotationEvent, function(channel, message, data) {204 dbapi.setDeviceRotation(message.serial, message.rotation)205 appDealer.send([channel, data])206 })207 .on(wire.ReverseForwardsEvent, function(channel, message, data) {208 dbapi.setDeviceReverseForwards(message.serial, message.forwards)209 appDealer.send([channel, data])210 })211 .handler())212 lifecycle.observe(function() {213 [appDealer, devDealer].forEach(function(sock) {214 try {215 sock.close()216 }217 catch (err) {218 // No-op219 }220 })221 })...

Full Screen

Full Screen

connect.js

Source:connect.js Github

copy

Full Screen

1var util = require('util')2var syrup = require('stf-syrup')3var Promise = require('bluebird')4var logger = require('../../../util/logger')5var grouputil = require('../../../util/grouputil')6var wire = require('../../../wire')7var wireutil = require('../../../wire/util')8var lifecycle = require('../../../util/lifecycle')9var dbapi = require('../../../db/api')10module.exports = syrup.serial()11 .dependency(require('../support/adb'))12 .dependency(require('../support/router'))13 .dependency(require('../support/push'))14 .dependency(require('./group'))15 .dependency(require('./solo'))16 .dependency(require('./util/urlformat'))17 .dependency(require('./rentcontrol'))18 .define(function (options, adb, router, push, group, solo, urlformat, rentcontrol) {19 var log = logger.createLogger('device:plugins:connect')20 var plugin = Object.create(null)21 var activeServer = null22 plugin.port = options.connectPort23 plugin.url = urlformat(options.connectUrlPattern, plugin.port)24 plugin.start = function () {25 console.log("start device")26 return new Promise(function (resolve, reject) {27 if (plugin.isRunning()) {28 return resolve(plugin.url)29 }30 console.log("start device:" + plugin.url)31 var server = adb.createTcpUsbBridge(options.serial, {32 auth: function (key) {33 var resolver = Promise.defer()34 function notify() {35 dbapi.dumpsUsersAdbKey(key.fingerprint).then(function () {36 group.get()37 .then(function (currentGroup) {38 console.log("notify:" + currentGroup)39 dbapi.dumpsUsersAdbKey(key.fingerprint).then(function () {40 push.send([41 solo.channel42 , wireutil.envelope(new wire.JoinGroupByAdbFingerprintMessage(43 options.serial44 , key.fingerprint45 , key.comment46 , currentGroup.group47 ))48 ])49 })50 })51 .catch(grouputil.NoGroupError, function () {52 push.send([53 solo.channel54 , wireutil.envelope(new wire.JoinGroupByAdbFingerprintMessage(55 options.serial56 , key.fingerprint57 , key.comment58 ))59 ])60 })61 })62 }63 function notify1() {64 group.get()65 .then(function (currentGroup) {66 console.log("notify1:" + currentGroup)67 push.send([68 solo.channel69 , wireutil.envelope(new wire.JoinGroupByAdbFingerprintMessage(70 options.serial71 , key.fingerprint72 , key.comment73 , currentGroup.group74 ))75 ])76 })77 .catch(grouputil.NoGroupError, function () {78 push.send([79 solo.channel80 , wireutil.envelope(new wire.JoinGroupByAdbFingerprintMessage(81 options.serial82 , key.fingerprint83 , key.comment84 ))85 ])86 })87 }88 function joinListener(group, identifier) {89 if (identifier !== key.fingerprint) {90 resolver.reject(new Error('Somebody else took the device'))91 }92 }93 function autojoinListener(identifier, joined) {94 if (identifier === key.fingerprint) {95 if (joined) {96 resolver.resolve()97 }98 else {99 resolver.reject(new Error('Device is already in use'))100 }101 }102 }103 group.on('join', joinListener)104 group.on('autojoin', autojoinListener)105 router.on(wire.AdbKeysUpdatedMessage, notify1)106 notify()107 return resolver.promise108 .timeout(120000)109 .finally(function () {110 group.removeListener('join', joinListener)111 group.removeListener('autojoin', autojoinListener)112 router.removeListener(wire.AdbKeysUpdatedMessage, notify)113 })114 }115 })116 server.on('listening', function () {117 resolve(plugin.url)118 })119 server.on('connection', function (conn) {120 log.info('New remote ADB connection from %s', conn.remoteAddress)121 conn.on('userActivity', function () {122 group.keepalive()123 rentcontrol.keepalive()124 })125 })126 server.on('error', reject)127 log.info(util.format('Listening on port %d', plugin.port))128 server.listen(plugin.port)129 activeServer = server130 lifecycle.share('Remote ADB', activeServer)131 })132 }133 plugin.stop = Promise.method(function () {134 if (plugin.isRunning()) {135 activeServer.close()136 activeServer.end()137 }138 })139 plugin.end = Promise.method(function () {140 if (plugin.isRunning()) {141 activeServer.end()142 }143 })144 plugin.isRunning = function () {145 return !!activeServer146 }147 lifecycle.observe(plugin.stop)148 group.on('leave', plugin.end)149 router150 .on(wire.ConnectStartMessage, function (channel) {151 var reply = wireutil.reply(options.serial)152 plugin.start()153 .then(function (url) {154 push.send([155 channel156 , reply.okay(url)157 ])158 // Update DB159 push.send([160 channel161 , wireutil.envelope(new wire.ConnectStartedMessage(162 options.serial163 , url164 ))165 ])166 log.important('Remote Connect Started for device "%s" at "%s"', options.serial, url)167 })168 .catch(function (err) {169 log.error('Unable to start remote connect service', err.stack)170 push.send([171 channel172 , reply.fail(err.message)173 ])174 })175 })176 .on(wire.ConnectStopMessage, function (channel) {177 var reply = wireutil.reply(options.serial)178 plugin.end()179 .then(function () {180 push.send([181 channel182 , reply.okay()183 ])184 // Update DB185 push.send([186 channel187 , wireutil.envelope(new wire.ConnectStoppedMessage(188 options.serial189 ))190 ])191 log.important('Remote Connect Stopped for device "%s"', options.serial)192 })193 .catch(function (err) {194 log.error('Failed to stop connect service', err.stack)195 push.send([196 channel197 , reply.fail(err.message)198 ])199 })200 })201 return plugin.start()202 .return(plugin)...

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.adb.fingerprint(1);10driver.quit();11I am running the test script on a real device (OnePlus 5T) with Android 8.1.012[HTTP] {"fingerprintId":1}13[W3C (9d7f6d2c)] Calling AppiumDriver.fingerprint() with args: [1,"9d7f6d2c-8a1b-4f6e-8a0a-2c8b9f9b6d49"]14[BaseDriver] Event 'newSessionStarted' logged at 1549370480760 (15:01:20 GMT+0530 (IST))15[W3C (9d7f6d2c)] Encountered internal error running command: Error: Command 'adb -P 5037 -s 3ccf0c5e shell am force-stop io.appium.settings' exited with code 116[W3C (9d7f6d2c)] at ChildProcess.proc.on.code (/usr/local/lib/node_modules/appium/node_modules/teen_process/lib/exec.js:94:19)

Full Screen

Using AI Code Generation

copy

Full Screen

1const adb = require('appium-adb');2const path = require('path');3const adbPath = path.resolve('C:\\Users\\username\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe');4const fingerprintPath = path.resolve('C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-adb\\test\\fixtures\\fingerprint.png');5const adbObj = new adb.ADB({adbPath: adbPath});6adbObj.fingerprint(fingerprintPath).then(function (data) {7 console.log('Fingerprint added successfully');8 console.log(data);9}, function (err) {10 console.log('Error adding fingerprint');11 console.log(err);12});13const androidDriver = require('appium-android-driver');14const path = require('path');15const adbPath = path.resolve('C:\\Users\\username\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe');16const fingerprintPath = path.resolve('C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-adb\\test\\fixtures\\fingerprint.png');17const adbObj = new androidDriver.ADB({adbPath: adbPath});18adbObj.fingerprint(fingerprintPath).then(function (data) {19 console.log('Fingerprint added successfully');20 console.log(data);21}, function (err) {22 console.log('Error adding fingerprint');23 console.log(err);24});25const androidDriver = require('appium-android-driver');26const path = require('path');27const adbPath = path.resolve('C:\\Users\\username\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe');28const fingerprintPath = path.resolve('C:\\Users\\username

Full Screen

Using AI Code Generation

copy

Full Screen

1const adb = require('appium-adb').getADB();2(async () => {3 await adb.fingerprint(1);4 await adb.fingerprint(0);5})();6const adb = require('appium-adb').getADB();7(async () => {8 await adb.fingerprint(1);9 await adb.fingerprint(0);10})();11const adb = require('appium-adb').getADB();12(async () => {13 await adb.fingerprint(1);14 await adb.fingerprint(0);15})();16const adb = require('appium-adb').getADB();17(async () => {18 await adb.fingerprint(1);19 await adb.fingerprint(0);20})();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var chai = require('chai');4var chaiAsPromised = require('chai-as-promised');5chai.use(chaiAsPromised);6var should = chai.should();7var expect = chai.expect;8var desiredCaps = {9};10var driver = wd.promiseChainRemote('localhost', 4723);11driver.on('status', function (info) {12 console.log(info);13});14driver.on('command', function (eventType, command, response) {15 console.log(' > ' + eventType + ': ' + command + ' ' + (response ? '(response: ' + JSON.stringify(response) + ')' : ''));16});17driver.on('http', function (meth, path, data) {18 console.log(' > ' + meth + ' ' + path + ' ' + (data || ''));19});20 .init(desiredCaps)21 .setImplicitWaitTimeout(10000)22 .then(function () {23 return driver.fingerprint(1);24 })25 .then(function () {26 return driver.elementById('com.example.app:id/button2').click();27 })28 .then(function () {29 return driver.elementById('com.example.app:id/button3').click();30 })31 .then(function () {32 return driver.elementById('com.example.app:id/button4').click();33 })34 .then(function () {35 return driver.elementById('com.example.app:id/button5').click();36 })37 .then(function () {38 return driver.elementById('com.example.app:id/button6').click();39 })40 .then(function () {41 return driver.elementById('com.example.app:id/button7').click();42 })43 .then(function () {44 return driver.elementById('com.example.app:id/button8').click();45 })46 .then(function () {47 return driver.elementById('com.example.app:id/button9').click();

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