How to use this.assertExists method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

ordered-set.js

Source:ordered-set.js Github

copy

Full Screen

1/**2 * Ordered Set object3 * @author Nicholas C. Zakas4 */5"use strict";6// hidden fields on the class7const first = Symbol("first");8const last = Symbol("last");9const nexts = Symbol("nexts");10const prevs = Symbol("prevs");11/**12 * Determines if the given value is valid for the set.13 * @param {*} value The value to check.14 * @returns {void}15 * @throws {Error} If the value is `null` or `undefined`. 16 */17function assertValidValue(value) {18 if (value == null) {19 throw new TypeError("Key cannot be null or undefined.");20 }21}22/**23 * Checks to see if a value already exists in the given map.24 * @param {*} value The value to check. 25 * @param {OrderedSet} set The set to check inside of.26 * @returns {void}27 * @throws {Error} If the value is a duplicate.28 */29function assertNoDuplicates(value, set) {30 if (set.has(value)) {31 throw new Error(`The value '${ value }' already exists in the set.`);32 }33}34/**35 * Determines if the given value already exists in the set.36 * @param {*} value The value to check for. 37 * @param {OrderedSet} set The map to check inside of.38 * @returns {void}39 * @throws {Error} If the value doesn't exist.40 */41function assertExists(value, set) {42 if (!set.has(value)) {43 throw new Error(`The value '${value}' does not exist.`);44 }45}46/**47 * Represents a list of unique values that can be accessed in order.48 */49class OrderedSet {50 /**51 * Creates a new instance.52 */53 constructor() {54 /**55 * Tracks the values that come after any given value.56 * @property nexts57 * @type Map58 * @private59 */60 this[nexts] = new Map();61 /**62 * Tracks the values that come before any given value.63 * @property prevs64 * @type Map65 * @private66 */67 this[prevs] = new Map();68 /**69 * Pointer to the first value in the set.70 * @property first71 * @type Map72 * @private73 */74 this[first] = undefined;75 /**76 * Pointer to the last value in the set.77 * @property last78 * @type Map79 * @private80 */81 this[last] = undefined;82 }83 /**84 * Returns the value that comes after the given value in the set.85 * @param {*} value The item to get the next value for.86 * @returns {*} The value that comes immediately after the given value or87 * `undefined` if no such value exists. 88 */89 next(value) {90 return this[nexts].get(value);91 }92 /**93 * Searches forward in the set to find the first value that matches.94 * @param {Function} matcher The function to run on each value. The95 * function must return `true` when the value matches. 96 * @param {*} start The value to start searching from.97 * @returns {*} The first matching value or `undefined` if no matches98 * are found. 99 */100 findNext(matcher, start) {101 assertExists(start, this);102 let current = this.next(start);103 while (current) {104 if (matcher(current)) {105 return current;106 }107 current = this.next(current);108 }109 return undefined;110 }111 /**112 * Searches backward in the set to find the first value that matches.113 * @param {Function} matcher The function to run on each value. The114 * function must return `true` when the value matches. 115 * @param {*} start The value to start searching from.116 * @returns {*} The first matching value or `undefined` if no matches117 * are found. 118 */119 findPrevious(matcher, start) {120 assertExists(start, this);121 let current = this.previous(start);122 while (current) {123 if (matcher(current)) {124 return current;125 }126 current = this.previous(current);127 }128 return undefined;129 }130 /**131 * Returns the value that comes before the given value in the set.132 * @param {*} value The item to get the previous value for.133 * @returns {*} The value that comes immediately before the given value or134 * `undefined` if no such value exists.135 */136 previous(value) {137 return this[prevs].get(value);138 }139 /**140 * Determines if the given value exists in the set.141 * @param {*} value The value to check for.142 * @returns {boolean} True if the value is found in the set, false if not. 143 */144 has(value) {145 return this[nexts].has(value);146 }147 /**148 * Adds a new value to the end of the set.149 * @param {*} value The value to add into the set.150 * @returns {void} 151 */152 add(value) {153 assertValidValue(value);154 assertNoDuplicates(value, this);155 // special case for first item156 if (this[first] === undefined) {157 this[first] = value;158 this[last] = value;159 this[nexts].set(value, undefined);160 this[prevs].set(value, undefined);161 } else {162 this[nexts].set(this[last], value);163 this[nexts].set(value, undefined);164 this[prevs].set(value, this[last]);165 this[last] = value;166 }167 }168 /**169 * Inserts a value after a given value that already exists in the set.170 * @param {*} value The value to insert.171 * @param {*} relatedValue The value after which to insert the new value.172 * @returns {void}173 * @throws {Error} If `value` is an invalid value for the set.174 * @throws {Error} If `value` already exists in the set.175 * @throws {Error} If `relatedValue` does not exist in the set.176 */177 insertAfter(value, relatedValue) {178 assertValidValue(value);179 assertNoDuplicates(value, this);180 assertExists(relatedValue, this);181 const curNext = this.next(relatedValue);182 this[nexts].set(relatedValue, value);183 this[nexts].set(value, curNext);184 this[prevs].set(curNext, value);185 this[prevs].set(value, relatedValue);186 // special case: relatedItem is the last item187 if (relatedValue === this[last]) {188 this[last] = value;189 }190 }191 /**192 * Inserts a value before a given value that already exists in the set.193 * @param {*} value The value to insert.194 * @param {*} relatedValue The value before which to insert the new value.195 * @returns {void}196 * @throws {Error} If `value` is an invalid value for the set.197 * @throws {Error} If `value` already exists in the set.198 * @throws {Error} If `relatedValue` does not exist in the set.199 */200 insertBefore(value, relatedValue) {201 assertValidValue(value);202 assertNoDuplicates(value, this);203 assertExists(relatedValue, this);204 const curPrev = this.previous(relatedValue);205 this[prevs].set(relatedValue, value);206 this[prevs].set(value, curPrev);207 this[nexts].set(value, relatedValue);208 209 // special case: relatedItem is the first item210 if (relatedValue === this[first]) {211 this[first] = value;212 } else {213 this[nexts].set(curPrev, value);214 }215 }216 /**217 * Removes a value from the set while ensuring the order remains correct.218 * @param {*} value The value to remove from the set.219 * @returns {void}220 * @throws {Error} If `value` is an invalid value for the set.221 * @throws {Error} If `value` already exists in the set.222 */223 delete(value) {224 assertValidValue(value);225 assertExists(value, this);226 // get the items currently before and after227 const curPrev = this.previous(value);228 const curNext = this.next(value);229 // check the list first and last pointers230 if (this[first] === value) {231 this[first] = curNext;232 }233 if (this[last] === value) {234 this[last] = curPrev;235 }236 // arrange pointers to skip over the item to remove237 if (curPrev !== undefined) {238 this[nexts].set(curPrev, curNext);239 }240 if (curNext !== undefined) {241 this[prevs].set(curNext, curPrev);242 }243 // officially remove the item244 this[prevs].delete(value);245 this[nexts].delete(value);246 }247 /**248 * Returns the number of values in the set.249 * @returns {int} The numbet of values in the set.250 */251 get size() {252 return this[nexts].size;253 }254 /**255 * Returns the first value in the set.256 * @returns {*} The first value in the set or `undefined` for an empty set.257 */258 first() {259 return this[first]; 260 }261 /**262 * Returns the last value in the set.263 * @returns {*} The last value in the set or `undefined` for an empty set.264 */265 last() {266 return this[last]; 267 }268 /**269 * Returns the default iterator for the set.270 * @returns {Iterator} The default iterator for the set.271 */272 [Symbol.iterator]() {273 return this.values();274 }275 /**276 * Returns an iterator over all of the values in the set.277 * @returns {Iterator} An iterator for the set.278 */279 *values() {280 let item = this[first];281 282 while (item) {283 yield item;284 item = this.next(item);285 }286 }287 /**288 * Returns an iterator over all of the values in the set going in reverse.289 * @returns {Iterator} An iterator for the set.290 */291 *reverse() {292 let item = this[last];293 while (item) {294 yield item;295 item = this.previous(item);296 }297 }298}...

Full Screen

Full Screen

hook.js

Source:hook.js Github

copy

Full Screen

...94 * @return {this}95 * @api private96 */97Hook.prototype.run = function(envVars, cb) {98 this.assertExists();99 if(envVars) { helper.log(JSON.stringify(envVars), 'env'); }100 helper.log(this.name, 'running');101 var command = this.command(envVars)102 , self = this;103 helper.log(command, 'exec');104 this.process = helper.exec(command, { cwd: this.path }, function(err) {105 if (err) { helper.log(err, '>'); }106 if(cb) { cb(null, self); }107 });108 var runLogName = dateFormat(new Date(), "yyyy-mm-dd-HHMMss") + '.log'109 , runLog = fse.createWriteStream(path.join(self.runsPath, runLogName));110 self.process.stdout.pipe(runLog);111 self.process.stderr.pipe(runLog);112 return this;113}114/**115 * Remove the script file for this hook.116 *117 * @api private118 */119Hook.prototype.destroy = function(cb) {120 this.assertExists();121 var self = this;122 fse.remove(this.path, function(err) {123 if (err) {124 helper.log(err, 'error');125 } else {126 helper.log(helper.relative(self.path), 'remove');127 }128 return cb && cb(err, self);129 });130}131/**132 * Throw an error if this hook's script file doesn't exist.133 *134 * @api private...

Full Screen

Full Screen

0100-TEST_INCORRECT_CREDENTIALS.js

Source:0100-TEST_INCORRECT_CREDENTIALS.js Github

copy

Full Screen

...37 initialCredential = adminMod.getCredentials();38 test.info("Initial credential for api_username_sandbox was :" + initialCredential);39 adminMod.fillCredentials(test, "WRONG CREDENTIALS");40 }, function fail() {41 this.assertExists(42 'form#account_form input[name="api_username_sandbox"]',43 'Field "api_username_sandbox" exists'44 );45 });46 })47 .thenOpen(baseURL, function () {48 checkoutMod.selectItemAndOptions(test);49 })50 .then(function () {51 checkoutMod.personalInformation(test);52 })53 .then(function () {54 checkoutMod.billingInformation(test, 'FR');55 })...

Full Screen

Full Screen

ajax_render.js

Source:ajax_render.js Github

copy

Full Screen

...43// fs.write('temp.html',this.getHTML(),'w');44// this.capture('test.png')45// //this.echo (__utils__.getElementByXPath('.//img')),46// // this.echo ('this is a test'),47// //this.assertExists(x('//*[@href="//shoppingcart.aliexpress.com"]'), 'the element exists')48// // if (this.visible('#hplogo')) {49// // this.echo("I can see the logo");50// // } else {51// // this.echo("I can't see the logo");52// // }53// })54casper.run(function(){55 //this.echo('So the whole suite ended');56 //__utils__.echo('php');57 this.exit();58})59//http://g01.a.alicdn.com/kf/HTB1kFXxIpXXXXbFXVXXq6xXFXXX2/222419831/HTB1kFXxIpXXXXbFXVXXq6xXFXXX2.jpg?size=128946&height=968&width=790&hash=6b7675c3c37ccb16c5bae8e62ce9482460//USAGE: E:\toolkit\n1k0-casperjs-e3a77d0\bin>python casperjs site.js --url=http://spys.ru/free-proxy-list/IE/ --outputfile='temp.html' 61 ...

Full Screen

Full Screen

credential.js

Source:credential.js Github

copy

Full Screen

1class Credentials {2 constructor(config, existing) {3 this.config = config;4 if (existing) {5 cy.contains('li.MuiListItem-container', config.label)6 .find('[data-cy="edit-credential-edit-button"]')7 .click();8 } else {9 cy.get('[data-cy="add-credential-add-button"]').click();10 }11 }12 applyMandatoryFields(config) {13 if (config !== undefined) {14 this.config = config;15 }16 cy.get('[data-cy="credential-form-auth-label-input"]')17 .clear()18 .type(this.config.label)19 .blur();20 return this;21 }22 applyUser(config) {23 if (config !== undefined) {24 this.config = config;25 }26 cy.get('[data-cy="credential-form-auth-user-input"]')27 .clear()28 .type(this.config.user)29 .blur();30 return this;31 }32 applyPassword(config) {33 if (config !== undefined) {34 this.config = config;35 }36 cy.get('[data-cy="credential-form-auth-password-input"]')37 .clear()38 .type(this.config.password)39 .blur();40 cy.get('[data-cy="credential-form-auth-password-confirmation-input"]')41 .clear()42 .type(this.config.passwordConf || this.config.password)43 .blur();44 return this;45 }46 applyToken(config) {47 if (config !== undefined) {48 this.config = config;49 }50 cy.get('[data-cy="credential-form-auth-token-input"]')51 .clear()52 .type(this.config.token)53 .blur();54 return this;55 }56 save() {57 cy.get('[data-cy="credential-form-submit-button"]').click();58 return this;59 }60 assertExists() {61 cy.get('[data-cy="app-dialog-content"]').should(62 'contain',63 this.config.label64 );65 return this;66 }67 assertTabDisappear() {68 cy.get('[data-cy="app-credential-form-tab"]').should('not.be.visible');69 return this;70 }71 assertErrorMessageVisible(message, dataCYName) {72 cy.contains(`[data-cy^="${dataCYName}"]`, message).should('is.visible');73 return this;74 }75}76export function addCredentials(config) {77 return new Credentials(config, false);78}79export function loadCredentials(config) {80 return new Credentials(config, true);...

Full Screen

Full Screen

endpoint.js

Source:endpoint.js Github

copy

Full Screen

1class Endpoint {2 constructor(config, existing) {3 this.config = config;4 if (existing) {5 cy.contains('li.MuiListItem-container', config.label)6 .find('[data-cy="edit-endpoint-edit-button"]')7 .click();8 } else {9 cy.get('[data-cy="add-endpoint-add-button"]').click();10 }11 }12 applyConfig(config) {13 if (config !== undefined) {14 this.config = config;15 }16 cy.get('[data-cy="endpoint-form-label-input"]')17 .clear()18 .type(this.config.label)19 .blur();20 cy.get('[data-cy="endpoint-form-url-input"]')21 .clear()22 .type(this.config.url)23 .blur();24 cy.get('[data-cy="endpoint-form-public-url-input"]')25 .clear()26 .type(this.config.publicUrl)27 .blur();28 cy.get('[data-cy="endpoint-form-credentials-input"]').click();29 cy.get('[role="listbox"]').within(() => {30 if (this.config.credentials) {31 cy.contains('li', this.config.credentials)32 .scrollIntoView()33 .click();34 } else {35 cy.get('li')36 .first()37 .click();38 }39 });40 return this;41 }42 save() {43 cy.get('[data-cy="endpoint-form-submit-button"]').click();44 return this;45 }46 cancel() {47 cy.get('[data-cy="endpoint-form-cancel-button"]').click();48 return this;49 }50 delete() {51 cy.contains('li.MuiListItem-container', this.config.label)52 .find('[data-cy="delete-endpoint-delete-button"]')53 .click();54 cy.get('[data-cy="confirmation-dialog-ok"]').click();55 return this;56 }57 assertErrorMessageVisible(message) {58 cy.contains('[data-cy^="endpoint-form-"]', message).should('is.visible');59 return this;60 }61 assertExists() {62 cy.get('[data-cy="app-dialog-content"]').should(63 'contain',64 this.config.label65 );66 return this;67 }68}69export function addEndpoint(config) {70 return new Endpoint(config, false);71}72export function loadEndpoint(config) {73 return new Endpoint(config, true);...

Full Screen

Full Screen

Session.js

Source:Session.js Github

copy

Full Screen

...4 var test = new Test('start session (invalid attempts)', queue);5 ApiTest.testApi(test, '/session/start/', {}, null, null, 'called without deviceId', false);6 test = new Test('start session', queue);7 ApiTest.testApi(test, '/session/start/', {deviceId: ApiTest.deviceId}, function(data) {8 this.assertExists(data, 'sessionIdentifier', 'response.sessionIdentifier exists');9 this.assert(data.isLoggedIn === false, 'response.isLoggedIn == false');10 this.assert(data.hasAccount === false, 'response.hasAccount == false');11 ApiTest.currentSession = data.sessionIdentifier;12 this.currentStep.complete();13 }, null);14 // Renew session tests15 test = new Test('renew session (invalid attempts)', queue);16 test.stepAsync(function(step) {17 ApiTest.callApi('/session/renew/', {deviceId: ApiTest.deviceId}, this.wrap(function() {18 this.assert(false, 'Called without sessionId was successful')19 }), this.wrap(function(message) {20 this.currentStep.complete();21 }));22 });23 ApiTest.testApi(test, '/session/renew/', {deviceId: ApiTest.deviceId, sessionId: 123}, null, null,24 'Called with invalid sessionId', false);25 test = new Test('renew session', queue);26 ApiTest.testApi(test, '/session/renew/', {deviceId: ApiTest.deviceId}, function(data) {27 this.assertExists(data, 'sessionIdentifier', 'sessionIdentifier');28 this.assert(data.isLoggedIn === false, 'response.isLoggedIn == false');29 this.assert(data.hasAccount === false, 'response.hasAccount == false');30 ApiTest.currentSession = data.sessionIdentifier;31 ApiTest.activeSessions.push(data.sessionIdentifier);32 this.currentStep.complete();33 }, null, false, true);...

Full Screen

Full Screen

utilities.js

Source:utilities.js Github

copy

Full Screen

...4 cb = expectedError;5 error = null;6 }7 var selector = '.alert.success.success-global';8 this.assertExists(selector);9 if (expectedError) {10 this.assertText(selector, expectedError);11 }12 this.call(cb);13 },14 assertGlobalError: function (expectedError, cb) {15 if (!cb) {16 cb = expectedError;17 error = null;18 }19 var selector = '.alert.error.error-global';20 this.assertExists(selector);21 if (expectedError) {22 this.assertText(selector, expectedError);23 }24 this.call(cb);25 },26 assertFormError: function (expectedError, cb) {27 if (!cb) {28 cb = expectedError;29 error = null;30 }31 var selector = '.alert.error.error-form';32 this.assertExists(selector);33 if (expectedError) {34 this.assertText(selector, expectedError);35 }36 this.call(cb);37 },38 assertFieldError: function (fieldName, expectedError, cb) {39 if (!cb) {40 cb = expectedError;41 error = null;42 }43 var selector = '.error.error-' + fieldName;44 this.assertExists(selector);45 if (expectedError) {46 this.assertText(selector, expectedError);47 }48 this.call(cb);49 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var chai = require('chai');4var chaiAsPromised = require('chai-as-promised');5chai.use(chaiAsPromised);6chai.should();7var desiredCaps = {8};9driver.init(desiredCaps)10 .then(function() {11 .elementByAccessibilityId('Alerts')12 .click()13 .elementByAccessibilityId('Text Entry')14 .click()15 .elementByAccessibilityId('Show Keyboard')16 .click()17 .elementByAccessibilityId('TextField1')18 .sendKeys('Hello World');19 })20 .then(function() {21 .elementByAccessibilityId('TextField1')22 .text()23 .should.eventually.equal('Hello World');24 })25 .fin(function() { return driver.quit(); })26 .done();27[debug] [MJSONWP] Calling AppiumDriver.execute() with args: ["mobile: assertElementNotExists",[{"element":"0.0","using":"accessibility id","value":"TextField1"}],"c0d0b9ba-9b4b-4c4e-8f4a-4d6b2e6b2f7d"]28 at XCUITestDriver.execute$ (../../../lib/commands/execute.js:15:11)29 at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)30 at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)31 at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)32 at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2var webdriver = require('selenium-webdriver');3var By = webdriver.By;4var until = webdriver.until;5var driver = new webdriver.Builder()6 .forBrowser('selenium')7 .build();8driver.findElement(By.name('q')).sendKeys('webdriver');9driver.findElement(By.name('btnG')).click();10driver.wait(until.titleIs('webdriver - Google Search'), 1000);11driver.wait(until.titleIs('Selenium - Web Browser Automation'), 1000);12driver.quit();13 assert(exists);14});15 at Object.assertElement (/var/lib/jenkins/jobs/MyProject/workspace/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgentLib/Categories/XCUIElement+FBFind.m:73)16 at -[FBFindElementCommands handleFindElementCommand:] (WebDriverAgentLib/FBFindElementCommands.m:78)17 at __35-[FBRoute_TargetAction mountRequest:intoResponse:]_block_invoke (WebDriverAgentLib/FBRoute.m:67)18 at -[FBWebServer handleMethod:withPath:parameters:request:connection:] (WebDriverAgentLib/FBWebServer.m:128)19 at __37-[FBWebServer registerRouteHandlers:]_block_invoke_2 (WebDriverAgentLib/FBWebServer.m:81)20 at -[FBWebServer registerRouteHandlers:] (WebDriverAgentLib/FBWebServer.m:82)21 at -[FBWebServer startServing] (WebDriverAgentLib/FBWebServer.m:65)22 at -[FBWebServer startServing] (WebDriverAgentLib/FBWebServer.m:65)

Full Screen

Using AI Code Generation

copy

Full Screen

1import { assertExists } from 'appium-support';2import { iosCommands } from 'appium-ios-driver';3import { XCUITestDriver } from 'appium-xcuitest-driver';4let driver = new XCUITestDriver();5let ios = iosCommands;6let el = await driver.findElement('accessibility id', 'someId');7await assertExists(el, 'element');8await ios.assertExists(el, 'element');9import { assertExists } from 'appium-support';10import { iosCommands } from 'appium-ios-driver';11import { XCUITestDriver } from 'appium-xcuitest-driver';12let driver = new XCUITestDriver();13let ios = iosCommands;14let el = await driver.findElement('accessibility id', 'someId');15await assertExists(el, 'element');16await ios.assertExists(el, 'element');17import { assertExists } from 'appium-support';18import { iosCommands } from 'appium-ios-driver';19import { XCUITestDriver } from 'appium-xcuitest-driver';20let driver = new XCUITestDriver();21let ios = iosCommands;22let el = await driver.findElement('accessibility id', 'someId');23await assertExists(el, 'element');24await ios.assertExists(el, 'element');25import { assertExists } from 'appium-support';26import { iosCommands } from 'appium-ios-driver';27import { XCUITestDriver } from 'appium-xcuitest-driver';28let driver = new XCUITestDriver();29let ios = iosCommands;30let el = await driver.findElement('accessibility id', 'someId');31await assertExists(el, 'element');32await ios.assertExists(el, 'element');33import { assertExists } from

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', function() {2 it('should show the correct title', function () {3 browser.pause(5000);4 browser.saveScreenshot('screenshot.png');5 });6});7exports.config = {8 capabilities: [{9 }],10 mochaOpts: {11 }12};

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