How to use driver.adb.getFocusedPackageAndActivity method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

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 '../../../lib/bootstrap';10import B from 'bluebird';11import ADB from 'appium-adb';12chai.should();13chai.use(chaiAsPromised);14let driver;15let sandbox = sinon.createSandbox();16let expect = chai.expect;17describe('General', function () {18 beforeEach(function () {19 driver = new AndroidDriver();20 driver.bootstrap = new Bootstrap();21 driver.adb = new ADB();22 driver.caps = {};23 driver.opts = {};24 });25 afterEach(function () {26 sandbox.restore();27 });28 describe('keys', function () {29 it('should send keys via setText bootstrap command', async function () {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 function () {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', function () {48 it('should return device time', async function () {49 sandbox.stub(driver.adb, 'shell');50 driver.adb.shell.returns(' 2018-06-09T16:21:54+0900 ');51 await driver.getDeviceTime().should.become('2018-06-09T16:21:54+09:00');52 driver.adb.shell.calledWithExactly(['date', '+%Y-%m-%dT%T%z']).should.be.true;53 });54 it('should return device time with custom format', async function () {55 sandbox.stub(driver.adb, 'shell');56 driver.adb.shell.returns(' 2018-06-09T16:21:54+0900 ');57 await driver.getDeviceTime('YYYY-MM-DD').should.become('2018-06-09');58 driver.adb.shell.calledWithExactly(['date', '+%Y-%m-%dT%T%z']).should.be.true;59 });60 it('should throw error if shell command failed', async function () {61 sandbox.stub(driver.adb, 'shell').throws();62 await driver.getDeviceTime().should.be.rejected;63 });64 });65 describe('getPageSource', function () {66 it('should return page source', async function () {67 sandbox.stub(driver.bootstrap, 'sendAction').withArgs('source').returns('sources');68 (await driver.getPageSource()).should.be.equal('sources');69 });70 });71 describe('back', function () {72 it('should press back', async function () {73 sandbox.stub(driver.bootstrap, 'sendAction');74 await driver.back();75 driver.bootstrap.sendAction.calledWithExactly('pressBack').should.be.true;76 });77 });78 describe('isKeyboardShown', function () {79 it('should return true if the keyboard is shown', async function () {80 driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {81 return {isKeyboardShown: true, canCloseKeyboard: true};82 };83 (await driver.isKeyboardShown()).should.equal(true);84 });85 it('should return false if the keyboard is not shown', async function () {86 driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {87 return {isKeyboardShown: false, canCloseKeyboard: true};88 };89 (await driver.isKeyboardShown()).should.equal(false);90 });91 });92 describe('hideKeyboard', function () {93 it('should hide keyboard with ESC command', async function () {94 sandbox.stub(driver.adb, 'keyevent');95 let callIdx = 0;96 driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {97 callIdx++;98 return {99 isKeyboardShown: callIdx <= 1,100 canCloseKeyboard: callIdx <= 1,101 };102 };103 await driver.hideKeyboard().should.eventually.be.fulfilled;104 driver.adb.keyevent.calledWithExactly(111).should.be.true;105 });106 it('should throw if cannot close keyboard', async function () {107 this.timeout(10000);108 sandbox.stub(driver.adb, 'keyevent');109 driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {110 return {111 isKeyboardShown: true,112 canCloseKeyboard: false,113 };114 };115 await driver.hideKeyboard().should.eventually.be.rejected;116 driver.adb.keyevent.notCalled.should.be.true;117 });118 it('should not throw if no keyboard is present', async function () {119 driver.adb.isSoftKeyboardPresent = function isSoftKeyboardPresent () {120 return {121 isKeyboardShown: false,122 canCloseKeyboard: false,123 };124 };125 await driver.hideKeyboard().should.eventually.be.fulfilled;126 });127 });128 describe('openSettingsActivity', function () {129 it('should open settings activity', async function () {130 sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')131 .returns({appPackage: 'pkg', appActivity: 'act'});132 sandbox.stub(driver.adb, 'shell');133 sandbox.stub(driver.adb, 'waitForNotActivity');134 await driver.openSettingsActivity('set1');135 driver.adb.shell.calledWithExactly(['am', 'start', '-a', 'android.settings.set1'])136 .should.be.true;137 driver.adb.waitForNotActivity.calledWithExactly('pkg', 'act', 5000)138 .should.be.true;139 });140 });141 describe('getWindowSize', function () {142 it('should get window size', async function () {143 sandbox.stub(driver.bootstrap, 'sendAction')144 .withArgs('getDeviceSize').returns('size');145 (await driver.getWindowSize()).should.be.equal('size');146 });147 });148 describe('getWindowRect', function () {149 it('should get window size', async function () {150 sandbox.stub(driver.bootstrap, 'sendAction')151 .withArgs('getDeviceSize').returns({width: 300, height: 400});152 const rect = await driver.getWindowRect();153 rect.width.should.be.equal(300);154 rect.height.should.be.equal(400);155 rect.x.should.be.equal(0);156 rect.y.should.be.equal(0);157 });158 });159 describe('getCurrentActivity', function () {160 it('should get current activity', async function () {161 sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')162 .returns({appActivity: 'act'});163 await driver.getCurrentActivity().should.eventually.be.equal('act');164 });165 });166 describe('getCurrentPackage', function () {167 it('should get current activity', async function () {168 sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')169 .returns({appPackage: 'pkg'});170 await driver.getCurrentPackage().should.eventually.equal('pkg');171 });172 });173 describe('isAppInstalled', function () {174 it('should return true if app is installed', async function () {175 sandbox.stub(driver.adb, 'isAppInstalled').withArgs('pkg').returns(true);176 (await driver.isAppInstalled('pkg')).should.be.true;177 });178 });179 describe('removeApp', function () {180 it('should remove app', async function () {181 sandbox.stub(driver.adb, 'uninstallApk').withArgs('pkg').returns(true);182 (await driver.removeApp('pkg')).should.be.true;183 });184 });185 describe('installApp', function () {186 it('should install app', async function () {187 let app = 'app.apk';188 sandbox.stub(driver.helpers, 'configureApp').withArgs(app, '.apk')189 .returns(app);190 sandbox.stub(fs, 'rimraf').returns();191 sandbox.stub(driver.adb, 'install').returns(true);192 await driver.installApp(app);193 driver.helpers.configureApp.calledOnce.should.be.true;194 fs.rimraf.notCalled.should.be.true;195 driver.adb.install.calledOnce.should.be.true;196 });197 it('should throw an error if APK does not exist', async function () {198 await driver.installApp('non/existent/app.apk').should.be199 .rejectedWith(/does not exist or is not accessible/);200 });201 });202 describe('background', function () {203 it('should bring app to background and back', async function () {204 const appPackage = 'wpkg';205 const appActivity = 'wacv';206 driver.opts = {appPackage, appActivity, intentAction: 'act',207 intentCategory: 'cat', intentFlags: 'flgs',208 optionalIntentArguments: 'opt'};209 sandbox.stub(driver.adb, 'goToHome');210 sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')211 .returns({appPackage, appActivity});212 sandbox.stub(B, 'delay');213 sandbox.stub(driver.adb, 'startApp');214 sandbox.stub(driver, 'activateApp');215 await driver.background(10);216 driver.adb.getFocusedPackageAndActivity.calledOnce.should.be.true;217 driver.adb.goToHome.calledOnce.should.be.true;218 B.delay.calledWithExactly(10000).should.be.true;219 driver.activateApp.calledWithExactly(appPackage).should.be.true;220 driver.adb.startApp.notCalled.should.be.true;221 });222 it('should bring app to background and back if started after session init', async function () {223 const appPackage = 'newpkg';224 const appActivity = 'newacv';225 driver.opts = {appPackage: 'pkg', appActivity: 'acv', intentAction: 'act',226 intentCategory: 'cat', intentFlags: 'flgs',227 optionalIntentArguments: 'opt'};228 let params = {pkg: appPackage, activity: appActivity, action: 'act', category: 'cat',229 flags: 'flgs', waitPkg: 'wpkg', waitActivity: 'wacv',230 optionalIntentArguments: 'opt', stopApp: false};231 driver._cachedActivityArgs = {[`${appPackage}/${appActivity}`]: params};232 sandbox.stub(driver.adb, 'goToHome');233 sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')234 .returns({appPackage, appActivity});235 sandbox.stub(B, 'delay');236 sandbox.stub(driver.adb, 'startApp');237 sandbox.stub(driver, 'activateApp');238 await driver.background(10);239 driver.adb.getFocusedPackageAndActivity.calledOnce.should.be.true;240 driver.adb.goToHome.calledOnce.should.be.true;241 B.delay.calledWithExactly(10000).should.be.true;242 driver.adb.startApp.calledWithExactly(params).should.be.true;243 driver.activateApp.notCalled.should.be.true;244 });245 it('should bring app to background and back if waiting for other pkg / activity', async function () { //eslint-disable-line246 const appPackage = 'somepkg';247 const appActivity = 'someacv';248 const appWaitPackage = 'somewaitpkg';249 const appWaitActivity = 'somewaitacv';250 driver.opts = {appPackage, appActivity, appWaitPackage, appWaitActivity,251 intentAction: 'act', intentCategory: 'cat',252 intentFlags: 'flgs', optionalIntentArguments: 'opt',253 stopApp: false};254 sandbox.stub(driver.adb, 'goToHome');255 sandbox.stub(driver.adb, 'getFocusedPackageAndActivity')256 .returns({appPackage: appWaitPackage, appActivity: appWaitActivity});257 sandbox.stub(B, 'delay');258 sandbox.stub(driver.adb, 'startApp');259 sandbox.stub(driver, 'activateApp');260 await driver.background(10);261 driver.adb.getFocusedPackageAndActivity.calledOnce.should.be.true;262 driver.adb.goToHome.calledOnce.should.be.true;263 B.delay.calledWithExactly(10000).should.be.true;264 driver.activateApp.calledWithExactly(appWaitPackage).should.be.true;265 driver.adb.startApp.notCalled.should.be.true;266 });267 it('should not bring app back if seconds are negative', async function () {268 sandbox.stub(driver.adb, 'goToHome');269 sandbox.stub(driver.adb, 'startApp');270 await driver.background(-1);271 driver.adb.goToHome.calledOnce.should.be.true;272 driver.adb.startApp.notCalled.should.be.true;273 });274 });275 describe('getStrings', withMocks({helpers}, (mocks) => {276 it('should return app strings', async function () {277 driver.bootstrap.sendAction = () => '';278 mocks.helpers.expects('pushStrings')279 .returns({test: 'en_value'});280 let strings = await driver.getStrings('en');281 strings.test.should.equal('en_value');282 mocks.helpers.verify();283 });284 it('should return cached app strings for the specified language', async function () {285 driver.adb.getDeviceLanguage = () => 'en';286 driver.apkStrings.en = {test: 'en_value'};287 driver.apkStrings.fr = {test: 'fr_value'};288 let strings = await driver.getStrings('fr');289 strings.test.should.equal('fr_value');290 });291 it('should return cached app strings for the device language', async function () {292 driver.adb.getDeviceLanguage = () => 'en';293 driver.apkStrings.en = {test: 'en_value'};294 driver.apkStrings.fr = {test: 'fr_value'};295 let strings = await driver.getStrings();296 strings.test.should.equal('en_value');297 });298 }));299 describe('launchApp', function () {300 it('should init and start app', async function () {301 sandbox.stub(driver, 'initAUT');302 sandbox.stub(driver, 'startAUT');303 await driver.launchApp();304 driver.initAUT.calledOnce.should.be.true;305 driver.startAUT.calledOnce.should.be.true;306 });307 });308 describe('startActivity', function () {309 let params;310 beforeEach(function () {311 params = {pkg: 'pkg', activity: 'act', waitPkg: 'wpkg', waitActivity: 'wact',312 action: 'act', category: 'cat', flags: 'flgs', optionalIntentArguments: 'opt'};313 sandbox.stub(driver.adb, 'startApp');314 });315 it('should start activity', async function () {316 params.optionalIntentArguments = 'opt';317 params.stopApp = false;318 await driver.startActivity('pkg', 'act', 'wpkg', 'wact', 'act',319 'cat', 'flgs', 'opt', true);320 driver.adb.startApp.calledWithExactly(params).should.be.true;321 });322 it('should use dontStopAppOnReset from opts if it is not passed as param', async function () {323 driver.opts.dontStopAppOnReset = true;324 params.stopApp = false;325 await driver.startActivity('pkg', 'act', 'wpkg', 'wact', 'act', 'cat', 'flgs', 'opt');326 driver.adb.startApp.calledWithExactly(params).should.be.true;327 });328 it('should use appPackage and appActivity if appWaitPackage and appWaitActivity are undefined', async function () {329 params.waitPkg = 'pkg';330 params.waitActivity = 'act';331 params.stopApp = true;332 await driver.startActivity('pkg', 'act', null, null, 'act', 'cat', 'flgs', 'opt', false);333 driver.adb.startApp.calledWithExactly(params).should.be.true;334 });335 });336 describe('reset', function () {337 it('should reset app via reinstall if fullReset is true', async function () {338 driver.opts.fullReset = true;339 driver.opts.appPackage = 'pkg';340 sandbox.stub(driver, 'startAUT').returns('aut');341 sandbox.stub(helpers, 'resetApp').returns(undefined);342 await driver.reset().should.eventually.be.equal('aut');343 helpers.resetApp.calledWith(driver.adb).should.be.true;344 driver.startAUT.calledOnce.should.be.true;345 });346 it('should do fast reset if fullReset is false', async function () {347 driver.opts.fullReset = false;348 driver.opts.appPackage = 'pkg';349 sandbox.stub(helpers, 'resetApp').returns(undefined);350 sandbox.stub(driver, 'startAUT').returns('aut');351 await driver.reset().should.eventually.be.equal('aut');352 helpers.resetApp.calledWith(driver.adb).should.be.true;353 driver.startAUT.calledOnce.should.be.true;354 expect(driver.curContext).to.eql('NATIVE_APP');355 });356 });357 describe('startAUT', function () {358 it('should start AUT', async function () {359 driver.opts = {360 appPackage: 'pkg',361 appActivity: 'act',362 intentAction: 'actn',363 intentCategory: 'cat',364 intentFlags: 'flgs',365 appWaitPackage: 'wpkg',366 appWaitActivity: 'wact',367 appWaitForLaunch: true,368 appWaitDuration: 'wdur',369 optionalIntentArguments: 'opt',370 userProfile: 1371 };372 let params = {373 pkg: 'pkg',374 activity: 'act',375 action: 'actn',376 category: 'cat',377 flags: 'flgs',378 waitPkg: 'wpkg',379 waitActivity: 'wact',380 waitForLaunch: true,381 waitDuration: 'wdur',382 optionalIntentArguments: 'opt',383 stopApp: false,384 user: 1385 };386 driver.opts.dontStopAppOnReset = true;387 params.stopApp = false;388 sandbox.stub(driver.adb, 'startApp');389 await driver.startAUT();390 driver.adb.startApp.calledWithExactly(params).should.be.true;391 });392 });393 describe('setUrl', function () {394 it('should set url', async function () {395 driver.opts = {appPackage: 'pkg'};396 sandbox.stub(driver.adb, 'startUri');397 await driver.setUrl('url');398 driver.adb.startUri.calledWithExactly('url', 'pkg').should.be.true;399 });400 });401 describe('closeApp', function () {402 it('should close app', async function () {403 driver.opts = {appPackage: 'pkg'};404 sandbox.stub(driver.adb, 'forceStop');405 await driver.closeApp();406 driver.adb.forceStop.calledWithExactly('pkg').should.be.true;407 });408 });409 describe('getDisplayDensity', function () {410 it('should return the display density of a device', async function () {411 driver.adb.shell = () => '123';412 (await driver.getDisplayDensity()).should.equal(123);413 });414 it('should return the display density of an emulator', async function () {415 driver.adb.shell = (cmd) => {416 let joinedCmd = cmd.join(' ');417 if (joinedCmd.indexOf('ro.sf') !== -1) {418 // device property look up419 return '';420 } else if (joinedCmd.indexOf('qemu.sf') !== -1) {421 // emulator property look up422 return '456';423 }424 return '';425 };426 (await driver.getDisplayDensity()).should.equal(456);427 });428 it('should throw an error if the display density property can\'t be found', async function () {429 driver.adb.shell = () => '';430 await driver.getDisplayDensity().should.be.rejectedWith(/Failed to get display density property/);431 });432 it('should throw and error if the display density is not a number', async function () {433 driver.adb.shell = () => 'abc';434 await driver.getDisplayDensity().should.be.rejectedWith(/Failed to get display density property/);435 });436 });437 describe('parseSurfaceLine', function () {438 it('should return visible true if the surface is visible', function () {439 parseSurfaceLine('shown=true rect=1 1 1 1').should.be.eql({440 visible: true,441 x: 1,442 y: 1,443 width: 1,444 height: 1445 });446 });447 it('should return visible false if the surface is not visible', function () {448 parseSurfaceLine('shown=false rect=1 1 1 1').should.be.eql({449 visible: false,450 x: 1,451 y: 1,452 width: 1,453 height: 1454 });455 });456 it('should return the parsed surface bounds', function () {457 parseSurfaceLine('shown=true rect=(1.0,2.0) 3.0 x 4.0').should.be.eql({458 visible: true,459 x: 1,460 y: 2,461 width: 3,462 height: 4463 });464 });465 });466 // these are used for both parseWindows and getSystemBars tests467 let validWindowOutput = [468 ' Window #1 Derp',469 ' stuff',470 ' Surface: derp shown=false lalalala rect=(9.0,8.0) 7.0 x 6.0',471 ' more stuff',472 ' Window #2 StatusBar',473 ' blah blah blah',474 ' Surface: blah blah shown=true blah blah rect=(1.0,2.0) 3.0 x 4.0',475 ' blah blah blah',476 ' Window #3 NavigationBar',477 ' womp womp',478 ' Surface: blah blah shown=false womp womp rect=(5.0,6.0) 50.0 x 60.0',479 ' qwerty asd zxc'480 ].join('\n');481 let validSystemBars = {482 statusBar: {visible: true, x: 1, y: 2, width: 3, height: 4},483 navigationBar: {visible: false, x: 5, y: 6, width: 50, height: 60}484 };485 describe('parseWindows', function () {486 it('should throw an error if the status bar info wasn\'t found', function () {487 expect(() => { parseWindows(''); })488 .to.throw(Error, /Failed to parse status bar information./);489 });490 it('should throw an error if the navigation bar info wasn\'t found', function () {491 let windowOutput = [492 ' Window #1 StatusBar',493 ' blah blah blah',494 ' Surface: blah blah shown=true blah blah rect=(1.0,2.0) 3.0 x 4.0',495 ' blah blah blah'496 ].join('\n');497 expect(() => { parseWindows(windowOutput); })498 .to.throw(Error, /Failed to parse navigation bar information./);499 });500 it('should return status and navigation bar info when both are given', function () {501 parseWindows(validWindowOutput).should.be.eql(validSystemBars);502 });503 });504 describe('getSystemBars', function () {505 it('should throw an error if there\'s no window manager output', async function () {506 driver = new AndroidDriver();507 driver.adb = {};508 driver.adb.shell = () => '';509 await driver.getSystemBars().should.be.rejectedWith(/Did not get window manager output./);510 });511 it('should return the parsed system bar info', async function () {512 driver = new AndroidDriver();513 driver.adb = {};514 driver.adb.shell = () => validWindowOutput;515 (await driver.getSystemBars()).should.be.eql(validSystemBars);516 });517 });...

Full Screen

Full Screen

general-e2e-specs.js

Source:general-e2e-specs.js Github

copy

Full Screen

...14 after(async function () {15 await driver.deleteSession();16 });17 it('should launch a new package and activity', async function () {18 let {appPackage, appActivity} = await driver.adb.getFocusedPackageAndActivity();19 appPackage.should.equal('io.appium.android.apis');20 appActivity.should.equal('.ApiDemos');21 let startAppPackage = 'io.appium.android.apis';22 let startAppActivity = '.view.SplitTouchView';23 await driver.startActivity(startAppPackage, startAppActivity);24 let {appPackage: newAppPackage, appActivity: newAppActivity} = await driver.adb.getFocusedPackageAndActivity();25 newAppPackage.should.equal(startAppPackage);26 newAppActivity.should.equal(startAppActivity);27 });28 it('should be able to launch activity with custom intent parameter category', async function () {29 let startAppPackage = 'io.appium.android.apis';30 let startAppActivity = 'io.appium.android.apis.app.HelloWorld';31 let startIntentCategory = 'appium.android.intent.category.SAMPLE_CODE';32 await driver.startActivity(startAppPackage, startAppActivity, undefined, undefined, startIntentCategory);33 let {appActivity} = await driver.adb.getFocusedPackageAndActivity();34 appActivity.should.include('HelloWorld');35 });36 it('should be able to launch activity with dontStopAppOnReset = true', async function () {37 let startAppPackage = 'io.appium.android.apis';38 let startAppActivity = '.os.MorseCode';39 await driver.startActivity(startAppPackage, startAppActivity,40 startAppPackage, startAppActivity,41 undefined, undefined,42 undefined, undefined,43 true);44 let {appPackage, appActivity} = await driver.adb.getFocusedPackageAndActivity();45 appPackage.should.equal(startAppPackage);46 appActivity.should.equal(startAppActivity);47 });48 it('should be able to launch activity with dontStopAppOnReset = false', async function () {49 let startAppPackage = 'io.appium.android.apis';50 let startAppActivity = '.os.MorseCode';51 await driver.startActivity(startAppPackage, startAppActivity,52 startAppPackage, startAppActivity,53 undefined, undefined,54 undefined, undefined,55 false);56 let {appPackage, appActivity} = await driver.adb.getFocusedPackageAndActivity();57 appPackage.should.equal(startAppPackage);58 appActivity.should.equal(startAppActivity);59 });60 });61 describe('getStrings', function () {62 before(async function () {63 driver = new AndroidDriver();64 await driver.createSession(CONTACT_MANAGER_CAPS);65 });66 after(async function () {67 await driver.deleteSession();68 });69 it('should return app strings', async function () {70 let strings = await driver.getStrings('en');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = new wd.Builder()2 .withCapabilities({3 })4 .build();5driver.adb.getFocusedPackageAndActivity(function(err, activity) {6 console.log('current activity is', activity);7 driver.quit();8});9var driver = new wd.Builder()10 .withCapabilities({11 })12 .build();13driver.adb.getFocusedPackageAndActivity(function(err, activity) {14 console.log('current activity is', activity);15 driver.quit();16});17var driver = new wd.Builder()18 .withCapabilities({19 })20 .build();21driver.adb.getFocusedPackageAndActivity(function(err, activity) {22 console.log('current activity is', activity);23 driver.quit();24});25var driver = new wd.Builder()26 .withCapabilities({27 })

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.adb.getFocusedPackageAndActivity().then(function (activity) {2 console.log("Activity is " + activity);3});4driver.adb.getFocusedPackageAndActivity().then(function (package) {5 console.log("Package is " + package);6});7driver.adb.getFocusedPackageAndActivity().then(function (activity) {8 console.log("Activity is " + activity);9});10driver.adb.getFocusedPackageAndActivity().then(function (package) {11 console.log("Package is " + package);12});13driver.adb.getFocusedPackageAndActivity().then(function (activity) {14 console.log("Activity is " + activity);15});16driver.adb.getFocusedPackageAndActivity().then(function (package) {17 console.log("Package is " + package);18});19driver.adb.getFocusedPackageAndActivity().then(function (activity) {20 console.log("Activity is " + activity);21});22driver.adb.getFocusedPackageAndActivity().then(function (package) {23 console.log("Package is " + package);24});25driver.adb.getFocusedPackageAndActivity().then(function (activity) {26 console.log("Activity is " + activity);27});28driver.adb.getFocusedPackageAndActivity().then(function (package) {29 console.log("Package is " + package);30});31driver.adb.getFocusedPackageAndActivity().then(function (activity) {32 console.log("Activity is " + activity);33});34driver.adb.getFocusedPackageAndActivity().then(function (package) {35 console.log("Package is " + package);36});37driver.adb.getFocusedPackageAndActivity().then(function (activity) {38 console.log("Activity is " + activity);39});40driver.adb.getFocusedPackageAndActivity().then(function (package) {41 console.log("Package is " + package);42});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd'),2 assert = require('assert'),3 androidDriver = require('appium-android-driver'),4 logger = require('appium-android-driver').logger,5 _ = require('lodash'),6 Q = require('q'),7 fs = require('fs');8logger.debug("Starting Android Driver");9var driver = new AppiumAndroidDriver({10 adb: new ADB(),11});12logger.debug("Starting Android Driver");13driver.adb.getFocusedPackageAndActivity().then(function (activity) {14 console.log("Activity: " + activity);15}).done();16Error: TypeError: Cannot read property 'getFocusedPackageAndActivity' of undefined at Object.<anonymous> (/Users/xyz/test.js:32:40) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:929:317var wd = require('wd'),18 assert = require('assert'),19 androidDriver = require('appium-android-driver'),20 logger = require('appium-android-driver').logger,21 _ = require('lodash'),22 Q = require('q'),23 fs = require('fs');24logger.debug("Starting Android Driver");

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = require('appium-android-driver').AndroidDriver;2var desiredCaps = {3};4driver.createSession(desiredCaps).then(function (driver) {5 driver.adb.getFocusedPackageAndActivity().then(function (currentPackageActivity) {6 console.log(currentPackageActivity);7 });8});9var driver = require('appium-android-driver').AndroidDriver;10var desiredCaps = {11};12driver.createSession(desiredCaps).then(function (driver) {13 driver.adb.getFocusedPackageAndActivity().then(function (currentPackageActivity) {14 console.log(currentPackageActivity);15 });16});17var driver = require('appium-android-driver').AndroidDriver;18var desiredCaps = {19};20driver.createSession(desiredCaps).then(function (driver) {21 driver.adb.getFocusedPackageAndActivity().then(function (currentPackageActivity) {22 console.log(currentPackageActivity);23 });24});25var driver = require('appium-android-driver').AndroidDriver;26var desiredCaps = {27};28driver.createSession(desiredCaps).then

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var driver = wd.promiseChainRemote("localhost", 4723);3var desired = {4};5driver.init(desired).then(function() {6 return driver.adb.getFocusedPackageAndActivity();7}).then(function (activity) {8 console.log("Current activity: " + activity);9 return driver.quit();10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require("wd");2var asserters = wd.asserters;3var Q = require('q');4var _ = require('underscore');5var fs = require('fs');6var path = require('path');7var desired = {8};9var driver = wd.promiseChainRemote("

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