How to use this.wda.retrieveDerivedDataPath method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

driver.js

Source:driver.js Github

copy

Full Screen

...306 this.wda = new WebDriverAgent(this.xcodeVersion, this.opts);307 // Derived data path retrieval is an expensive operation308 // We could start that now in background and get the cached result309 // whenever it is needed310 this.wda.retrieveDerivedDataPath().catch((e) => log.debug(e));311 const memoizedLogInfo = _.memoize(function logInfo () {312 log.info("'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network.");313 });314 const startLogCapture = async () => {315 if (this.opts.skipLogCapture) {316 memoizedLogInfo();317 return false;318 }319 const result = await this.startLogCapture();320 if (result) {321 this.logEvent('logCaptureStarted');322 }323 return result;324 };325 const isLogCaptureStarted = await startLogCapture();326 log.info(`Setting up ${this.isRealDevice() ? 'real device' : 'simulator'}`);327 if (this.isSimulator()) {328 if (this.opts.shutdownOtherSimulators) {329 this.ensureFeatureEnabled(SHUTDOWN_OTHER_FEAT_NAME);330 await shutdownOtherSimulators(this.opts.device);331 }332 // this should be done before the simulator is started333 // if it is already running, this cap won't work, which is documented334 if (this.isSafari() && this.opts.safariGlobalPreferences) {335 if (await this.opts.device.updateSafariGlobalSettings(this.opts.safariGlobalPreferences)) {336 log.debug(`Safari global preferences updated`);337 }338 }339 this.localConfig = await iosSettings.setLocaleAndPreferences(this.opts.device, this.opts, this.isSafari(), async (sim) => {340 await shutdownSimulator(sim);341 // we don't know if there needs to be changes a priori, so change first.342 // sometimes the shutdown process changes the settings, so reset them,343 // knowing that the sim is already shut344 await iosSettings.setLocaleAndPreferences(sim, this.opts, this.isSafari());345 });346 if (this.opts.customSSLCert) {347 const certHead = _.truncate(this.opts.customSSLCert, {length: 20});348 log.info(`Installing the custom SSL certificate '${certHead}'`);349 try {350 await this.opts.device.simctl.addRootCertificate(this.opts.customSSLCert, {raw: true});351 } catch (ign) {352 if (await hasSSLCert(this.opts.customSSLCert, this.opts.udid)) {353 log.info(`SSL certificate '${certHead}' already installed`);354 } else {355 log.info(`Making sure Simulator is shut down, ' +356 'so that SSL certificate installation takes effect`);357 await shutdownSimulator(this.opts.device);358 await installSSLCert(this.opts.customSSLCert, this.opts.udid);359 }360 }361 this.logEvent('customCertInstalled');362 }363 await this.startSim();364 if (this.opts.launchWithIDB && this.isSimulator()) {365 try {366 const idb = new IDB({udid});367 await idb.connect();368 this.opts.device.idb = idb;369 } catch (e) {370 log.info(`idb will not be used for Simulator interaction. Original error: ${e.message}`);371 }372 }373 this.logEvent('simStarted');374 if (!isLogCaptureStarted) {375 // Retry log capture if Simulator was not running before376 await startLogCapture();377 }378 }379 if (this.opts.app) {380 await this.installAUT();381 this.logEvent('appInstalled');382 }383 // if we only have bundle identifier and no app, fail if it is not already installed384 if (!this.opts.app && this.opts.bundleId && !this.safari) {385 if (!await this.opts.device.isAppInstalled(this.opts.bundleId)) {386 log.errorAndThrow(`App with bundle identifier '${this.opts.bundleId}' unknown`);387 }388 }389 if (this.opts.permissions) {390 if (this.isSimulator()) {391 log.debug('Setting the requested permissions before WDA is started');392 for (const [bundleId, permissionsMapping] of _.toPairs(JSON.parse(this.opts.permissions))) {393 await this.opts.device.setPermissions(bundleId, permissionsMapping);394 }395 } else {396 log.warn('Setting permissions is only supported on Simulator. ' +397 'The "permissions" capability will be ignored.');398 }399 }400 await this.startWda(this.opts.sessionId, realDevice);401 await this.setReduceMotion(this.opts.reduceMotion);402 await this.setInitialOrientation(this.opts.orientation);403 this.logEvent('orientationSet');404 // real devices will be handled later, after the web context has been initialized405 if (this.isSafari() && !this.isRealDevice()406 && util.compareVersions(this.opts.platformVersion, '>=', '12.2')) {407 // on 12.2 the page is not opened in WDA408 await this.opts.device.openUrl(this._currentUrl);409 }410 if (this.isSafari() || this.opts.autoWebview) {411 log.debug('Waiting for initial webview');412 await this.navToInitialWebview();413 this.logEvent('initialWebviewNavigated');414 }415 if (this.isSafari() && this.isRealDevice() && util.compareVersions(this.opts.platformVersion, '>=', '12.2')) {416 // on 12.2 the page is not opened in WDA417 await this.setUrl(this._currentUrl);418 }419 if (!this.isRealDevice()) {420 if (this.opts.calendarAccessAuthorized) {421 await this.opts.device.enableCalendarAccess(this.opts.bundleId);422 } else if (this.opts.calendarAccessAuthorized === false) {423 await this.opts.device.disableCalendarAccess(this.opts.bundleId);424 }425 }426 }427 /**428 * Start WebDriverAgentRunner429 * @param {string} sessionId - The id of the target session to launch WDA with.430 * @param {boolean} realDevice - Equals to true if the test target device is a real device.431 */432 async startWda (sessionId, realDevice) {433 // Don't cleanup the processes if webDriverAgentUrl is set434 if (!util.hasValue(this.wda.webDriverAgentUrl)) {435 await this.wda.cleanupObsoleteProcesses();436 }437 const usePortForwarding = this.isRealDevice()438 && !this.wda.webDriverAgentUrl439 && isLocalHost(this.wda.wdaBaseUrl);440 await DEVICE_CONNECTIONS_FACTORY.requestConnection(this.opts.udid, this.wda.url.port, {441 devicePort: usePortForwarding ? this.wda.wdaRemotePort : null,442 usePortForwarding,443 });444 // Let multiple WDA binaries with different derived data folders be built in parallel445 // Concurrent WDA builds from the same source will cause xcodebuild synchronization errors446 let synchronizationKey = XCUITestDriver.name;447 if (this.opts.useXctestrunFile || !(await this.wda.isSourceFresh())) {448 // First-time compilation is an expensive operation, which is done faster if executed449 // sequentially. Xcodebuild spreads the load caused by the clang compiler to all available CPU cores450 const derivedDataPath = await this.wda.retrieveDerivedDataPath();451 if (derivedDataPath) {452 synchronizationKey = path.normalize(derivedDataPath);453 }454 }455 log.debug(`Starting WebDriverAgent initialization with the synchronization key '${synchronizationKey}'`);456 if (SHARED_RESOURCES_GUARD.isBusy() && !this.opts.derivedDataPath && !this.opts.bootstrapPath) {457 log.debug(`Consider setting a unique 'derivedDataPath' capability value for each parallel driver instance ` +458 `to avoid conflicts and speed up the building process`);459 }460 return await SHARED_RESOURCES_GUARD.acquire(synchronizationKey, async () => {461 if (this.opts.useNewWDA) {462 log.debug(`Capability 'useNewWDA' set to true, so uninstalling WDA before proceeding`);463 await this.wda.quitAndUninstall();464 this.logEvent('wdaUninstalled');465 } else if (!util.hasValue(this.wda.webDriverAgentUrl)) {466 await this.wda.setupCaching();467 }468 // local helper for the two places we need to uninstall wda and re-start it469 const quitAndUninstall = async (msg) => {470 log.debug(msg);471 if (this.opts.webDriverAgentUrl) {472 log.debug('Not quitting/uninstalling WebDriverAgent since webDriverAgentUrl capability is provided');473 throw new Error(msg);474 }475 log.warn('Quitting and uninstalling WebDriverAgent');476 await this.wda.quitAndUninstall();477 throw new Error(msg);478 };479 const startupRetries = this.opts.wdaStartupRetries || (this.isRealDevice() ? WDA_REAL_DEV_STARTUP_RETRIES : WDA_SIM_STARTUP_RETRIES);480 const startupRetryInterval = this.opts.wdaStartupRetryInterval || WDA_STARTUP_RETRY_INTERVAL;481 log.debug(`Trying to start WebDriverAgent ${startupRetries} times with ${startupRetryInterval}ms interval`);482 if (!util.hasValue(this.opts.wdaStartupRetries) && !util.hasValue(this.opts.wdaStartupRetryInterval)) {483 log.debug(`These values can be customized by changing wdaStartupRetries/wdaStartupRetryInterval capabilities`);484 }485 let retryCount = 0;486 await retryInterval(startupRetries, startupRetryInterval, async () => {487 this.logEvent('wdaStartAttempted');488 if (retryCount > 0) {489 log.info(`Retrying WDA startup (${retryCount + 1} of ${startupRetries})`);490 }491 try {492 // on xcode 10 installd will often try to access the app from its staging493 // directory before fully moving it there, and fail. Retrying once494 // immediately helps495 const retries = this.xcodeVersion.major >= 10 ? 2 : 1;496 this.cachedWdaStatus = await retry(retries, this.wda.launch.bind(this.wda), sessionId, realDevice);497 } catch (err) {498 this.logEvent('wdaStartFailed');499 retryCount++;500 let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`;501 if (this.isRealDevice()) {502 errorMsg += `. Make sure you follow the tutorial at ${WDA_REAL_DEV_TUTORIAL_URL}. ` +503 `Try to remove the WebDriverAgentRunner application from the device if it is installed ` +504 `and reboot the device.`;505 }506 await quitAndUninstall(errorMsg);507 }508 this.proxyReqRes = this.wda.proxyReqRes.bind(this.wda);509 this.jwpProxyActive = true;510 let originalStacktrace = null;511 try {512 await retryInterval(15, 1000, async () => {513 this.logEvent('wdaSessionAttempted');514 log.debug('Sending createSession command to WDA');515 try {516 this.cachedWdaStatus = this.cachedWdaStatus || await this.proxyCommand('/status', 'GET');517 await this.startWdaSession(this.opts.bundleId, this.opts.processArguments);518 } catch (err) {519 originalStacktrace = err.stack;520 log.debug(`Failed to create WDA session (${err.message}). Retrying...`);521 throw err;522 }523 });524 this.logEvent('wdaSessionStarted');525 } catch (err) {526 if (originalStacktrace) {527 log.debug(originalStacktrace);528 }529 let errorMsg = `Unable to start WebDriverAgent session because of xcodebuild failure: ${err.message}`;530 if (this.isRealDevice()) {531 errorMsg += ` Make sure you follow the tutorial at ${WDA_REAL_DEV_TUTORIAL_URL}. ` +532 `Try to remove the WebDriverAgentRunner application from the device if it is installed ` +533 `and reboot the device.`;534 }535 await quitAndUninstall(errorMsg);536 }537 if (this.opts.clearSystemFiles && !this.opts.webDriverAgentUrl) {538 await markSystemFilesForCleanup(this.wda);539 }540 // we expect certain socket errors until this point, but now541 // mark things as fully working542 this.wda.fullyStarted = true;543 this.logEvent('wdaStarted');544 });545 });546 }547 async runReset (opts = null) {548 this.logEvent('resetStarted');549 if (this.isRealDevice()) {550 await runRealDeviceReset(this.opts.device, opts || this.opts);551 } else {552 await runSimulatorReset(this.opts.device, opts || this.opts);553 }554 this.logEvent('resetComplete');555 }556 async deleteSession () {557 await removeAllSessionWebSocketHandlers(this.server, this.sessionId);558 for (const recorder of _.compact([this._recentScreenRecorder, this._audioRecorder])) {559 await recorder.interrupt(true);560 await recorder.cleanup();561 }562 if (!_.isEmpty(this._perfRecorders)) {563 await B.all(this._perfRecorders.map((x) => x.stop(true)));564 this._perfRecorders = [];565 }566 await this.stop();567 if (this.wda && !this.opts.webDriverAgentUrl) {568 if (this.opts.clearSystemFiles) {569 let synchronizationKey = XCUITestDriver.name;570 const derivedDataPath = await this.wda.retrieveDerivedDataPath();571 if (derivedDataPath) {572 synchronizationKey = path.normalize(derivedDataPath);573 }574 await SHARED_RESOURCES_GUARD.acquire(synchronizationKey, async () => {575 await clearSystemFiles(this.wda);576 });577 } else {578 log.debug('Not clearing log files. Use `clearSystemFiles` capability to turn on.');579 }580 }581 if (this.remote) {582 log.debug('Found a remote debugger session. Removing...');583 await this.stopRemote();584 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const appium = require('appium');2const wd = require('wd');3async function main() {4 await driver.init({5 });6 let derivedDataPath = await driver.wda.retrieveDerivedDataPath();7 console.log(derivedDataPath);8 await driver.quit();9}10main();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const path = require('path');3const fs = require('fs');4const assert = require('assert');5const { exec } = require('child_process');6const WDA_BUNDLE_ID = 'com.apple.test.WebDriverAgentRunner-Runner';7const WDA_RETRIEVE_DERIVED_DATA_PATH_URL = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveDerivedDataPath`;8const WDA_RETRIEVE_DERIVED_DATA_PATH_URL_WITH_SESSION_ID = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveDerivedDataPath`;9const WDA_RETRIEVE_LOGS_URL = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveLogs`;10const WDA_RETRIEVE_LOGS_URL_WITH_SESSION_ID = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveLogs`;11const WDA_RETRIEVE_LOGS_URL_WITH_SESSION_ID = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveLogs`;12const WDA_RETRIEVE_LOGS_URL_WITH_SESSION_ID = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveLogs`;13const WDA_RETRIEVE_LOGS_URL_WITH_SESSION_ID = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveLogs`;14const WDA_RETRIEVE_LOGS_URL_WITH_SESSION_ID = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveLogs`;15const WDA_RETRIEVE_LOGS_URL_WITH_SESSION_ID = `${WDA_BASE_URL}/session/00000000-0000-0000-0000-000000000000/wda/retrieveLogs`;16const WDA_RETRIEVE_LOGS_URL_WITH_SESSION_ID = `${WDA_BASE_URL}/session/

Full Screen

Using AI Code Generation

copy

Full Screen

1const { wda } = require('appium-xcuitest-driver');2const derivedDataPath = wda.retrieveDerivedDataPath();3console.log(derivedDataPath);4const { wda } = require('appium-xcuitest-driver');5const derivedDataPath = wda.retrieveDerivedDataPath();6console.log(derivedDataPath);7const { retrieveDerivedDataPath } = require('appium-xcuitest-driver/lib/wda/utils');8const derivedDataPath = retrieveDerivedDataPath();9console.log(derivedDataPath);10const { retrieveDerivedDataPath } = require('appium-xcuitest-driver/lib/wda/utils');11const derivedDataPath = retrieveDerivedDataPath();12console.log(derivedDataPath);13const { getAndCheckXcodeVersion } = require('appium-xcuitest-driver/lib/utils');14const derivedDataPath = getAndCheckXcodeVersion().derivedDataPath;15console.log(derivedDataPath);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs');2const path = require('path');3const { execSync } = require('child_process');4const { exec } = require('teen_process');5const { fs: fsutil } = require('appium-support');6const { logger } = require('appium-support');7const log = logger.getLogger('WDA');8const logDir = '/Users/username/Desktop/Logs';9const wda = require('appium-xcuitest-driver/lib/wda');10const xcode = require('appium-xcuitest-driver/lib/utils/xcode');11const xcodeUtils = require('appium-xcuitest-driver/lib/utils/xcode-utils');12const WDA_RUNNER_BUNDLE_ID = 'com.facebook.WebDriverAgentRunner';13const WDA_BUNDLE_ID = 'com.facebook.WebDriverAgentRunner.xctrunner';14const getWDAPaths = async (udid, xcodeVersion) => {15 const wdaPath = await wda.getWDAPath();16 const wdaRunnerPath = await wda.getWDAxcodebuildPath();17 const realDevice = !udid || udid.toLowerCase() === 'auto';18 const platformVersion = await xcode.getIosSdkVersion();19 const wdaBundleId = WDA_BUNDLE_ID;20 const wdaRunnerBundleId = WDA_RUNNER_BUNDLE_ID;21 const wdaLocalPort = 8100;22 const derivedDataPath = await wda.retrieveDerivedDataPath(wdaRunnerPath, wdaRunnerBundleId, xcodeVersion, platformVersion, realDevice, udid);23 const wdaLaunchTimeout = 60000;24 const wdaConnectionTimeout = 60000;25 const wdaStartupRetries = 3;26 const wdaStartupRetryInterval = 10000;27 const wdaPid = 0;28 const wdaBaseUrlRetries = 3;29 const wdaBaseUrlRetryInterval = 10000;30 const wdaLocalPortUsedRetries = 3;31 const wdaLocalPortUsedRetryInterval = 10000;32 const wdaRemotePort = 8100;33 const wdaRemoteProxy = null;34 const wdaCustomUrl = null;35 const wdaRealDeviceLogger = null;36 const wdaRealDeviceLoggerJpegStream = null;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { execSync } = require('child_process');2const path = require('path');3const fs = require('fs');4const os = require('os');5const { getWda } = require('appium-xcuitest-driver/lib/wda/utils');6const wda = getWda();7const wdaPath = wda.retrieveDerivedDataPath();8console.log(`wdaPath: ${wdaPath}`);9const wdaBundlePath = path.resolve(wdaPath, 'Build', 'Products', 'Debug-iphonesimulator', 'WebDriverAgentRunner-Runner.app');10console.log(`wdaBundlePath: ${wdaBundlePath}`);11const wdaBundleId = execSync(`defaults read "${wdaBundlePath}/Info.plist" CFBundleIdentifier`).toString().trim();12console.log(`wdaBundleId: ${wdaBundleId}`);13const wdaLocalPort = 8100;14const wdaRemotePort = 8100;15const wdaService = wda.createWdaService({16 wdaAgentPath: path.resolve(wdaPath, 'Build', 'Products', 'Debug-iphonesimulator', 'WebDriverAgentRunner-Runner.app'),17});18wdaService.start().then(() => {19 console.log(`wdaService started`);20 wdaService.stop();21}).catch((err) => {22 console.error(`wdaService failed to start: ${err}`);23});24const { execSync } = require('child_process');25const path = require('path');26const fs = require('fs');27const os = require('os');28const { getWda } = require('appium-xcuitest-driver/lib/wda/utils');29const wda = getWda();30const wdaPath = wda.retrieveDerivedDataPath();31console.log(`w

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const driver = wd.promiseChainRemote({3});4(async () => {5 await driver.init({6 });7 const derivedDataPath = await driver.execute('wda.retrieveDerivedDataPath');8 console.log(derivedDataPath);9 await driver.quit();10})();11const wd = require('wd');12const driver = wd.promiseChainRemote({13});14(async () => {15 await driver.init({16 });17 const derivedDataPath = await driver.execute('wda.retrieveDerivedDataPath');18 console.log(derivedDataPath);19 await driver.quit();20})();

Full Screen

Using AI Code Generation

copy

Full Screen

1import wd from 'wd';2import chai from 'chai';3import chaiAsPromised from 'chai-as-promised';4const {assert} = chai;5chai.use(chaiAsPromised);6const PORT = 4723;

Full Screen

Using AI Code Generation

copy

Full Screen

1const desiredCaps = {2};3async function main () {4 const driver = await wdio.remote({5 });6 const derivedDataPath = await driver.wda.retrieveDerivedDataPath();7 console.log(derivedDataPath);8}9main();10const desiredCaps = {11};12async function main () {13 const driver = await wdio.remote({14 });15 const derivedDataPath = await driver.wda.retrieveDerivedDataPath();16 console.log(derivedDataPath);17}18main();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4const assert = chai.assert;5const expect = chai.expect;6chai.use(chaiAsPromised);7const caps = {8};9const driver = wd.promiseChainRemote('localhost', 4723);10 .init(caps)11 .then(function() {12 return driver.wda.retrieveDerivedDataPath();13 })14 .then(function(derivedDataPath) {15 console.log('derivedDataPath: ' + derivedDataPath);16 return driver.wda.getBundleIdFromDerivedDataPath(derivedDataPath);17 })18 .then(function(bundleId) {19 console.log('bundleId: ' + bundleId);20 return driver.wda.getBundleVersionFromBundleId(bundleId);21 })22 .then(function(bundleVersion) {23 console.log('bundleVersion: ' + bundleVersion);24 return driver.wda.getBundleShortVersionStringFromBundleId(bundleId);25 })26 .then(function(bundleShortVersionString) {27 console.log('bundleShortVersionString: ' + bundleShortVersionString);28 return driver.wda.getBundleNameFromBundleId(bundleId);29 })30 .then(function(bundleName) {31 console.log('bundleName: ' + bundleName);32 return driver.wda.getBundlePathFromBundleId(bundleId);33 })34 .then(function(bundlePath) {35 console.log('bundlePath: ' + bundlePath);36 })37 .catch(function(err) {38 console.log(err

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