Best JavaScript code snippet using appium-xcuitest-driver
cropper.js
Source:cropper.js
1/**2 * Copyright (c) 2006, David Spurr (http://www.defusion.org.uk/)3 * All rights reserved.4 *5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:6 *7 * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.8 * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.9 * * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.10 *11 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.12 *13 * http://www.opensource.org/licenses/bsd-license.php14 *15 * See scriptaculous.js for full scriptaculous licence16 */17var CropDraggable=Class.create();18Object.extend(Object.extend(CropDraggable.prototype,Draggable.prototype),{initialize:function(_1){19this.options=Object.extend({drawMethod:function(){20}},arguments[1]||{});21this.element=$(_1);22this.handle=this.element;23this.delta=this.currentDelta();24this.dragging=false;25this.eventMouseDown=this.initDrag.bindAsEventListener(this);26Event.observe(this.handle,"mousedown",this.eventMouseDown);27Draggables.register(this);28},draw:function(_2){29var _3=Position.cumulativeOffset(this.element);30var d=this.currentDelta();31_3[0]-=d[0];32_3[1]-=d[1];33var p=[0,1].map(function(i){34return (_2[i]-_3[i]-this.offset[i]);35}.bind(this));36this.options.drawMethod(p);37}});38var Cropper={};39Cropper.Img=Class.create();40Cropper.Img.prototype={initialize:function(_7,_8){41this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true},_8||{});42if(this.options.minWidth>0&&this.options.minHeight>0){43this.options.ratioDim.x=this.options.minWidth;44this.options.ratioDim.y=this.options.minHeight;45}46this.img=$(_7);47this.clickCoords={x:0,y:0};48this.dragging=false;49this.resizing=false;50this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent);51this.isIE=/MSIE/.test(navigator.userAgent);52this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent);53this.ratioX=0;54this.ratioY=0;55this.attached=false;56$A(document.getElementsByTagName("script")).each(function(s){57if(s.src.match(/cropper\.js/)){58var _a=s.src.replace(/cropper\.js(.*)?/,"");59var _b=document.createElement("link");60_b.rel="stylesheet";61_b.type="text/css";62_b.href=_a+"cropper.css";63_b.media="screen";64document.getElementsByTagName("head")[0].appendChild(_b);65}66});67if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){68var _c=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y);69this.ratioX=this.options.ratioDim.x/_c;70this.ratioY=this.options.ratioDim.y/_c;71}72this.subInitialize();73if(this.img.complete||this.isWebKit){74this.onLoad();75}else{76Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this));77}78},getGCD:function(a,b){return 1;79if(b==0){80return a;81}82return this.getGCD(b,a%b);83},onLoad:function(){84var _f="imgCrop_";85var _10=this.img.parentNode;86var _11="";87if(this.isOpera8){88_11=" opera8";89}90this.imgWrap=Builder.node("div",{"class":_f+"wrap"+_11});91if(this.isIE){92this.north=Builder.node("div",{"class":_f+"overlay "+_f+"north"},[Builder.node("span")]);93this.east=Builder.node("div",{"class":_f+"overlay "+_f+"east"},[Builder.node("span")]);94this.south=Builder.node("div",{"class":_f+"overlay "+_f+"south"},[Builder.node("span")]);95this.west=Builder.node("div",{"class":_f+"overlay "+_f+"west"},[Builder.node("span")]);96var _12=[this.north,this.east,this.south,this.west];97}else{98this.overlay=Builder.node("div",{"class":_f+"overlay"});99var _12=[this.overlay];100}101this.dragArea=Builder.node("div",{"class":_f+"dragArea"},_12);102this.handleN=Builder.node("div",{"class":_f+"handle "+_f+"handleN"});103this.handleNE=Builder.node("div",{"class":_f+"handle "+_f+"handleNE"});104this.handleE=Builder.node("div",{"class":_f+"handle "+_f+"handleE"});105this.handleSE=Builder.node("div",{"class":_f+"handle "+_f+"handleSE"});106this.handleS=Builder.node("div",{"class":_f+"handle "+_f+"handleS"});107this.handleSW=Builder.node("div",{"class":_f+"handle "+_f+"handleSW"});108this.handleW=Builder.node("div",{"class":_f+"handle "+_f+"handleW"});109this.handleNW=Builder.node("div",{"class":_f+"handle "+_f+"handleNW"});110this.selArea=Builder.node("div",{"class":_f+"selArea"},[Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeNorth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeEast"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeSouth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeWest"},[Builder.node("span")]),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,Builder.node("div",{"class":_f+"clickArea"})]);111Element.setStyle($(this.selArea),{backgroundColor:"transparent",backgroundRepeat:"no-repeat",backgroundPosition:"0 0"});112this.imgWrap.appendChild(this.img);113this.imgWrap.appendChild(this.dragArea);114this.dragArea.appendChild(this.selArea);115this.dragArea.appendChild(Builder.node("div",{"class":_f+"clickArea"}));116_10.appendChild(this.imgWrap);117Event.observe(this.dragArea,"mousedown",this.startDrag.bindAsEventListener(this));118Event.observe(document,"mousemove",this.onDrag.bindAsEventListener(this));119Event.observe(document,"mouseup",this.endCrop.bindAsEventListener(this));120var _13=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];121for(var i=0;i<_13.length;i++){122Event.observe(_13[i],"mousedown",this.startResize.bindAsEventListener(this));123}124if(this.options.captureKeys){125Event.observe(document,"keydown",this.handleKeys.bindAsEventListener(this));126}127new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)});128this.setParams();129},setParams:function(){130this.imgW=this.img.width;131this.imgH=this.img.height;132if(!this.isIE){133Element.setStyle($(this.overlay),{width:this.imgW+"px",height:this.imgH+"px"});134Element.hide($(this.overlay));135Element.setStyle($(this.selArea),{backgroundImage:"url("+this.img.src+")"});136}else{137Element.setStyle($(this.north),{height:0});138Element.setStyle($(this.east),{width:0,height:0});139Element.setStyle($(this.south),{height:0});140Element.setStyle($(this.west),{width:0,height:0});141}142Element.setStyle($(this.imgWrap),{"width":this.imgW+"px","height":this.imgH+"px"});143Element.hide($(this.selArea));144var _15=Position.positionedOffset(this.imgWrap);145this.wrapOffsets={"top":_15[1],"left":_15[0]};146var _16={x1:0,y1:0,x2:0,y2:0};147this.setAreaCoords(_16);148if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0&&this.options.displayOnInit){149_16.x1=Math.ceil((this.imgW-this.options.ratioDim.x)/2);150_16.y1=Math.ceil((this.imgH-this.options.ratioDim.y)/2);151_16.x2=_16.x1+this.options.ratioDim.x;152_16.y2=_16.y1+this.options.ratioDim.y;153Element.show(this.selArea);154this.drawArea();155this.endCrop();156}157this.attached=true;158},remove:function(){159this.attached=false;160this.imgWrap.parentNode.insertBefore(this.img,this.imgWrap);161this.imgWrap.parentNode.removeChild(this.imgWrap);162Event.stopObserving(this.dragArea,"mousedown",this.startDrag.bindAsEventListener(this));163Event.stopObserving(document,"mousemove",this.onDrag.bindAsEventListener(this));164Event.stopObserving(document,"mouseup",this.endCrop.bindAsEventListener(this));165var _17=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];166for(var i=0;i<_17.length;i++){167Event.stopObserving(_17[i],"mousedown",this.startResize.bindAsEventListener(this));168}169if(this.options.captureKeys){170Event.stopObserving(document,"keydown",this.handleKeys.bindAsEventListener(this));171}172},reset:function(){173if(!this.attached){174this.onLoad();175}else{176this.setParams();177}178this.endCrop();179},handleKeys:function(e){180var dir={x:0,y:0};181if(!this.dragging){182switch(e.keyCode){183case (37):184dir.x=-1;185break;186case (38):187dir.y=-1;188break;189case (39):190dir.x=1;191break;192case (40):193dir.y=1;194break;195}196if(dir.x!=0||dir.y!=0){197if(e.shiftKey){198dir.x*=10;199dir.y*=10;200}201this.moveArea([this.areaCoords.x1+dir.x,this.areaCoords.y1+dir.y]);202Event.stop(e);203}204}205},calcW:function(){206return (this.areaCoords.x2-this.areaCoords.x1);207},calcH:function(){208return (this.areaCoords.y2-this.areaCoords.y1);209},moveArea:function(_1b){210this.setAreaCoords({x1:_1b[0],y1:_1b[1],x2:_1b[0]+this.calcW(),y2:_1b[1]+this.calcH()},true);211this.drawArea();212},cloneCoords:function(_1c){213return {x1:_1c.x1,y1:_1c.y1,x2:_1c.x2,y2:_1c.y2};214},setAreaCoords:function(_1d,_1e,_1f,_20,_21){215var _22=typeof _1e!="undefined"?_1e:false;216var _23=typeof _1f!="undefined"?_1f:false;217if(_1e){218var _24=_1d.x2-_1d.x1;219var _25=_1d.y2-_1d.y1;220if(_1d.x1<0){221_1d.x1=0;222_1d.x2=_24;223}224if(_1d.y1<0){225_1d.y1=0;226_1d.y2=_25;227}228if(_1d.x2>this.imgW){229_1d.x2=this.imgW;230_1d.x1=this.imgW-_24;231}232if(_1d.y2>this.imgH){233_1d.y2=this.imgH;234_1d.y1=this.imgH-_25;235}236}else{237if(_1d.x1<0){238_1d.x1=0;239}240if(_1d.y1<0){241_1d.y1=0;242}243if(_1d.x2>this.imgW){244_1d.x2=this.imgW;245}246if(_1d.y2>this.imgH){247_1d.y2=this.imgH;248}249if(typeof (_20)!="undefined"){250if(this.ratioX>0){251this.applyRatio(_1d,{x:this.ratioX,y:this.ratioY},_20,_21);252}else{253if(_23){254this.applyRatio(_1d,{x:1,y:1},_20,_21);255}256}257var _26={a1:_1d.x1,a2:_1d.x2};258var _27={a1:_1d.y1,a2:_1d.y2};259var _28=this.options.minWidth;260var _29=this.options.minHeight;261if((_28==0||_29==0)&&_23){262if(_28>0){263_29=_28;264}else{265if(_29>0){266_28=_29;267}268}269}270this.applyMinDimension(_26,_28,_20.x,{min:0,max:this.imgW});271this.applyMinDimension(_27,_29,_20.y,{min:0,max:this.imgH});272_1d={x1:_26.a1,y1:_27.a1,x2:_26.a2,y2:_27.a2};273}274}275this.areaCoords=_1d;276},applyMinDimension:function(_2a,_2b,_2c,_2d){277if((_2a.a2-_2a.a1)<_2b){278if(_2c==1){279_2a.a2=_2a.a1+_2b;280}else{281_2a.a1=_2a.a2-_2b;282}283if(_2a.a1<_2d.min){284_2a.a1=_2d.min;285_2a.a2=_2b;286}else{287if(_2a.a2>_2d.max){288_2a.a1=_2d.max-_2b;289_2a.a2=_2d.max;290}291}292}293},applyRatio:function(_2e,_2f,_30,_31){294var _32;295if(_31=="N"||_31=="S"){296_32=this.applyRatioToAxis({a1:_2e.y1,b1:_2e.x1,a2:_2e.y2,b2:_2e.x2},{a:_2f.y,b:_2f.x},{a:_30.y,b:_30.x},{min:0,max:this.imgW});297_2e.x1=_32.b1;298_2e.y1=_32.a1;299_2e.x2=_32.b2;300_2e.y2=_32.a2;301}else{302_32=this.applyRatioToAxis({a1:_2e.x1,b1:_2e.y1,a2:_2e.x2,b2:_2e.y2},{a:_2f.x,b:_2f.y},{a:_30.x,b:_30.y},{min:0,max:this.imgH});303_2e.x1=_32.a1;304_2e.y1=_32.b1;305_2e.x2=_32.a2;306_2e.y2=_32.b2;307}308},applyRatioToAxis:function(_33,_34,_35,_36){309var _37=Object.extend(_33,{});310var _38=_37.a2-_37.a1;311var _3a=Math.floor(_38*_34.b/_34.a);312var _3b;313var _3c;314var _3d=null;315if(_35.b==1){316_3b=_37.b1+_3a;317if(_3b>_36.max){318_3b=_36.max;319_3d=_3b-_37.b1;320}321_37.b2=_3b;322}else{323_3b=_37.b2-_3a;324if(_3b<_36.min){325_3b=_36.min;326_3d=_3b+_37.b2;327}328_37.b1=_3b;329}330if(_3d!=null){331_3c=Math.floor(_3d*_34.a/_34.b);332if(_35.a==1){333_37.a2=_37.a1+_3c;334}else{335_37.a1=_37.a1=_37.a2-_3c;336}337}338return _37;339},drawArea:function(){340if(!this.isIE){341Element.show($(this.overlay));342}343var _3e=this.calcW();344var _3f=this.calcH();345var _40=this.areaCoords.x2;346var _41=this.areaCoords.y2;347var _42=this.selArea.style;348_42.left=this.areaCoords.x1+"px";349_42.top=this.areaCoords.y1+"px";350_42.width=_3e+"px";351_42.height=_3f+"px";352var _43=Math.ceil((_3e-6)/2)+"px";353var _44=Math.ceil((_3f-6)/2)+"px";354this.handleN.style.left=_43;355this.handleE.style.top=_44;356this.handleS.style.left=_43;357this.handleW.style.top=_44;358if(this.isIE){359this.north.style.height=this.areaCoords.y1+"px";360var _45=this.east.style;361_45.top=this.areaCoords.y1+"px";362_45.height=_3f+"px";363_45.left=_40+"px";364_45.width=(this.img.width-_40)+"px";365var _46=this.south.style;366_46.top=_41+"px";367_46.height=(this.img.height-_41)+"px";368var _47=this.west.style;369_47.top=this.areaCoords.y1+"px";370_47.height=_3f+"px";371_47.width=this.areaCoords.x1+"px";372}else{373_42.backgroundPosition="-"+this.areaCoords.x1+"px "+"-"+this.areaCoords.y1+"px";374}375this.subDrawArea();376this.forceReRender();377},forceReRender:function(){378if(this.isIE||this.isWebKit){379var n=document.createTextNode(" ");380var d,el,fixEL,i;381if(this.isIE){382fixEl=this.selArea;383}else{384if(this.isWebKit){385fixEl=document.getElementsByClassName("imgCrop_marqueeSouth",this.imgWrap)[0];386d=Builder.node("div","");387d.style.visibility="hidden";388var _4a=["SE","S","SW"];389for(i=0;i<_4a.length;i++){390el=document.getElementsByClassName("imgCrop_handle"+_4a[i],this.selArea)[0];391if(el.childNodes.length){392el.removeChild(el.childNodes[0]);393}394el.appendChild(d);395}396}397}398fixEl.appendChild(n);399fixEl.removeChild(n);400}401},startResize:function(e){402this.startCoords=this.cloneCoords(this.areaCoords);403this.resizing=true;404this.resizeHandle=Element.classNames(Event.element(e)).toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,"");405Event.stop(e);406},startDrag:function(e){407Element.show(this.selArea);408this.clickCoords=this.getCurPos(e);409this.setAreaCoords({x1:this.clickCoords.x,y1:this.clickCoords.y,x2:this.clickCoords.x,y2:this.clickCoords.y});410this.dragging=true;411this.onDrag(e);412Event.stop(e);413},getCurPos:function(e){414return curPos={x:Event.pointerX(e)-this.wrapOffsets.left,y:Event.pointerY(e)-this.wrapOffsets.top};415},onDrag:function(e){416var _4f=null;417if(this.dragging||this.resizing){418var _50=this.getCurPos(e);419var _51=this.cloneCoords(this.areaCoords);420var _52={x:1,y:1};421}422if(this.dragging){423if(_50.x<this.clickCoords.x){424_52.x=-1;425}426if(_50.y<this.clickCoords.y){427_52.y=-1;428}429this.transformCoords(_50.x,this.clickCoords.x,_51,"x");430this.transformCoords(_50.y,this.clickCoords.y,_51,"y");431}else{432if(this.resizing){433_4f=this.resizeHandle;434if(_4f.match(/E/)){435this.transformCoords(_50.x,this.startCoords.x1,_51,"x");436if(_50.x<this.startCoords.x1){437_52.x=-1;438}439}else{440if(_4f.match(/W/)){441this.transformCoords(_50.x,this.startCoords.x2,_51,"x");442if(_50.x<this.startCoords.x2){443_52.x=-1;444}445}446}447if(_4f.match(/N/)){448this.transformCoords(_50.y,this.startCoords.y2,_51,"y");449if(_50.y<this.startCoords.y2){450_52.y=-1;451}452}else{453if(_4f.match(/S/)){454this.transformCoords(_50.y,this.startCoords.y1,_51,"y");455if(_50.y<this.startCoords.y1){456_52.y=-1;457}458}459}460}461}462if(this.dragging||this.resizing){463this.setAreaCoords(_51,false,e.shiftKey,_52,_4f);464this.drawArea();465Event.stop(e);466}467},transformCoords:function(_53,_54,_55,_56){468var _57=new Array();469if(_53<_54){470_57[0]=_53;471_57[1]=_54;472}else{473_57[0]=_54;474_57[1]=_53;475}476if(_56=="x"){477_55.x1=_57[0];478_55.x2=_57[1];479}else{480_55.y1=_57[0];481_55.y2=_57[1];482}483},endCrop:function(){484this.dragging=false;485this.resizing=false;486this.options.onEndCrop(this.areaCoords,{width:this.calcW(),height:this.calcH()});487},subInitialize:function(){488},subDrawArea:function(){489}};490Cropper.ImgWithPreview=Class.create();491Object.extend(Object.extend(Cropper.ImgWithPreview.prototype,Cropper.Img.prototype),{subInitialize:function(){492this.hasPreviewImg=false;493if(typeof (this.options.previewWrap)!="undefined"&&this.options.minWidth>0&&this.options.minHeight>0){494this.previewWrap=$(this.options.previewWrap);495this.previewImg=this.img.cloneNode(false);496this.options.displayOnInit=true;497this.hasPreviewImg=true;498Element.addClassName(this.previewWrap,"imgCrop_previewWrap");499Element.setStyle(this.previewWrap,{width:this.options.minWidth+"px",height:this.options.minHeight+"px"});500this.previewWrap.appendChild(this.previewImg);501}502},subDrawArea:function(){503if(this.hasPreviewImg){504var _58=this.calcW();505var _59=this.calcH();506var _5a={x:this.imgW/_58,y:this.imgH/_59};507var _5b={x:_58/this.options.minWidth,y:_59/this.options.minHeight};508var _5c={w:Math.ceil(this.options.minWidth*_5a.x)+"px",h:Math.ceil(this.options.minHeight*_5a.y)+"px",x:"-"+Math.ceil(this.areaCoords.x1/_5b.x)+"px",y:"-"+Math.ceil(this.areaCoords.y1/_5b.y)+"px"};509var _5d=this.previewImg.style;510_5d.width=_5c.w;511_5d.height=_5c.h;512_5d.left=_5c.x;513_5d.top=_5c.y;514}...
Using AI Code Generation
1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5chai.should();6const assert = chai.assert;7const expect = chai.expect;8const _ = require('lodash');9const iosConfigs = require('./ios-configs');10const caps = iosConfigs.ios11;11caps.app = '/Users/username/Downloads/MyApp.app';12driver.init(caps)13 .then(() => {14 return driver.wait(() => {15 return driver.elementByAccessibilityId('MyButton').click()16 .then(() => {17 return driver.elementByAccessibilityId('MyButton').getLocation()18 .then((location) => {19 return driver.elementByAccessibilityId('MyButton').getSize()20 .then((size) => {21 const x = location.x + size.width / 2;22 const y = location.y + size.height / 2;23 return driver.clickCoords(x, y);24 });25 });26 });27 }, 30000);28 })29 .fin(() => driver.quit())30 .done();31const ios11 = {32};33exports.ios11 = ios11;34{35 "scripts": {36 },37 "dependencies": {38 }39}
Using AI Code Generation
1const { remote } = require('webdriverio');2const opts = {3 capabilities: {4 }5};6async function main () {7 const client = await remote(opts);8 const element = await client.$('XCUIElementTypeWebView');9 await client.switchContext(element.value.ELEMENT);10 const x = await client.execute('return this.clickCoords.x');11 const y = await client.execute('return this.clickCoords.y');12 console.log(x, y);13 await client.switchContext('NATIVE_APP');14 await client.deleteSession();15}16main();17commands.execute = async function (script, args) {18 if (script === 'return this.clickCoords.x') {19 return this.clickCoords.x;20 }21 if (script === 'return this.clickCoords.y') {22 return this.clickCoords.y;23 }24 return await this.executeAtom('execute_script', [script, args], true);25};26commands.executeAtom = async function (atom, args, frames) {27 const script = await this.getAtom(atom, args, frames);28 return await this.execute(script, []);29};30commands.getAtom = async function (atom, args, frames) {31 const atomFile = path.resolve(ATOMS_PATH, `${atom}.js`);32 const atomCode = await fs.readFile(atomFile, 'utf8');33 const script = `return (${atomCode}).apply(null, arguments);`;34 return await this.execute(script, [args, frames]);35};36commands.execute = async function (script, args) {37 if (script === 'return this.clickCoords.x') {38 return this.clickCoords.x;39 }40 if (script === 'return this.clickCoords.y') {41 return this.clickCoords.y;42 }43 return await this.executeAtom('execute_script', [script, args], true);44};
Using AI Code Generation
1const {remote} = require('webdriverio');2const opts = {3 capabilities: {4 }5};6(async () => {7 const client = await remote(opts);8 await client.pause(10000);9 await client.clickCoords(100, 100);10 await client.pause(10000);11 await client.clickCoords(200, 200);12 await client.pause(10000);13 await client.clickCoords(300, 300);14 await client.pause(10000);15 await client.clickCoords(400, 400);16 await client.pause(10000);17 await client.clickCoords(500, 500);18})();19#import "FBCustomCommands.h"20#import "FBRouteRequest.h"21#import "FBSession.h"22#import "FBMacros.h"23#import "FBElementCache.h"24#import "XCUIElement+FBTap.h"25#import "XCUIElement+FBUtilities.h"26#import "XCUIElement+FBIsVisible.h"27#import "FBXCodeCompatibility.h"28#import "FBLogger.h"29#import "FBApplication.h"30#import "FBConfiguration.h"31#import "FBAlert.h"32#import "FBElement.h"33#import "FBExceptionHandler.h"34#import "FBXCTestDaemonsProxy.h"35#import "FBRunLoopSpinner.h"36#import "FBResponsePayload.h"37+ (NSArray<FBRoute *> *)routes38{39 [[FBRoute GET:@"/clickCoords"].withoutSession respondWithTarget:self action:@selector(handleClickCoords:)],40 ];41}42+ (id<FBResponsePayload>)handleClickCoords:(FBRouteRequest *)request43{
Using AI Code Generation
1var clickCoordinates = driver.clickCoords(100,200);2driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});3var clickCoordinates = driver.clickCoords(100,200);4driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});5var clickCoordinates = driver.clickCoords(100,200);6driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});7var clickCoordinates = driver.clickCoords(100,200);8driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});9var clickCoordinates = driver.clickCoords(100,200);10driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});11var clickCoordinates = driver.clickCoords(100,200);12driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});13var clickCoordinates = driver.clickCoords(100,200);14driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});15var clickCoordinates = driver.clickCoords(100,200);16driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});17var clickCoordinates = driver.clickCoords(100,200);18driver.execute('mobile: tap', {x: clickCoordinates.x, y: clickCoordinates.y});
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .forBrowser('selenium')4 .build();5var By = webdriver.By;6var until = webdriver.until;7driver.findElement(By.id('identifierId')).sendKeys('yourusername');8driver.findElement(By.id('identifierNext')).click();9driver.sleep(2000);10driver.findElement(By.name('password')).sendKeys('yourpassword');11driver.findElement(By.id('passwordNext')).click();12driver.sleep(2000);13driver.findElement(By.className('z0')).click();14driver.sleep(2000);15driver.executeScript('mobile: clickCoords', {x: 44, y: 80}).then(function() {16 console.log("clicked on 'New' button");17});18driver.quit();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!