How to use initDriver method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

driver-e2e-specs.js

Source:driver-e2e-specs.js Github

copy

Full Screen

...31 }32 driver = null;33 });34 it('should start android session focusing on default pkg and act', async function () {35 driver = await initDriver(APIDEMOS_CAPS);36 let appPackage = await driver.getCurrentPackage();37 let appActivity = await driver.getCurrentDeviceActivity();38 appPackage.should.equal(APIDEMOS_PACKAGE);39 appActivity.should.equal(APIDEMOS_MAIN_ACTIVITY);40 });41 it('should start android session focusing on custom pkg and act', async function () {42 let caps = Object.assign({}, APIDEMOS_CAPS, {43 appPackage: APIDEMOS_PACKAGE,44 appActivity: APIDEMOS_SPLIT_TOUCH_ACTIVITY,45 });46 driver = await initDriver(caps);47 let appPackage = await driver.getCurrentPackage();48 let appActivity = await driver.getCurrentDeviceActivity();49 appPackage.should.equal(caps.appPackage);50 appActivity.should.equal(caps.appActivity);51 });52 it('should error out for not apk extension', async function () {53 // Don't test this on TestObject. The 'app' cap gets stripped out and can't be tested54 if (process.env.TESTOBJECT_E2E_TESTS) {55 return;56 }57 let caps = Object.assign({}, APIDEMOS_CAPS, {58 app: 'foo',59 appPackage: APIDEMOS_PACKAGE,60 appActivity: APIDEMOS_SPLIT_TOUCH_ACTIVITY,61 });62 try {63 await initDriver(caps);64 throw new Error(`Call to 'initDriver' should not have succeeded`);65 } catch (e) {66 e.data.should.match(/does not exist or is not accessible/);67 }68 });69 it('should error out for invalid app path', async function () {70 // Don't test this on TestObject. The 'app' cap gets stripped out and can't be tested71 if (process.env.TESTOBJECT_E2E_TESTS) {72 return;73 }74 let caps = Object.assign({}, APIDEMOS_CAPS, {75 app: 'foo.apk',76 appPackage: APIDEMOS_PACKAGE,77 appActivity: APIDEMOS_SPLIT_TOUCH_ACTIVITY,78 });79 try {80 await initDriver(caps);81 throw new Error(`Call to 'initDriver' should not have succeeded`);82 } catch (e) {83 e.data.should.match(/does not exist or is not accessible/);84 }85 });86 it('should get device model, manufacturer and screen size in session details', async function () {87 let caps = Object.assign({}, APIDEMOS_CAPS, {88 appPackage: APIDEMOS_PACKAGE,89 appActivity: APIDEMOS_SPLIT_TOUCH_ACTIVITY,90 });91 driver = await initDriver(caps);92 let serverCaps = await driver.sessionCapabilities();93 serverCaps.deviceScreenSize.should.exist;94 serverCaps.deviceScreenDensity.should.exist;95 serverCaps.deviceModel.should.exist;96 serverCaps.deviceManufacturer.should.exist;97 serverCaps.deviceApiLevel.should.be.greaterThan(0);98 });99 });100 describe('custom adb port', function () {101 // Don't do these tests on TestObject. Cannot use TestObject's ADB.102 if (process.env.TESTOBJECT_E2E_TESTS) {103 return;104 }105 let adbPort = 5042;106 let driver;107 before(async function () {108 await killServer(DEFAULT_ADB_PORT);109 });110 afterEach(async function () {111 if (driver) {112 await driver.quit();113 }114 await killServer(adbPort);115 });116 it('should start android session with a custom adb port', async function () {117 let caps = Object.assign({}, APIDEMOS_CAPS, {118 adbPort,119 });120 driver = await initDriver(caps, adbPort);121 let appPackage = await driver.getCurrentPackage();122 let appActivity = await driver.getCurrentDeviceActivity();123 appPackage.should.equal(APIDEMOS_PACKAGE);124 appActivity.should.equal(APIDEMOS_MAIN_ACTIVITY);125 });126 });127 describe('w3c compliance', function () {128 it('should start a session with W3C caps', async function () {129 const { value, sessionId, status } = await request.post({url: `http://${DEFAULT_HOST}:${DEFAULT_PORT}/wd/hub/session`, json: {130 capabilities: {131 alwaysMatch: APIDEMOS_CAPS,132 firstMatch: [{}],133 }134 }});135 value.should.exist;136 value.capabilities.should.exist;137 value.sessionId.should.exist;138 should.not.exist(sessionId);139 should.not.exist(status);140 await request.delete({url: `http://${DEFAULT_HOST}:${DEFAULT_PORT}/wd/hub/session/${value.sessionId}`});141 });142 });143});144describe('close', function () {145 it('should close application', async function () {146 let driver = await initDriver(APIDEMOS_CAPS);147 await driver.closeApp();148 let appPackage = await driver.getCurrentPackage();149 if (appPackage) {150 appPackage.should.not.equal(APIDEMOS_PACKAGE);151 }152 });...

Full Screen

Full Screen

driver.js

Source:driver.js Github

copy

Full Screen

...17 function initController() {18 $scope.selectedOption = null;19 $scope.options = [];20 $scope.logentries = [];21 initDriver('getDriver', [myDriverService.getOptions()], function(result) {22 console.log("driver is " , result);23 $scope.options = result[0].data.driver;24 self.driver = result[0].data.driver;25 $scope.selectedOption = 0;26 });27 28 29 $scope.$on('appInitialized', function () {30 console.log("appInitialized - selection: " + $scope.selectedOption);31 $scope.logentries.push(($scope.logentries.length + 1) + " - appInitialized - selection: " + $scope.selectedOption);32 });33 } 34 35 self.post = function(DriverRepository, driverList)36 { 37 console.log("in driver.post BEGAIN. DriverRepository= " + DriverRepository + ", driverList= " + driverList);38 39 DriverRepository.post(self.driverList).then(40 function(result)41 {42 if(result != null && result != "undefined")43 {44 if(result.status == true)45 {46 console.log("in driver.post. in success handler scope. result is true");47 }48 }49 },50 function(result)51 {52 if(result != null && result != "undefined")53 {54 console.log("in driver.post. in error handler scope");55 }56 }57 )58 .catch(function(result)59 {60 console.log("in driver.post. in catch handler scope");61 });62 }63 64 self.buttonClicked = function()65 {66 DriverRepository.post([self.driver]);67 $timeout(function(){ $route.reload(); }, 2000);68 }69 70 initController();71 72});73angular.module('app.Repositories').factory('DriverRepository', function($http) {74 return {75 post: function(driverList) {76 $http.post('http://localhost:3000/DriverRequest', driverList).then( 77 function(response) 78 { 79 console.log('in DriverRepository.post. got response=', response.data);80 for (i= 0; i< driverList.length; i++) 81 {82 driverList[i].is_in_db = true;83 84 }85 86 },87 88 function(response)89 {90 console.log('in DriverRepository.post. got response=', response.data);91 for (i= 0; i< driverList.length; i++) 92 {93 driverList[i].is_in_db = false;94 }95 alert ('Error');96 } 97 );98 }99 };100}); 101myModule.factory('initDriver', function ($q, $rootScope, $browser) {102 103 var initFunctions = [104 'getDriver'105 ];106 var registeredInitFunctions = {};107 var initialized = false;108 109 var initApplication = function () {110 var getDriver = registeredInitFunctions['getDriver'];111 112 var broadcastAppInitialized = function () {113 $browser.defer(function () {114 initialized = true;115 $rootScope.$apply(function () {116 $rootScope.$broadcast('appInitialized');117 });118 });119 };120 getDriver.initDriver()121 .then(broadcastAppInitialized);122 };123 124 $rootScope.$on('$routeChangeStart', function () {125 registeredInitFunctions = {};126 initialized = false;127 });128 129 var initAppWhenReady = function () {130 initApplication();131 132 };133 134 var initDriver = function (name, dependencies, initCallback) {...

Full Screen

Full Screen

devices.js

Source:devices.js Github

copy

Full Screen

1load("basics.js");2function Device(settings) {3 this.deviceName = settings.deviceName;4 this.tags = settings.tags;5 this.excludedTags = settings.excludedTags;6 this.initDriver = settings.initDriver;7 this.quit = settings.quit;8}9Device.prototype.withProperty = function (propName, value) {10 this[propName] = value;11 return this;12};13function inLocalBrowser(name, size, tags, browserType) {14 return new Device({15 deviceName: name,16 tags: tags,17 size: size,18 initDriver: function (url) {19 this.driver = createDriver(url, size, browserType);20 return this.driver;21 },22 quit: function () {23 this.driver.quit();24 }25 });26}27function inSeleniumGrid(gridUrl, deviceName, tags, gridSettings) {28 return new Device({29 deviceName: deviceName,30 tags: tags,31 initDriver: function (url) {32 this.driver = createGridDriver(gridUrl, gridSettings);33 return this.driver;34 },35 quit: function () {36 this.driver.quit();37 }38 });39}40function convertGridDevices(devicesJson, gridUrl) {41 if (gridUrl === undefined || gridUrl === null) {42 throw new Error("Missing gridUrl argument");43 }44 var devices = {};45 forMap(devicesJson, function (deviceName, deviceSettings) {46 devices[deviceName] = inSeleniumGrid(gridUrl, deviceSettings.deviceName, deviceSettings.tags, deviceSettings.gridSettings);47 });48 return devices;49}50function loadGridDevices(configPath, gridUrl) {51 if (gridUrl === undefined || gridUrl === null) {52 throw new Error("Missing gridUrl argument");53 }54 if (fileExists(configPath)) {55 var devicesText = readFile(configPath);56 var devicesJson = JSON.parse(devicesText);57 return convertGridDevices(devicesJson, gridUrl);58 } else {59 throw new Error("Devices file not found: " + configPath);60 }61}62var _globalSingleDriver = null;63function inSingleBrowser(name, size, tags) {64 return new Device({65 deviceName: name,66 tags: tags,67 size: size,68 initDriver: function (url) {69 if (_globalSingleDriver === null) {70 _globalSingleDriver = createDriver(url, size);71 }72 this.driver = _globalSingleDriver;73 if (url !== null) {74 this.driver.get(url);75 }76 77 if (size !== null) {78 resize(this.driver, size);79 }80 return this.driver;81 },82 quit: function () {83 }84 });85}86afterTestSuite(function () {87 if (_globalSingleDriver !== null) {88 _globalSingleDriver.quit();89 _globalSingleDriver = null;90 }91});92(function (export) {93 export.inLocalBrowser = inLocalBrowser;94 export.inSeleniumGrid = inSeleniumGrid;95 export.inSingleBrowser = inSingleBrowser;96 export.Device = Device;97 export.loadGridDevices = loadGridDevices;...

Full Screen

Full Screen

orientation-e2e-specs.js

Source:orientation-e2e-specs.js Github

copy

Full Screen

...12 await driver.setOrientation('PORTRAIT');13 await driver.quit();14 });15 it('should have portrait orientation if requested', async function () {16 driver = await initDriver(Object.assign({}, APIDEMOS_CAPS, {17 appActivity: '.view.TextFields',18 orientation: 'PORTRAIT',19 }));20 await driver.getOrientation().should.eventually.eql('PORTRAIT');21 });22 it('should have landscape orientation if requested', async function () {23 driver = await initDriver(Object.assign({}, APIDEMOS_CAPS, {24 appActivity: '.view.TextFields',25 orientation: 'LANDSCAPE',26 }));27 await driver.getOrientation().should.eventually.eql('LANDSCAPE');28 });29 it('should have portrait orientation if nothing requested', async function () {30 driver = await initDriver(Object.assign({}, APIDEMOS_CAPS, {31 appActivity: '.view.TextFields',32 }));33 await driver.getOrientation().should.eventually.eql('PORTRAIT');34 });35 });36 describe('setting -', function () {37 before(async function () {38 driver = await initDriver(Object.assign({}, APIDEMOS_CAPS, {39 appActivity: '.view.TextFields'40 }));41 });42 after(async function () {43 await driver.quit();44 });45 it('should rotate screen to landscape', async function () {46 await driver.setOrientation('PORTRAIT');47 await B.delay(3000);48 await driver.setOrientation('LANDSCAPE');49 await B.delay(3000);50 await driver.getOrientation().should.eventually.become('LANDSCAPE');51 });52 it('should rotate screen to landscape', async function () {...

Full Screen

Full Screen

install.js

Source:install.js Github

copy

Full Screen

1'use strict';2var fs = require('fs');3var path = require('path');4var async = require('async');5var rimraf = require('rimraf');6var cli = require('./cli');7var config = require('./config');8var initDriver = require('./init-driver');9var configureIe = require('./configure-ie');10try {11 // reset drivers if any critical config has changed (such as arch version).12 var lastConfig = require('../last-config.json');13 if (lastConfig.is64 !== config.is64 || lastConfig.isWin !== config.isWin) {14 rimraf.sync(config.binariesPath);15 }16} catch (e) {17 // cannot locate last-config.json, nothing to do.18}19var tasks = [20 initDriver.bind(null, 'seleniumserver'),21 initDriver.bind(null, 'chromedriver'),22 initDriver.bind(null, 'geckodriver')23];24if (config.isWin) {25 tasks.push(26 initDriver.bind(null, 'iedriver'),27 configureIe.bind(null)28 );29}30async.series(tasks, function (err, taskResults) {31 var binaries;32 if (err) {33 cli.err('The following error occurred:');34 cli.err(err);35 cli.exit(1);36 return;37 }38 binaries = {39 home: process.env.SELENIUM_BINARIES_HOME40 };41 for (var i = 0; i < taskResults.length; i++) {42 var taskResult = taskResults[i];43 if (taskResult && taskResult.driverName) {44 binaries[taskResult.driverName] = taskResult.driverPath;45 }46 }47 fs.writeFileSync(48 path.resolve(__dirname, '..', 'last-config.json'),49 JSON.stringify(config, null, ' ')50 );51 fs.writeFileSync(52 path.resolve(__dirname, '..', 'binary-paths.json'),53 JSON.stringify(binaries, null, ' ')54 );...

Full Screen

Full Screen

session.js

Source:session.js Github

copy

Full Screen

...9 server = await startServer(PORT, HOST);10 return driver;11}12async function initSession (caps) {13 await initDriver();14 let serverRes = await driver.init(caps);15 if (!caps.udid && !caps.fullReset && serverRes[1].udid) {16 caps.udid = serverRes[1].udid;17 }18 await driver.setImplicitWaitTimeout(5000);19 return driver;20}21async function deleteSession () {22 try {23 await driver.quit();24 } catch (ign) {}25 try {26 await server.close();27 } catch (ign) {}...

Full Screen

Full Screen

all_3.js

Source:all_3.js Github

copy

Full Screen

1var searchData=2[3 ['initdriver',['initDriver',['../classLaserSensor.html#a1137c622e564b5706e6f36e253c2828b',1,'LaserSensor::initDriver()'],['../classSensor.html#a12851eb9413ee61c2d694b4168e365fd',1,'Sensor::initDriver()'],['../classUltrasonicSensor.html#a7e35552a5e39f38202c2a8650a90f43c',1,'UltrasonicSensor::initDriver()']]],4 ['initializemotorcontroller',['initializeMotorController',['../classMotorController.html#a56ae5e4c44399b8afe94eb721514dd5e',1,'MotorController']]]...

Full Screen

Full Screen

functions_3.js

Source:functions_3.js Github

copy

Full Screen

1var searchData=2[3 ['initdriver',['initDriver',['../classLaserSensor.html#a1137c622e564b5706e6f36e253c2828b',1,'LaserSensor::initDriver()'],['../classSensor.html#a12851eb9413ee61c2d694b4168e365fd',1,'Sensor::initDriver()'],['../classUltrasonicSensor.html#a7e35552a5e39f38202c2a8650a90f43c',1,'UltrasonicSensor::initDriver()']]],4 ['initializemotorcontroller',['initializeMotorController',['../classMotorController.html#a56ae5e4c44399b8afe94eb721514dd5e',1,'MotorController']]]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const initDriver = require('appium-xcuitest-driver').initDriver;2const initDriver = require('appium-ios-driver').initDriver;3const initDriver = require('appium-xcuitest-driver').initDriver;4const initDriver = require('appium-ios-driver').initDriver;5const initDriver = require('appium-xcuitest-driver').initDriver;6const initDriver = require('appium-ios-driver').initDriver;7const initDriver = require('appium-xcuitest-driver').initDriver;8const initDriver = require('appium-ios-driver').initDriver;9const initDriver = require('appium-xcuitest-driver').initDriver;10const initDriver = require('appium-ios-driver').initDriver;11const initDriver = require('appium-xcuitest-driver').initDriver;12const initDriver = require('appium-ios-driver').initDriver;13const initDriver = require('appium-xcuitest-driver').initDriver;14const initDriver = require('appium-ios-driver').initDriver;15const initDriver = require('appium-xcuitest-driver').initDriver;

Full Screen

Using AI Code Generation

copy

Full Screen

1const AppiumXCUITestDriver = require('appium-xcuitest-driver');2const driver = new AppiumXCUITestDriver();3driver.initDriver({4});5const AppiumXCUITestDriver = require('appium-xcuitest-driver');6const driver = new AppiumXCUITestDriver();7driver.initDriver({8});9const AppiumXCUITestDriver = require('appium-xcuitest-driver');10const driver = new AppiumXCUITestDriver();11driver.initDriver({12});13const AppiumXCUITestDriver = require('appium-xcuitest-driver');14const driver = new AppiumXCUITestDriver();15driver.initDriver({16});17const AppiumXCUITestDriver = require('appium-xcuitest-driver');18const driver = new AppiumXCUITestDriver();19driver.initDriver({20});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { initDriver } = require('appium-xcuitest-driver');2initDriver({3}).then((driver) => {4});5const { initDriver } = require('appium-xcuitest-driver');6initDriver({7}).then((driver) => {8});9const { initDriver } = require('appium-xcuitest-driver');10initDriver({11}).then((driver) => {12});13const { initDriver } = require('appium-xcuitest-driver');14initDriver({15}).then((driver) => {16});17const { initDriver } = require('appium-xcuitest-driver');18initDriver({19}).then((driver) => {20});21const { initDriver } = require('appium-xcuitest-driver');22initDriver({23}).then((driver) => {24});

Full Screen

Using AI Code Generation

copy

Full Screen

1const XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver;2const driver = new XCUITestDriver();3driver.initDriver({app: 'path/to/my.app'});4const XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver;5const driver = new XCUITestDriver();6driver.initDriver({app: 'path/to/my.app'});7const XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver;8const driver = new XCUITestDriver();9driver.initDriver({app: 'path/to/my.app'});10const XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver;11const driver = new XCUITestDriver();12driver.initDriver({app: 'path/to/my.app'});13const XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver;14const driver = new XCUITestDriver();15driver.initDriver({app: 'path/to/my.app'});16const XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver;17const driver = new XCUITestDriver();18driver.initDriver({app: 'path/to/my.app'});19const XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver;20const driver = new XCUITestDriver();21driver.initDriver({app: 'path/to/my.app'});22const XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver

Full Screen

Using AI Code Generation

copy

Full Screen

1const { initDriver } = require('appium-xcuitest-driver/build/lib/driver');2(async () => {3 const driver = await initDriver({ 4 });5 await driver.deleteSession();6})();7{8 "scripts": {9 },10 "dependencies": {11 }12}

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const { initDriver } = require('appium-xcuitest-driver');3const { startServer } = require('appium');4const { getPort } = require('portastic');5const { getSimulator } = require('appium-ios-simulator');6const { createDevice } = require('node-simctl');7const PORT = 4723;8const BUNDLE_ID = 'com.apple.Preferences';9const DEVICE_NAME = 'iPhone 8';10const startSimulator = async () => {11 const sim = await getSimulator(DEVICE_NAME);12 if (!sim) {13 await createDevice(DEVICE_NAME, 'iPhone 8', 'iOS 11.4');14 }15 return await getSimulator(DEVICE_NAME);16};17const startAppiumServer = async (port) => {18 return await startServer({

Full Screen

Using AI Code Generation

copy

Full Screen

1const { initDriver } = require('appium-xcuitest-driver');2const driver = await initDriver({caps: {platformName: 'iOS', deviceName: 'iPhone 11 Pro', app: 'path/to/app'}});3const { initDriver } = require('appium-xcuitest-driver');4const driver = await initDriver({caps: {platformName: 'iOS', deviceName: 'iPhone 11 Pro', app: 'path/to/app'}});5const { initDriver } = require('appium-xcuitest-driver');6const driver = await initDriver({caps: {platformName: 'iOS', deviceName: 'iPhone 11 Pro', app: 'path/to/app'}});7const { initDriver } = require('appium-xcuitest-driver');8const driver = await initDriver({caps: {platformName: 'iOS', deviceName: 'iPhone 11 Pro', app: 'path/to/app'}});9const { initDriver } = require('appium-xcuitest-driver');10const driver = await initDriver({caps: {platformName: 'iOS', deviceName: 'iPhone 11 Pro', app: 'path/to/app'}});11const { initDriver } = require('appium-xcuitest-driver');12const driver = await initDriver({caps: {platformName: 'iOS', deviceName: 'iPhone 11 Pro', app: 'path/to/app'}});13const { initDriver } = require('appium-xcuitest-driver');14const driver = await initDriver({caps: {platformName: 'iOS', deviceName: 'iPhone 11 Pro', app: 'path/to/app'}});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { initDriver } = require('appium-xcuitest-driver');2const driver = await initDriver({3});4await driver.quit();5const { initDriver } = require('appium-xcuitest-driver');6const driver = await initDriver({7});8await driver.quit();9const { initDriver } = require('appium-xcuitest-driver');10const driver = await initDriver({

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