How to use driver.backgroundApp method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

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 webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .forBrowser('selenium')4 .build();5driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');6driver.findElement(webdriver.By.name('btnG')).click();7driver.sleep(5000).then(function() {8 driver.getTitle().then(function(title) {9 if(title === 'webdriver - Google Search') {10 console.log('Test passed');11 } else {12 console.log('Test failed');13 }14 });15});16driver.backgroundApp(5).then(function() {17 driver.getTitle().then(function(title) {18 if(title === 'Google') {19 console.log('Test passed');20 } else {21 console.log('Test failed');22 }23 });24});25driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Appium Xcuitest Driver', function() {2 it('should background app', async function() {3 await driver.backgroundApp(3);4 });5});6describe('Appium XCUITest Driver', function() {7 it('should background app', async function() {8 await driver.backgroundApp(3);9 });10});11describe('Appium XCUITest Driver', function() {12 it('should background app', async function() {13 await driver.backgroundApp(3);14 });15});16describe('Appium XCUITest Driver', function() {17 it('should background app', async function() {18 await driver.backgroundApp(3);19 });20});21describe('Appium XCUITest Driver', function() {22 it('should background app', async function() {23 await driver.backgroundApp(3);24 });25});26describe('Appium XCUITest Driver', function() {27 it('should background app', async function() {28 await driver.backgroundApp(3);29 });30});31describe('Appium XCUITest Driver', function() {32 it('should background app', async function() {33 await driver.backgroundApp(3);34 });35});36describe('Appium XCUITest Driver', function() {37 it('should background app', async function() {38 await driver.backgroundApp(3);39 });40});41describe('Appium XCUITest Driver', function() {42 it('should background app', async function() {43 await driver.backgroundApp(3);44 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var asserters = wd.asserters;3var chai = require('chai');4var chaiAsPromised = require('chai-as-promised');5var should = chai.should();6var expect = chai.expect;7var Q = require('q');8var fs = require('fs');9chai.use(chaiAsPromised);

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test Appium Xcuitest Driver backgroundApp method', function () {2 it('should background the app', async function () {3 await driver.backgroundApp(3);4 });5});6[debug] [BaseDriver] Event 'newSessionStarted' logged at 1516785699445 (12:28:19 GMT-0500 (EST))7 at JWProxy.command$ (../../../lib/proxy.js:137:13)8 at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)9 at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)10 at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)11 at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)12 at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:155:20)

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Appium XCUITest Driver test', function() {2 it('should put app in background', function() {3 driver.backgroundApp(10);4 });5});6exports.config = {7 capabilities: [{8 }],9 mochaOpts: {10 }11};

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require("webdriverio");2const assert = require('assert');3const opts = {4 capabilities: {5 }6};7async function main () {8 const client = await wdio.remote(opts);9 const context = await client.getContext();10 console.log("Current context: " + context);11 const activity = await client.getCurrentActivity();12 console.log("Current activity: " + activity);13 const package = await client.getCurrentPackage();14 console.log("Current package: " + package);15 await client.backgroundApp(2);16 const context2 = await client.getContext();17 console.log("Current context: " + context2);18 const activity2 = await client.getCurrentActivity();19 console.log("Current activity: " + activity2);20 const package2 = await client.getCurrentPackage();21 console.log("Current package: " + package2);22 assert.strictEqual(context, context2);23 assert.strictEqual(activity, activity2);24 assert.strictEqual(package, package2);25 await client.deleteSession();26}27main();

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 Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful