How to use adb.packageAndLaunchActivityFromManifest method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

android-common.js

Source:android-common.js Github

copy

Full Screen

...618    return cb();619  }620  if (this.args.appPackage && this.args.appActivity) return cb();621  logger.debug("Parsing package and activity from app manifest");622  this.adb.packageAndLaunchActivityFromManifest(this.args.app, function (err, pkg, act) {623    if (err) {624      logger.error("Problem parsing package and activity from manifest: " +625                   err);626      return cb(err);627    }628    if (pkg && !this.args.appPackage) this.args.appPackage = pkg;629    if (!this.args.appWaitPackage) this.args.appWaitPackage = this.args.appPackage;630    // Retrying to parse activity from AndroidManifest.xml631    if (act === null) {632      var appiumApkToolsJarPath = this.adb.jars['appium_apk_tools.jar'];633      var outputPath = path.resolve(this.args.tmpDir, pkg);634      var getLaunchActivity = ['java -jar "', appiumApkToolsJarPath,635                                '" "', 'printLaunchActivity',636                                '" "', this.args.app, '" "', outputPath, '"'].join('');...

Full Screen

Full Screen

ah1.js

Source:ah1.js Github

copy

Full Screen

...235    return;236  }237  logger.debug("Parsing package and activity from app manifest");238  let {apkPackage, apkActivity} =239    await adb.packageAndLaunchActivityFromManifest(app);240  if (apkPackage && !appPackage) {241    appPackage = apkPackage;242  }243  if (!appWaitPackage) {244    appWaitPackage = appPackage;245  }246  if (apkActivity && !appActivity) {247    appActivity = apkActivity;248  }249  if (!appWaitActivity) {250    appWaitActivity = appActivity;251  }252  logger.debug(`Parsed package and activity are: ${apkPackage}/${apkActivity}`);253  return {appPackage, appWaitPackage, appActivity, appWaitActivity};...

Full Screen

Full Screen

android-helpers.js

Source:android-helpers.js Github

copy

Full Screen

...208    return;209  }210  logger.debug("Parsing package and activity from app manifest");211  let {apkPackage, apkActivity} =212    await adb.packageAndLaunchActivityFromManifest(app);213  if (apkPackage && !appPackage) {214    appPackage = apkPackage;215  }216  if (!appWaitPackage) {217    appWaitPackage = appPackage;218  }219  if (apkActivity && !appActivity) {220    appActivity = apkActivity;221  }222  if (!appWaitActivity) {223    appWaitActivity = appActivity;224  }225  logger.debug(`Parsed package and activity are: ${apkPackage}/${apkActivity}`);226  return {appPackage, appWaitPackage, appActivity, appWaitActivity};...

Full Screen

Full Screen

general-specs.js

Source:general-specs.js Github

copy

Full Screen

1import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';3import sinon from 'sinon';4import AndroidDriver from '../../..';5import { parseSurfaceLine, parseWindows } from '../../../lib/commands/general';6import helpers from '../../../lib/android-helpers';7import { withMocks } from 'appium-test-support';8import { fs } from 'appium-support';9import Bootstrap from 'appium-android-bootstrap';10import B from 'bluebird';11import ADB from 'appium-adb';12chai.should();13chai.use(chaiAsPromised);14let driver;15let sandbox = sinon.sandbox.create();16let expect = chai.expect;17describe('General', () => {18  beforeEach(() => {19    driver = new AndroidDriver();20    driver.bootstrap = new Bootstrap();21    driver.adb = new ADB();22    driver.caps = {};23    driver.opts = {};24  });25  afterEach(() => {26    sandbox.restore();27  });28  describe('keys', () => {29    it('should send keys via setText bootstrap command', async () => {30      sandbox.stub(driver.bootstrap, 'sendAction');31      driver.opts.unicodeKeyboard = true;32      await driver.keys('keys');33      driver.bootstrap.sendAction34        .calledWithExactly('setText',35          {text: 'keys', replace: false, unicodeKeyboard: true})36        .should.be.true;37    });38    it('should join keys if keys is array', async () => {39      sandbox.stub(driver.bootstrap, 'sendAction');40      driver.opts.unicodeKeyboard = false;41      await driver.keys(['k', 'e', 'y', 's']);42      driver.bootstrap.sendAction43        .calledWithExactly('setText', {text: 'keys', replace: false})44        .should.be.true;45    });46  });47  describe('getDeviceTime', () => {48    it('should return device time', async () => {49      sandbox.stub(driver.adb, 'shell');50      driver.adb.shell.returns(' 11:12 ');51      await driver.getDeviceTime().should.become('11:12');52      driver.adb.shell.calledWithExactly(['date']).should.be.true;53    });54    it('should thorws error if shell command failed', async () => {55      sandbox.stub(driver.adb, 'shell').throws();56      await driver.getDeviceTime().should.be.rejectedWith('Could not capture');57    });58  });59  describe('getPageSource', () => {60    it('should return page source', async () => {61      sandbox.stub(driver.bootstrap, 'sendAction').withArgs('source').returns('sources');62      await driver.getPageSource().should.be.equal('sources');63    });64  });65  describe('back', () => {66    it('should press back', async () => {67      sandbox.stub(driver.bootstrap, 'sendAction');68      await driver.back();69      driver.bootstrap.sendAction.calledWithExactly('pressBack').should.be.true;70    });71  });72  describe('isKeyboardShown', () => {73    it('should return true if the keyboard is shown', async () => {74      driver.adb.isSoftKeyboardPresent = () => { return {isKeyboardShown: true, canCloseKeyboard: true}; };75      (await driver.isKeyboardShown()).should.equal(true);76    });77    it('should return false if the keyboard is not shown', async () => {78      driver.adb.isSoftKeyboardPresent = () => { return {isKeyboardShown: false, canCloseKeyboard: true}; };79      (await driver.isKeyboardShown()).should.equal(false);80    });81  });82  describe('hideKeyboard', () => {83    it('should hide keyboard via back command', async () => {84      sandbox.stub(driver, 'back');85      driver.adb.isSoftKeyboardPresent = () => { return {isKeyboardShown: true, canCloseKeyboard: true}; };86      await driver.hideKeyboard();87      driver.back.calledOnce.should.be.true;88    });89    it('should not call back command if can\'t close keyboard', async () => {90      sandbox.stub(driver, 'back');91      driver.adb.isSoftKeyboardPresent = () => { return {isKeyboardShown: true, canCloseKeyboard: false}; };92      await driver.hideKeyboard();93      driver.back.notCalled.should.be.true;94    });95    it('should throw an error if no keyboard is present', async () => {96      driver.adb.isSoftKeyboardPresent = () => { return false; };97      await driver.hideKeyboard().should.be.rejectedWith(/not present/);98    });99  });100  describe('openSettingsActivity', () => {101    it('should open settings activity', async () => {102      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')103        .returns({appPackage: 'pkg', appActivity: 'act'});104      sandbox.stub(driver.adb, 'shell');105      sandbox.stub(driver.adb, 'waitForNotActivity');106      await driver.openSettingsActivity('set1');107      driver.adb.shell.calledWithExactly(['am', 'start', '-a', 'android.settings.set1'])108        .should.be.true;109      driver.adb.waitForNotActivity.calledWithExactly('pkg', 'act', 5000)110        .should.be.true;111    });112  });113  describe('getWindowSize', () => {114    it('should get window size', async () => {115      sandbox.stub(driver.bootstrap, 'sendAction')116        .withArgs('getDeviceSize').returns('size');117      await driver.getWindowSize().should.be.equal('size');118    });119  });120  describe('getCurrentActivity', () => {121    it('should get current activity', async () => {122      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')123        .returns({appActivity: 'act'});124      await driver.getCurrentActivity().should.eventually.be.equal('act');125    });126  });127  describe('getCurrentPackage', () => {128    it('should get current activity', async () => {129      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')130        .returns({appPackage: 'pkg'});131      await driver.getCurrentPackage().should.eventually.equal('pkg');132    });133  });134  describe('getLogTypes', () => {135    it('should get log types', async () => {136      await driver.getLogTypes().should.be.deep.equal(['logcat']);137    });138  });139  describe('getLog', () => {140    it('should get log types', async () => {141      sandbox.stub(driver.adb, 'getLogcatLogs').returns('logs');142      await driver.getLog('logcat').should.be.equal('logs');143    });144    it('should throws exception if log type is unsupported', async () => {145      expect(() => driver.getLog('unsupported_type'))146        .to.throw('Unsupported log type unsupported_type');147    });148  });149  describe('isAppInstalled', () => {150    it('should return true if app is installed', async () => {151      sandbox.stub(driver.adb, 'isAppInstalled').withArgs('pkg').returns(true);152      await driver.isAppInstalled('pkg').should.be.true;153    });154  });155  describe('removeApp', () => {156    it('should remove app', async () => {157      sandbox.stub(driver.adb, 'uninstallApk').withArgs('pkg').returns(true);158      await driver.removeApp('pkg').should.be.true;159    });160  });161  describe('installApp', () => {162    it('should install app', async () => {163      driver.opts.fastReset = 'fastReset';164      let app = 'app.apk';165      let opts = {app: 'app.apk', appPackage: 'pkg', fastReset: 'fastReset'};166      sandbox.stub(driver.helpers, 'configureApp').withArgs('app', '.apk')167        .returns(app);168      sandbox.stub(fs, 'exists').withArgs(app).returns(true);169      sandbox.stub(driver.adb, 'packageAndLaunchActivityFromManifest')170        .withArgs(app).returns({apkPackage: 'pkg'});171      sandbox.stub(helpers, 'installApkRemotely')172        .returns(true);173      await driver.installApp('app').should.eventually.be.true;174      driver.helpers.configureApp.calledOnce.should.be.true;175      fs.exists.calledOnce.should.be.true;176      driver.adb.packageAndLaunchActivityFromManifest.calledOnce.should.be.true;177      helpers.installApkRemotely.calledWithExactly(driver.adb, opts)178        .should.be.true;179    });180    it('should throw an error if APK does not exist', async () => {181      await driver.installApp('non/existent/app.apk').should.be.rejectedWith(/Could not find/);182    });183  });184  describe('background', function () {185    it('should bring app to background and back', async function () {186      const appPackage = 'wpkg';187      const appActivity = 'wacv';188      driver.opts = {appPackage, appActivity, intentAction: 'act',189                     intentCategory: 'cat', intentFlags: 'flgs',190                     optionalIntentArguments: 'opt'};191      let params = {pkg: appPackage, activity: appActivity, action: 'act', category: 'cat',192                    flags: 'flgs',193                    optionalIntentArguments: 'opt', stopApp: false};194      sandbox.stub(driver.adb, 'goToHome');195      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')196        .returns({appPackage, appActivity});197      sandbox.stub(B, 'delay');198      sandbox.stub(driver.adb, 'startApp');199      await driver.background(10);200      driver.adb.getFocusedPackageAndActivity.calledOnce.should.be.true;201      driver.adb.goToHome.calledOnce.should.be.true;202      B.delay.calledWithExactly(10000).should.be.true;203      driver.adb.startApp.calledWithExactly(params).should.be.true;204    });205    it('should bring app to background and back if started after session init', async function () {206      const appPackage = 'newpkg';207      const appActivity = 'newacv';208      driver.opts = {appPackage: 'pkg', appActivity: 'acv', intentAction: 'act',209                     intentCategory: 'cat', intentFlags: 'flgs',210                     optionalIntentArguments: 'opt'};211      let params = {pkg: appPackage, activity: appActivity, action: 'act', category: 'cat',212                    flags: 'flgs', waitPkg: 'wpkg', waitActivity: 'wacv',213                    optionalIntentArguments: 'opt', stopApp: false};214      driver.opts.startActivityArgs = {[`${appPackage}/${appActivity}`]: params};215      sandbox.stub(driver.adb, 'goToHome');216      sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')217        .returns({appPackage, appActivity});218      sandbox.stub(B, 'delay');219      sandbox.stub(driver.adb, 'startApp');220      await driver.background(10);221      driver.adb.getFocusedPackageAndActivity.calledOnce.should.be.true;222      driver.adb.goToHome.calledOnce.should.be.true;223      B.delay.calledWithExactly(10000).should.be.true;224      driver.adb.startApp.calledWithExactly(params).should.be.true;225    });226    it('should not bring app back if seconds are negative', async function () {227      sandbox.stub(driver.adb, 'goToHome');228      sandbox.stub(driver.adb, 'startApp');229      await driver.background(-1);230      driver.adb.goToHome.calledOnce.should.be.true;231      driver.adb.startApp.notCalled.should.be.true;232    });233  });234  describe('getStrings', withMocks({helpers}, (mocks) => {235    it('should return app strings', async () => {236      driver.bootstrap.sendAction = () => { return ''; };237      mocks.helpers.expects("pushStrings")238          .returns({test: 'en_value'});239      let strings = await driver.getStrings('en');240      strings.test.should.equal('en_value');241      mocks.helpers.verify();242    });243    it('should return cached app strings for the specified language', async () => {244      driver.adb.getDeviceLanguage = () => { return 'en'; };245      driver.apkStrings.en = {test: 'en_value'};246      driver.apkStrings.fr = {test: 'fr_value'};247      let strings = await driver.getStrings('fr');248      strings.test.should.equal('fr_value');249    });250    it('should return cached app strings for the device language', async () => {251      driver.adb.getDeviceLanguage = () => { return 'en'; };252      driver.apkStrings.en = {test: 'en_value'};253      driver.apkStrings.fr = {test: 'fr_value'};254      let strings = await driver.getStrings();255      strings.test.should.equal('en_value');256    });257  }));258  describe('launchApp', () => {259    it('should init and start app', async () => {260      sandbox.stub(driver, 'initAUT');261      sandbox.stub(driver, 'startAUT');262      await driver.launchApp();263      driver.initAUT.calledOnce.should.be.true;264      driver.startAUT.calledOnce.should.be.true;265    });266  });267  describe('startActivity', () => {268    let params;269    beforeEach(() => {270      params = {pkg: 'pkg', activity: 'act', waitPkg: 'wpkg', waitActivity: 'wact',271                action: 'act', category: 'cat', flags: 'flgs', optionalIntentArguments: 'opt'};272      sandbox.stub(driver.adb, 'startApp');273    });274    it('should start activity', async () => {275      params.optionalIntentArguments = 'opt';276      params.stopApp = false;277      await driver.startActivity('pkg', 'act', 'wpkg', 'wact', 'act',278        'cat', 'flgs', 'opt', true);279      driver.adb.startApp.calledWithExactly(params).should.be.true;280    });281    it('should use dontStopAppOnReset from opts if it is not passed as param', async () => {282      driver.opts.dontStopAppOnReset = true;283      params.stopApp = false;284      await driver.startActivity('pkg', 'act', 'wpkg', 'wact', 'act', 'cat', 'flgs', 'opt');285      driver.adb.startApp.calledWithExactly(params).should.be.true;286    });287    it('should use appPackage and appActivity if appWaitPackage and appWaitActivity are undefined', async () => {288      params.waitPkg = 'pkg';289      params.waitActivity = 'act';290      params.stopApp = true;291      await driver.startActivity('pkg', 'act', null, null, 'act', 'cat', 'flgs', 'opt', false);292      driver.adb.startApp.calledWithExactly(params).should.be.true;293    });294  });295  describe('reset', () => {296    it('should reset app via reinstall if fullReset is true', async () => {297      driver.opts.fullReset = true;298      driver.opts.appPackage = 'pkg';299      sandbox.stub(driver.adb, 'stopAndClear');300      sandbox.stub(driver.adb, 'uninstallApk');301      sandbox.stub(helpers, 'installApkRemotely');302      sandbox.stub(driver, 'grantPermissions');303      sandbox.stub(driver, 'startAUT').returns('aut');304      await driver.reset().should.eventually.be.equal('aut');305      driver.adb.stopAndClear.calledWithExactly('pkg').should.be.true;306      driver.adb.uninstallApk.calledWithExactly('pkg').should.be.true;307      helpers.installApkRemotely.calledWithExactly(driver.adb, driver.opts)308        .should.be.true;309      driver.grantPermissions.calledOnce.should.be.true;310      driver.startAUT.calledOnce.should.be.true;311    });312    it('should do fast reset if fullReset is false', async () => {313      driver.opts.fullReset = false;314      driver.opts.appPackage = 'pkg';315      sandbox.stub(driver.adb, 'stopAndClear');316      sandbox.stub(driver, 'grantPermissions');317      sandbox.stub(driver, 'startAUT').returns('aut');318      await driver.reset().should.eventually.be.equal('aut');319      driver.adb.stopAndClear.calledWithExactly('pkg').should.be.true;320      driver.grantPermissions.calledOnce.should.be.true;321      driver.startAUT.calledOnce.should.be.true;322    });323  });324  describe('startAUT', () => {325    it('should start AUT', async () => {326      driver.opts = {appPackage: 'pkg', appActivity: 'act', intentAction: 'actn',327                     intentCategory: 'cat', intentFlags: 'flgs', appWaitPackage: 'wpkg',328                     appWaitActivity: 'wact', appWaitDuration: 'wdur',329                     optionalIntentArguments: 'opt'};330      let params = {pkg: 'pkg', activity: 'act', action: 'actn', category: 'cat',331                    flags: 'flgs', waitPkg: 'wpkg', waitActivity: 'wact',332                    waitDuration: 'wdur', optionalIntentArguments: 'opt', stopApp: false};333      driver.opts.dontStopAppOnReset = true;334      params.stopApp = false;335      sandbox.stub(driver.adb, 'startApp');336      await driver.startAUT();337      driver.adb.startApp.calledWithExactly(params).should.be.true;338    });339  });340  describe('setUrl', () => {341    it('should set url', async () => {342      driver.opts = {appPackage: 'pkg'};343      sandbox.stub(driver.adb, 'startUri');344      await driver.setUrl('url');345      driver.adb.startUri.calledWithExactly('url', 'pkg').should.be.true;346    });347  });348  describe('closeApp', () => {349    it('should close app', async () => {350      driver.opts = {appPackage: 'pkg'};351      sandbox.stub(driver.adb, 'forceStop');352      await driver.closeApp();353      driver.adb.forceStop.calledWithExactly('pkg').should.be.true;354    });355  });356  describe('getDisplayDensity', () => {357    it('should return the display density of a device', async () => {358      driver.adb.shell = () => { return '123'; };359      (await driver.getDisplayDensity()).should.equal(123);360    });361    it('should return the display density of an emulator', async () => {362      driver.adb.shell = (cmd) => {363        let joinedCmd = cmd.join(' ');364        if (joinedCmd.indexOf('ro.sf') !== -1) {365          // device property look up366          return '';367        } else if (joinedCmd.indexOf('qemu.sf') !== -1) {368          // emulator property look up369          return '456';370        }371        return '';372      };373      (await driver.getDisplayDensity()).should.equal(456);374    });375    it('should throw an error if the display density property can\'t be found', async () => {376      driver.adb.shell = () => { return ''; };377      await driver.getDisplayDensity().should.be.rejectedWith(/Failed to get display density property/);378    });379    it('should throw and error if the display density is not a number', async () => {380      driver.adb.shell = () => { return 'abc'; };381      await driver.getDisplayDensity().should.be.rejectedWith(/Failed to get display density property/);382    });383  });384  describe('parseSurfaceLine', () => {385    it('should return visible true if the surface is visible', async () => {386      parseSurfaceLine('shown=true rect=1 1 1 1').should.be.eql({387        visible: true,388        x: 1,389        y: 1,390        width: 1,391        height: 1392      });393    });394    it('should return visible false if the surface is not visible', async () => {395      parseSurfaceLine('shown=false rect=1 1 1 1').should.be.eql({396        visible: false,397        x: 1,398        y: 1,399        width: 1,400        height: 1401      });402    });403    it('should return the parsed surface bounds', async () => {404      parseSurfaceLine('shown=true rect=(1.0,2.0) 3.0 x 4.0').should.be.eql({405        visible: true,406        x: 1,407        y: 2,408        width: 3,409        height: 4410      });411    });412  });413  // these are used for both parseWindows and getSystemBars tests414  let validWindowOutput = [415    '  Window #1 Derp',416    '    stuff',417    '      Surface: derp shown=false lalalala rect=(9.0,8.0) 7.0 x 6.0',418    '    more stuff',419    '  Window #2 StatusBar',420    '    blah blah blah',421    '      Surface: blah blah shown=true blah blah rect=(1.0,2.0) 3.0 x 4.0',422    '    blah blah blah',423    '  Window #3 NavigationBar',424    '    womp womp',425    '      Surface: blah blah shown=false womp womp rect=(5.0,6.0) 50.0 x 60.0',426    '    qwerty asd zxc'427  ].join('\n');428  let validSystemBars = {429    statusBar: {visible: true, x: 1, y: 2, width: 3, height: 4},430    navigationBar: {visible: false, x: 5, y: 6, width: 50, height: 60}431  };432  describe('parseWindows', () => {433    it('should throw an error if the status bar info wasn\'t found', async () => {434      expect(() => { parseWindows(''); })435        .to.throw(Error, /Failed to parse status bar information./);436    });437    it('should throw an error if the navigation bar info wasn\'t found', async () => {438      let windowOutput = [439        '  Window #1 StatusBar',440        '    blah blah blah',441        '      Surface: blah blah shown=true blah blah rect=(1.0,2.0) 3.0 x 4.0',442        '    blah blah blah'443      ].join('\n');444      expect(() => { parseWindows(windowOutput); })445        .to.throw(Error, /Failed to parse navigation bar information./);446    });447    it('should return status and navigation bar info when both are given', async () => {448      parseWindows(validWindowOutput).should.be.eql(validSystemBars);449    });450  });451  describe('getSystemBars', () => {452    it('should throw an error if there\'s no window manager output', async () => {453      driver = new AndroidDriver();454      driver.adb = {};455      driver.adb.shell = () => { return ''; };456      await driver.getSystemBars().should.be.rejectedWith(/Did not get window manager output./);457    });458    it('should return the parsed system bar info', async () => {459      driver = new AndroidDriver();460      driver.adb = {};461      driver.adb.shell = () => { return validWindowOutput; };462      (await driver.getSystemBars()).should.be.eql(validSystemBars);463    });464  });...

Full Screen

Full Screen

general.js

Source:general.js Github

copy

Full Screen

...89  appPath = await this.helpers.configureApp(appPath, APP_EXTENSION);90  if (!(await fs.exists(appPath))) {91    log.errorAndThrow(`Could not find app apk at ${appPath}`);92  }93  let {apkPackage} = await this.adb.packageAndLaunchActivityFromManifest(appPath);94  let opts = {95    app: appPath,96    appPackage: apkPackage,97    fastReset: this.opts.fastReset98  };99  return androidHelpers.installApkRemotely(this.adb, opts);100};101commands.background = async function (seconds) {102  if (seconds < 0) {103    // if user passes in a negative seconds value, interpret that as the instruction104    // to not bring the app back at all105    await this.adb.goToHome();106    return true;107  }...

Full Screen

Full Screen

android-manifest-e2e-specs.js

Source:android-manifest-e2e-specs.js Github

copy

Full Screen

...21  before(async () => {22    adb = await ADB.createADB();23  });24  it('packageAndLaunchActivityFromManifest should parse package and Activity', async () => {25    let {apkPackage, apkActivity} = await adb.packageAndLaunchActivityFromManifest(contactManagerPath);26    apkPackage.should.equal('com.example.android.contactmanager');27    apkActivity.should.equal('com.example.android.contactmanager.ContactManager');28  });29  it('hasInternetPermissionFromManifest should be true', async () => {30    let flag = await adb.hasInternetPermissionFromManifest(contactMangerSelendroidPath);31    flag.should.be.true;32  });33  it('hasInternetPermissionFromManifest should be false', async () => {34    let flag = await adb.hasInternetPermissionFromManifest(contactManagerPath);35    flag.should.be.false;36  });37  // TODO fix this test38  it.skip('should compile and insert manifest', async () => {39    let appPackage = 'com.example.android.contactmanager',...

Full Screen

Full Screen

android-manifest-specs.js

Source:android-manifest-specs.js Github

copy

Full Screen

...35      mocks.teen_process.expects("exec")36        .once().withExactArgs('dummy_aapt', ['dump', 'badging', localApk])37        .returns({stdout: ` package: name='${dummyPackageName}'38                            launchable-activity: name='${dummyActivityName}'`});39      let {apkPackage, apkActivity} = (await adb.packageAndLaunchActivityFromManifest(localApk));40      apkPackage.should.equal(dummyPackageName);41      apkActivity.should.equal(dummyActivityName);42      mocks.adb.verify();43    });44  }));45  describe('hasInternetPermissionFromManifest', withMocks({adb, teen_process}, (mocks) => {46    it('should correctly parse internet permission from manifest', async () => {47      adb.binaries.aapt = 'dummy_aapt';48      const localApk = 'dummyAPK';49      mocks.adb.expects("initAapt")50        .once().withExactArgs()51              .returns('');52      mocks.teen_process.expects("exec")53        .once().withExactArgs('dummy_aapt', ['dump', 'badging', localApk])...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var opts = {3    desiredCapabilities: {4    }5};6    .remote(opts)7    .init()8    .then(function() {9        return client.packageAndLaunchActivityFromManifest();10    })11    .then(function(activity) {12        console.log(activity);13    })14    .end();15var webdriverio = require('webdriverio');16var opts = {17    desiredCapabilities: {18    }19};20    .remote(opts)21    .init()22    .then(function() {23        return client.getFocusedPackageAndActivity();24    })25    .then(function(activity) {26        console.log(activity);27    })28    .end();29var webdriverio = require('webdriverio');30var opts = {31    desiredCapabilities: {32    }33};34    .remote(opts)35    .init()36    .then(function() {37        return client.getApiLevel();38    })39    .then(function(apiLevel) {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Appium Android Driver', function() {2    it('should launch app', function(done) {3        var desired = {4        };5        driver = wd.promiseChainRemote('localhost', 4723);6            .init(desired)7            .then(function() {8                return driver.packageAndLaunchActivityFromManifest();9            })10            .then(function() {11                return driver.startActivity({12                });13            })14            .fin(function() {15                return driver.quit();16            })17            .done();18    });19});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var adb = require('appium-adb');3var desiredCaps = {4};5var driver = wd.remote("localhost", 4723);6driver.init(desiredCaps, function (err) {7    if (err) {8        console.error("Error initializing driver: " + err);9        return;10    }11    console.log("Driver initialized");12    adb.packageAndLaunchActivityFromManifest("C:/Users/Aditya/AppData/Local/Android/sdk/platform-tools/ApiDemos-debug.apk", function(err, pkg, act) {13        console.log(pkg, act);14    });15});16(function (exports, require, module, __filename, __dirname) { var Q = require('q');17    at Object.<anonymous> (C:\Users\Aditya\AppData\Roaming\npm\node_modules\appium-adb\lib\adb.js:2:10)18    at Module._compile (module.js:456:26)19    at Object.Module._extensions..js (module.js:474:10)20    at Module.load (module.js:356:32)21    at Function.Module._load (module.js:312:12)22    at Module.require (module.js:364:17)23    at require (module.js:380:17)24    at Object.<anonymous> (C:\Users\Aditya\AppData\Roaming\npm\node_modules\appium-adb\lib\android-helpers.js:1:19)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var _ = require('underscore');4var fs = require('fs');5var path = require('path');6var desired = {7};8var driver = wd.promiseChainRemote("localhost", 4723);9driver.on("status", function(info) {10  console.log(info);11});12driver.on("command", function(meth, path, data) {13  console.log(" > " + meth + " " + path + " " + (data || ""));14});15driver.on("http", function(meth, path, data) {16  console.log(" > " + meth + " " + path + " " + (data || ""));17});18  .init(desired)19  .then(function() {20    return driver.packageAndLaunchActivityFromManifest();21  })22  .then(function(data) {23    console.log(data);24  })25  .fin(function() { return driver.quit(); })26  .done();27{ package: 'com.example.test',28  activity: 'com.example.test.MainActivity' }29var wd = require('wd');30var assert = require('assert');31var _ = require('underscore');32var fs = require('fs');33var path = require('path');34var desired = {35};36var driver = wd.promiseChainRemote("localhost", 4723);37driver.on("status", function(info) {38  console.log(info);39});40driver.on("command", function(meth, path, data) {41  console.log(" > " + meth + " " + path + " " + (data || ""));42});43driver.on("http", function(meth, path, data) {44  console.log(" > " + meth + " " + path + " " + (data || ""));45});46  .init(desired)47  .then(function() {48    return driver.packageAndLaunchActivityFromManifest();49  })

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