How to use driver.backgroundApp method in Appium

Best JavaScript code snippet using appium

cuebot-phone-steps.js

Source:cuebot-phone-steps.js Github

copy

Full Screen

1/*2 * Copyright 2020 Jonathan L. Magaru <jonathan.magaru.code@gmail.com>3 * Licensed under the MIT license. See LICENSE.4 *5 * Cuebot - Gherkin Mobile Steps6 */7'use strict';8const { Given, When, Then } = require('cucumber');9const { expect } = require('chai');10const { MobileBuilder } = require('./cuebot-phone');11Given('that I set {string} as platform with version of {string}', async (platform, version) => {12 await MobileBuilder.platform(platform, version);13});14Given('that I set {string} as device', async (deviceName) => {15 await MobileBuilder.deviceName(deviceName);16});17Given('that app is located at {string}', async (appPathOrURL) => {18 await MobileBuilder.appLocation(appPathOrURL);19});20When('I create new session on {string}', async (appiumServer) => {21 if(MobileBuilder.hasApp()) {22 await MobileBuilder.initialize(appiumServer);23 } else {24 return Promise.reject('Application location must be supplied before creating new session.');25 }26});27Then(/^I wait (.*) seconds$/, async (waitTime) => {28 await MobileBuilder.waitFor(waitTime);29});30Then('I capture mobile screen as {string}', async path => {31 await MobileBuilder.capture(path);32});33Then(/^I swipe to the (.*)$/, async direction => {34 await MobileBuilder.swipe(direction);35});36Then('I tap on element with accessibility id of {string}', async id => {37 let target = await MobileBuilder.accessibilityId(id);38 await MobileBuilder.tap(target);39});40Then('I tap on element with xpath of {string}', async id => {41 let target = await MobileBuilder.xpath(id);42 await MobileBuilder.tap(target);43});44Then(/^I tap on (.*), (.*)$/, async (x, y) => {45 await MobileBuilder.tapWithCoordinates(x, y);46});47Then('I set {string} value to element with accessibility id of {string}', async (value, id) => {48 let target = await MobileBuilder.accessibilityId(id);49 await MobileBuilder.text(target, value);50});51Then('I set {string} value to element with xpath of {string}', async (value, id) => {52 let target = await MobileBuilder.xpath(id);53 await MobileBuilder.text(target, value);54});55Then('I expect element with accessibility id of {string} has value {string}', async (id, valueExpect) => {56 let target = await MobileBuilder.accessibilityId(id);57 let value = await MobileBuilder.text(target);58 expect(value).to.eql(valueExpect);59});60Then('I expect element with xpath of {string} has value {string}', async (id, valueExpect) => {61 let target = await MobileBuilder.xpath(id);62 let value = await MobileBuilder.text(target);63 expect(value).to.eql(valueExpect);64});65Then('I expect device keyboard is visible', async () => {66 let deviceDriver = await MobileBuilder.getDriver();67 let isShown = await deviceDriver.isKeyboardShown();68 expect(isShown).to.eql(true);69});70Then('I hide device keyboard', async () => {71 let deviceDriver = await MobileBuilder.getDriver();72 await deviceDriver.hideDeviceKeyboard();73});74Then('I shake the device', async () => {75 let deviceDriver = await MobileBuilder.getDriver();76 await deviceDriver.shake();77});78Then(/^I make the app run in the background and make active after (.*) seconds$/, async (timeout) => {79 let deviceDriver = await MobileBuilder.getDriver();80 await deviceDriver.backgroundApp(MobileBuilder.resolveInt(timeout));81});82Then('I close the session', async () => {83 await MobileBuilder.closeSession();...

Full Screen

Full Screen

application.js

Source:application.js Github

copy

Full Screen

...39 chai.assert.isTrue(await oriantation.isDisplayed(), "LANDSCAPE is not visible");40 await driver.setOrientation("PORTRAIT");41 oriantation = await driver.findElementByText("Portrait", "contains");42 chai.assert.isTrue(await oriantation.isDisplayed(), "Portrait is not visible");43 await driver.backgroundApp(2);44 const suspendSuspendEvent = await driver.findElementByText("The appication was suspended!", "contains");45 chai.assert.isTrue(await suspendSuspendEvent.isDisplayed(), "suspendSuspendEvent is not thrown"); 46 const suspendResumeEvent = await driver.findElementByText("The appication was resumed", "contains");47 chai.assert.isTrue(await suspendResumeEvent.isDisplayed(), "suspendResumeEvent is not thrown"); 48 });49 it(`Check Platform`, async () => {50 const platform = driver.isAndroid ? "Android" : "iOS";51 const batteryIndicator = await driver.findElementByText(`${platform} Applicaiton`, "contains");52 chai.assert.isTrue(await batteryIndicator.isDisplayed(), "Not correct platform!");53 });...

Full Screen

Full Screen

device-specs.js

Source:device-specs.js Github

copy

Full Screen

1"use strict";2var env = require('../../../helpers/env'),3 setup = require("../../common/setup-base"),4 desired = require('./desired');5describe('uicatalog - device @skip-ios7up', function () {6 describe('lock device', function () {7 var driver;8 setup(this, desired).then(function (d) { driver = d; });9 var allowance = env.IOS7 ? 5 : 2;10 it("should lock the device for 4 of seconds (+/- " + allowance + " secs)", function (done) {11 var before = new Date().getTime() / 1000;12 driver13 .lockDevice(4)14 .then(function () {15 var now = (new Date().getTime() / 1000);16 (now - before).should.be.above(4);17 (now - before).should.be.below(4 + allowance + 1);18 }).nodeify(done);19 });20 });21 describe('background app', function () {22 var driver;23 setup(this, desired).then(function (d) { driver = d; });24 it("should background the app for 4 of seconds (+/- 6 secs)", function (done) {25 var before = new Date().getTime() / 1000;26 driver27 .backgroundApp(4)28 .then(function () {29 ((new Date().getTime() / 1000) - before).should.be.below(11);30 }).nodeify(done);31 });32 });...

Full Screen

Full Screen

background-app-specs.js

Source:background-app-specs.js Github

copy

Full Screen

1"use strict";2var setup = require("../../common/setup-base"),3 desired = require('./desired');4describe('uicatalog - background app @skip-ios6', function () {5 var driver;6 setup(this, desired).then(function (d) { driver = d; });7 it("should background the app for 4 of seconds (+/- 6 secs)", function (done) {8 var before = new Date().getTime() / 1000;9 driver10 .backgroundApp(4)11 .then(function () {12 ((new Date().getTime() / 1000) - before).should.be.below(11);13 }).nodeify(done);14 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .pause(2000)9 .backgroundApp(5)10 .end();11var webdriverio = require('webdriverio');12var options = {13 desiredCapabilities: {14 }15};16var client = webdriverio.remote(options);17 .init()18 .pause(2000)19 .backgroundApp(5)20 .end();21var webdriverio = require('webdriverio');22var options = {23 desiredCapabilities: {24 }25};26var client = webdriverio.remote(options);27 .init()28 .pause(2000)29 .backgroundApp(5)30 .end();31var webdriverio = require('webdriverio');32var options = {33 desiredCapabilities: {34 }35};36var client = webdriverio.remote(options);37 .init()38 .pause(2000)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var driver = wd.promiseChainRemote("localhost", 4723);4driver.init({5}).then(function () {6 return driver.backgroundApp(5);7}).then(function () {8 return driver.quit();9});10info: Welcome to Appium v1.3.4 (REV 9d9f2b2a7b7f2f2d1d8b4e4b4f7c2b9d1e8c1b4e)

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Background App', function() {2 it('should put the app in the background', function() {3 driver.backgroundApp(3);4 });5});6describe('Hide Keyboard', function() {7 it('should hide the keyboard', function() {8 driver.hideKeyboard();9 });10});11describe('Lock Device', function() {12 it('should lock the device', function() {13 driver.lock(3);14 });15});16describe('Check if Device is Locked', function() {17 it('should check if the device is locked', function() {18 driver.isLocked();19 });20});21describe('Unlock Device', function() {22 it('should unlock the device', function() {23 driver.unlock();24 });25});26describe('Rotate Device', function() {27 it('should rotate the device', function() {28 driver.rotate('LANDSCAPE');29 });30});31describe('Get Device Orientation', function() {32 it('should get the device orientation', function() {33 driver.getOrientation();34 });35});36describe('Set Device Orientation', function() {37 it('should set the device orientation', function() {38 driver.setOrientation('LANDSCAPE');39 });40});41describe('Get Device Location', function() {42 it('should get the device location', function() {43 driver.getGeoLocation();44 });45});46describe('Set Device Location', function() {47 it('should set the device location', function() {48 driver.setGeoLocation(40.7143528, -74.0059731, 100.12);49 });50});51describe('Get

Full Screen

Using AI Code Generation

copy

Full Screen

1import wd from 'wd';2const {assert} = require('chai');3const config = {4};5describe('Calculator', () => {6 let driver;7 before(async () => {8 await driver.init(config);9 await driver.setImplicitWaitTimeout(5000);10 });11 it('should have the right title', async () => {12 const title = await driver.title();13 assert.equal(title, 'Calculator');14 });15 it('should add two numbers', async () => {16 await driver.backgroundApp(5);17 await driver.elementByAccessibilityId('digit_5').click();18 await driver.elementByAccessibilityId('plus').click();19 await driver.elementByAccessibilityId('digit_9').click();20 await driver.elementByAccessibilityId('equals').click();21 const result = await driver.elementByAccessibilityId('result').text();22 assert.equal(result, '14');23 });24 after(async () => {25 await driver.quit();26 });27});28[HTTP] {"seconds":5}29[W3C (0a7e4f6c)] Driver proxy active, passing request on via HTTP proxy

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.backgroundApp(5);2driver.backgroundApp(10);3driver.backgroundApp(10);4driver.backgroundApp(20);5driver.backgroundApp(30);6driver.backgroundApp(40);7driver.backgroundApp(50);8driver.backgroundApp(60);9driver.backgroundApp(70);10driver.backgroundApp(80);11driver.backgroundApp(90);12driver.backgroundApp(100);13driver.backgroundApp(110);14driver.backgroundApp(120);15driver.backgroundApp(130);16driver.backgroundApp(140);17driver.backgroundApp(150);18driver.backgroundApp(160);19driver.backgroundApp(170);20driver.backgroundApp(180);21driver.backgroundApp(190);22driver.backgroundApp(200);23driver.backgroundApp(210);24driver.backgroundApp(220);25driver.backgroundApp(230);26driver.backgroundApp(240);27driver.backgroundApp(250);28driver.backgroundApp(260);29driver.backgroundApp(270);30driver.backgroundApp(280);31driver.backgroundApp(290);32driver.backgroundApp(300);33driver.backgroundApp(310);34driver.backgroundApp(320);35driver.backgroundApp(330);36driver.backgroundApp(340);37driver.backgroundApp(350);38driver.backgroundApp(360);39driver.backgroundApp(370);40driver.backgroundApp(380);41driver.backgroundApp(390);42driver.backgroundApp(400);43driver.backgroundApp(410);44driver.backgroundApp(420);45driver.backgroundApp(430);46driver.backgroundApp(440);47driver.backgroundApp(450);48driver.backgroundApp(460);49driver.backgroundApp(470);50driver.backgroundApp(480);51driver.backgroundApp(490);52driver.backgroundApp(500);53driver.backgroundApp(510);54driver.backgroundApp(520);55driver.backgroundApp(530);56driver.backgroundApp(540);57driver.backgroundApp(550);58driver.backgroundApp(560);59driver.backgroundApp(570);60driver.backgroundApp(580);61driver.backgroundApp(590);62driver.backgroundApp(600);63driver.backgroundApp(610);64driver.backgroundApp(620);65driver.backgroundApp(630);66driver.backgroundApp(640);67driver.backgroundApp(650);68driver.backgroundApp(660);69driver.backgroundApp(670);70driver.backgroundApp(680);71driver.backgroundApp(690);72driver.backgroundApp(700);73driver.backgroundApp(710);74driver.backgroundApp(720);75driver.backgroundApp(730);76driver.backgroundApp(740);77driver.backgroundApp(750);78driver.backgroundApp(760);79driver.backgroundApp(770);80driver.backgroundApp(780);81driver.backgroundApp(790

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('should set the app to background', function() {3 .backgroundApp(10)4 .then(function() {5 });6 });7});

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.backgroundApp(5);2driver.startActivity("com.android.calculator2", "com.android.calculator2.Calculator");3driver.currentActivity();4driver.currentContext();5driver.getContexts();6driver.getPageSource();7driver.getOrientation();8driver.setOrientation('LANDSCAPE');

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 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