How to use xcode.getVersion method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

xcode.js

Source:xcode.js Github

copy

Full Screen

...103 });104};105xcode.getiOSSDKVersion = function (cb) {106 var msg;107 xcode.getVersion(function (err, versionNumber) {108 if (err) {109 msg = "Could not get the iOS SDK version because the Xcode version could not be determined.";110 logger.error(msg);111 cb(new Error(msg), null);112 } else if (versionNumber[0] === '4') {113 cb(null, '6.1');114 } else {115 logger.debug("Getting sdk version from xcrun with a timeout");116 exec('xcrun --sdk iphonesimulator --show-sdk-version', { maxBuffer: 524288, timeout: 3000 }, function (err, stdout, stderr) {117 if (!err) {118 var iosSDKVersion = stdout.replace("\n", "");119 var match = /\d.\d/.exec(iosSDKVersion);120 if (match) {121 cb(null, iosSDKVersion);...

Full Screen

Full Screen

xcode-specs.js

Source:xcode-specs.js Github

copy

Full Screen

...16 });17 describe('getVersion', function () {18 let versionRE = /\d\.\d\.*\d*/;19 it('should get the version of xcode', async function () {20 let version = await xcode.getVersion();21 should.exist(version);22 _.isString(version).should.be.true;23 versionRE.test(version).should.be.true;24 });25 it('should get the path and version again, these values are cached', async function () {26 await xcode.getPath();27 await xcode.getVersion();28 let before = new Date();29 let path = await xcode.getPath();30 let after = new Date();31 should.exist(path);32 await fs.exists(path);33 (after - before).should.be.at.most(2);34 before = new Date();35 let version = await xcode.getVersion();36 after = new Date();37 should.exist(version);38 _.isString(version).should.be.true;39 versionRE.test(version).should.be.true;40 (after - before).should.be.at.most(2);41 });42 it('should get the parsed version', async function () {43 let nonParsedVersion = await xcode.getVersion();44 let version = await xcode.getVersion(true);45 should.exist(version);46 _.isString(version.versionString).should.be.true;47 version.versionString.should.eql(nonParsedVersion);48 parseFloat(version.versionFloat).should.equal(version.versionFloat);49 parseInt(version.major, 10).should.equal(version.major);50 parseInt(version.minor, 10).should.equal(version.minor);51 });52 });53 it('should get the command line tools version', async function () {54 if (!process.env.CI) {55 // The function does not work anymore for recent xcode versions56 return this.skip();57 }58 let cliVersion = await xcode.getCommandLineToolsVersion();59 _.isString(cliVersion).should.be.true;60 });61 it('should clear the cache if asked to', async function () {62 xcode.clearInternalCache();63 let before = new Date();64 await xcode.getPath();65 let after = new Date();66 (after - before).should.be.at.least(6);67 });68 it('should get max iOS SDK version', async function () {69 let version = await xcode.getMaxIOSSDK();70 should.exist(version);71 (typeof version).should.equal('string');72 (parseFloat(version) - 6.1).should.be.at.least(0);73 });74 it('should get max tvOS SDK version', async function () {75 let version = await xcode.getMaxTVOSSDK();76 should.exist(version);77 (typeof version).should.equal('string');78 });79 it('should get a list of devices', async function () {80 let devices = await xcode.getConnectedDevices();81 should.exist(devices);82 (typeof devices).should.equal('object');83 });84 it('should get the path to instruments binary', async function () {85 const version = await xcode.getVersion(true);86 if (version.major >= 13) {87 return this.skip();88 }89 const instrumentsPath = await xcode.getInstrumentsPath();90 should.exist(instrumentsPath);91 (typeof instrumentsPath).should.equal('string');92 instrumentsPath.length.should.be.above(3);93 await fs.exists(instrumentsPath);94 });95 describe('ui automation', function () {96 before(async function () {97 let version = await xcode.getVersion(true);98 if (version.major >= 8) {99 this.skip();100 }101 });102 it('should find the automation trace template', async function () {103 let path = await xcode.getAutomationTraceTemplatePath();104 should.exist(path);105 await fs.exists(path).should.eventually.be.true;106 let suffix = '.tracetemplate';107 path.slice(-suffix.length).should.equal(suffix);108 });109 });...

Full Screen

Full Screen

simulator.js

Source:simulator.js Github

copy

Full Screen

...25 * [node-simctl](github.com/appium/node-simctl).26 * @return {object} Simulator object associated with the udid passed in.27 */28async function getSimulator (udid) {29 const xcodeVersion = await xcode.getVersion(true);30 const simulatorInfo = await getSimulatorInfo(udid);31 if (!simulatorInfo) {32 throw new Error(`No sim found with udid '${udid}'`);33 }34 // make sure we have the right logging prefix35 setLoggingPlatform(simulatorInfo.platform);36 log.info(`Constructing ${simulatorInfo.platform || 'iOS'} simulator for Xcode version ${xcodeVersion.versionString} ` +37 `with udid '${udid}'`);38 let SimClass;39 switch (xcodeVersion.major) {40 case 6:41 SimClass = SimulatorXcode6;42 break;43 case 7:44 if (xcodeVersion.minor < 3) {45 SimClass = SimulatorXcode7;46 } else {47 SimClass = SimulatorXcode73;48 }49 break;50 case 8:51 SimClass = SimulatorXcode8;52 break;53 case 9:54 if (xcodeVersion.minor < 3) {55 SimClass = SimulatorXcode9;56 } else {57 SimClass = SimulatorXcode93;58 }59 break;60 case 10:61 SimClass = SimulatorXcode10;62 break;63 case 11:64 SimClass = SimulatorXcode11;65 break;66 default:67 handleUnsupportedXcode(xcodeVersion);68 SimClass = SimulatorXcode93;69 }70 return new SimClass(udid, xcodeVersion);71}72/**73 * Takes a set of options and finds the correct device string in order for Instruments to74 * identify the correct simulator.75 *76 * @param {object} opts - The options available are:77 * - `deviceName` - a name for the device. If the given device name starts with `=`, the name, less the equals sign, is returned.78 * - `platformVersion` - the version of iOS to use. Defaults to the current Xcode's maximum SDK version.79 * - `forceIphone` - force the configuration of the device string to iPhone. Defaults to `false`.80 * - `forceIpad` - force the configuration of the device string to iPad. Defaults to `false`.81 * If both `forceIphone` and `forceIpad` are true, the device will be forced to iPhone.82 *83 * @return {string} The found device string, for example:84 * 'iPhone 5 (8.4)' with Xcode 7+85 * 'iPhone 5 (8.4 Simulator)' with Xcode 6+86 */87async function getDeviceString (opts) {88 let xcodeVersion = await xcode.getVersion(true);89 handleUnsupportedXcode(xcodeVersion);90 log.info(`Retrieving device name string for Xcode version ${xcodeVersion.versionString}`);91 if (xcodeVersion.major >= 8) {92 return await SimulatorXcode7.getDeviceString(opts);93 } else if (xcodeVersion.major === 7) {94 return await SimulatorXcode7.getDeviceString(opts);95 } else if (xcodeVersion.major === 6) {96 return await SimulatorXcode6.getDeviceString(opts);97 }98}...

Full Screen

Full Screen

early-failures-specs.js

Source:early-failures-specs.js Github

copy

Full Screen

1// transpile:mocha2import { Instruments, instrumentsUtils } from '../../..';3import chai from 'chai';4import chaiAsPromised from 'chai-as-promised';5import sinon from 'sinon';6import { withSandbox } from 'appium-test-support';7import xcode from 'appium-xcode';8import { getXcodeVersion } from './helpers';9chai.should();10chai.use(chaiAsPromised);11describe('Early failures', withSandbox({}, (S) => {12 it('should error when Xcode does not support Instruments', async function () {13 S.sandbox.stub(xcode, 'getVersion').returns(getXcodeVersion(8, 0, 0));14 let instruments = new Instruments({});15 let onExitSpy = sinon.spy();16 instruments.onShutdown.then(onExitSpy, onExitSpy).done(); // eslint-disable-line17 await instruments.launch().should.be.rejectedWith(/Instruments-based automation was removed in Xcode 8/);18 onExitSpy.callCount.should.eql(0);19 });20 it('should error when Xcode 5.0.1 is used', async function () {21 S.sandbox.stub(xcode, 'getVersion').returns(getXcodeVersion(5, 0, 1));22 let instruments = new Instruments({});23 let onExitSpy = sinon.spy();24 instruments.onShutdown.then(onExitSpy, onExitSpy).done(); // eslint-disable-line25 await instruments.launch().should.be.rejectedWith(/Xcode 5.0.1 ships with a broken version of Instruments/);26 onExitSpy.callCount.should.eql(0);27 });28 it('should error on getAutomationTraceTemplatePath failure', async function () {29 S.sandbox.stub(xcode, 'getVersion').returns(getXcodeVersion());30 S.sandbox.stub(xcode, 'getAutomationTraceTemplatePath').callsFake(async function () { // eslint-disable-line require-await31 throw new Error('ouch!');32 });33 let instruments = new Instruments({});34 let onExitSpy = sinon.spy();35 instruments.onShutdown.then(onExitSpy, onExitSpy).done(); // eslint-disable-line36 await instruments.launch().should.be.rejectedWith(/ouch!/);37 onExitSpy.callCount.should.eql(0);38 });39 it('should error on getInstrumentsPath failure', async function () {40 S.sandbox.stub(xcode, 'getVersion').returns(getXcodeVersion());41 S.sandbox.stub(xcode, 'getAutomationTraceTemplatePath').returns('/path/to/trace/template');42 let instruments = new Instruments({});43 S.sandbox.stub(instrumentsUtils, 'getInstrumentsPath').callsFake(async function () { // eslint-disable-line require-await44 throw new Error('ouch!');45 });46 let onExitSpy = sinon.spy();47 instruments.onShutdown.then(onExitSpy, onExitSpy).done(); // eslint-disable-line48 await instruments.launch().should.be.rejectedWith(/ouch!/);49 onExitSpy.callCount.should.eql(0);50 });...

Full Screen

Full Screen

check-safari-settings.js

Source:check-safari-settings.js Github

copy

Full Screen

...57};58exports.ios7up = function (desired, setting, expected, cb) {59 xcode.getMaxIOSSDK(function (err, sdk) {60 if (parseFloat(sdk) >= 8) {61 xcode.getVersion(function (err, xcodeVersion) {62 if (err) return cb(err);63 getSimUdid(xcodeVersion, sdk, desired, function (err, udid) {64 if (err) return cb(err);65 ios7up(desired.platformVersion, udid, setting, expected, cb);66 });67 });68 } else {69 ios7up(desired.platformVersion, null, setting, expected, cb);70 }71 });...

Full Screen

Full Screen

build-webdriveragent.js

Source:build-webdriveragent.js Github

copy

Full Screen

...7const log = new logger.getLogger('WDABuild');8const rootDir = path.resolve(__dirname, '..', '..');9async function buildWebDriverAgent (xcodeVersion) {10 // Get Xcode version11 xcodeVersion = xcodeVersion || await xcode.getVersion();12 log.info(`Building bundle for Xcode version '${xcodeVersion}'`);13 // Clean and build14 await exec('npx', ['gulp', 'clean:carthage']);15 log.info('Running ./Scripts/build.sh');16 let env = {TARGET: 'runner', SDK: 'sim'};17 await exec('/bin/bash', ['./Scripts/build.sh'], {env, cwd: rootDir});18 // Create bundles folder19 await mkdirp('bundles');20 const pathToBundles = path.resolve(rootDir, 'bundles');21 // Start creating tarball22 const uncompressedDir = path.resolve(rootDir, 'uncompressed');23 await fs.rimraf(uncompressedDir);24 await mkdirp(uncompressedDir);25 log.info('Creating tarball');...

Full Screen

Full Screen

ios-log.js

Source:ios-log.js Github

copy

Full Screen

...9 async startCaptureSimulator () {10 if (_.isUndefined(this.sim.udid)) {11 throw new Error(`Log capture requires a sim udid`);12 }13 const xcodeVersion = await xcode.getVersion(true);14 let tool, args;15 if (xcodeVersion.major < 9) {16 const systemLogPath = path.resolve(this.sim.getLogDir(), 'system.log');17 if (!await fs.exists(systemLogPath)) {18 throw new Error(`No logs could be found at ${systemLogPath}`);19 }20 log.debug(`System log path: ${systemLogPath}`);21 tool = 'tail';22 args = ['-f', '-n', '1', systemLogPath];23 } else {24 if (!await this.sim.isRunning()) {25 throw new Error(`iOS Simulator with udid ${this.sim.udid} is not running`);26 }27 tool = 'xcrun';...

Full Screen

Full Screen

gulpfile.js

Source:gulpfile.js Github

copy

Full Screen

...18 appName,19 },20});21gulp.task('install', async function (done) {22 const xcodeVersion = await xcode.getVersion(true);23 if (xcodeVersion.major < 11) {24 log(`Not building ${appName} on Xcode version ${xcodeVersion.versionString}`);25 return done();26 }27 return gulp.series('ios-apps:install', function installDone (seriesDone) {28 seriesDone();29 done();30 })();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var xcode = require('appium-xcuitest-driver').xcode;4var desired = {5};6var driver = wd.promiseChainRemote('localhost', 4723);7 .init(desired)8 .then(function () {9 return xcode.getVersion();10 })11 .then(function (version) {12 console.log('xcode version: ' + version);13 })14 .fin(function () { return driver.quit(); })15 .done();16info: [debug] [XCUITest] Available devices: iPhone 6, iPhone 6 Plus, iPhone 6s, iPhone 6s Plus, iPhone 5s, iPhone SE, iPad Air 2, iPad Pro (9.7-inch), iPad Pro (12.9-inch), iPad (5th generation), iPad Pro (12.9-inch) (2nd generation), iPad Pro (10.5-inch), iPad (6th generation), iPad Pro (11-inch), iPad Pro (12.9-inch) (3rd generation), iPad mini 4, iPad Air (3rd generation)

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const xcode = require('appium-xcuitest-driver').xcode;3async function test() {4 const version = await xcode.getVersion();5 console.log(version);6}7test().catch(console.error);

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