Best JavaScript code snippet using appium-xcuitest-driver
utils-specs.js
Source:utils-specs.js
...27 mocks.iosUtils.expects('clearLogs')28 .once()29 .withExactArgs([`${DERIVED_DATA_ROOT}/Logs`])30 .returns();31 await clearSystemFiles(wda);32 });33 it('should only delete logs once if the same folder was marked twice for deletion', async function () {34 let wda = {35 retrieveDerivedDataPath () {36 return DERIVED_DATA_ROOT;37 }38 };39 mocks.fs.expects('exists')40 .withExactArgs(`${DERIVED_DATA_ROOT}/Logs`)41 .returns(true);42 mocks.iosUtils.expects('clearLogs')43 .once()44 .withExactArgs([`${DERIVED_DATA_ROOT}/Logs`])45 .returns();46 await markSystemFilesForCleanup(wda);47 await markSystemFilesForCleanup(wda);48 await clearSystemFiles(wda);49 await clearSystemFiles(wda);50 });51 it('should do nothing if no derived data path is found', async function () {52 let wda = {53 retrieveDerivedDataPath () {54 return null;55 }56 };57 mocks.iosUtils.expects('clearLogs')58 .never();59 await clearSystemFiles(wda);60 });61 }));62 describe('adjustWDAAttachmentsPermissions', withMocks({fs}, function (mocks) {63 afterEach(function () {64 mocks.verify();65 });66 it('should change permissions to Attachments folder', async function () {67 let wda = {68 retrieveDerivedDataPath () {69 return DERIVED_DATA_ROOT;70 }71 };72 mocks.fs.expects('exists')73 .once()...
wdio.appium.conf.js
Source:wdio.appium.conf.js
1const { config } = require('./wdio.shared.conf')2exports.config = {3 ...config,4 ...{5 host: '0.0.0.0',6 port: 4723,7 //path: '/wd/hub',8 services: [9 ['appium',10 {11 // For options see12 // https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-appium-service13 args: {14 // For arguments see15 // https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-appium-service16 },17 command: 'appium',18 },19 ],20 ],21 // For iOS bases mobile device22 capabilities: [{23 appiumVersion: '1.6.5',24 automationName: 'XCUITest',25 platformName: 'iOS',26 //platformVersion: '9.0',27 deviceName: 'iPhone Simulator',28 //deviceName: 'iPhone 6s',29 browserName: 'Safari',30 //orientation: 'PORTRAIT',31 //nativeInstrumentsLib: true,32 //isolateSimDevice: true,33 clearSystemFiles: true,34 //commandTimeout: '7200',35 //app: APP_PATH36 }],37 // // For Android bases mobile device38 // capabilities: [{39 // appiumVersion: '1.6.5',40 // automationName: 'Appium',41 // platformName: 'Android',42 // //platformVersion: '9.0',43 // deviceName: 'Android Emulator',44 // //deviceName: 'iPhone 6s',45 // browserName: 'chrome',46 // // chromeOptions: {47 // // androidPackage: 'com.android.chrome',48 // // },49 // //setDebugApp: '--persistent com.android.chrome',50 // chromeOptions: {args: ['--no-managed-user-acknowledgment-check', '--no-user-gesture-required', '--oobe-force-show-screen â']},51 // //orientation: 'PORTRAIT',52 // //nativeInstrumentsLib: true,53 // //isolateSimDevice: true,54 // //clearSystemFiles: true,55 // //app: APP_PATH56 // commandTimeout: '7200',57 // noReset: false,58 // //show_on_first_run_allowed: false,59 // dontStopAppOnReset: false,60 // show_on_first_run_allowed : false,61 // show_welcome_page: false,62 // appActivity: '.MainActivity',63 // appWaitActivity: 'SplashActivity',64 // noSign: true,65 // // intentCategory: 'android.intent.category.APP_CONTACTS',66 // // intentAction: 'android.intent.action.MAIN',67 // }],68 }...
wdio.dev.conf.js
Source:wdio.dev.conf.js
1require("babel-core/register")({2 presets: ['es2015']3});4require('./wdio.conf.js');5global.cfg.capabilities = [{6 /*7 udid: "",8 bundleId: "com.racing.enterprise.alpha",9 platformName: "iOS",10 platformVersion: "11.4.1",11 deviceName: "iPhoneRHM",12 automationName: "XCUITest",13 newCommandTimeout: "600000",14 useJSONSource: true,15 wdaStartupRetryInterval: "1000",16 clearSystemFiles: true,17 useNewWDA: true,18 waitForQuiescence: false,19 shouldUseSingletonTestManager: false20 platformName: "Android",21 platformVersion: "8.1",22 deviceName: "Nexus 5X API 27",23 browserName: 'android',24 app: "/Users/Jobayer/Documents/workspace/racing.com-appv2-appium/app-release.apk",25 automationName: "Appium"26*/27 platformName: "Android",28 platformVersion: "6.0.1",29 deviceName: "Samsung Galaxy S7",30 browserName: 'Android',31 app: "/Users/Jobayer/Documents/workspace/racing.com-appv2-appium/app-release.apk",32 //appPackage: 'com.racing.android',33 clearSystemFiles: "true",34 automationName: "Appium",35 appActivity: ".MainActivity"36 /*37 platformName: "Android",38 platformVersion: "8.0.0",39 deviceName: "Galaxy Note8",40 //browserName: 'Android',41 app: "/Users/Jobayer/Documents/workspace/racing.com-appv2-appium/app-release.apk",42 appPackage: 'com.racing.android',43 clearSystemFiles: "true",44 automationName: "Appium",45 appActivity: ".MainActivity"46 platformName: "Android",47 platformVersion: "8.1.0",48 deviceName: "Nexus 5x API 27",49 app: "/Users/Jobayer/Documents/workspace/racing.com-appv2-appium/app-release.apk",50 //appPackage: 'com.racing.android',51 clearSystemFiles: "true",52 automationName: "Appium",53 appActivity: ".MainActivity"54*/55}];56global.cfg.specs = [57 'tests/specs/validateHorseCardPopup.js'58];59global.cfg.exclude = [60 // 'tests/specs/*.js'61];62global.cfg.suites = {63 set1: [64 'tests/specs/testHomescreen.js',65 'tests/specs/testHorseProfile.js',66 'tests/specs/testJockeyCard.js',67 ]68};69global.cfg.host = '0.0.0.0';70global.cfg.port = '4723';71//global.cfg.port = '4723';72global.cfg.baseUrl = 'http://localhost';...
runner_android.js
Source:runner_android.js
1let date = new Date() + "";2date = date.substr(0, date.indexOf(" GMT"));3let browserStartGlobal;4exports.config = {5 multiCapabilities:6 [7 {8 seleniumAddress: 'http://127.0.0.1:4760/wd/hub',9 browserName: 'android',10 platformName: 'Android',11 platformVersion: '11',12 deviceName: 'Pixel 2',13 udid: 'FA7AC1A05643',14 app: process.cwd() + "/e2e/com.sirius.library/Apps/amazon.apk",15 bundleId: 'com.cutco.rep',16 autoWebviewTimeout: 30000,17 autoWebview: true,18 nativeWebTap: true,19 name: 'android',20 automationName: 'appium',21 nativeWebScreenshot: true,22 noReset: false,23 fullReset: true,24 clearSystemFiles: true,25 }26 ],27 framework: 'jasmine2',28 29 specs : process.cwd() + '/e2e/com.sirius.specs/launchapp.js',30 restartBrowserBetweenTests: true,31 allScriptsTimeout: 40000,32 getPageTimeout: 50000,33 jasmineNodeOpts: {34 defaultTimeoutInterval: 250000035 },36 onPrepare: function () {37 var AllureReporter = require('jasmine-allure-reporter');38 jasmine.getEnv().addReporter(new AllureReporter({39 resultDir: '../../Cutco_Framework/allure-results/',40 }));41 jasmine.getEnv().afterEach(function (done) {42 browser.takeScreenshot().then(function (png) {43 allure.createAttachment('Screenshot', function () {44 return new Buffer(png, 'base64')45 }, 'image/png')();46 done();47 })48 });49 }...
desiredCapabilities.js
Source:desiredCapabilities.js
1//These are desired capabilities for Android and iOS2exports.Android = {3 desiredCapabilities: {4 platformName: 'Android',5 platformVersion: '6.0.1',6 appPackage: 'com.techmahindra.mybeatplusapp',7 appActivity: 'com.techmahindra.mybeatplusapp.MainActivity',8 deviceName: 'LG G5',9 udid: 'LGH8605b04963d',10 unicodeKeyboard: true,11 resetKeyboard: true,12 clearSystemFiles: true,13 noReset: false14 },15 host: 'localhost',16 port: 4723,17 bp: 10018};19exports.mEasyAndroid = {20 desiredCapabilities: {21 platformName: 'Android',22 platformVersion: '6.0.1',23 appPackage: 'com.techmahindra.measy',24 appActivity: 'com.android.cioapp.activity.SplashScreen',25 deviceName: 'LG G5',26 udid: 'LGH8605b04963d',27 unicodeKeyboard: true,28 resetKeyboard: true,29 clearSystemFiles: true,30 noReset: false31 },32 host: 'localhost',33 port: 4723,34 bp: 10035};36exports.Android1 = {37 desiredCapabilities: {38 platformName: 'Android',39 platformVersion: '6.0.1',40 appPackage: 'com.techmahindra.measy',41 appActivity: 'com.android.cioapp.activity.SplashScreen',42 deviceName: 'LG G5',43 udid: 'LGH8605b04963d',44 unicodeKeyboard: true,45 resetKeyboard: true,46 clearSystemFiles: true,47 noReset: false48 },49 host: 'localhost',50 port: 4723,51 bp: 100...
appium.config.js
Source:appium.config.js
1exports.config = {2 fullUrl: 'http://hub.mobven.com:6008/wd/hub',3 host: 'hub.mobven.com',4 port: 6008,5 // eslint-disable-next-line radix6 wport: 2000,7 capabilities: {8 autoGrantPermissions: true,9 browserName: '',10 xcodeOrgId: 'CH3LB52K62', // 'RE9892F24F',11 xcodeSigningId: 'iPhone Developer',12 keychainPath: '/Users/mobven/Library/Keychains/appium2.keychain',13 keychainPassword: 'appium',14 wdaLocalPort: 2000,15 remoteDebugProxy: 2000,16 systemPort: 2000,17 ignoreUnimportantViews: false,18 unicodeKeyboard: true,19 resetKeyboard: true,20 wdaLaunchTimeout: 100000,21 wdaConnectionTimeout: 1000000,22 platformName: 'ios',23 platformVersion: '4.1',24 deviceName: 'deviceId',25 automationName: 'automationName',26 udid: 'udid',27 app: 'app',28 clearSystemFiles: true,29 usePrebuiltWDA: true,30 useNewWDA: false,31 disableWindowAnimation: true,32 fullReset: false,33 noReset: false,34 newCommandTimeout: 340000,35 },...
config.js
Source:config.js
1/* Appium capabilities2 * @doc http://appium.io/docs/en/writing-running-appium/caps/3 */4exports.desiredCapabilities = {5 platformName: "android",6 platformVersion: "1.0",7 deviceName: "Android Device",8 automationName: "UIAutomator2",9 udid: "udid",10 app: "sample-android.apk",11 //Advanced capabilities12 appPackage: "",13 appActivity: "",14 browserName: "",15 ignoreUnimportantViews: false,16 unicodeKeyboard: true,17 resetKeyboard: true,18 clearSystemFiles: true,19 usePrebuiltWDA: false,20 useNewWDA: true,21 noReset: true,22 fullReset: false,23 wdaLaunchTimeout: 100000,24};25//Set relative path for screencasts, make sure that path is writable26exports.screenShotPath = "/hdd/screenshots/";27// Server configuration28exports.serverConfig = {29 host: "localhost",30 port: 4723...
caps.js
Source:caps.js
1exports.Android10 = {2 automationName: 'UiAutomator2',3 platformName: 'Android',4 platformVersion: '10',5 deviceName: 'Android10',6 app: `${process.env.PWD}/app/com.monefy.apk`,7 browserName: '',8 clearSystemFiles: true,9 udid: 'emulator-5554',10 appPackage: 'com.monefy.app.lite',11 appWaitDuration: 60000,12 fullReset: true,13 language: 'EN',14 locale: 'EN',15 uiautomator2ServerLaunchTimeout: 60000,16 uiautomator2ServerInstallTimeout: 60000,17 androidInstallTimeout: 600000,18 remoteAppsCacheLimit: 0,19 newCommandTimeout: 450,...
Using AI Code Generation
1const wdio = require('webdriverio');2const opts = {3 capabilities: {4 }5};6async function main () {7 const driver = await wdio.remote(opts);8 await driver.deleteSession();9}10main();11exports.config = {12 capabilities: [{13 }],14 appium: {15 args: {
Using AI Code Generation
1const { remote } = require('webdriverio');2const opts = {3 capabilities: {4 }5};6(async () => {7 const client = await remote(opts);8 await client.clearSystemFiles();9 await client.deleteSession();10})();11from appium import webdriver12caps = {13}14driver.clear_system_files()15driver.quit()16const { remote } = require('webdriverio');17const opts = {18 capabilities: {19 }20};21(async () => {22 const client = await remote(opts);23 await client.getSettings();24 await client.deleteSession();25})();26from appium import webdriver27caps = {28}29driver.get_settings()30driver.quit()31const { remote } = require('webdriverio');32const opts = {33 capabilities: {
Using AI Code Generation
1const { AppiumDriver } = require('appium-base-driver');2const { XCUITestDriver } = require('appium-xcuitest-driver');3const { fs } = require('appium-support');4const path = require('path');5const xcuitestDriver = new XCUITestDriver();6const appiumDriver = new AppiumDriver();7xcuitestDriver.clearSystemFiles(appiumDriver, path.resolve('./'));8console.log(fs.readdirSync(path.resolve('./')));
Using AI Code Generation
1const wd = require('wd');2const {exec} = require('child_process');3const caps = {4};5async function clearSystemFiles() {6 const cmd = 'xcrun simctl erase "iPhone 8"';7 exec(cmd, (err, stdout, stderr) => {8 if (err) {9 return console.error(err);10 }11 console.log(stdout);12 });13}14async function main() {15 try {16 await driver.init(caps);17 await driver.sleep(5000);18 await clearSystemFiles();19 await driver.sleep(5000);20 await driver.quit();21 } catch (err) {22 console.error('Error: ', err);23 }24}25main();
Using AI Code Generation
1const wdio = require("webdriverio");2const opts = {3 capabilities: {4 }5};6async function main() {7 const client = await wdio.remote(opts);8 await client.deleteSession();9}10main();
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!!