How to use verifyApplicationPlatform method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

driver.js

Source:driver.js Github

copy

Full Screen

...842 if (this.opts.autoLaunch === false) {843 return;844 }845 try {846 await verifyApplicationPlatform(this.opts.app, this.isSimulator());847 } catch (err) {848 // TODO: Let it throw after we confirm the architecture verification algorithm is stable849 log.warn(`*********************************`);850 log.warn(`${this.isSimulator() ? 'Simulator' : 'Real device'} architecture appears to be unsupported ` +851 `by the '${this.opts.app}' application. ` +852 `Make sure the correct deployment target has been selected for its compilation in Xcode.`);853 log.warn('Don\'t be surprised if the application fails to launch.');854 log.warn(`*********************************`);855 }856 if (this.isRealDevice()) {857 await installToRealDevice(this.opts.device, this.opts.app, this.opts.bundleId, this.opts.noReset);858 } else {859 await installToSimulator(this.opts.device, this.opts.app, this.opts.bundleId, this.opts.noReset);860 }...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

1import B from 'bluebird';2import { utilities } from 'appium-ios-device';3import { fs, util, net, plist } from 'appium-support';4import path from 'path';5import { utils as iosUtils } from 'appium-ios-driver';6import { exec } from 'teen_process';7import xcode from 'appium-xcode';8import _ from 'lodash';9import log from './logger';10import iosGenericSimulators from './ios-generic-simulators';11import url from 'url';12import os from 'os';13import semver from 'semver';14const DEFAULT_TIMEOUT_KEY = 'default';15const XCTEST_LOG_FILES_PATTERNS = [16 /^Session-WebDriverAgentRunner.*\.log$/i,17 /^StandardOutputAndStandardError\.txt$/i,18];19const XCTEST_LOGS_CACHE_FOLDER_PREFIX = 'com.apple.dt.XCTest';20async function detectUdid () {21 log.debug('Auto-detecting real device udid...');22 const udids = await utilities.getConnectedDevices();23 if (_.isEmpty(udids)) {24 throw new Error('No device is connected to the host');25 }26 const udid = _.last(udids);27 if (udids.length > 1) {28 log.warn(`Multiple devices found: ${udids.join(', ')}`);29 log.warn(`Choosing '${udid}'. If this is wrong, manually set with 'udid' desired capability`);30 }31 log.debug(`Detected real device udid: '${udid}'`);32 return udid;33}34async function getAndCheckXcodeVersion () {35 let version;36 try {37 version = await xcode.getVersion(true);38 } catch (err) {39 log.debug(err);40 log.errorAndThrow(`Could not determine Xcode version: ${err.message}`);41 }42 // we do not support Xcodes < 7.3,43 if (version.versionFloat < 7.3) {44 log.errorAndThrow(`Xcode version '${version.versionString}'. Support for ` +45 `Xcode ${version.versionString} is not supported. ` +46 `Please upgrade to version 7.3 or higher`);47 }48 return version;49}50async function getAndCheckIosSdkVersion () {51 try {52 return await xcode.getMaxIOSSDK();53 } catch (err) {54 log.errorAndThrow(`Could not determine iOS SDK version: ${err.message}`);55 }56}57/**58 * Get the generic simulator for a given IOS version and device type (iPhone, iPad)59 *60 * @param {string|number} platformVersion IOS version. e.g.) 13.061 * @param {string} deviceName Type of IOS device. Can be iPhone, iPad (possibly more in the future)62 *63 * @returns {string} Generic iPhone or iPad simulator (if applicable)64 */65function getGenericSimulatorForIosVersion (platformVersion, deviceName) {66 let genericSimulators = iosGenericSimulators[deviceName];67 if (genericSimulators) {68 genericSimulators = genericSimulators.sort(([simOne], [simTwo]) => util.compareVersions(simOne, '<', simTwo) ? -1 : 1);69 // Find the highest iOS version in the list that is below the provided version70 let genericIosSimulator;71 for (const [platformVersionFromList, iosSimulator] of genericSimulators) {72 if (util.compareVersions(platformVersionFromList, '>', platformVersion)) {73 break;74 }75 genericIosSimulator = iosSimulator;76 }77 return genericIosSimulator;78 }79}80function translateDeviceName (platformVersion, deviceName = '') {81 const deviceNameTranslated = getGenericSimulatorForIosVersion(platformVersion, deviceName.toLowerCase().trim());82 if (deviceNameTranslated) {83 log.debug(`Changing deviceName from '${deviceName}' to '${deviceNameTranslated}'`);84 return deviceNameTranslated;85 }86 return deviceName;87}88// This map contains derived data logs folders as keys89// and values are the count of times the particular90// folder has been scheduled for removal91const derivedDataCleanupMarkers = new Map();92async function markSystemFilesForCleanup (wda) {93 if (!wda || !await wda.retrieveDerivedDataPath()) {94 log.warn('No WebDriverAgent derived data available, so unable to mark system files for cleanup');95 return;96 }97 const logsRoot = path.resolve(await wda.retrieveDerivedDataPath(), 'Logs');98 let markersCount = 0;99 if (derivedDataCleanupMarkers.has(logsRoot)) {100 markersCount = derivedDataCleanupMarkers.get(logsRoot);101 }102 derivedDataCleanupMarkers.set(logsRoot, ++markersCount);103}104async function clearSystemFiles (wda) {105 // only want to clear the system files for the particular WDA xcode run106 if (!wda || !await wda.retrieveDerivedDataPath()) {107 log.warn('No WebDriverAgent derived data available, so unable to clear system files');108 return;109 }110 const logsRoot = path.resolve(await wda.retrieveDerivedDataPath(), 'Logs');111 if (derivedDataCleanupMarkers.has(logsRoot)) {112 let markersCount = derivedDataCleanupMarkers.get(logsRoot);113 derivedDataCleanupMarkers.set(logsRoot, --markersCount);114 if (markersCount > 0) {115 log.info(`Not cleaning '${logsRoot}' folder, because the other session does not expect it to be cleaned`);116 return;117 }118 }119 derivedDataCleanupMarkers.set(logsRoot, 0);120 // Cleaning up big temporary files created by XCTest: https://github.com/appium/appium/issues/9410121 const globPattern = `${os.tmpdir()}/${XCTEST_LOGS_CACHE_FOLDER_PREFIX}*/`;122 const dstFolders = await fs.glob(globPattern);123 if (_.isEmpty(dstFolders)) {124 log.debug(`Did not find the temporary XCTest logs root at '${globPattern}'`);125 } else {126 // perform the cleanup asynchronously127 for (const dstFolder of dstFolders) {128 let scheduledFilesCount = 0;129 B.resolve(fs.walkDir(dstFolder, true, (itemPath, isDir) => {130 if (isDir) {131 return;132 }133 const fileName = path.basename(itemPath);134 if (!XCTEST_LOG_FILES_PATTERNS.some((p) => p.test(fileName))) {135 return;136 }137 // delete the file asynchronously138 fs.unlink(itemPath).catch((e) => {139 log.info(e.message);140 });141 scheduledFilesCount++;142 })).finally(() => {143 if (scheduledFilesCount > 0) {144 log.info(`Scheduled ${scheduledFilesCount} temporary XCTest log ` +145 `${util.pluralize('file', scheduledFilesCount)} for cleanup in '${dstFolder}'`);146 }147 }).catch((e) => {148 log.info(e.message);149 });150 }151 log.debug(`Started background XCTest logs cleanup in '${dstFolders}'`);152 }153 if (await fs.exists(logsRoot)) {154 log.info(`Cleaning test logs in '${logsRoot}' folder`);155 await iosUtils.clearLogs([logsRoot]);156 return;157 }158 log.info(`There is no ${logsRoot} folder, so not cleaning files`);159}160async function checkAppPresent (app) {161 log.debug(`Checking whether app '${app}' is actually present on file system`);162 if (!(await fs.exists(app))) {163 log.errorAndThrow(`Could not find app at '${app}'`);164 }165 log.debug('App is present');166}167async function getDriverInfo () {168 const stat = await fs.stat(path.resolve(__dirname, '..'));169 const built = stat.mtime.getTime();170 // get the package.json and the version from it171 const pkg = require(__filename.includes('build/lib/utils') ? '../../package.json' : '../package.json');172 const version = pkg.version;173 return {174 built,175 version,176 };177}178function normalizeCommandTimeouts (value) {179 // The value is normalized already180 if (typeof value !== 'string') {181 return value;182 }183 let result = {};184 // Use as default timeout for all commands if a single integer value is provided185 if (!isNaN(value)) {186 result[DEFAULT_TIMEOUT_KEY] = _.toInteger(value);187 return result;188 }189 // JSON object has been provided. Let's parse it190 try {191 result = JSON.parse(value);192 if (!_.isPlainObject(result)) {193 throw new Error();194 }195 } catch (err) {196 log.errorAndThrow(`"commandTimeouts" capability should be a valid JSON object. "${value}" was given instead`);197 }198 for (let [cmd, timeout] of _.toPairs(result)) {199 if (!_.isInteger(timeout) || timeout <= 0) {200 log.errorAndThrow(`The timeout for "${cmd}" should be a valid natural number of milliseconds. "${timeout}" was given instead`);201 }202 }203 return result;204}205async function printUser () {206 try {207 let {stdout} = await exec('whoami');208 log.debug(`Current user: '${stdout.trim()}'`);209 } catch (err) {210 log.debug(`Unable to get username running server: ${err.message}`);211 }212}213/**214 * Get the IDs of processes listening on the particular system port.215 * It is also possible to apply additional filtering based on the216 * process command line.217 *218 * @param {string|number} port - The port number.219 * @param {?Function} filteringFunc - Optional lambda function, which220 * receives command line string of the particular process221 * listening on given port, and is expected to return222 * either true or false to include/exclude the corresponding PID223 * from the resulting array.224 * @returns {Array<string>} - the list of matched process ids.225 */226async function getPIDsListeningOnPort (port, filteringFunc = null) {227 const result = [];228 try {229 // This only works since Mac OS X El Capitan230 const {stdout} = await exec('lsof', ['-ti', `tcp:${port}`]);231 result.push(...(stdout.trim().split(/\n+/)));232 } catch (e) {233 return result;234 }235 if (!_.isFunction(filteringFunc)) {236 return result;237 }238 return await B.filter(result, async (x) => {239 const {stdout} = await exec('ps', ['-p', x, '-o', 'command']);240 return await filteringFunc(stdout);241 });242}243/**244 * @typedef {Object} UploadOptions245 *246 * @property {?string} user - The name of the user for the remote authentication. Only works if `remotePath` is provided.247 * @property {?string} pass - The password for the remote authentication. Only works if `remotePath` is provided.248 * @property {?string} method - The http multipart upload method name. The 'PUT' one is used by default.249 * Only works if `remotePath` is provided.250 * @property {?Object} headers - Additional headers mapping for multipart http(s) uploads251 * @property {?string} fileFieldName [file] - The name of the form field, where the file content BLOB should be stored for252 * http(s) uploads253 * @property {?Object|Array<Pair>} formFields - Additional form fields for multipart http(s) uploads254 */255/**256 * Encodes the given local file to base64 and returns the resulting string257 * or uploads it to a remote server using http/https or ftp protocols258 * if `remotePath` is set259 *260 * @param {string} localPath - The path to an existing local file261 * @param {?string} remotePath - The path to the remote location, where262 * this file should be uploaded263 * @param {?UploadOptions} uploadOptions - Set of upload options264 * @returns {string} Either an empty string if the upload was successful or265 * base64-encoded file representation if `remotePath` is falsy266 */267async function encodeBase64OrUpload (localPath, remotePath = null, uploadOptions = {}) {268 if (!await fs.exists(localPath)) {269 log.errorAndThrow(`The file at '${localPath}' does not exist or is not accessible`);270 }271 if (_.isEmpty(remotePath)) {272 const {size} = await fs.stat(localPath);273 log.debug(`The size of the file is ${util.toReadableSizeString(size)}`);274 return (await util.toInMemoryBase64(localPath)).toString();275 }276 const {user, pass, method, headers, fileFieldName, formFields} = uploadOptions;277 const options = {278 method: method || 'PUT',279 headers,280 fileFieldName,281 formFields,282 };283 if (user && pass) {284 options.auth = {user, pass};285 }286 await net.uploadFile(localPath, remotePath, options);287 return '';288}289/**290 * Stops and removes all web socket handlers that are listening291 * in scope of the currect session.292 *293 * @param {Object} server - The instance of NodeJs HTTP server,294 * which hosts Appium295 * @param {string} sessionId - The id of the current session296 */297async function removeAllSessionWebSocketHandlers (server, sessionId) {298 if (!server || !_.isFunction(server.getWebSocketHandlers)) {299 return;300 }301 const activeHandlers = await server.getWebSocketHandlers(sessionId);302 for (const pathname of _.keys(activeHandlers)) {303 await server.removeWebSocketHandler(pathname);304 }305}306/**307 * @typedef {Object} PlatformOpts308 *309 * @property {boolean} isSimulator - Whether the destination platform is a Simulator310 * @property {boolean} isTvOS - Whether the destination platform is a Simulator311 */312/**313 * Verify whether the given application is compatible to the314 * platform where it is going to be installed and tested.315 *316 * @param {string} app - The actual path to the application bundle317 * @param {PlatformOpts} expectedPlatform318 * @throws {Error} If bundle architecture does not match the expected device architecture.319 */320async function verifyApplicationPlatform (app, expectedPlatform) {321 log.debug('Verifying application platform');322 const infoPlist = path.resolve(app, 'Info.plist');323 if (!await fs.exists(infoPlist)) {324 log.debug(`'${infoPlist}' does not exist`);325 return;326 }327 const {CFBundleSupportedPlatforms} = await plist.parsePlistFile(infoPlist);328 log.debug(`CFBundleSupportedPlatforms: ${JSON.stringify(CFBundleSupportedPlatforms)}`);329 if (!_.isArray(CFBundleSupportedPlatforms)) {330 log.debug(`CFBundleSupportedPlatforms key does not exist in '${infoPlist}'`);331 return;332 }333 const {334 isSimulator,335 isTvOS,336 } = expectedPlatform;337 const prefix = isTvOS ? 'AppleTV' : 'iPhone';338 const suffix = isSimulator ? 'Simulator' : 'OS';339 const dstPlatform = `${prefix}${suffix}`;340 if (!CFBundleSupportedPlatforms.includes(dstPlatform)) {341 throw new Error(`${isSimulator ? 'Simulator' : 'Real device'} architecture is unsupported by the '${app}' application. ` +342 `Make sure the correct deployment target has been selected for its compilation in Xcode.`);343 }344}345/**346 * Returns true if the urlString is localhost347 * @param {?string} urlString348 * @returns {boolean} Return true if the urlString is localhost349 */350function isLocalHost (urlString) {351 try {352 const {hostname} = url.parse(urlString);353 return ['localhost', '127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(hostname);354 } catch (ign) {355 log.warn(`'${urlString}' cannot be parsed as a valid URL`);356 }357 return false;358}359/**360 * Normalizes platformVersion to a valid iOS version string361 *362 * @param {string} originalVersion - Loose version number, that can be parsed by semver363 * @return {string} iOS version number in <major>.<minor> format364 * @throws {Error} if the version number cannot be parsed365 */366function normalizePlatformVersion (originalVersion) {367 const normalizedVersion = semver.coerce(originalVersion);368 if (!normalizedVersion) {369 throw new Error(`The platform version '${originalVersion}' should be a valid version number`);370 }371 return `${normalizedVersion.major}.${normalizedVersion.minor}`;372}373export { detectUdid, getAndCheckXcodeVersion, getAndCheckIosSdkVersion, getGenericSimulatorForIosVersion,374 checkAppPresent, getDriverInfo,375 clearSystemFiles, translateDeviceName, normalizeCommandTimeouts,376 DEFAULT_TIMEOUT_KEY, markSystemFilesForCleanup, printUser,377 getPIDsListeningOnPort, encodeBase64OrUpload, removeAllSessionWebSocketHandlers,...

Full Screen

Full Screen

app-utils.js

Source:app-utils.js Github

copy

Full Screen

1import _ from 'lodash';2import path from 'path';3import { plist, fs, util } from '@appium/support';4import log from './logger.js';5const STRINGSDICT_RESOURCE = '.stringsdict';6const STRINGS_RESOURCE = '.strings';7async function extractPlistEntry (app, entryName) {8 const plistPath = path.resolve(app, 'Info.plist');9 try {10 return (await plist.parsePlistFile(plistPath))[entryName];11 } catch (err) {12 throw new Error(`Could not extract Info.plist from '${path.basename(app)}': ${err.message}`);13 }14}15async function extractBundleId (app) {16 const bundleId = await extractPlistEntry(app, 'CFBundleIdentifier');17 log.debug(`Getting bundle ID from app '${app}': '${bundleId}'`);18 return bundleId;19}20/**21 * @typedef {Object} PlatformOpts22 *23 * @property {boolean} isSimulator - Whether the destination platform is a Simulator24 * @property {boolean} isTvOS - Whether the destination platform is a Simulator25 */26/**27 * Verify whether the given application is compatible to the28 * platform where it is going to be installed and tested.29 *30 * @param {string} app - The actual path to the application bundle31 * @param {PlatformOpts} expectedPlatform32 * @throws {Error} If bundle architecture does not match the expected device architecture.33 */34async function verifyApplicationPlatform (app, expectedPlatform) {35 log.debug('Verifying application platform');36 let supportedPlatforms;37 try {38 supportedPlatforms = await extractPlistEntry(app, 'CFBundleSupportedPlatforms');39 } catch (err) {40 log.debug(err.message);41 return;42 }43 log.debug(`CFBundleSupportedPlatforms: ${JSON.stringify(supportedPlatforms)}`);44 if (!_.isArray(supportedPlatforms)) {45 log.debug(`CFBundleSupportedPlatforms key does not exist in '${path.basename(app)}'`);46 return;47 }48 const {49 isSimulator,50 isTvOS,51 } = expectedPlatform;52 const prefix = isTvOS ? 'AppleTV' : 'iPhone';53 const suffix = isSimulator ? 'Simulator' : 'OS';54 const dstPlatform = `${prefix}${suffix}`;55 if (!supportedPlatforms.includes(dstPlatform)) {56 throw new Error(`${isSimulator ? 'Simulator' : 'Real device'} architecture is unsupported by the '${app}' application. ` +57 `Make sure the correct deployment target has been selected for its compilation in Xcode.`);58 }59}60async function readResource (resourcePath) {61 const data = await plist.parsePlistFile(resourcePath);62 const result = {};63 for (const [key, value] of _.toPairs(data)) {64 result[key] = _.isString(value) ? value : JSON.stringify(value);65 }66 return result;67}68async function parseLocalizableStrings (opts) {69 const {70 app,71 language = 'en',72 localizableStringsDir,73 stringFile,74 strictMode,75 } = opts;76 if (!app) {77 const message = `Strings extraction is not supported if 'app' capability is not set`;78 if (strictMode) {79 throw new Error(message);80 }81 log.info(message);82 return {};83 }84 let lprojRoot;85 for (const subfolder of [`${language}.lproj`, localizableStringsDir, '']) {86 lprojRoot = path.resolve(app, subfolder);87 if (await fs.exists(lprojRoot)) {88 break;89 }90 const message = `No '${lprojRoot}' resources folder has been found`;91 if (strictMode) {92 throw new Error(message);93 }94 log.debug(message);95 }96 log.info(`Will extract resource strings from '${lprojRoot}'`);97 const resourcePaths = [];98 if (stringFile) {99 const dstPath = path.resolve(lprojRoot, stringFile);100 if (await fs.exists(dstPath)) {101 resourcePaths.push(dstPath);102 } else {103 const message = `No '${dstPath}' resource file has been found for '${app}'`;104 if (strictMode) {105 throw new Error(message);106 }107 log.info(message);108 log.info(`Getting all the available strings from '${lprojRoot}'`);109 }110 }111 if (_.isEmpty(resourcePaths) && await fs.exists(lprojRoot)) {112 const resourceFiles = (await fs.readdir(lprojRoot))113 .filter((name) => _.some([STRINGS_RESOURCE, STRINGSDICT_RESOURCE], (x) => name.endsWith(x)))114 .map((name) => path.resolve(lprojRoot, name));115 resourcePaths.push(...resourceFiles);116 }117 log.info(`Got ${resourcePaths.length} resource file(s) in '${lprojRoot}'`);118 if (_.isEmpty(resourcePaths)) {119 return {};120 }121 const resultStrings = {};122 const toAbsolutePath = function (p) {123 return path.isAbsolute(p) ? p : path.resolve(process.cwd(), p);124 };125 for (const resourcePath of resourcePaths) {126 if (!util.isSubPath(toAbsolutePath(resourcePath), toAbsolutePath(app))) {127 // security precaution128 throw new Error(`'${resourcePath}' is expected to be located under '${app}'`);129 }130 try {131 const data = await readResource(resourcePath);132 log.debug(`Parsed ${_.keys(data).length} string(s) from '${resourcePath}'`);133 _.merge(resultStrings, data);134 } catch (e) {135 log.warn(`Cannot parse '${resourcePath}' resource. Original error: ${e.message}`);136 }137 }138 log.info(`Got ${_.keys(resultStrings).length} string(s) from '${lprojRoot}'`);139 return resultStrings;140}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const { XCUITestDriver } = require('appium-xcuitest-driver');3driver.init({4}).then(async () => {5 const xcuitestDriver = new XCUITestDriver({server: driver.server});6 const isAppInstalled = await xcuitestDriver.verifyApplicationPlatform();7 console.log(isAppInstalled);8});9const wd = require('wd');10const { XCUITestDriver } = require('appium-xcuitest-driver');11driver.init({12}).then(async () => {13 const xcuitestDriver = new XCUITestDriver({server: driver.server});14 const isAppInstalled = await xcuitestDriver.verifyApplicationPlatform();15 console.log(isAppInstalled);16});17const wd = require('wd');18const { XCUITestDriver } = require('appium-xcuitest-driver');19driver.init({20}).then(async () => {21 const xcuitestDriver = new XCUITestDriver({server: driver.server});22 const isAppInstalled = await xcuitestDriver.verifyApplicationPlatform();23 console.log(isAppInstalled);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var caps = {4};5var driver = wd.promiseChainRemote('ondemand.saucelabs.com', 80, 'SAUCE_USERNAME', 'SAUCE_ACCESS_KEY');6 .init(caps)7 .then(function() {8 return driver.verifyApplicationPlatform();9 })10 .then(function() {11 console.log("Application is installed on the right platform");12 })13 .then(function() {14 return driver.quit();15 })16 .catch(function(err) {17 console.log(err);18 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const AppiumXcuitestDriver = require('appium-xcuitest-driver').default;2const driver = new AppiumXcuitestDriver();3driver.verifyApplicationPlatform('iOS');4const AppiumXcuitestDriver = require('appium-xcuitest-driver').default;5const driver = new AppiumXcuitestDriver();6driver.verifyApplicationPlatform('iOS');7const AppiumXcuitestDriver = require('appium-xcuitest-driver').default;8const driver = new AppiumXcuitestDriver();9driver.verifyApplicationPlatform('iOS');10const AppiumXcuitestDriver = require('appium-xcuitest-driver').default;11const driver = new AppiumXcuitestDriver();12driver.verifyApplicationPlatform('iOS');13const AppiumXcuitestDriver = require('appium-xcuitest-driver').default;14const driver = new AppiumXcuitestDriver();15driver.verifyApplicationPlatform('iOS');16const AppiumXcuitestDriver = require('appium-xcuitest-driver').default;17const driver = new AppiumXcuitestDriver();18driver.verifyApplicationPlatform('iOS');19const AppiumXcuitestDriver = require('appium-xcuitest-driver').default;20const driver = new AppiumXcuitestDriver();21driver.verifyApplicationPlatform('iOS');22const AppiumXcuitestDriver = require('appium-xcuitest-driver').default;23const driver = new AppiumXcuitestDriver();24driver.verifyApplicationPlatform('iOS');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require("wd");2var chai = require("chai");3var chaiAsPromised = require("chai-as-promised");4chai.use(chaiAsPromised);5chai.should();6chaiAsPromised.transferPromiseness = wd.transferPromiseness;7var desiredCaps = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const {assert} = require('chai');3const {exec} = require('teen_process');4const {fs, tempDir} = require('appium-support');5const {XCUITestDriver} = require('appium-xcuitest-driver');6describe('my tests', function () {7 let driver;8 let caps = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const {verifyApplicationPlatform} = require('appium-xcuitest-driver');2(async () => {3 const platform = await verifyApplicationPlatform('/path/to/your/app');4 console.log(platform);5})();6const {verifyApplicationPlatform} = require('appium-android-driver');7(async () => {8 const platform = await verifyApplicationPlatform('/path/to/your/app');9 console.log(platform);10})();11const {verifyApplicationPlatform} = require('appium-windows-driver');12(async () => {13 const platform = await verifyApplicationPlatform('/path/to/your/app');14 console.log(platform);15})();16const {verifyApplicationPlatform} = require('appium-mac-driver');17(async () => {18 const platform = await verifyApplicationPlatform('/path/to/your/app');19 console.log(platform);20})();21const {verifyApplicationPlatform} = require('appium-espresso-driver');22(async () => {23 const platform = await verifyApplicationPlatform('/path/to/your/app');24 console.log(platform);25})();26const {verifyApplicationPlatform} = require('appium-youiengine-driver');27(async () => {28 const platform = await verifyApplicationPlatform('/path/to/your/app');29 console.log(platform);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { verifyApplicationPlatform } from 'appium-ios-driver/build/lib/commands/general';2import { util } from 'appium-support';3import _ from 'lodash';4const PLATFORM_NAME = 'iOS';5const PLATFORM_VERSION = '13.3';6async function test() {7 const platformName = PLATFORM_NAME;8 const platformVersion = PLATFORM_VERSION;9 const app = null;10 const bundleId = null;11 const deviceName = null;12 const isSimulator = true;13 const realDevice = false;14 const opts = {15 };16 const driver = {17 capabilities: {18 },19 };20 const capabilities = {21 };22 ];23 const capabilitiesConstraints = {24 app: {25 },26 bundleId: {27 },28 };29 const result = await verifyApplicationPlatform(driver, capabilities, requiredCaps, capabilitiesConstraints);30 console.log(result);31}32test();33import _ from 'lodash';34import { util } from 'appium-support';35async function verifyApplicationPlatform (driver, caps, requiredCaps, capabilitiesConstraints) {36 const {app, bundleId, deviceName, isSimulator, realDevice} = caps;37 const {platformVersion} = driver.opts;38 const {app: appConstraint, bundleId: bundleIdConstraint} = capabilitiesConstraints;39 const {app: appRequired, bundleId: bundleIdRequired} = requiredCaps;40 const isSafari = app === 'safari' || bundleId === 'com.apple.mobilesafari';41 if (isSafari) {42 return true;43 }44 if (!app && !bundleId) {45 return true;46 }47 if (app) {48 if (appConstraint)

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