How to use driver.performTouch method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

Steps.js

Source:Steps.js Github

copy

Full Screen

1import { Then, Given, When} from "cucumber";2import Payments from "../../page-objects/Payments/Payments";3import axios from 'axios'4import { Gestures } from '../../../helpers/Gestures'5//'./helpers/Gestures.js'6var chai = require('chai');7var sinon = require('sinon-chai');8chai.use(require('sinon-chai'));9Given(/^Usuario realiza login (.*)$/, 10function (email) {11 console.log(" USUARIO REALIZA LOGIN");12 13var deviceId = Payments.getText("//*[contains(@content-desc, 'deviceId:')]");14var linkAccountTokenPath = Payments.getText("//*[contains(@content-desc, 'magicLinkBaseUrl:')]")15var actionToken16var appBundleId17var environment18var urlLinkAccount19console.log("getCurrentDevice id: "+deviceId);20appBundleId = driver.getCurrentPackage();21console.log("getCurrentPackage id: "+appBundleId);22// ar.com.bdsol.bds.squads.yellow23environment= appBundleId.slice(17,20)24console.log("getCurrent Environment: "+environment);25// urlLinkAccount= "https://bff-mobile-"+environment+".bdsdigital.com.ar/api/auth/link-account-token";26urlLinkAccount= "https://bff-mobile-int.bdsdigital.com.ar/api/auth/link-account-token";27console.log("getCurrent urlLinkAccount: "+urlLinkAccount);28 axios.post(urlLinkAccount, { // auth-int.bdsdigital29 deviceId,30 email,31 appBundleId //: "ar.com.bdsol.bds.integration"//"ar.com.bdsol.bds.uat"//32 }).then(resp => {33 actionToken =resp.data.actionToken;34 console.log("action token : "+actionToken);35 console.log("getCurrent resp.data: "+resp.data);36 browser.url(linkAccountTokenPath+"/link-account?token="+actionToken);// open-uat37 // driver.url("https://open-int.bdsdigital.com.ar/link-account?token="+actionToken);38 });39});40Given(/^usuario swipea (.*)$/, 41function (elemento) {42 var label='~';43 // var selector =label+element44 // driver.touchScroll(10, 100, element);45 // AppiumDriver.performTouch() with args: [[46 // {"action":"press","options":{"x":1034,"y":1188}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"x":677,"y":1177}},{"action":"release","options":{}}],"13019aae-2e08-49f1-b4fe-4dfb12d2b4b3"]47 // driver.touchPerform([48 // { action: 'press', options: { x: 1034, y: 1188 }},49 // { action: 'moveTo', options: { x: 677, y: 1177 }},50 // { action: 'release' }51 // { action: 'press', options: [Object] },52 // { action: 'moveTo', options: [Object] },53 // { action: 'release' }54 // ]);55 // Payments.sistemaIndica(label.concat(fileName));56 Payments.sistemaIndica(elemento)57 58 // $(elemento).touchAction([59 // 'press',60 // { action: 'moveTo', x: 0, y: 632 },61 // 'release'62 // ])63 // browser.touchAction([64 // { action: 'press', x: 600, y: 600 },65 // { action: 'moveTo', x: 100, y: 600 },66 // 'release'67 // ])68 69 console.log('Localization x: '+$(elemento).getLocation('x'));70 let xpos = $(elemento).getLocation('x') +10071 console.log('Localization y: '+$(elemento).getLocation('y')); 72 let ypos = $(elemento).getLocation('y') +10073 driver.touchPerform([74 { action: 'press', options: { x: xpos, y: ypos }},75 {76 action: "wait",77 options: { ms: 1000 }78 },79 { action: 'moveTo', options: { x: xpos-100, y: ypos }},80 { action: 'release' }81 ]);82 driver.pause(1000);83});84// Given(/^Login con usuario (.*)$/, mail => {85// Payments.sistemaIndica('~¡Bienvenido!')86// deviceId = $('~deviceId').getText().trim();87// magicLinkBaseUrl = $('~magicLinkBaseUrl').getText().trim()88// const actionToken = browser.call(() => linkAccountToken(mail, deviceId));89// browser.url(`${magicLinkBaseUrl}/link-account?token=${actionToken}`);90// });91Given(/^Usuario selecciona (.*)$/, 92function (fileName) {93 var label='~';94 label.concat(fileName);95 Payments.usuarioSelecciona(label.concat(fileName));96});97Given(/^Usuario recibe notificacion beneficios (.*)$/, 98function (nroBenef) {99 var customerId="16"100 var campaignId="LOYALTY_PROGRAM_20"101 var completedStepId="TRANSFERS"102 var completedStepsCount=nroBenef103 var payload={campaignId,completedStepId,completedStepsCount}104 105 axios.post('https://notifications-yellow.bdsdigital.com.ar/campaigns/notify-completed-step', { 106 customerId,107 payload108 }).then();109});110Given(/^Sistema indica (.*)$/, 111function (fileName) {112 var label='~';113 label.concat(fileName);114 Payments.sistemaIndica(label.concat(fileName));115});116Given(/^Wait (.*) seconds$/, 117function (time) {118 Payments.waitTIme(time);119});120Given(/^usuario abre notificaciones$/, 121function () {122 driver.openNotifications();123 124});125 126When(/^usuario selecciona (.*)$/, 127function (fileName) {128 var label='~';129 label.concat(fileName); 130 // Agendar servicio131 if(fileName=='Agendar servicio')132 {133 if(browser.config.capabilities.browserName=='iOS')134 {135 Payments.usuarioPresiona('(//XCUIElementTypeOther[@name="Agendar servicio"])[2]/XCUIElementTypeOther'); 136 } else {137 Payments.usuarioPresiona('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup[4]/android.view.ViewGroup'); 138 }139 } else {140 Payments.usuarioSelecciona(label.concat(fileName)); 141 }142 143});144Given(/^usuario cierra notificaciones$/, 145 function () {146 driver.pressKeyCode(4);147 148 });149When(/^usuario copia el valor (.*)$/, 150function (valorCopiado) {151 var clipboard =driver.getClipboard().trim();;152console.log(clipboard)153 if(valorCopiado==clipboard)154 {155 } else {156 new Error('oh no' + driver.getClipboard())157 }158});159When(/^usuario presiona Xpath (.*)$/, 160function (fileName) {161 Payments.usuarioPresiona(fileName);162});163When(/^sistema muestra Xpath (.*)$/, 164function (fileName) {165 Payments.sistemaIndicaXpath(fileName);166});167When(/^sistema no muestra Xpath (.*)$/, 168function (fileName) {169 Payments.sistemaNOIndicaXpath(fileName);170});171When(/^sistema indica Xpath (.*)$/, 172function (fileName) {173 Payments.sistemaIndicaXpath(fileName);174});175When(/^sistema muestra xpath (.*) con texto (.*)$/, 176function (fileName,texto) {177 Payments.sistemaIndicaXpathConTexto(fileName, texto);178});179When(/^sistema indica (.*)$/, 180function (fileName) {181 var label='~';182 label.concat(fileName);183 Payments.sistemaIndica(label.concat(fileName));184});185When(/^sistema no muestra el valor (.*)$/, 186function (fileName) {187 var label='~';188 label.concat(fileName);189 Payments.sistema_no_muestra_el_valor(label.concat(fileName));190});191Then(/^Usuario selecciona (.*)$/, 192function (fileName) {193 var label='~';194 label.concat(fileName);195 Payments.usuarioSelecciona(label.concat(fileName));196});197Then(/^usuario verifica monto a pagar (.*) en el campo (.*)$/, 198function (factura, montoAPagar) {199 Payments.usuarioVerificaMonto(factura, );200});201Then(/^Sistema indica (.*)$/, 202function (fileName) {203 var label='~';204 label.concat(fileName);205 Payments.sistemaIndica(label.concat(fileName));206});207 208When(/^usuario completa el campo (.*) con el valor (.*)$/, 209function (fileName, valor) {210 var label='~';211 label.concat(fileName);212 Payments.usuario_completa_el_campo(label.concat(fileName), valor);213});214When(/^usuario completa campo xpath (.*) con el valor (.*)$/, 215function (fileName, valor) {216 Payments.usuario_completa_el_campo(fileName, valor);217});218When(/^usuario presiona borrar (.*) veces$/, 219function (cant) {220 if(browser.config.capabilities.browserName=='iOS')221 {222 console.log("ESTA EN IOS");223 var label='~';224 for (var i = 0; i < cant; i++) {225 Payments.usuario_completa_el_campo(label.concat('Ingresa el monto a pagar'), '\b');226 }227 228 } else {229 console.log("ESTA EN ANDROID");230 for (var i = 0; i < cant; i++) {231 driver.pressKeyCode(67);232 }233 }234 235});236When(/^usuario swipea elemento (.*) a la izquierda$/, 237function (element) {238 $("~"+element).touchAction({239 action: 'tap', x: 30, y:20240 })241 242});243Given(/^CloseSystemUIisntResponding$/, 244 function () {245 var fileName ="android:id/aerr_close"246 var label='~';247 try {248 Payments.usuarioSelecciona(label.concat(fileName));249 Payments.usuarioSelecciona(label.concat(fileName));250 Payments.usuarioSelecciona(label.concat(fileName));251 } catch (error) {252 console.log(error);253 }254 255 });256 257When(/^usuario presiona Boton Volver Atras$/, 258function () {259 driver.pressKeyCode(4); 260});261When(/^usuario ingresa el valor (.*) al campo (.*)$/, 262function (value, label) {263 // console.log(driver.sessionCapabilities());264 console.log(browser.config.capabilities.browserName);265 // iOS266 // Android267 if(browser.config.capabilities.browserName=='iOS')268 {269 console.log("ESTA EN IOS");270 var labelTag='~';271 Payments.usuario_completa_el_campo(labelTag.concat(label), value);272 } else {273 console.log("ESTA EN ANDROID");274 var labelTag='~';275 Payments.usuarioSelecciona(labelTag.concat(label));276 for (var i = 0; i < value.length; i++) { 277 switch (value.charAt(i)) {278 case '0':279 driver.pressKeyCode(7);280 break; 281 case '1':282 driver.pressKeyCode(8);283 break;284 case '2':285 driver.pressKeyCode(9);286 break;287 case '3':288 driver.pressKeyCode(10);289 break;290 case '4':291 driver.pressKeyCode(11);292 break;293 case '5':294 driver.pressKeyCode(12);295 break;296 case '6':297 driver.pressKeyCode(13);298 break;299 case '7':300 driver.pressKeyCode(14);301 break;302 case '8':303 driver.pressKeyCode(15);304 break;305 case '9':306 driver.pressKeyCode(16);307 break;308 default: 309 } }310 }311 312});313When(/^Reset wiremock$/, 314function () {315 316 if(browser.config.capabilities.browserName=='iOS')317 {318 console.log("ESTA EN IOS");319 axios.post("http://localhost:9999/__admin/mappings/reset").then(resp => {320 console.log(resp.data);321 });322 } else {323 console.log("ESTA EN ANDROID");324 axios.post("http://localhost:8080/__admin/mappings/reset ").then(resp => {325 console.log(resp.data);326 });327 }328 driver.reset();329});330When(/^sistema muestra elemento (.*) con texto (.*)$/, 331function (field, valor) {332 var label='~';333 Payments.sistema_muestra_elemento_con_texto(label.concat(field), valor);334 335});336When(/^usuario scrolea hacia (.*)$/, 337function (element) {338 // var label='~';339 driver.touchScroll(10, 100, element);340 341});342// @Given("^Get to wiremock (.*)$")343// public void reset_wiremock(String url){344// //__admin/reset345// given().when().get("http://localhost:8080"+url).then().statusCode(200);346// }347When(/^Get to wiremock (.*)$/, 348 function (url) {349 if(browser.config.capabilities.browserName=='iOS')350 {351 console.log("ESTA EN IOS");352 axios.get("http://localhost:9999"+url).then(resp => {353 console.log(resp.data);354 });355 } else {356 console.log("ESTA EN ANDROID");357 axios.get("http://localhost:8080"+url).then(resp => {358 console.log(resp.data);359 });360 }361 362 });...

Full Screen

Full Screen

image-element.js

Source:image-element.js Github

copy

Full Screen

...181 action: 'tap',182 options: {x, y}183 };184 if (driver.performTouch) {185 return await driver.performTouch([action]);186 }187 throw new Error("Driver did not implement the 'performTouch' command. " +188 'For drivers to support finding image elements, they ' +189 "should support 'performTouch' and 'performActions'");190 }191 /**192 * Handle various Appium commands that involve an image element193 *194 * @param {BaseDriver} driver - the driver to use for commands195 * @param {string} cmd - the name of the driver command196 * @param {string} imgElId - the id of the ImageElement to work with197 * @param {Array} args - Rest of arguments for executeScripts198 *199 * @returns {Object} - the result of running a command...

Full Screen

Full Screen

unlock-helpers.js

Source:unlock-helpers.js Github

copy

Full Screen

...70 {action: 'press', options: {element: null, x: x0, y: y0}},71 {action: 'moveTo', options: {element: null, x: x0, y: yP}},72 {action: 'release'}73 ];74 await driver.performTouch(actions);75};76helpers.encodePassword = function encodePassword (key) {77 return key.replace(/\s/ig, '%s');78};79helpers.stringKeyToArr = function stringKeyToArr (key) {80 return key.trim().replace(/\s+/g, '').split(/\s*/);81};82helpers.fingerprintUnlock = async function fingerprintUnlock (adb, driver, capabilities) {83 if (await adb.getApiLevel() < 23) {84 throw new Error('Fingerprint unlock only works for Android 6+ emulators');85 }86 await adb.fingerprint(capabilities.unlockKey);87 await sleep(UNLOCK_WAIT_TIME);88};89helpers.pinUnlock = async function pinUnlock (adb, driver, capabilities) {90 logger.info(`Trying to unlock device using pin ${capabilities.unlockKey}`);91 await helpers.dismissKeyguard(driver, adb);92 let keys = helpers.stringKeyToArr(capabilities.unlockKey);93 if (await adb.getApiLevel() >= 21) {94 let els = await driver.findElOrEls('id', 'com.android.systemui:id/digit_text', true);95 if (_.isEmpty(els)) {96 throw new Error('Error finding unlock pin buttons!');97 }98 let pins = {};99 for (let el of els) {100 let text = await driver.getAttribute('text', util.unwrapElement(el));101 pins[text] = el;102 }103 for (let pin of keys) {104 let el = pins[pin];105 await driver.click(util.unwrapElement(el));106 }107 } else {108 for (let pin of keys) {109 let el = await driver.findElOrEls('id', `com.android.keyguard:id/key${pin}`, false);110 if (el === null) {111 throw new Error(`Error finding unlock pin '${pin}' button!`);112 }113 await driver.click(util.unwrapElement(el));114 }115 }116 // Some devices accept entering the code without pressing the Enter key117 // When I rushed commands without this wait before pressKeyCode, rarely UI2 sever crashed118 await sleep(UNLOCK_WAIT_TIME);119 if (await adb.isScreenLocked()) {120 await driver.pressKeyCode(KEYCODE_NUMPAD_ENTER);121 await sleep(UNLOCK_WAIT_TIME);122 }123};124helpers.passwordUnlock = async function passwordUnlock (adb, driver, capabilities) {125 logger.info(`Trying to unlock device using password ${capabilities.unlockKey}`);126 await helpers.dismissKeyguard(driver, adb);127 let key = capabilities.unlockKey;128 // Replace blank spaces with %s129 key = helpers.encodePassword(key);130 // Why adb ? It was less flaky131 await adb.shell(['input', 'text', key]);132 // Why sleeps ? Avoid some flakyness waiting for the input to receive the keys133 await sleep(INPUT_KEYS_WAIT_TIME);134 await adb.shell(['input', 'keyevent', KEYCODE_NUMPAD_ENTER]);135 // Waits a bit for the device to be unlocked136 await sleep(UNLOCK_WAIT_TIME);137};138helpers.getPatternKeyPosition = function getPatternKeyPosition (key, initPos, piece) {139 /*140 How the math works:141 We have 9 buttons divided in 3 columns and 3 rows inside the lockPatternView,142 every button has a position on the screen corresponding to the lockPatternView since143 it is the parent view right at the middle of each column or row.144 */145 const cols = 3;146 const pins = 9;147 let xPos = (key, x, piece) => {148 return Math.round(x + ((key % cols) || cols) * piece - piece / 2);149 };150 let yPos = (key, y, piece) => {151 return Math.round(y + (Math.ceil(((key % pins) || pins) / cols) * piece - piece / 2));152 };153 return {x: xPos(key, initPos.x, piece), y: yPos(key, initPos.y, piece)};154};155helpers.getPatternActions = function getPatternActions (keys, initPos, piece) {156 let actions = [];157 let lastPos;158 for (let key of keys) {159 let keyPos = helpers.getPatternKeyPosition(key, initPos, piece);160 if (key === keys[0]) {161 actions.push({action: 'press', options: {element: null, x: keyPos.x, y: keyPos.y}});162 lastPos = keyPos;163 continue;164 }165 let moveTo = {x: 0, y: 0};166 let diffX = keyPos.x - lastPos.x;167 if (diffX > 0) {168 moveTo.x = piece;169 if (Math.abs(diffX) > piece) {170 moveTo.x += piece;171 }172 } else if (diffX < 0) {173 moveTo.x = -1 * piece;174 if (Math.abs(diffX) > piece) {175 moveTo.x -= piece;176 }177 }178 let diffY = keyPos.y - lastPos.y;179 if (diffY > 0) {180 moveTo.y = piece;181 if (Math.abs(diffY) > piece) {182 moveTo.y += piece;183 }184 } else if (diffY < 0) {185 moveTo.y = -1 * piece;186 if (Math.abs(diffY) > piece) {187 moveTo.y -= piece;188 }189 }190 actions.push({action: 'moveTo', options: {element: null, x: moveTo.x + lastPos.x, y: moveTo.y + lastPos.y}});191 lastPos = keyPos;192 }193 actions.push({action: 'release'});194 return actions;195};196helpers.patternUnlock = async function patternUnlock (adb, driver, capabilities) {197 logger.info(`Trying to unlock device using pattern ${capabilities.unlockKey}`);198 await helpers.dismissKeyguard(driver, adb);199 let keys = helpers.stringKeyToArr(capabilities.unlockKey);200 /* We set the device pattern buttons as number of a regular phone201 * | • • • | | 1 2 3 |202 * | • • • | --> | 4 5 6 |203 * | • • • | | 7 8 9 |204 The pattern view buttons are not seeing by the uiautomator since they are205 included inside a FrameLayout, so we are going to try clicking on the buttons206 using the parent view bounds and math.207 */208 let apiLevel = await adb.getApiLevel();209 let el = await driver.findElOrEls('id',210 `com.android.${apiLevel >= 21 ? 'systemui' : 'keyguard'}:id/lockPatternView`,211 false212 );213 let initPos = await driver.getLocation(util.unwrapElement(el));214 let size = await driver.getSize(util.unwrapElement(el));215 // Get actions to perform216 let actions = helpers.getPatternActions(keys, initPos, size.width / 3);217 // Perform gesture218 await driver.performTouch(actions);219 // Waits a bit for the device to be unlocked220 await sleep(UNLOCK_WAIT_TIME);221};222helpers.PIN_UNLOCK = PIN_UNLOCK;223helpers.PASSWORD_UNLOCK = PASSWORD_UNLOCK;224helpers.PATTERN_UNLOCK = PATTERN_UNLOCK;225helpers.FINGERPRINT_UNLOCK = FINGERPRINT_UNLOCK;226export { PIN_UNLOCK, PASSWORD_UNLOCK, PATTERN_UNLOCK, FINGERPRINT_UNLOCK, helpers };...

Full Screen

Full Screen

touch-specs.js

Source:touch-specs.js Github

copy

Full Screen

...13 } catch (ign) {}14 if (!map) {15 let buttons = await driver.findElements('class name', 'UIAButton');16 let gestures = [{action: 'tap', options: {element: buttons[5].ELEMENT}}];17 await driver.performTouch(gestures);18 await B.delay(500);19 await okIfAlert(driver);20 await B.delay(500);21 }22 }23 describe('tap', function () {24 it('should tap on a specified element', async function () {25 let buttons = await driver.findElements('class name', 'UIAButton');26 let gestures = [{action: 'tap', options: { element: buttons[1].ELEMENT}}];27 await driver.performTouch(gestures);28 await B.delay(1000);29 await okIfAlert(driver);30 });31 });32 describe('wait', function () {33 it('should move the page and wait a bit', async function () {34 await goToMap();35 let map = await driver.findElement('xpath', '//UIAMapView');36 let gestures = [37 {action: 'press', options: {element: map.ELEMENT}},38 {action: 'moveTo', options: {element: map.ELEMENT, x: 0, y: 100}},39 {action: 'wait', options: {ms: 5000}},40 {action: 'moveTo', options: {element: map.ELEMENT, x: 0, y: 0}},41 {action: 'release'}42 ];43 await driver.performTouch(gestures);44 });45 });46 describe('pinch', function () {47 it('should do some pinching', async function () {48 await goToMap();49 let map = await driver.findElement('xpath', '//UIAMapView');50 let actions = [51 [52 {action: 'press', options: {element: map.ELEMENT}},53 {action: 'moveTo', options: {element: map.ELEMENT, x: 0, y: 0}},54 {action: 'release'}55 ],56 [57 {action: 'press', options: {element: map.ELEMENT}},58 {action: 'moveTo', options: {element: map.ELEMENT, x: 100, y: 100}},59 {action: 'release'}60 ],61 ];62 await driver.performMultiAction(actions);63 await B.delay(1000);64 });65 it('should do more involved pinching in and out', async function () {66 await goToMap();67 let map = await driver.findElement('xpath', '//UIAMapView');68 let actions = [69 [70 {action: 'press', options: {element: map.ELEMENT}},71 {action: 'moveTo', options: {element: map.ELEMENT, x: 25, y: 25}},72 {action: 'wait', options: {ms: 3000}},73 {action: 'moveTo', options: {element: map.ELEMENT, x: 100, y: 100}},74 {action: 'release'}75 ],76 [77 {action: 'press', options: {element: map.ELEMENT}},78 {action: 'moveTo', options: {element: map.ELEMENT, x: 100, y: 0}},79 {action: 'wait', options: {ms: 3000}},80 {action: 'moveTo', options: {element: map.ELEMENT, x: 0, y: 0}},81 {action: 'release'}82 ],83 ];84 await driver.performMultiAction(actions);85 await B.delay(1000);86 });87 });88});89describe('testapp - swipe actions', function () {90 let session = setup(this, desired);91 let driver = session.driver;92 describe('swipe', function () {93 let slider, target, loc;94 let leftPos = { x: 0, y: 0 },95 rightPos = { x: 0, y: 0 },96 centerPos = { x: 0, y: 0 };97 let getNumericValue = function (pctVal) {98 pctVal = pctVal.replace('%', '');99 pctVal = parseInt(pctVal, 10);100 return pctVal;101 };102 let testSliderValueNot0or100 = function (value) {103 value = getNumericValue(value);104 // should be ~50105 value.should.be.above(15);106 value.should.be.below(85);107 };108 let getSliderValue = async function () {109 return await driver.getAttribute('value', slider);110 };111 before(async function () {112 slider = await driver.findElement('class name', 'UIASlider');113 loc = await driver.getLocation(slider);114 let size = await driver.getSize(slider);115 leftPos.x = loc.x - 5;116 centerPos.x = loc.x + (size.width * 0.5);117 rightPos.x = loc.x + size.width + 5;118 leftPos.y = rightPos.y = centerPos.y = loc.y + (size.height * 0.5);119 target = await driver.findElement('accessibility id', "Access'ibility");120 testSliderValueNot0or100(await getSliderValue());121 });122 // TODO: For some reason it does not swipe to 100% in ci env, investigate123 it('should work with: press {element}, moveTo {destEl} @skip-ci', async function () {124 let origValue = await getSliderValue();125 let gestures = [126 {action: 'press', options: {element: slider.ELEMENT}},127 {action: 'wait', options: {ms: 500}},128 {action: 'moveTo', options: {element: target.ELEMENT}},129 {action: 'release'}130 ];131 await driver.performTouch(gestures);132 (await getSliderValue()).should.not.equal(origValue);133 await B.delay(1000);134 // TODO: in ios84 the destEl is in a weird place, so we don't test value135 //(await getSliderValue()).should.equal("100%")136 });137 it('should work with: press {element, x, y}, moveTo {element, x, y}', async function () {138 let gestures = [139 {action: 'press', options: {element: slider.ELEMENT, x: 0.8665, y: 0.5}},140 {action: 'wait', options: {ms: 500}},141 {action: 'moveTo', options: {element: slider.ELEMENT, x: 0.5, y: 0.5}},142 {action: 'release'}143 ];144 await driver.performTouch(gestures);145 testSliderValueNot0or100(await getSliderValue());146 await B.delay(1000);147 });148 it('should work with: press {x, y}, moveTo {x, y}', async function () {149 let gestures = [150 {action: 'press', options: {x: centerPos.x, y: centerPos.y}},151 {action: 'wait', options: {ms: 500}},152 {action: 'moveTo', options: {x: leftPos.x - centerPos.x, y: leftPos.y - centerPos.y}},153 {action: 'release'}154 ];155 await driver.performTouch(gestures);156 (await getSliderValue()).should.equal('0%');157 });158 it('should work with: {element, x, y}, moveTo {destEl, x, y} @skip-ci', async function () {159 let gestures = [160 {action: 'press', options: {element: slider.ELEMENT, x: 0, y: 0.5}},161 {action: 'wait', options: {ms: 500}},162 {action: 'moveTo', options: {element: target.ELEMENT, x: 50, y: 0.5}},163 {action: 'release'}164 ];165 await driver.performTouch(gestures);166 testSliderValueNot0or100(await getSliderValue());167 });168 // TODO: Crashes in ci env, investigate169 // TODO: For some reason it does not swipe to 100% in ci env, investigate170 it('should work with press {x, y}, moveTo {destEl} @skip-ci', async function () {171 let origValue = await getSliderValue();172 let gestures = [173 {action: 'press', options: {x: centerPos.x, y: centerPos.y}},174 {action: 'wait', options: {ms: 500}},175 {action: 'moveTo', options: {element: target.ELEMENT}},176 {action: 'release'}177 ];178 await driver.performTouch(gestures);179 (await getSliderValue()).should.not.equal(origValue);180 // TODO: weird element position in iOS 8.4 so not checking exact value.181 //.then(getSliderValue).should.become("100%")182 });183 });...

Full Screen

Full Screen

drag-e2e-specs.js

Source:drag-e2e-specs.js Github

copy

Full Screen

...52 let endEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_2");53 let gestures = [{action: "longPress", options: {element: startEle.ELEMENT}},54 {action: "moveTo", options: {element: endEle.ELEMENT}},55 {action: "release", options: {}}];56 await driver.performTouch(gestures);57 let resultEle = await driver.findElement("id", "io.appium.android.apis:id/drag_result_text");58 await driver.getText(resultEle.ELEMENT).should.eventually.equal("Dropped!");59 });60 it('should drag by element by offset', async () => {61 let startEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_3");62 let endEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_2");63 let gestures = [{action: "longPress",64 options: {element: startEle.ELEMENT, x: 5, y: 5}},65 {action: "moveTo", options:66 {element: endEle.ELEMENT, x: 5, y: 5}},67 {action: "release", options: {}}];68 await driver.performTouch(gestures);69 let element3 = await driver.findElement("id", "io.appium.android.apis:id/drag_result_text");70 await driver.getText(element3.ELEMENT).should.eventually.equal("Dropped!");71 });72 it('should drag by absolute position', async () => {73 let startEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_3");74 let startLoc = await driver.getLocationInView(startEle.ELEMENT);75 let startSize = await driver.getSize(startEle.ELEMENT);76 let endEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_2");77 let endLoc = await driver.getLocationInView(endEle.ELEMENT);78 let endSize = await driver.getSize(endEle.ELEMENT);79 let gestures = [{action: "longPress",80 options: {x: startLoc.x + (startSize.width / 2),81 y: startLoc.y + (startSize.height / 2)}},82 {action: "moveTo",83 options: {x: endLoc.x + (endSize.width / 2),84 y: endLoc.y + (endSize.height / 2)}},85 {action: "release", options: {}}];86 await driver.performTouch(gestures);87 let resultEle = await driver.findElement("id", "io.appium.android.apis:id/drag_result_text");88 await driver.getText(resultEle.ELEMENT).should.eventually.equal("Dropped!");89 });90 });...

Full Screen

Full Screen

gesture-specs.js

Source:gesture-specs.js Github

copy

Full Screen

...10 it('should send POST request to /tap on WDA when no element is given', async () => {11 let actions = [12 {action: 'tap'}13 ];14 await driver.performTouch(actions);15 proxySpy.calledOnce.should.be.true;16 proxySpy.firstCall.args[0].should.eql('/tap/0');17 proxySpy.firstCall.args[1].should.eql('POST');18 });19 it('should send POST request to /tap/element on WDA', async () => {20 let actions = [21 {action: 'tap', options: {element: 42}}22 ];23 await driver.performTouch(actions);24 proxySpy.calledOnce.should.be.true;25 proxySpy.firstCall.args[0].should.eql('/tap/42');26 proxySpy.firstCall.args[1].should.eql('POST');27 });28 it('should send POST request to /tap/element with offset on WDA', async () => {29 let actions = [30 {action: 'tap', options: {element: 42, x: 1, y: 2}}31 ];32 await driver.performTouch(actions);33 proxySpy.calledOnce.should.be.true;34 proxySpy.firstCall.args[0].should.eql('/tap/42');35 proxySpy.firstCall.args[1].should.eql('POST');36 });37 });38 describe('mobile methods', () => {39 describe('anything other than scroll', () => {40 it('should throw an error', async () => {41 await driver.execute('mobile: somesuch').should.be.rejected;42 });43 });44 describe('scroll', () => {45 it('should throw an error if no scroll type is specified', async () => {46 await driver.execute('mobile: scroll', {element: 4})...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const webdriverio = require('webdriverio');2const opts = {3 desiredCapabilities: {4 }5};6 .remote(opts)7 .init()8 .performTouch({9 options: {10 }11 })12 .end();13const webdriverio = require('webdriverio');14const opts = {15 desiredCapabilities: {16 }17};18 .remote(opts)19 .init()20 .touchAction({21 options: {22 }23 })24 .end();25const webdriverio = require('webdriverio');26const opts = {27 desiredCapabilities: {28 }29};30 .remote(opts)31 .init()32 .touchAction({33 options: {34 }35 })36 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const assert = require('assert');3const opts = {4 capabilities: {5 }6};7(async () => {8 const client = await wdio.remote(opts);9 await client.performTouch({10 options: {11 }12 });13 await client.pause(3000);14 await client.deleteSession();15})();16[debug] [WD Proxy] Got response with status 200: {"sessionId":"0d7f0b8e-2f9e-4f9d-8a5a-7a1d3c3c2d3a","status":13,"value":{"message":"An unknown server-side error occurred while processing the command. Original error: 'undefined' is not an object (evaluating 'u.touchAction.perform')"}}17await el.click();18Is there a way to get this to work in Appium (1.9.1)?19I am trying to automate a web app using Appium (1.9.1) and I am able to access

Full Screen

Using AI Code Generation

copy

Full Screen

1const { remote } = require('webdriverio');2(async () => {3 const browser = await remote({4 capabilities: {5 }6 })7 await browser.performTouch({8 options: {9 }10 })11 await browser.performTouch({12 options: {13 }14 })15 await browser.performTouch({16 })17})().catch((e) => console.error(e))18const { remote } = require('webdriverio');19(async () => {20 const browser = await remote({21 capabilities: {22 }23 })24 await browser.touchPerform([25 {26 options: {27 }28 },29 {30 options: {31 }32 },33 {34 }35})().catch((e) => console.error(e))

Full Screen

Using AI Code Generation

copy

Full Screen

1let action = new wd.TouchAction(driver);2action.press({x: 100, y: 100}).release();3await driver.performTouchAction(action);4let action = new wd.TouchAction(driver);5action.press({x: 100, y: 100}).release();6await driver.performTouchAction(action);7let action = new wd.TouchAction(driver);8action.press({x: 100, y: 100}).release();9await driver.performTouchAction(action);10let action = new wd.TouchAction(driver);11action.press({x: 100, y: 100}).release();12await driver.performTouchAction(action);13let action = new wd.TouchAction(driver);14action.press({x: 100, y: 100}).release();15await driver.performTouchAction(action);16let action = new wd.TouchAction(driver);17action.press({x: 100, y: 100}).release();18await driver.performTouchAction(action);19let action = new wd.TouchAction(driver);20action.press({x: 100, y: 100}).release();21await driver.performTouchAction(action);22let action = new wd.TouchAction(driver);23action.press({x: 100, y: 100}).release();24await driver.performTouchAction(action);25let action = new wd.TouchAction(driver);26action.press({x: 100, y: 100}).release();27await driver.performTouchAction(action);28let action = new wd.TouchAction(driver);29action.press({x: 100, y: 100}).release();30await driver.performTouchAction(action);31let action = new wd.TouchAction(driver);32action.press({x: 100, y

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3 desiredCapabilities: {4 },5};6(async () => {7 const client = await wdio.remote(opts);8 await client.setValue('input[name="q"]', 'hello world');9 await client.pause(5000);10 await client.click('input[type="submit"]');11 await client.pause(5000);12 await client.click('a[href*="hello-world"]');13 await client.pause(5000);14 const element = await client.$('div#main');15 await client.performTouchAction({16 options: {17 },18 });19 await client.pause(5000);20 await client.deleteSession();21})();22const wdio = require('webdriverio');23const opts = {24 desiredCapabilities: {25 },26};27(async () => {28 const client = await wdio.remote(opts);29 await client.setValue('input[name="q"]', 'hello world');30 await client.pause(5000);31 await client.click('input[type="submit"]');32 await client.pause(5000);33 await client.click('a[href*="hello-world"]');34 await client.pause(500

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = new webdriver.Builder()2.forBrowser('safari')3.build();4driver.manage().window().getSize().then(function(size) {5 var width = size.width;6 var height = size.height;7 var startx = width/2;8 var starty = height/2;9 var endx = width/2;10 var endy = height/2;11 driver.performTouchAction({12 options: {13 }14 }, {15 options: {16 }17 }, {18 options: {19 }20 }, {21 });22});23driver.quit();

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();7chaiAsPromised.transferPromiseness = wd.transferPromiseness;8var _ = require('underscore');9var serverConfig = {

Full Screen

Using AI Code Generation

copy

Full Screen

1async function test() {2 const driver = await wd.promiseChainRemote({3 });4 await driver.init({5 });6 await driver.performTouch({7 options: {8 element: await driver.elementByAccessibilityId('add')9 }10 });11}12test();

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