How to use this.helpers.configureApp method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

driver.js

Source:driver.js Github

copy

Full Screen

...132 this.opts.app = null;133 }134 if (this.opts.app) {135 // find and copy, or download and unzip an app url or path136 this.opts.app = await this.helpers.configureApp(this.opts.app, APP_EXTENSION);137 await this.checkAppPresent();138 } else if (this.appOnDevice) {139 // the app isn't an actual app file but rather something we want to140 // assume is on the device and just launch via the appPackage141 log.info(`App file was not listed, instead we're going to run ` +142 `${this.opts.appPackage} directly on the device`);143 await this.checkPackagePresent();144 }145 // Some cloud services using appium launch the avd themselves, so we ensure netspeed146 // is set for emulators by calling adb.networkSpeed before running the app147 if (util.hasValue(this.opts.networkSpeed)) {148 if (!this.isEmulator()) {149 log.warn('Sorry, networkSpeed capability is only available for emulators');150 } else {151 const networkSpeed = ensureNetworkSpeed(this.adb, this.opts.networkSpeed);152 await this.adb.networkSpeed(networkSpeed);153 }154 }155 // check if we have to enable/disable gps before running the application156 if (util.hasValue(this.opts.gpsEnabled)) {157 if (this.isEmulator()) {158 log.info(`Trying to ${this.opts.gpsEnabled ? 'enable' : 'disable'} gps location provider`);159 await this.adb.toggleGPSLocationProvider(this.opts.gpsEnabled);160 } else {161 log.warn('Sorry! gpsEnabled capability is only available for emulators');162 }163 }164 await this.startAndroidSession(this.opts);165 return [sessionId, this.caps];166 } catch (e) {167 // ignoring delete session exception if any and throw the real error168 // that happened while creating the session.169 try {170 await this.deleteSession();171 } catch (ign) {}172 throw e;173 }174 }175 isEmulator () {176 return helpers.isEmulator(this.adb, this.opts);177 }178 setAvdFromCapabilities (caps) {179 if (this.opts.avd) {180 log.info('avd name defined, ignoring device name and platform version');181 } else {182 if (!caps.deviceName) {183 log.errorAndThrow('avd or deviceName should be specified when reboot option is enables');184 }185 if (!caps.platformVersion) {186 log.errorAndThrow('avd or platformVersion should be specified when reboot option is enabled');187 }188 let avdDevice = caps.deviceName.replace(/[^a-zA-Z0-9_.]/g, '-');189 this.opts.avd = `${avdDevice}__${caps.platformVersion}`;190 }191 }192 get appOnDevice () {193 return this.helpers.isPackageOrBundle(this.opts.app) || (!this.opts.app &&194 this.helpers.isPackageOrBundle(this.opts.appPackage));195 }196 get isChromeSession () {197 return helpers.isChromeBrowser(this.opts.browserName);198 }199 async onSettingsUpdate (key, value) {200 if (key === 'ignoreUnimportantViews') {201 await this.setCompressedLayoutHierarchy(value);202 }203 }204 async startAndroidSession () {205 log.info(`Starting Android session`);206 // set up the device to run on (real or emulator, etc)207 this.defaultIME = await helpers.initDevice(this.adb, this.opts);208 // set actual device name, udid, platform version, screen size, model and manufacturer details.209 this.caps.deviceName = this.adb.curDeviceId;210 this.caps.deviceUDID = this.opts.udid;211 this.caps.platformVersion = await this.adb.getPlatformVersion();212 this.caps.deviceScreenSize = await this.adb.getScreenSize();213 this.caps.deviceModel = await this.adb.getModel();214 this.caps.deviceManufacturer = await this.adb.getManufacturer();215 if (this.opts.disableWindowAnimation) {216 if (await this.adb.isAnimationOn()) {217 if (await this.adb.getApiLevel() >= 28) { // API level 28 is Android P218 // Don't forget to reset the relaxing in delete session219 log.warn('Relaxing hidden api policy to manage animation scale');220 await this.adb.setHiddenApiPolicy('1', !!this.opts.ignoreHiddenApiPolicyError);221 }222 log.info('Disabling window animation as it is requested by "disableWindowAnimation" capability');223 await this.adb.setAnimationState(false);224 this._wasWindowAnimationDisabled = true;225 } else {226 log.info('Window animation is already disabled');227 }228 }229 // If the user sets autoLaunch to false, they are responsible for initAUT() and startAUT()230 if (this.opts.autoLaunch) {231 // set up app under test232 await this.initAUT();233 }234 // start UiAutomator235 this.bootstrap = new helpers.bootstrap(this.adb, this.opts.bootstrapPort, this.opts.websocket);236 await this.bootstrap.start(this.opts.appPackage, this.opts.disableAndroidWatchers, this.opts.acceptSslCerts);237 // handling unexpected shutdown238 this.bootstrap.onUnexpectedShutdown.catch(async (err) => { // eslint-disable-line promise/prefer-await-to-callbacks239 if (!this.bootstrap.ignoreUnexpectedShutdown) {240 await this.startUnexpectedShutdown(err);241 }242 });243 if (!this.opts.skipUnlock) {244 // Let's try to unlock the device245 await helpers.unlock(this, this.adb, this.caps);246 }247 // Set CompressedLayoutHierarchy on the device based on current settings object248 // this has to happen _after_ bootstrap is initialized249 if (this.opts.ignoreUnimportantViews) {250 await this.settings.update({ignoreUnimportantViews: this.opts.ignoreUnimportantViews});251 }252 if (this.isChromeSession) {253 // start a chromedriver session and proxy to it254 await this.startChromeSession();255 } else {256 if (this.opts.autoLaunch) {257 // start app258 await this.startAUT();259 }260 }261 if (util.hasValue(this.opts.orientation)) {262 log.debug(`Setting initial orientation to '${this.opts.orientation}'`);263 await this.setOrientation(this.opts.orientation);264 }265 await this.initAutoWebview();266 }267 async initAutoWebview () {268 if (this.opts.autoWebview) {269 let viewName = this.defaultWebviewName();270 let timeout = (this.opts.autoWebviewTimeout) || 2000;271 log.info(`Setting auto webview to context '${viewName}' with timeout ${timeout}ms`);272 // try every 500ms until timeout is over273 await retryInterval(timeout / 500, 500, async () => {274 await this.setContext(viewName);275 });276 }277 }278 async initAUT () {279 // populate appPackage, appActivity, appWaitPackage, appWaitActivity,280 // and the device being used281 // in the opts and caps (so it gets back to the user on session creation)282 let launchInfo = await helpers.getLaunchInfo(this.adb, this.opts);283 Object.assign(this.opts, launchInfo);284 Object.assign(this.caps, launchInfo);285 // Uninstall any uninstallOtherPackages which were specified in caps286 if (this.opts.uninstallOtherPackages) {287 helpers.validateDesiredCaps(this.opts);288 // Only SETTINGS_HELPER_PKG_ID package is used by UIA1289 await helpers.uninstallOtherPackages(290 this.adb,291 helpers.parseArray(this.opts.uninstallOtherPackages),292 [SETTINGS_HELPER_PKG_ID]293 );294 }295 // Install any "otherApps" that were specified in caps296 if (this.opts.otherApps) {297 let otherApps;298 try {299 otherApps = helpers.parseArray(this.opts.otherApps);300 } catch (e) {301 log.errorAndThrow(`Could not parse "otherApps" capability: ${e.message}`);302 }303 otherApps = await B.all(otherApps.map((app) => this.helpers.configureApp(app, APP_EXTENSION)));304 await helpers.installOtherApks(otherApps, this.adb, this.opts);305 }306 // install app307 if (!this.opts.app) {308 if (this.opts.fullReset) {309 log.errorAndThrow('Full reset requires an app capability, use fastReset if app is not provided');310 }311 log.debug('No app capability. Assuming it is already on the device');312 if (this.opts.fastReset) {313 await helpers.resetApp(this.adb, this.opts);314 }315 return;316 }317 if (!this.opts.skipUninstall) {...

Full Screen

Full Screen

actions.js

Source:actions.js Github

copy

Full Screen

...229 return result;230}231commands.mobileInstallApp = async function (opts = {}) {232 const {app} = extractMandatoryOptions(opts, ['app']);233 const dstPath = await this.helpers.configureApp(app, '.app');234 log.info(`Installing '${dstPath}' to the ${this.isRealDevice() ? 'real device' : 'Simulator'} ` +235 `with UDID ${this.opts.device.udid}`);236 if (!await fs.exists(dstPath)) {237 log.errorAndThrow(`The application at '${dstPath}' does not exist or is not accessible`);238 }239 try {240 await this.opts.device.installApp(dstPath);241 log.info(`Installation of '${dstPath}' succeeded`);242 } finally {243 if (dstPath !== app) {244 await fs.rimraf(dstPath);245 }246 }247};...

Full Screen

Full Screen

general.js

Source:general.js Github

copy

Full Screen

...85commands.removeApp = function (appPackage) {86 return this.adb.uninstallApk(appPackage);87};88commands.installApp = async function (appPath) {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 instruction...

Full Screen

Full Screen

xctest.js

Source:xctest.js Github

copy

Full Screen

...203 `must be a string. Found '${xctestApp}'`);204 }205 xctestLog.info(`Installing bundle '${xctestApp}'`);206 const idb = assertIDB(this.opts);207 const res = await this.helpers.configureApp(xctestApp, '.xctest');208 await idb.installXCTestBundle(res);209};210/**211 * List XCTest bundles that are installed on device212 *213 * @returns {Array<string>} List of XCTest bundles (e.g.: "XCTesterAppUITests.XCTesterAppUITests/testLaunchPerformance")214 */215commands.mobileListXCTestBundles = async function listXCTestsInTestBundle () {216 return await assertIDB(this.opts).listXCTestBundles();217};218/**219 * @typedef {Object} ListXCTestsOpts220 *221 * @property {!string} bundle Bundle ID of the XCTest...

Full Screen

Full Screen

app-management.js

Source:app-management.js Github

copy

Full Screen

...14 return result;15}16commands.mobileInstallApp = async function (opts = {}) {17 const {app} = extractMandatoryOptions(opts, ['app']);18 const dstPath = await this.helpers.configureApp(app, '.app');19 log.info(`Installing '${dstPath}' to the ${this.isRealDevice() ? 'real device' : 'Simulator'} ` +20 `with UDID ${this.opts.device.udid}`);21 if (!await fs.exists(dstPath)) {22 log.errorAndThrow(`The application at '${dstPath}' does not exist or is not accessible`);23 }24 try {25 await this.opts.device.installApp(dstPath);26 log.info(`Installation of '${dstPath}' succeeded`);27 } finally {28 if (dstPath !== app) {29 await fs.rimraf(dstPath);30 }31 }32};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { AppiumDriver, createDriver } = require('appium-base-driver');2const XCUITestDriver = require('appium-xcuitest-driver');3const { configureApp } = require('appium-xcuitest-driver/lib/utils');4const driver = createDriver(XCUITestDriver, {5});6const app = await configureApp(driver.caps.app, driver.caps.platformVersion, driver.opts.deviceName, driver.opts.platformName);7driver.caps.app = app;8await driver.startSession();9const { AppiumDriver, createDriver } = require('appium-base-driver');10const XCUITestDriver = require('appium-xcuitest-driver');11const { configureApp } = require('appium-xcuitest-driver/lib/utils');12const driver = createDriver(XCUITestDriver, {13});14const app = await configureApp(driver.caps.app, driver.caps.platformVersion, driver.opts.deviceName, driver.opts.platformName);15driver.caps.app = app;16await driver.startSession();17const { AppiumDriver, createDriver } = require('appium-base-driver');18const XCUITestDriver = require('appium-xcuitest-driver');19const { configureApp } = require('appium-xcuitest-driver/lib/utils');20const driver = createDriver(XCUITestDriver, {21});22const app = await configureApp(driver.caps.app, driver.caps.platformVersion, driver.opts.deviceName, driver.opts.platformName);23driver.caps.app = app;24await driver.startSession();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { AppiumDriver, utils } = require('@wdio/appium-service');2class CustomAppiumDriver extends AppiumDriver {3 constructor(config, options) {4 super(config, options);5 this.helpers = utils.merge(this.helpers, {6 configureApp: this.configureApp.bind(this)7 });8 }9 configureApp(app, params) {10 return new Promise((resolve, reject) => {11 let opts = {12 };13 this.sendCommand('configureApp', opts, (err, res) => {14 if (err) return reject(err);15 resolve(res);16 });17 });18 }19}20exports.default = CustomAppiumDriver;21exports.config = {22 ['appium', {23 args: {24 }25 }]26 before: function () {27 const params = {28 };29 browser.configureApp('path/to/my.app', params);30 }31}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { config } = require('./wdio.conf.js');2];3 {4 }5];6exports.config = config;7exports.config = {8 capabilities: [{9 }],10 mochaOpts: {11 }12};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { AppiumDriver, createDriver } = require('appium-xcuitest-driver');2const { configureApp } = require('appium-xcuitest-driver/lib/commands/general');3const { configureAppHelper } = require('appium-xcuitest-driver/lib/commands/general');4class MyDriver extends AppiumDriver {5 constructor () {6 super();7 this.configureApp = configureAppHelper;8 }9}10const driver = createDriver(MyDriver, {11});12driver.configureApp('path/to/My.app');13const { AppiumDriver, createDriver } = require('appium-xcuitest-driver');14const { configureApp } = require('appium-xcuitest-driver/lib/commands/general');15const { configureAppHelper } = require('appium-xcuitest-driver/lib/commands/general');16class MyDriver extends AppiumDriver {17 constructor () {18 super();19 this.configureApp = configureAppHelper;20 }21}22const driver = createDriver(MyDriver, {23});24driver.configureApp('path/to/My.app');25const { AppiumDriver, createDriver } = require('appium-xcuitest-driver');26const { configureApp } = require('appium-xcuitest-driver/lib/commands/general');27const { configureAppHelper } = require('appium-xcuitest-driver/lib/commands/general');28class MyDriver extends AppiumDriver {29 constructor () {30 super();31 this.configureApp = configureAppHelper;32 }33}34const driver = createDriver(MyDriver, {35});36driver.configureApp('path/to/My.app');37const { AppiumDriver, createDriver } = require('appium-xcuitest-driver');38const { configureApp

Full Screen

Using AI Code Generation

copy

Full Screen

1import { test } from '@playwright/test';2test.describe('Appium XCUITest Driver', () => {3 test.beforeEach(async ({ browser }) => {4 await browser.newContext();5 });6 test('should configure app', async ({ browser }) => {7 const page = await browser.newPage();8 const title = await page.title();9 expect(title).toBe('Playwright');10 });11});12const { devices } = require('@playwright/test');13module.exports = {14 use: {15 viewport: { width: 1280, height: 720 },16 launchOptions: {17 },18 geolocation: { longitude: 12.492507, latitude: 41.889938 },19 extraHTTPHeaders: { 'foo': 'bar' },20 userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1',21 proxy: {22 },23 helpers: {24 configureApp: {25 }26 }27 },28 {29 use: {30 viewport: { width: 1280, height: 720 },

Full Screen

Using AI Code Generation

copy

Full Screen

1const { driver, idFromAccessId } = require('../helpers/driver');2const { configureApp } = require('../helpers/configureApp');3describe('Appium XCUITest Driver', function () {4 before(async function () {5 await driver.init();6 });7 it('should configure the app under test', async function () {8 await configureApp();9 });10 after(async function () {11 await driver.quit();12 });13});14async function configureApp() {15 await driver.execute('mobile: configureApp', {16 settings: {17 },18 });19}20exports.configureApp = configureApp;21const wd = require('wd');22const { HOST, PORT, UDID } = require('../config');23const driver = wd.promiseChainRemote(HOST, PORT);24exports.driver = driver;25async function idFromAccessId(accessId) {26 const el = await driver.elementByAccessibilityId(accessId);27 return el.value;28}29exports.idFromAccessId = idFromAccessId;30const HOST = 'localhost';31const PORT = 4723;32const UDID = '00008020-000D3C3C1E1A802E';33exports.HOST = HOST;34exports.PORT = PORT;35exports.UDID = UDID;36{37 "scripts": {38 },39 "dependencies": {

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 await client.helpers.configureApp();10 await client.pause(5000);11 await client.deleteSession();12}13main();14[debug] [XCUITest] Sending command to instruments: au.bundleId()15[debug] [Instruments] [INST] 2017-06-27 15:19:47 +0000 Debug: Got new command 1 from instruments: au.bundleId()16[debug] [Instruments] [INST] 2017-06-27 15:19:47 +0000 Debug: evaluating au.bundleId()

Full Screen

Using AI Code Generation

copy

Full Screen

1this.helpers.configureApp({2 waitForAppScript: '$.delay(100); $.acceptAlert(); $.delay(100); $.acceptAlert();',3 launchArgs: {4 }5});6this.helpers.configureApp({7 waitForAppScript: '$.delay(100); $.acceptAlert(); $.delay(100); $.acceptAlert();',8 launchArgs: {9 }10});11this.helpers.configureApp({12 waitForAppScript: '$.delay(100); $.acceptAlert(); $.delay(100); $.acceptAlert();',13 launchArgs: {14 }15});16this.helpers.configureApp({17 waitForAppScript: '$.delay(100); $.acceptAlert(); $.delay(100); $.acceptAlert();',18 launchArgs: {19 }20});21this.helpers.configureApp({22 waitForAppScript: '$.delay(100); $.acceptAlert(); $.delay(100); $.acceptAlert();',23 launchArgs: {24 }25});26this.helpers.configureApp({27 waitForAppScript: '$.delay(100); $.acceptAlert(); $.delay(100); $.acceptAlert();',28 launchArgs: {

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