Best JavaScript code snippet using appium-xcuitest-driver
simulator-xcode-6.js
Source:simulator-xcode-6.js
...1255 log.info(`SSL certificate '${_.truncate(payload, {length: 20})}' already installed`);1256 return false;1257 }1258 log.info(`Installing SSL root certificate '${_.truncate(payload, {length: 20})}'`);1259 await installSSLCert(payload, this.udid);1260 return true;1261 }1262 /**1263 * Simulates push notification delivery1264 *1265 * @since Xcode SDK 11.41266 */1267 async pushNotification (/* payload */) { // eslint-disable-line require-await1268 throw new Error(`Xcode SDK '${this.xcodeVersion}' is too old to push notifications`);1269 }1270 async getLaunchDaemonsRoot () {1271 const devRoot = await getDeveloperRoot();1272 return path.resolve(devRoot,1273 'Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/LaunchDaemons');...
driver.js
Source:driver.js
...150 this.opts.device = device;151 this.opts.udid = udid;152 this.opts.realDevice = realDevice;153 if (this.isSimulator() && this.opts.customSSLCert) {154 await installSSLCert(this.opts.customSSLCert, this.opts.udid);155 }156 // at this point if there is no platformVersion, get it from the device157 if (!this.opts.platformVersion) {158 if (this.opts.device && _.isFunction(this.opts.device.getPlatformVersion)) {159 this.opts.platformVersion = await this.opts.device.getPlatformVersion();160 log.info(`No platformVersion specified. Using device version: '${this.opts.platformVersion}'`);161 } else {162 // TODO: this is when it is a real device. when we have a real object wire it in163 }164 }165 // make sure that the xcode we are using can handle the platform166 if (parseFloat(this.opts.platformVersion) > parseFloat(this.iosSdkVersion)) {167 let msg = `Xcode ${this.xcodeVersion.versionString} has a maximum SDK version of ${this.iosSdkVersion}. ` +168 `It does not support iOS version ${this.opts.platformVersion}`;169 log.errorAndThrow(msg);170 }171 if ((this.opts.browserName || '').toLowerCase() === 'safari') {172 log.info('Safari test requested');173 this.safari = true;174 this.opts.app = undefined;175 this.opts.processArguments = this.opts.processArguments || {};176 this.opts.bundleId = SAFARI_BUNDLE_ID;177 this._currentUrl = this.opts.safariInitialUrl || (178 this.isRealDevice() ?179 'http://appium.io' :180 `http://${this.opts.address}:${this.opts.port}/welcome`181 );182 this.opts.processArguments.args = ['-u', this._currentUrl];183 } else {184 await this.configureApp();185 }186 // fail very early if the app doesn't actually exist187 if (this.opts.app) {188 await this.checkAppPresent();189 }190 if (!this.opts.bundleId) {191 this.opts.bundleId = await this.extractBundleId(this.opts.app);192 }193 if (!this.opts.realDevice && this.opts.scaleFactor !== undefined) {194 log.info(`Settings non-default Simulator scale factor ${this.opts.scaleFactor}`);195 device.setScaleFactor(this.opts.scaleFactor);196 }197 // handle logging198 this.logs = {};199 await this.startLogCapture();200 log.info(`Setting up ${this.isRealDevice() ? 'real device' : 'simulator'}`);201 if (!this.isRealDevice()) {202 this.localeConfig = await iosSettings.setLocale(this.opts.device, this.opts, {}, this.isSafari());203 await iosSettings.setPreferences(this.opts.device, this.opts, this.isSafari());204 await this.startSim();205 }206 if (this.opts.app) {207 await this.installApp();208 }209 await this.startWda(this.opts.sessionId, realDevice);210 await this.setInitialOrientation(this.opts.orientation);211 if (this.isSafari() || this.opts.autoWebview) {212 log.debug('Waiting for initial webview');213 await this.navToInitialWebview();214 }215 }216 async startWda (sessionId, realDevice, tries = 0) {217 tries++;218 this.wda = new WebDriverAgent(this.xcodeVersion, this.opts);219 if (this.opts.useNewWDA) {220 log.debug(`Capability 'useNewWDA' set, so uninstalling WDA before proceeding`);221 await this.wda.uninstall();222 }223 // local helper for the two places we need to uninstall wda and re-start it224 let uninstallAndRestart = async () => {225 log.debug('Quitting and uninstalling WebDriverAgent, then retrying');226 await this.wda.quit();227 await this.wda.uninstall();228 await this.startWda(sessionId, realDevice, tries);229 };230 try {231 await this.wda.launch(sessionId, realDevice);232 } catch (err) {233 if (tries > WDA_STARTUP_RETRIES) throw err;234 log.debug(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`);235 await uninstallAndRestart();236 }237 this.proxyReqRes = this.wda.proxyReqRes.bind(this.wda);238 this.jwpProxyActive = true;239 try {240 await retryInterval(15, 500, async () => {241 log.debug('Sending createSession command to WDA');242 try {243 await this.startWdaSession(this.opts.bundleId, this.opts.processArguments);244 } catch (err) {245 log.debug('Failed to create session. Retrying...');246 throw err;247 }248 });249 } catch (err) {250 log.debug(`Unable to start WebDriverAgent session: ${err.message}`);251 if (tries > WDA_STARTUP_RETRIES) throw err;252 await uninstallAndRestart();253 }254 if (typeof this.opts.preventWDAAttachments !== 'undefined') {255 await adjustWDAAttachmentsPermissions(this.opts.preventWDAAttachments ? '555' : '755');256 }257 }258 // create an alias so we can actually unit test createSession by stubbing259 // this260 async extractBundleId (app) {261 return await appUtils.extractBundleId(app);262 }263 async deleteSession () {264 await this.stop();265 await super.deleteSession();266 }267 async stop () {268 this.jwpProxyActive = false;269 this.proxyReqRes = null;270 if (this.wda) {271 if (this.wda.jwproxy) {272 await this.proxyCommand(`/session/${this.sessionId}`, 'DELETE');273 }274 await this.wda.quit();275 }276 if (this.isWebContext()) {277 log.debug('In a web session. Removing remote debugger');278 await this.stopRemote();279 }280 if (this.isRealDevice()) {281 await runRealDeviceReset(this.opts.device, this.opts);282 } else {283 await runSimulatorReset(this.opts.device, this.opts);284 }285 if (this.isSimulator() && this.opts.udid && this.opts.customSSLCert) {286 await uninstallSSLCert(this.opts.customSSLCert, this.opts.udid);287 }288 if (!this.opts.noReset && !!this.opts.device) {289 log.debug('Resetting simulator');290 if (this.lifecycleData.bootSim) {291 log.debug('Shutting down simulator');292 await this.opts.device.shutdown();293 }294 if (this.lifecycleData.createSim) {295 log.debug('Deleting simulator created for this run');296 await this.opts.device.delete();297 }298 }299 if (!_.isEmpty(this.logs)) {300 this.logs.syslog.stopCapture();...
utils.js
Source:utils.js
1import log from './logger';2import _ from 'lodash';3import { exec } from 'teen_process';4import { waitForCondition } from 'asyncbox';5import { getVersion } from 'appium-xcode';6import { getDevices } from 'node-simctl';7import { fs, tempDir } from 'appium-support';8import { Certificate } from './certificate';9import path from 'path';10import Simulator from './simulator-xcode-6';11import fkill from 'fkill';12const DEFAULT_SIM_SHUTDOWN_TIMEOUT = 30000;13const BIOMETRICS = {14 touchId: 'fingerTouch',15 faceId: 'pearl',16};17function toBiometricDomainComponent (name) {18 if (!BIOMETRICS[name]) {19 throw new Error(`'${name}' is not a valid biometric. Use one of: ${JSON.stringify(_.keys(BIOMETRICS))}`);20 }21 return BIOMETRICS[name];22}23// pgrep/pkill exit codes:24// 0 One or more processes were matched.25// 1 No processes were matched.26// 2 Invalid options were specified on the command line.27// 3 An internal error occurred.28async function pkill (appName, forceKill = false) {29 let args = forceKill ? ['-9'] : [];30 args.push('-x', appName);31 try {32 await exec('pkill', args);33 return 0;34 } catch (err) {35 if (!_.isUndefined(err.code)) {36 throw new Error(`Cannot forcefully terminate ${appName}. pkill error code: ${err.code}`);37 }38 log.error(`Received unexpected error while trying to kill ${appName}: ${err.message}`);39 throw err;40 }41}42async function killAllSimulators (timeout = DEFAULT_SIM_SHUTDOWN_TIMEOUT) {43 log.debug('Killing all iOS Simulators');44 const xcodeVersion = await getVersion(true);45 const appName = xcodeVersion.major >= 7 ? 'Simulator' : 'iOS Simulator';46 // later versions are slower to close47 timeout = timeout * (xcodeVersion.major >= 8 ? 2 : 1);48 try {49 await exec('xcrun', ['simctl', 'shutdown', xcodeVersion.major > 8 ? 'all' : 'booted'], {timeout});50 } catch (ign) {}51 const pids = [];52 try {53 const {stdout} = await exec('pgrep', ['-f', `${appName}.app/Contents/MacOS/`]);54 if (stdout.trim()) {55 pids.push(...(stdout.trim().split(/\s+/)));56 }57 } catch (e) {58 if (e.code === 1) {59 log.debug(`${appName} is not running. Continuing...`);60 return;61 }62 if (_.isEmpty(pids)) {63 log.warn(`pgrep error ${e.code} while detecting whether ${appName} is running. Trying to kill anyway.`);64 }65 }66 if (!_.isEmpty(pids)) {67 log.debug(`Using fkill to kill processes: ${pids.join(', ')}`);68 try {69 await fkill(pids, {force: true});70 } catch (ign) {}71 }72 log.debug(`Using pkill to kill application: ${appName}`);73 try {74 await pkill(appName, true);75 } catch (ign) {}76 // wait for all the devices to be shutdown before Continuing77 // but only print out the failed ones when they are actually fully failed78 let remainingDevices = [];79 async function allSimsAreDown () {80 remainingDevices = [];81 let devices = await getDevices();82 devices = _.flatten(_.values(devices));83 return _.every(devices, (sim) => {84 let state = sim.state.toLowerCase();85 let done = state === 'shutdown' ||86 state === 'unavailable' ||87 state === 'disconnected';88 if (!done) {89 remainingDevices.push(`${sim.name} (${sim.sdk}, udid: ${sim.udid}) is still in state '${state}'`);90 }91 return done;92 });93 }94 try {95 await waitForCondition(allSimsAreDown, {96 waitMs: timeout,97 intervalMs: 20098 });99 } catch (err) {100 if (remainingDevices.length > 0) {101 log.warn(`The following devices are still not in the correct state after ${timeout} ms:`);102 for (let device of remainingDevices) {103 log.warn(` ${device}`);104 }105 }106 throw err;107 }108}109async function endAllSimulatorDaemons () {110 log.debug('Ending all simulator daemons');111 for (let servicePattern of ['com.apple.iphonesimulator', 'com.apple.CoreSimulator']) {112 log.debug(`Killing any other ${servicePattern} daemons`);113 let launchCtlCommand = `launchctl list | grep ${servicePattern} | cut -f 3 | xargs -n 1 launchctl`;114 try {115 let stopCmd = `${launchCtlCommand} stop`;116 await exec('bash', ['-c', stopCmd]);117 } catch (err) {118 log.warn(`Could not stop ${servicePattern} daemons, carrying on anyway!`);119 }120 try {121 let removeCmd = `${launchCtlCommand} remove`;122 await exec('bash', ['-c', removeCmd]);123 } catch (err) {124 log.warn(`Could not remove ${servicePattern} daemons, carrying on anyway!`);125 }126 }127 // waiting until the simulator service has died.128 try {129 await waitForCondition(async () => {130 let {stdout} = await exec('bash', ['-c',131 `ps -e | grep launchd_sim | grep -v bash | grep -v grep | awk {'print$1'}`]);132 return stdout.trim().length === 0;133 }, {waitMs: 5000, intervalMs: 500});134 } catch (err) {135 log.warn(`Could not end all simulator daemons, carrying on!`);136 }137 log.debug('Finishing ending all simulator daemons');138}139async function getSimulatorInfo (udid) {140 // see the README for github.com/appium/node-simctl for example output of getDevices()141 let devices = await getDevices();142 devices = _.toPairs(devices)143 .map((pair) => pair[1])144 .reduce((a, b) => a.concat(b), []);145 return _.find(devices, (sim) => sim.udid === udid);146}147async function simExists (udid) {148 return !!(await getSimulatorInfo(udid));149}150async function safeRimRaf (delPath, tryNum = 0) {151 try {152 await fs.rimraf(delPath);153 } catch (err) {154 if (tryNum < 20) {155 if (err.message.indexOf('ENOTEMPTY') !== -1) {156 log.debug(`Path '${delPath}' was not empty during delete; retrying`);157 return await safeRimRaf(delPath, tryNum + 1);158 } else if (err.message.indexOf('ENOENT') !== -1) {159 log.debug(`Path '${delPath}' did not exist when we tried to delete, ignoring`);160 return await safeRimRaf(delPath, tryNum + 1);161 }162 }163 }164}165/**166 * Install an SSL certificate to a device with given udid167 * @param {string} pemText SSL pem text168 * @param {string} udid Identifier of the Simulator169 */170async function installSSLCert (pemText, udid) {171 // Check that openssl is installed on the path172 try {173 await fs.which('openssl');174 } catch (e) {175 log.debug(`customSSLCert requires openssl to be available on path`);176 log.errorAndThrow(`Command 'openssl' not found`);177 }178 // Check that sqlite3 is installed on the path179 try {180 await fs.which('sqlite3');181 } catch (e) {182 log.debug(`customSSLCert requires sqlite3 to be available on path`);183 log.errorAndThrow(`Command 'sqlite3' not found`);184 }185 // Create a temporary file to store PEM text186 // (a temp file is necessary to run `openssl` shell commands, can't be done in memory)187 let tempFileName = path.resolve(await tempDir.openDir(), 'temp-ssl-cert.pem');188 let pathToKeychain = new Simulator(udid).getDir();189 await fs.writeFile(tempFileName, pemText);190 try {191 await fs.stat(pathToKeychain);192 } catch (e) {193 log.debug(`Could not install SSL certificate. No simulator with udid '${udid}'`);194 log.errorAndThrow(e);195 }196 // Do the certificate installation197 let certificate = new Certificate(tempFileName);198 log.debug(`Installing certificate to ${pathToKeychain}`);199 await certificate.add(pathToKeychain);200 // Remove the temporary file201 await fs.unlink(tempFileName);202 return certificate;203}204async function uninstallSSLCert (pemText, udid) {205 try {206 let tempFileName = path.resolve(__dirname, 'temp-ssl-cert.pem');207 let pathToKeychain = path.resolve(new Simulator(udid).getDir());208 await fs.writeFile(tempFileName, pemText);209 let certificate = new Certificate(tempFileName);210 await certificate.remove(pathToKeychain);211 await fs.unlink(tempFileName);212 return certificate;213 } catch (e) {214 log.debug(`Could not uninstall SSL certificate. No simulator with udid '${udid}'`);215 log.errorAndThrow(e);216 }217}218/**219 * Check if the Simulator already has this SSL certificate220 * @param {string} pemText PEM text of SSL cert221 * @param {string} udid Identifier of the Simulator222 */223async function hasSSLCert (pemText, udid) {224 const tempFileName = path.resolve(await tempDir.openDir(), 'temp-ssl-cert.pem');225 const pathToKeychain = new Simulator(udid).getDir();226 await fs.writeFile(tempFileName, pemText);227 const certificate = new Certificate(tempFileName);228 return certificate.has(pathToKeychain);229}230/**231 * Runs a command line sqlite3 query232 *233 * @param {string} db - Full path to sqlite database234 * @param {string} query - The actual query string235 * @param {...string} queryParams - The list of query parameters236 * @returns {string} sqlite command stdout237 */238async function execSQLiteQuery (db, query, ...queryParams) {239 query = query.replace(/\n+/g, ' ');240 let queryTokens = query.split('?');241 let formattedQuery = [];242 queryParams243 .map((param) => `${param}`)244 .forEach((param, i) => {245 formattedQuery.push(queryTokens[i]);246 formattedQuery.push(param.replace(/'/g, "''"));247 });248 formattedQuery.push(queryTokens[queryTokens.length - 1]);249 log.debug(`Executing SQL query "${formattedQuery.join('')}" on '${db}'`);250 try {251 return (await exec('sqlite3', ['-line', db, formattedQuery.join('')])).stdout;252 } catch (err) {253 throw new Error(`Cannot execute SQLite query "${formattedQuery.join('')}" to '${db}'. ` +254 `Original error: ${err.stderr}`);255 }256}257async function getDeveloperRoot () {258 const {stdout} = await exec('xcode-select', ['-p']);259 return stdout.trim();260}261export {262 killAllSimulators,263 endAllSimulatorDaemons,264 safeRimRaf,265 simExists,266 getSimulatorInfo,267 installSSLCert,268 uninstallSSLCert,269 hasSSLCert,270 execSQLiteQuery,271 toBiometricDomainComponent,272 getDeveloperRoot,...
utils-specs.js
Source:utils-specs.js
...124 let simulatorGetDirStub = sinon.stub(Simulator.prototype, 'getDir').callsFake(function () {125 return path.resolve(assetsDir);126 });127 let testPem = await fs.readFile(path.resolve(assetsDir, 'test-pem.pem'));128 let certificate = await installSSLCert(testPem, `using mock, udid doesn't matter`);129 let certExistsInAssetsDir = await certificate.has(assetsDir);130 expect(certExistsInAssetsDir).to.be.true;131 await uninstallSSLCert(testPem, `using mock, udid doesn't matter`);132 certExistsInAssetsDir = await certificate.has(assetsDir);133 expect(certExistsInAssetsDir).to.be.false;134 simulatorGetDirStub.restore();135 });136 it('should throw exception if openssl is unavailable', async function () {137 let whichStub = sinon.stub(fs, 'which').callsFake(function () {138 throw new Error('no openssl');139 });140 await installSSLCert(`doesn't matter`, `doesn't matter`).should.be.rejected;141 whichStub.calledOnce.should.be.true;142 whichStub.restore();143 });144 it('should throw exception on installSSLCert if udid is invalid', async function () {145 await installSSLCert('pem dummy text', 'invalid UDID').should.be.rejected;146 });147 it('should throw exception on uninstallSSLCert if udid is invalid', async function () {148 await uninstallSSLCert('pem dummy text', 'invalid UDID').should.be.rejected;149 });150});151describe('Device preferences verification', function () {152 const sim = new SimulatorXcode9('1234', XCODE_VERSION_9);153 describe('for SimulatorWindowLastScale option', function () {154 it('should pass if correct', function () {155 const validValues = [0.5, 1, 1.5];156 for (const validValue of validValues) {157 (() => sim.verifyDevicePreferences({158 SimulatorWindowLastScale: validValue159 })).should.not.throw();160 }161 });162 it('should throw if incorrect', function () {...
execute.js
Source:execute.js
...88 } else {89 // xcuitest driver90 udid = this.opts.udid;91 }92 await installSSLCert(this.opts.httpsServerCertificate, udid);93};94helpers.stopHttpsAsyncServer = async function () {95 logger.debug('Stopping https server for async responses');96 if (this.opts.sslServer) {97 await this.opts.sslServer.close();98 }99 await uninstallSSLCert(this.opts.httpsServerCertificate, this.opts.udid);100};101commands.executeMobile = async function (mobileCommand, opts = {}) {102 // we only support mobile: scroll103 if (mobileCommand === 'scroll') {104 await this.mobileScroll(opts);105 } else if (mobileCommand === 'viewportScreenshot') {106 return await this.getViewportScreenshot();107 } else {108 throw new errors.UnknownCommandError('Unknown command, all the mobile commands except scroll have been removed.');109 }110};111Object.assign(extensions, commands, helpers);112export { commands, helpers };113export default extensions;
server.js
Source:server.js
...38 console.log(`Navigate to https://localhost:9758 in '${deviceName} Simulator'`.yellow);39 console.log('DO NOT PUSH THE CONTINUE BUTTON. PUSH CANCEL.'.red);40 // Call this if the user answers 'No' to any prompts41 async function done () {42 await uninstallSSLCert(keys.certificate, udid);43 server.close();44 console.log('Incomplete/failed test'.red);45 }46 let result = await inquirer.prompt([{47 type: 'confirm',48 name: 'confirmOpenSite',49 message: `Is https//localhost:9758 on '${deviceName} Simulator' unaccessible?`,50 }]);51 console.log('Certificate', keys.certificate, udid);52 await installSSLCert(keys.certificate, udid);53 if (!result.confirmOpenSite) return done(); // eslint-disable-line curly54 // Apply certificate to Simulator55 console.log('Installing certificate'.yellow);56 console.log(`Certificate installed to '${deviceName} ${udid}'. Navigate back to https://localhost:9758.`.yellow);57 result = await inquirer.prompt([{58 type: 'confirm',59 name: 'confirmOpenedSite',60 message: 'Now is https://localhost:9758 accessible?',61 }]);62 if (!result.confirmOpenedSite) {63 return done();64 }65 // Uninstall cert66 console.log(`Uninstalling SSL cert`.yellow);67 await uninstallSSLCert(keys.certificate, udid);68 console.log(`SSL cert removed.`.yellow);69 console.log(`Close the simulator, re-open it and then navigate back to https://localhost:9758`.yellow);70 result = await inquirer.prompt([{71 type: 'confirm',72 name: 'confirmUninstallCert',73 message: `Is https://localhost:9758 unaccessible?`,74 }]);75 if (result.confirmUninstallCert) {76 console.log('Test passed'.green);77 }78 return server.close();...
cert-utils.js
Source:cert-utils.js
...46 * @param {object} device Simulator instance created by appium-ios-simulator module47 * @param {string} payload Certificate payload48 */49async function installCertificateLegacy (device, payload) {50 await installSSLCert(payload, device.udid);51}52export {53 doesSupportKeychainApi, installCertificate, installCertificateLegacy,54 hasCertificateLegacy...
index.js
Source:index.js
1// transpile:main2import * as sim from './lib/simulator';3import * as utils from './lib/utils';4import * as sim6 from './lib/simulator-xcode-6';5const { getSimulator, getDeviceString } = sim;6const { killAllSimulators, endAllSimulatorDaemons, simExists, installSSLCert, uninstallSSLCert, hasSSLCert } = utils;7const { BOOT_COMPLETED_EVENT } = sim6;8export {9 getSimulator,10 getDeviceString,11 killAllSimulators,12 endAllSimulatorDaemons,13 simExists,14 installSSLCert,15 uninstallSSLCert,16 hasSSLCert,17 BOOT_COMPLETED_EVENT...
Using AI Code Generation
1var AppiumXCUITestDriver = require('appium-xcuitest-driver');2var appiumXCUITestDriver = new AppiumXCUITestDriver();3appiumXCUITestDriver.installSSLCert(sslCertPath, sslCertPassword);4var AppiumIOSDriver = require('appium-xcuitest-driver');5var appiumIOSDriver = new AppiumIOSDriver();6appiumIOSDriver.installSSLCert(sslCertPath, sslCertPassword);7var AppiumAndroidDriver = require('appium-android-driver');8var appiumAndroidDriver = new AppiumAndroidDriver();9appiumAndroidDriver.installSSLCert(sslCertPath, sslCertPassword);10var AppiumBaseDriver = require('appium-base-driver');11var appiumBaseDriver = new AppiumBaseDriver();12appiumBaseDriver.installSSLCert(sslCertPath, sslCertPassword);13var AppiumSelendroidDriver = require('appium-selendroid-driver');14var appiumSelendroidDriver = new AppiumSelendroidDriver();15appiumSelendroidDriver.installSSLCert(sslCertPath, sslCertPassword);16var AppiumYouiEngineDriver = require('appium-youiengine-driver');17var appiumYouiEngineDriver = new AppiumYouiEngineDriver();18appiumYouiEngineDriver.installSSLCert(sslCertPath, sslCertPassword);19var AppiumMacDriver = require('appium-mac-driver');20var appiumMacDriver = new AppiumMacDriver();21appiumMacDriver.installSSLCert(sslCertPath, sslCertPassword);22var AppiumWindowsDriver = require('appium-windows-driver');23var appiumWindowsDriver = new AppiumWindowsDriver();24appiumWindowsDriver.installSSLCert(sslCertPath, sslCertPassword);
Using AI Code Generation
1var AppiumXCUITestDriver = require('appium-xcuitest-driver');2var appiumXCUITestDriver = new AppiumXCUITestDriver();3appiumXCUITestDriver.installSSLCert(sslCertPath, sslCertPassword);4var AppiumIOSDriver = require('appium-xcuitest-driver');5var appiumIOSDriver = new AppiumIOSDriver();6appiumIOSDriver.installSSLCert(sslCertPath, sslCertPassword);7var AppiumAndroidDriver = require('appium-android-driver');8var appiumAndroidDriver = new AppiumAndroidDriver();9appiumAndroidDriver.installSSLCert(sslCertPath, sslCertPassword);10var AppiumBaseDriver = require('appium-base-driver');11var appiumBaseDriver = new AppiumBaseDriver();12appiumBaseDriver.installSSLCert(sslCertPath, sslCertPassword);13var AppiumSelendroidDriver = require('appium-selendroid-driver');14var appiumSelendroidDriver = new AppiumSelendroidDriver();15appiumSelendroidDriver.installSSLCert(sslCertPath, sslCertPassword);16var AppiumYouiEngineDriver = require('appium-youiengine-driver');17var appiumYouiEngineDriver = new AppiumYouiEngineDriver();18appiumYouiEngineDriver.installSSLCert(sslCertPath, sslCertPassword);19var AppiumMacDriver = require('appium-mac-driver');20var appiumMacDriver = new AppiumMacDriver();21appiumMacDriver.installSSLCert(sslCertPath, sslCertPassword);22var AppiumWindowsDriver = require('appium-windows-driver');23var appiumWindowsDriver = new AppiumWindowsDriver();24appiumWindowsDriver.installSSLCert(sslCertPath, sslCertPassword);
Using AI Code Generation
1const wd = require/('/wd');2const { installSSLCert } = require(ib/commands/certificate');3driver.init({4});=5 .then(() => installSSLCert.call(driver, 'path/to/cert.p12', 'password'))6 .then(() => d=rver.quit());
Using AI Code Generation
1const { AppiumDriver } = require('appium');2const { XCUITestDriver } = require('appium-xcuitest-driver');3cono{i tu ue( pistallSSLCmru mpthd of Appium X4const { fs } = require('appium-support');5const B = require('bluebird');6async function runTest() {7 const driver =uiew XCUITestDriver();8 const caps = {9 };t10 await driver.cr ateSession(caps);11 await driver.installSSLCert('path/to/cert');12}13runTest();
Using AI Code Generation
1var wd require('apwd;2var drbvud rwd.pqomes'ChdRmoe'lofalhuct',i4723);3on run. ih(piur.r3.amaz= awsCtom/T stApp7.1.app.z{p4}).sen(funcin}()){5.treturnhdriver.instfllSSLCere('pteh t cr'passorfo ct6}).then(function ()i{;n e for cert;7})reournn {quit();8});9Thetfollor;ngco wll uin the cific fom hu device.wll iSSLstDrtieic =e req(ppiuevict-driver');10const { util } = require('appium-support');11 const drivuner = new XCUITestDriver();cuit12da);i=rwd.l7rmivChnRe:',mcalhNm=',:4723);13='=Pho.ei (14). u( atNameXCUITest15 unssword for cer');616})noResetin{rue17/).hn(fun {18Threeurn nst {wiunllCUnstDrive the r } c= cip-tat'passwoid fo ccrn't driver = new XCUITestDriver();19}).ep n(funrw1 ) {20 tuiid.t);21}22var w;=reqir('wd');23vardrv =wd.proisCanReo('localho',4723);24dSSLC(p/thstr cvrtefi=.',s'paeC'httk/ysfrle');r25ratm'c,f, 'p hceNvkPyhoi e');26 };27}).th(fuct () {28}.then(function (isInstalled {29 =console.log('Is=SSL=Cert=Ins=alld: ' + isIstalled;30 return;31}32});33en(() => driver.quit());34commands.insicate to be stasync fenctdon (ce t, koy) {35 const {the} = th s.opts;36 const {keychanPah, kychainPaswod} = awat this.opts.deic.getDiForApplication(app37 co {sdou}= awaiexe('scuiy',['ist-kychains-d','user','-s', chanPath]38 nst{sdt:keychaLi}=awatexe('secry',['lst-kycais','-d','use']);39if(!kychainLincuds(kychainPah)){40 rnw===/l(`/ould tlsstkcha ach list'${kychaPath}'. ` +41/ `Oo ginaletaarcSLredf:p'${stdoum}'. LXscuafter aDtempt:r'${reychainList}'`);42 if (!keychiPwd.icuds(keychanPa)){43 rowErrr(`Couldt eteflt keycetnstto '${keychaiSPath}'. ` +rt } = require('appium-xcuitest-driver');44 `Origidulkechan:'${stout}'Deflt keychaafrattempt:'${keyhainPw}'`);45 }
Using AI Code Generation
1 co {stdout: unockKychain}awat xecsery', ['unlockkychan', '-p', keyhiPaswod, keyhPh])2e f (!utsockKtycSaLneinclthes(keyc aAeivh)){3 rnw (`ould unlock kychina${keychaPh}.`+TypeError: Cannot read property 'installSSLCert' of undefined4 `S:'${do}'.Srr: '${der}'`);5 }I have tried to use the following syntax, but it doesn't work:6 stdout:mpor awaitxcserity', ['mpor', cr, 'k', keychanPath, '-P', '', '-T', '/usbndesign']);7 if (!iportCert.iclue('1 te impord) {const { installSSLCert } = require('appium-xcuitest-driver-webdcommands/certificate');8rowErrr(`Clddfr'${rt}'. ` +9 `Stdot: '${tdout}'.Sdrr:'${strr}'`);10 }I am using appirm 1.6.5 and I want io vnstale srl certificate on my iOS device. I am using the following code:11 cons{tdou: impoKey} awaitexec('scrity', ['mpot', ky, '-k, keychnPath, '-P', '', 'T', '/bnegn]12 fn !qmprr(Keyainclpues('1 key-umsirlad')n {await installSSLCert(this.opts.udid, this.opts.iosInstallPausege13 r ewE(`Culddivae ke from'${key}. ` +
Using AI Code Generation
1le');2tallSSLC(ptht crtfi','pakyfle');3 { }wbge4stallSSLCert = 'sotcf,'phkyie');5const { installSSLCert } = require('appium-xcuitest-driver/lib/commands/certificate');6let installSSLCert = require('appium-xcuitest-driver/lib/commands/certificate').installSSLCert;7await installSSLCert(this.opts.udid, this.opts.iosInstallPause);8let { installSSLCert } = require('appium-ios-driver');9installSSLCert('path to cert file', 'path to key file');10let { installSSLCert } = require('appium-android-driver');11installSSLCert('path to cert file', 'path to key file');12let { installSSLCert } = require('appium-base-driver');13installSSLCert('path to cert file', 'path to key file');14let { installSSLCert } = require('appium-support');15installSSLCert('path to cert file', 'path to key file');16let { installSSLCert } = require('appium');17installSSLCert('path to cert file', 'path to key file');18let { installSSLCert } = require('appium/lib/utils');19installSSLCert('path to cert file', 'path to key file');20let { installSSLCert } = require('appium/lib/utils');21installSSLCert('path to cert file', 'path to key file');22let { installSSLCert } = require('appium/lib/utils');23installSSLCert('path to cert file', 'path to key file');
Using AI Code Generation
1const { installSSLCert } = require('appium-xcuitest-driver/lib/commands/certificate');2let installSSLCert = require('appium-xcuitest-driver/lib/commands/certificate').installSSLCert;3await installSSLCert(this.opts.udid, this.opts.iosInstallPause);4const { installSSLCert } = require('appium-xcuitest-driver/lib/commands/certificate');5let installSSLCert = require('appium-xcuitest-driver/lib/commands/certificate').installSSLCert;6await installSSLCert(this.opts.udid, this.opts.iosInstallPause);7const { installSSLCert } = require('appium-xcuitest-driver/lib/commands/certificate');8let installSSLCert = require('appium-xcuitest-driver/lib/commands/certificate').installSSLCert;9await installSSLCert(this.opts.udid, this.opts.iosInstallPause);
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!