How to use getPackageAndActivity method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

driver-e2e-specs.js

Source:driver-e2e-specs.js Github

copy

Full Screen

...24 return {appPackage, appActivity};25 }26 it('should start android session focusing on default package and activity', async function () {27 await driver.createSession(defaultCaps);28 let {appPackage, appActivity} = await getPackageAndActivity(driver);29 appPackage.should.equal('io.appium.android.apis');30 appActivity.should.equal('.ApiDemos');31 });32 it('should start android session focusing on custom pkg and act', async function () {33 let caps = Object.assign({}, defaultCaps);34 caps.appPackage = 'io.appium.android.apis';35 caps.appActivity = '.view.SplitTouchView';36 await driver.createSession(caps);37 let {appPackage, appActivity} = await getPackageAndActivity(driver);38 appPackage.should.equal(caps.appPackage);39 appActivity.should.equal(caps.appActivity);40 });41 it('should error out for not apk extention', async function () {42 let caps = Object.assign({}, defaultCaps);43 caps.app = 'foo';44 caps.appPackage = 'io.appium.android.apis';45 caps.appActivity = '.view.SplitTouchView';46 await driver.createSession(caps).should.eventually.be.rejectedWith(/does not exist or is not accessible/);47 });48 it('should error out if neither an app or a browser is defined', async function () {49 let caps = Object.assign({}, defaultCaps);50 caps.app = '';51 await driver.createSession(caps).should.eventually.be.rejectedWith(/include/);52 });53 it('should error out for invalid app path', async function () {54 let caps = Object.assign({}, defaultCaps);55 caps.app = 'foo.apk';56 caps.appPackage = 'io.appium.android.apis';57 caps.appActivity = '.view.SplitTouchView';58 await driver.createSession(caps).should.eventually.be.rejectedWith(/Could not find/);59 });60 it('should be able to start session without launching or installing app', async function () {61 let caps = Object.assign({}, defaultCaps);62 caps.appPackage = 'io.appium.android.apis';63 caps.appActivity = '.view.SplitTouchView';64 caps.autoLaunch = false;65 await driver.createSession(caps);66 let {appPackage, appActivity} = await getPackageAndActivity(driver);67 expect(appPackage).to.not.equal(caps.appPackage);68 expect(appActivity).to.not.equal(caps.appActivity);69 });70 it('should be able to launch activity with custom intent parameter category', async function () {71 let caps = Object.assign({}, defaultCaps);72 caps.appPackage = 'io.appium.android.apis';73 caps.appActivity = 'io.appium.android.apis.app.HelloWorld';74 caps.intentCategory = 'appium.android.intent.category.SAMPLE_CODE';75 await driver.createSession(caps);76 let appActivity = await driver.getCurrentActivity();77 appActivity.should.include('HelloWorld');78 });79 it('should be able to load an app via package', async function () {80 let caps = Object.assign({}, defaultCaps);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPackageAndActivity } = require('appium-android-driver');2const { getPackageAndActivity } = require('appium-android-driver');3getPackageAndActivity('com.example.app', 'com.example.app.activity')4getPackageAndActivity('com.example.app', 'com.example.app.activity')5getPackageAndActivity('com.example.app')6getPackageAndActivity('com.example.app')7getPackageAndActivity('com.example.app/.activity')8getPackageAndActivity('com.example.app/.activity')9getPackageAndActivity('com.example.app', 'com.example.app.activity', 'com.example.app.otheractivity')10getPackageAndActivity('com.example.app', 'com.example.app.activity', 'com.example.app.otheractivity')11getPackageAndActivity('/path/to/my.apk')12getPackageAndActivity('/path/to/my.apk')13getPackageAndActivity('com.example.app', '/path/to/my.apk')14getPackageAndActivity('com.example.app', '/path/to/my.apk')15getPackageAndActivity('com.example.app', 'com.example.app.activity', '/path/to/my.apk')16getPackageAndActivity('com

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desiredCaps = {4};5var driver = wd.promiseChainRemote("localhost", 4723);6 .init(desiredCaps)7 .getPackageAndActivity()8 .then(function (pkgAndAct) {9 console.log(pkgAndAct);10 assert.equal(pkgAndAct.package, "com.example.android.contactmanager");11 assert.equal(pkgAndAct.activity, ".ContactManager");12 })13 .fin(function () {14 driver.quit();15 })16 .done();17var wd = require('wd');18var assert = require('assert');19var desiredCaps = {20};21var driver = wd.promiseChainRemote("localhost", 4723);22 .init(desiredCaps)23 .startActivity("com.example.android.contactmanager", ".ContactManager")24 .then(function () {25 return driver.getPackageAndActivity();26 })27 .then(function (pkgAndAct) {28 console.log(pkgAndAct);29 assert.equal(pkgAndAct.package, "com.example.android.contactmanager");30 assert.equal(pkgAndAct.activity, ".ContactManager");31 })32 .fin(function () {33 driver.quit();34 })35 .done();36var wd = require('wd');37var assert = require('assert');38var desiredCaps = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = new AppiumDriver();2driver.getPackageAndActivity();3var driver = new AppiumDriver();4driver.getPackageAndActivity();5var driver = new AppiumDriver();6driver.getPackageAndActivity();7var driver = new AppiumDriver();8driver.getPackageAndActivity();9var driver = new AppiumDriver();10driver.getPackageAndActivity();11var driver = new AppiumDriver();12driver.getPackageAndActivity();13var driver = new AppiumDriver();14driver.getPackageAndActivity();15var driver = new AppiumDriver();16driver.getPackageAndActivity();17var driver = new AppiumDriver();18driver.getPackageAndActivity();19var driver = new AppiumDriver();20driver.getPackageAndActivity();21var driver = new AppiumDriver();22driver.getPackageAndActivity();23var driver = new AppiumDriver();24driver.getPackageAndActivity();25var driver = new AppiumDriver();26driver.getPackageAndActivity();27var driver = new AppiumDriver();28driver.getPackageAndActivity();29var driver = new AppiumDriver();30driver.getPackageAndActivity();31var driver = new AppiumDriver();32driver.getPackageAndActivity();33var driver = new AppiumDriver();34driver.getPackageAndActivity();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require("selenium-webdriver"),2 Appium = require("appium"),3 AppiumAndroidDriver = require("appium-android-driver");4var appium = new Appium();5var driver = new AppiumAndroidDriver(appium);6driver.getPackageAndActivity('com.android.calculator2').then(function(pn){7 console.log(pn);8});9var webdriver = require("selenium-webdriver"),10 Appium = require("appium"),11 AppiumAndroidDriver = require("appium-android-driver");12var appium = new Appium();13var driver = new AppiumAndroidDriver(appium);14driver.getPackageAndActivity('com.android.calculator2').then(function(pn){15 console.log(pn);16});17var webdriver = require("selenium-webdriver"),18 Appium = require("appium"),19 AppiumAndroidDriver = require("appium-android-driver");20var appium = new Appium();21var driver = new AppiumAndroidDriver(appium);22driver.getPackageAndActivity('com.android.calculator2').then(function(pn){23 console.log(pn);24});25at Object.wrappedLogger.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:78:13)26at AndroidDriver.getPackageAndActivity$ (/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/lib/driver.js:169:11)27at tryCatch (/usr/local/lib/node_modules

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 driver = new webdriver.Builder().forBrowser('chrome').build();3var adb = require('adbkit');4var client = adb.createClient();5driver.findElement(By.id("package")).sendKeys("com.android.calculator2");6driver.findElement(By.id("activity")).sendKeys("com.android.calculator2.Calculator");7driver.findElement(By.id("launch")).click();8driver.wait(until.elementLocated(By.id('com.android.calculator2:id/digit_7')), 10000);9driver.findElement(By.id('com.android.calculator2:id/digit_7')).click();10driver.findElement(By.id('com.android.calculator2:id/op_add')).click();11driver.findElement(By.id('com.android.calculator2:id/digit_9')).click();12driver.findElement(By.id('com.android.calculator2:id/eq')).click();13driver.findElement(By.id('com.android.calculator2:id/result')).getText().then(function(text){14 console.log(text);15});16driver.quit();17var webdriver = require('selenium-webdriver'),18 driver = new webdriver.Builder().forBrowser('chrome').build();19var adb = require('adbkit');20var client = adb.createClient();21driver.findElement(By.id("package")).sendKeys("com.android.calculator2");22driver.findElement(By.id("activity")).sendKeys("com.android.calculator2.Calculator");23driver.findElement(By.id("launch")).click();24driver.wait(until.elementLocated(By.id('com.android.calculator2:id/digit_7')), 10000);25driver.findElement(By.id('com.android.calculator2:id/digit_7')).click();26driver.findElement(By.id('com.android.calculator2:id/op_add')).click();27driver.findElement(By.id('com.android.calculator2:id/digit_9')).click();28driver.findElement(By.id('com.android.calculator2:id/eq')).click();29driver.findElement(By.id('com.android.calculator2:id/result')).getText().then(function(text){30 console.log(text);31});32driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = require("appium").androidDriver;2driver.getPackageAndActivity(function(err, packageActivity) {3 console.log("Package Activity: " + packageActivity);4});5var driver = require("appium").iosDriver;6driver.getPackageAndActivity(function(err, packageActivity) {7 console.log("Package Activity: " + packageActivity);8});9var driver = require("appium").windowsDriver;10driver.getPackageAndActivity(function(err, packageActivity) {11 console.log("Package Activity: " + packageActivity);12});

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