How to use el.getLocation method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

touch-e2e-specs.js

Source:touch-e2e-specs.js Github

copy

Full Screen

...181 });182 it('should swipe on drag and drop', async function () {183 await startDragAndDropActivity();184 const el = await driver.elementById('io.appium.android.apis:id/drag_dot_1');185 const {x, y} = await el.getLocation();186 const touchActions = [187 {type: 'pointerMove', duration: 0, x: x + 30, y: y + 30},188 {type: 'pointerDown', button: 0},189 {type: 'pointerMove', duration: 100, x: x + 10, y: y + 10},190 {type: 'pointerUp', button: 0},191 ];192 await performTouchAction(touchActions);193 });194 });195 describe('touches', function () {196 let nextEl;197 beforeEach(async function () {198 await startTextSwitcherActivity();199 await driver.elementByXPath("//*[@text='0']").should.eventually.exist;...

Full Screen

Full Screen

gestures-specs.js

Source:gestures-specs.js Github

copy

Full Screen

...248 driver.elementsByClassName('UIATableCell').then(function (els) {249 el = els[10];250 scrollOpts = { element: el.value };251 })252 .then(function () { return el.getLocation(); })253 .then(function (loc) { location1 = loc; })254 .then(function () {255 return driver.execute("mobile: scrollTo", [scrollOpts]);256 }).then(function () { return el.getLocation(); })257 .then(function (location2) {258 location2.x.should.equal(location1.x);259 location2.y.should.not.equal(location1.y);260 }).nodeify(done);261 });262 });263 describe('mobile: scroll', function () {264 var driver;265 setup(this, desired).then(function (d) { driver = d; });266 it('should scroll down and up', function (done) {267 var firstEl, location1, location2;268 driver269 .elementByClassName('UIATableCell')270 .then(function (el) { firstEl = el; return el.getLocation(); })271 .then(function (loc) { location1 = loc; })272 .then(function () {273 return driver.execute("mobile: scroll", [{direction: 'down'}]);274 })275 .then(function () { return firstEl.getLocation(); })276 .then(function (loc2) {277 location2 = loc2;278 loc2.x.should.equal(location1.x);279 loc2.y.should.not.equal(location1.y);280 })281 .then(function () {282 return driver.execute("mobile: scroll", [{direction: 'up'}]);283 })284 .then(function () { return firstEl.getLocation(); })285 .then(function (loc3) {286 loc3.x.should.equal(location2.x);287 loc3.y.should.not.equal(location2.y);288 })289 .nodeify(done);290 });291 it('should scroll down and up using element', function (done) {292 var firstEl, location1, location2, table_view;293 driver.elementByClassName('UIATableView').then(function (el) {294 table_view = el;295 })296 .elementByClassName('UIATableCell')297 .then(function (el) { firstEl = el; return el.getLocation(); })298 .then(function (loc) { location1 = loc; })299 .then(function () {300 return driver.execute("mobile: scroll", [{element: table_view.value, direction: 'down'}]);301 })302 .then(function () { return firstEl.getLocation(); })303 .then(function (loc2) {304 location2 = loc2;305 loc2.x.should.equal(location1.x);306 loc2.y.should.not.equal(location1.y);307 })308 .then(function () {309 return driver.execute("mobile: scroll", [{element: table_view.value, direction: 'up'}]);310 })311 .then(function () { return firstEl.getLocation(); })...

Full Screen

Full Screen

gesture-e2e-specs.js

Source:gesture-e2e-specs.js Github

copy

Full Screen

...61 await exitModal('OK');62 });63 it('should tap on arbitrary coordinates', async function () {64 let el = await driver.elementByAccessibilityId('Okay / Cancel');65 let loc = await el.getLocation();66 let size = await el.getSize();67 loc = {68 x: loc.x + size.width / 2,69 y: loc.y + size.height / 2,70 };71 let action = new wd.TouchAction(driver);72 action.tap(loc);73 await action.perform();74 await exitModal('OK');75 });76 });77 it('should long press on an element', async function () {78 let el = await driver.elementByAccessibilityId('Okay / Cancel');79 let action = new wd.TouchAction(driver);80 action.longPress({el}).release();81 await action.perform();82 await exitModal('Cancel');83 });84 it('should long press on an element with duration through press-wait-release', async function () {85 let el = await driver.elementByAccessibilityId('Okay / Cancel');86 let action = new wd.TouchAction(driver);87 action.press({el}).wait(1200).release();88 await action.perform();89 await exitModal('Cancel');90 });91 it('should long press on an element with duration through pressOpts.duration', async function () {92 let el = await driver.elementByAccessibilityId('Okay / Cancel');93 let action = new wd.TouchAction(driver);94 action.longPress({el, duration: 1200}).release();95 await action.perform();96 await exitModal('Cancel');97 });98 it('should long press on arbitrary coordinates', async function () {99 let el = await driver.elementByAccessibilityId('Okay / Cancel');100 let loc = await el.getLocation();101 let size = await el.getSize();102 loc = {103 x: loc.x + size.width / 2,104 y: loc.y + size.height / 2,105 };106 let action = new wd.TouchAction(driver);107 action.press(loc).wait(500).release();108 await action.perform();109 await exitModal('OK');110 });111 });112 it('should scroll using touch actions', async function () {113 let el1 = await driver.elementByAccessibilityId('Action Sheets');114 let el2 = await driver.elementByAccessibilityId('Progress Views');...

Full Screen

Full Screen

swipe-specs.js

Source:swipe-specs.js Github

copy

Full Screen

1"use strict";2var env = require('../../../../helpers/env')3 , setup = require("../../../common/setup-base")4 , desired = require("../desired")5 , reset = require("../reset")6 , wd = require("wd")7 , TouchAction = wd.TouchAction;8describe("apidemo - touch - swipe", function () {9 var driver;10 setup(this, desired).then(function (d) { driver = d; });11 var contentEl, animationEl, viewsEl;12 if (env.FAST_TESTS) {13 beforeEach(function () {14 return reset(driver);15 });16 }17 var _assertResultAndReset = function () {18 if (!viewsEl) {19 return driver.elementByName("Views")20 .then(function (el) {21 viewsEl = el;22 return _assertResultAndReset();23 });24 } else {25 return viewsEl.isDisplayed().should.become(true)26 .then(function () {27 return new TouchAction(driver)28 .press({el: contentEl}).wait({ms: 500}).moveTo({el: viewsEl}).release().perform()29 .elementByName("Accessibility").isDisplayed().should.become(true);30 });31 }32 };33 var x = 0, y = 0, hOffset;34 var contentElPos = { x: 0, y: 0 }35 , animationElPos = { x: 0, y: 0 }36 , delta = { x: 0, y: 0 };37 it('should properly initialize the test', function (done) {38 driver39 .elementByName("Content")40 .then(function (el) { contentEl = el; return contentEl; })41 .getLocation()42 .then(function (loc) {x = loc.x; y = loc.y; return contentEl;})43 .getSize()44 .then(function (re) {45 hOffset = re.height * 0.5;46 contentElPos.x = x + (re.width * 0.5);47 contentElPos.y = y + hOffset;48 })49 .elementByName("Animation")50 .then(function (el) {51 animationEl = el;52 return animationEl;53 })54 .getLocation()55 .then(function (loc) {56 animationElPos.x = contentElPos.x;57 animationElPos.y = loc.y + hOffset;58 delta.x = 0;59 delta.y = animationElPos.y - contentElPos.y;60 return contentEl;61 })62 .nodeify(done);63 });64 it('should work with: press {element}, moveTo {destEl}', function (done) {65 driver.chain()66 // test: press {element}, moveTo {element}67 .then(function () {68 return new TouchAction(driver)69 .press({el: contentEl}).wait({ms: 500}).moveTo({el: animationEl}).release().perform();70 })71 .then(_assertResultAndReset)72 .nodeify(done);73 });74 it('should work with: press {element, x, y}, moveTo {element, x, y}', function (done) {75 driver.chain()76 // test: press {element, x, y}, moveTo {element, x, y}77 .then(function () {78 return new TouchAction(driver)79 .press({el: contentEl, x: 20, y: 0.4}).wait({ms: 500}).moveTo({el: contentEl, x: delta.x, y: delta.y }).release().perform();80 })81 .then(_assertResultAndReset)82 .nodeify(done);83 });84 it('should work with: press {x, y}, moveTo {x, y}', function (done) {85 driver.chain()86 // test: press {x, y}, moveTo {x, y}87 .then(function () {88 return new TouchAction(driver)89 .press(contentElPos).wait({ms: 500}).moveTo(animationElPos).release().perform();90 })91 .then(_assertResultAndReset)92 .nodeify(done);93 });94 it('should work with: {element, x, y}, moveTo {destEl, x, y}', function (done) {95 driver.chain()96 // test: press {element, x, y}, moveTo {destEl, x, y}97 .then(function () {98 return new TouchAction(driver)99 .press({el: contentEl, x: 0.6, y: 35}).wait({ms: 500}).moveTo({el: animationEl, x: 25, y: 25 }).release().perform();100 })101 .then(_assertResultAndReset)102 .nodeify(done);103 });104 it("should work with press {x, y}, moveTo {destEl}", function (done) {105 driver.chain()106 // test: press {x, y}, moveTo {destEl}107 .then(function () {108 return new TouchAction(driver)109 .press(contentElPos).wait({ms: 500}).moveTo({el: animationEl}).release().perform();110 })111 .then(_assertResultAndReset)112 .nodeify(done);113 });...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...63 const previews = await $$('img.file-preview')64 // Names should all be listed before previews--indicates that previews were generated asynchronously.65 /* Nevermind this, setValue() doesn't accept multiple files so they are added one by one and the thumbnails66 * have finished generating by the time we add the next.67 const nys = names.map((el) => el.getLocation('y'))68 const pys = previews.map((el) => el.getLocation('y'))69 for (const ny of nys) {70 for (const py of pys) {71 expect(ny).to.be.below(py, 'names should be listed before previews')72 }73 }74 */75 expect(previews).to.have.lengthOf(3) // ex. the invalid image76 for (const p of previews) {77 expect(await p.getAttribute('src')).to.match(/^blob:/)78 // Doesn't appear to work in Chrome 67 on Android 6.079 if (capabilities.platformName !== 'Android') {80 expect(await getWidth(p)).to.equal(200)81 }82 }...

Full Screen

Full Screen

mobile-scroll-specs.js

Source:mobile-scroll-specs.js Github

copy

Full Screen

...7 it('should scroll down and up', function (done) {8 var firstEl, location1, location2;9 driver10 .elementByClassName('UIATableCell')11 .then(function (el) { firstEl = el; return el.getLocation(); })12 .then(function (loc) { location1 = loc; })13 .then(function () {14 return driver.execute("mobile: scroll", [{direction: 'down'}]);15 })16 .then(function () { return firstEl.getLocation(); })17 .then(function (loc2) {18 location2 = loc2;19 loc2.x.should.equal(location1.x);20 loc2.y.should.not.equal(location1.y);21 })22 .then(function () {23 return driver.execute("mobile: scroll", [{direction: 'up'}]);24 })25 .then(function () { return firstEl.getLocation(); })26 .then(function (loc3) {27 loc3.x.should.equal(location2.x);28 loc3.y.should.not.equal(location2.y);29 })30 .nodeify(done);31 });32 it('should scroll down and up using element', function (done) {33 var firstEl, location1, location2, table_view;34 driver.elementByClassName('UIATableView').then(function (el) {35 table_view = el;36 })37 .elementByClassName('UIATableCell')38 .then(function (el) { firstEl = el; return el.getLocation(); })39 .then(function (loc) { location1 = loc; })40 .then(function () {41 return driver.execute("mobile: scroll", [{element: table_view.value, direction: 'down'}]);42 })43 .then(function () { return firstEl.getLocation(); })44 .then(function (loc2) {45 location2 = loc2;46 loc2.x.should.equal(location1.x);47 loc2.y.should.not.equal(location1.y);48 })49 .then(function () {50 return driver.execute("mobile: scroll", [{element: table_view.value, direction: 'up'}]);51 })52 .then(function () { return firstEl.getLocation(); })...

Full Screen

Full Screen

scroll-to-el-specs.js

Source:scroll-to-el-specs.js Github

copy

Full Screen

...20 driver.elementsByClassName('UIATableCell').then(function (els) {21 el = els[10];22 scrollOpts = { element: el.value };23 })24 .then(function () { return el.getLocation(); })25 .then(function (loc) { location1 = loc; })26 .then(function () {27 return driver.execute("mobile: scrollTo", [scrollOpts]);28 }).then(function () { return el.getLocation(); })29 .then(function (location2) {30 location2.x.should.equal(location1.x);31 location2.y.should.not.equal(location1.y);32 }).nodeify(done);33 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const el = await driver.$('~myElement')2const location = await el.getLocation()3console.log('location is: ', location)4const el = await driver.$('~myElement')5const location = await el.getLocation({xOffset: 200, yOffset: 300})6console.log('location is: ', location)7const el = await driver.$('~myElement')8const location = await el.getLocationInView()9console.log('location is: ', location)10const el = await driver.$('~myElement')11const size = await el.getSize()12console.log('size is: ', size)13const el = await driver.$('~myElement')14const size = await el.getSize({widthOffset: 100, heightOffset: 200})15console.log('size is: ', size)16const el = await driver.$('~myElement')17const tagName = await el.getTagName()18console.log('tagName is: ', tagName)19const el = await driver.$('~myElement')20const text = await el.getText()21console.log('text is: ', text)22const el = await driver.$('~myElement')

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