Best JavaScript code snippet using appium-xcuitest-driver
module_BCD.js
Source:module_BCD.js  
...438      **/439     calculate:function()440     {441         //- For Segment a442         if (this.getPort("Port_a1").getValue() && this.getPort("Port_a2").getValue() && this.getPort("Port_a4").getValue() && this.getPort("Port_a8").getValue()) {443            this.layerAttr("seg_a0", { fill: "#C21B7A"});444            this.layerAttr("seg_a1", { fill: null});445            this.layerAttr("seg_a2", { fill: null});446            this.layerAttr("seg_a3", { fill: null});447            this.layerAttr("seg_a4", { fill: "#C21B7A"});448            this.layerAttr("seg_a5", { fill: "#C21B7A"});449            this.layerAttr("seg_a6", { fill: "#C21B7A"});450         }451         else if (!this.getPort("Port_a1").getValue() && this.getPort("Port_a2").getValue() && this.getPort("Port_a4").getValue() && this.getPort("Port_a8").getValue()) {452            this.layerAttr("seg_a0", { fill: "#C21B7A"});453            this.layerAttr("seg_a1", { fill: null});454            this.layerAttr("seg_a2", { fill: null});455            this.layerAttr("seg_a4", { fill: "#C21B7A"});456            this.layerAttr("seg_a5", { fill: "#C21B7A"});457            this.layerAttr("seg_a6", { fill: "#C21B7A"});458            this.layerAttr("seg_a3", { fill: "#C21B7A"});459         }460         else if (this.getPort("Port_a1").getValue() && !this.getPort("Port_a2").getValue() && this.getPort("Port_a4").getValue() && this.getPort("Port_a8").getValue()) {461            this.layerAttr("seg_a1", { fill: "#C21B7A"});462            this.layerAttr("seg_a2", { fill: "#C21B7A"});463            this.layerAttr("seg_a4", { fill: "#C21B7A"});464            this.layerAttr("seg_a6", { fill: "#C21B7A"});465            this.layerAttr("seg_a3", { fill: "#C21B7A"});466            this.layerAttr("seg_a0", { fill: null});467            this.layerAttr("seg_a5", { fill: null});468         }469         else if (!this.getPort("Port_a1").getValue() && !this.getPort("Port_a2").getValue() && this.getPort("Port_a4").getValue() && this.getPort("Port_a8").getValue()) {470            this.layerAttr("seg_a0", { fill: "#C21B7A"});471            this.layerAttr("seg_a3", { fill: "#C21B7A"});472            this.layerAttr("seg_a4", { fill: "#C21B7A"});473            this.layerAttr("seg_a5", { fill: "#C21B7A"});474            this.layerAttr("seg_a1", { fill: null});475            this.layerAttr("seg_a2", { fill: null});476            this.layerAttr("seg_a6", { fill: null});477         }478         else if (this.getPort("Port_a1").getValue() && this.getPort("Port_a2").getValue() && !this.getPort("Port_a4").getValue() && this.getPort("Port_a8").getValue()) {479            this.layerAttr("seg_a2", { fill: "#C21B7A"});480            this.layerAttr("seg_a3", { fill: "#C21B7A"});481            this.layerAttr("seg_a4", { fill: "#C21B7A"});482            this.layerAttr("seg_a5", { fill: "#C21B7A"});483            this.layerAttr("seg_a6", { fill: "#C21B7A"});484            this.layerAttr("seg_a1", { fill: null});485            this.layerAttr("seg_a0", { fill: null});486         }487         else if (!this.getPort("Port_a1").getValue() && this.getPort("Port_a2").getValue() && !this.getPort("Port_a4").getValue() && this.getPort("Port_a8").getValue()) {488            this.layerAttr("seg_a0", { fill: "#C21B7A"});489            this.layerAttr("seg_a1", { fill: "#C21B7A"});490            this.layerAttr("seg_a2", { fill: "#C21B7A"});491            this.layerAttr("seg_a4", { fill: "#C21B7A"});492            this.layerAttr("seg_a5", { fill: "#C21B7A"});493            this.layerAttr("seg_a6", { fill: "#C21B7A"});494            this.layerAttr("seg_a3", { fill: null});495         }496         else if (this.getPort("Port_a1").getValue() && !this.getPort("Port_a2").getValue() && !this.getPort("Port_a4").getValue() && this.getPort("Port_a8").getValue()) {497            this.layerAttr("seg_a0", { fill: "#C21B7A"});498            this.layerAttr("seg_a1", { fill: "#C21B7A"});499            this.layerAttr("seg_a2", { fill: "#C21B7A"});500            this.layerAttr("seg_a5", { fill: "#C21B7A"});501            this.layerAttr("seg_a6", { fill: "#C21B7A"});502            this.layerAttr("seg_a3", { fill: null});503            this.layerAttr("seg_a4", { fill: null});504         }505         else if (!this.getPort("Port_a1").getValue() && !this.getPort("Port_a2").getValue() && !this.getPort("Port_a4").getValue() && this.getPort("Port_a8").getValue()) {506            this.layerAttr("seg_a0", { fill: "#C21B7A"});507            this.layerAttr("seg_a1", { fill: "#C21B7A"});508            this.layerAttr("seg_a3", { fill: "#C21B7A"});509            this.layerAttr("seg_a4", { fill: "#C21B7A"});510            this.layerAttr("seg_a2", { fill: "#C21B7A"});511            this.layerAttr("seg_a5", { fill: "#C21B7A"});512            this.layerAttr("seg_a6", { fill: "#C21B7A"});513         }514         else if (this.getPort("Port_a1").getValue() && this.getPort("Port_a2").getValue() && this.getPort("Port_a4").getValue() && !this.getPort("Port_a8").getValue()) {515            this.layerAttr("seg_a0", { fill: "#C21B7A"});516            this.layerAttr("seg_a1", { fill: "#C21B7A"});517            this.layerAttr("seg_a3", { fill: null});518            this.layerAttr("seg_a4", { fill: null});519            this.layerAttr("seg_a2", { fill: "#C21B7A"});520            this.layerAttr("seg_a5", { fill: null});521            this.layerAttr("seg_a6", { fill: null});522         }523         else if (!this.getPort("Port_a1").getValue() && this.getPort("Port_a2").getValue() && this.getPort("Port_a4").getValue() && !this.getPort("Port_a8").getValue()) {524            this.layerAttr("seg_a0", { fill: "#C21B7A"});525            this.layerAttr("seg_a1", { fill: null});526            this.layerAttr("seg_a3", { fill: "#C21B7A"});527            this.layerAttr("seg_a4", { fill: "#C21B7A"});528            this.layerAttr("seg_a2", { fill: "#C21B7A"});529            this.layerAttr("seg_a5", { fill: "#C21B7A"});530            this.layerAttr("seg_a6", { fill: "#C21B7A"});531         }532         else if (this.getPort("Port_a1").getValue() && !this.getPort("Port_a2").getValue() && this.getPort("Port_a4").getValue() && !this.getPort("Port_a8").getValue()) {533            this.layerAttr("seg_a0", { fill: "#C21B7A"});534            this.layerAttr("seg_a1", { fill: null});535            this.layerAttr("seg_a3", { fill: "#C21B7A"});536            this.layerAttr("seg_a4", { fill: null});537            this.layerAttr("seg_a2", { fill: "#C21B7A"});538            this.layerAttr("seg_a5", { fill: "#C21B7A"});539            this.layerAttr("seg_a6", { fill: "#C21B7A"});540         }541         else if (!this.getPort("Port_a1").getValue() && !this.getPort("Port_a2").getValue() && this.getPort("Port_a4").getValue() && !this.getPort("Port_a8").getValue()) {542            this.layerAttr("seg_a0", { fill: null});543            this.layerAttr("seg_a1", { fill: "#C21B7A"});544            this.layerAttr("seg_a3", { fill: null});545            this.layerAttr("seg_a4", { fill: null});546            this.layerAttr("seg_a2", { fill: "#C21B7A"});547            this.layerAttr("seg_a5", { fill: "#C21B7A"});548            this.layerAttr("seg_a6", { fill: "#C21B7A"});549         }550         else if (this.getPort("Port_a1").getValue() && this.getPort("Port_a2").getValue() && !this.getPort("Port_a4").getValue() && !this.getPort("Port_a8").getValue()) {551            this.layerAttr("seg_a0", { fill: "#C21B7A"});552            this.layerAttr("seg_a1", { fill: "#C21B7A"});553            this.layerAttr("seg_a3", { fill: "#C21B7A"});554            this.layerAttr("seg_a4", { fill: null});555            this.layerAttr("seg_a2", { fill: "#C21B7A"});556            this.layerAttr("seg_a5", { fill: null});557            this.layerAttr("seg_a6", { fill: "#C21B7A"});558         }559         else if (!this.getPort("Port_a1").getValue() && this.getPort("Port_a2").getValue() && !this.getPort("Port_a4").getValue() && !this.getPort("Port_a8").getValue()) {560            this.layerAttr("seg_a0", { fill: "#C21B7A"});561            this.layerAttr("seg_a1", { fill: "#C21B7A"});562            this.layerAttr("seg_a3", { fill: "#C21B7A"});563            this.layerAttr("seg_a4", { fill: "#C21B7A"});564            this.layerAttr("seg_a2", { fill: null});565            this.layerAttr("seg_a5", { fill: null});566            this.layerAttr("seg_a6", { fill: "#C21B7A"});567         }568         else if (this.getPort("Port_a1").getValue() && !this.getPort("Port_a2").getValue() && !this.getPort("Port_a4").getValue() && !this.getPort("Port_a8").getValue()) {569            this.layerAttr("seg_a0", { fill: null});570            this.layerAttr("seg_a1", { fill: "#C21B7A"});571            this.layerAttr("seg_a3", { fill: null});572            this.layerAttr("seg_a4", { fill: null});573            this.layerAttr("seg_a2", { fill: "#C21B7A"});574            this.layerAttr("seg_a5", { fill: null});575            this.layerAttr("seg_a6", { fill: null});576         }577         else if (!this.getPort("Port_a1").getValue() && !this.getPort("Port_a2").getValue() && !this.getPort("Port_a4").getValue() && !this.getPort("Port_a8").getValue()) {578            this.layerAttr("seg_a0", { fill: "#C21B7A"});579            this.layerAttr("seg_a1", { fill: "#C21B7A"});580            this.layerAttr("seg_a3", { fill: "#C21B7A"});581            this.layerAttr("seg_a4", { fill: "#C21B7A"});582            this.layerAttr("seg_a2", { fill: "#C21B7A"});583            this.layerAttr("seg_a5", { fill: "#C21B7A"});584            this.layerAttr("seg_a6", { fill: null});585         }586         // For b587         if (this.getPort("Port_b1").getValue() && this.getPort("Port_b2").getValue() && this.getPort("Port_b4").getValue() && this.getPort("Port_b8").getValue()) {588            this.layerAttr("seg_b0", { fill: "#C21B7A"});589            this.layerAttr("seg_b1", { fill: null});590            this.layerAttr("seg_b2", { fill: null});591            this.layerAttr("seg_b3", { fill: null});592            this.layerAttr("seg_b4", { fill: "#C21B7A"});593            this.layerAttr("seg_b5", { fill: "#C21B7A"});594            this.layerAttr("seg_b6", { fill: "#C21B7A"});595         }596         else if (!this.getPort("Port_b1").getValue() && this.getPort("Port_b2").getValue() && this.getPort("Port_b4").getValue() && this.getPort("Port_b8").getValue()) {597            this.layerAttr("seg_b0", { fill: "#C21B7A"});598            this.layerAttr("seg_b1", { fill: null});599            this.layerAttr("seg_b2", { fill: null});600            this.layerAttr("seg_b4", { fill: "#C21B7A"});601            this.layerAttr("seg_b5", { fill: "#C21B7A"});602            this.layerAttr("seg_b6", { fill: "#C21B7A"});603            this.layerAttr("seg_b3", { fill: "#C21B7A"});604         }605         else if (this.getPort("Port_b1").getValue() && !this.getPort("Port_b2").getValue() && this.getPort("Port_b4").getValue() && this.getPort("Port_b8").getValue()) {606            this.layerAttr("seg_b1", { fill: "#C21B7A"});607            this.layerAttr("seg_b2", { fill: "#C21B7A"});608            this.layerAttr("seg_b4", { fill: "#C21B7A"});609            this.layerAttr("seg_b6", { fill: "#C21B7A"});610            this.layerAttr("seg_b3", { fill: "#C21B7A"});611            this.layerAttr("seg_b0", { fill: null});612            this.layerAttr("seg_b5", { fill: null});613         }614         else if (!this.getPort("Port_b1").getValue() && !this.getPort("Port_b2").getValue() && this.getPort("Port_b4").getValue() && this.getPort("Port_b8").getValue()) {615            this.layerAttr("seg_b0", { fill: "#C21B7A"});616            this.layerAttr("seg_b3", { fill: "#C21B7A"});617            this.layerAttr("seg_b4", { fill: "#C21B7A"});618            this.layerAttr("seg_b5", { fill: "#C21B7A"});619            this.layerAttr("seg_b1", { fill: null});620            this.layerAttr("seg_b2", { fill: null});621            this.layerAttr("seg_b6", { fill: null});622         }623         else if (this.getPort("Port_b1").getValue() && this.getPort("Port_b2").getValue() && !this.getPort("Port_b4").getValue() && this.getPort("Port_b8").getValue()) {624            this.layerAttr("seg_b2", { fill: "#C21B7A"});625            this.layerAttr("seg_b3", { fill: "#C21B7A"});626            this.layerAttr("seg_b4", { fill: "#C21B7A"});627            this.layerAttr("seg_b5", { fill: "#C21B7A"});628            this.layerAttr("seg_b6", { fill: "#C21B7A"});629            this.layerAttr("seg_b1", { fill: null});630            this.layerAttr("seg_b0", { fill: null});631         }632         else if (!this.getPort("Port_b1").getValue() && this.getPort("Port_b2").getValue() && !this.getPort("Port_b4").getValue() && this.getPort("Port_b8").getValue()) {633            this.layerAttr("seg_b0", { fill: "#C21B7A"});634            this.layerAttr("seg_b1", { fill: "#C21B7A"});635            this.layerAttr("seg_b2", { fill: "#C21B7A"});636            this.layerAttr("seg_b4", { fill: "#C21B7A"});637            this.layerAttr("seg_b5", { fill: "#C21B7A"});638            this.layerAttr("seg_b6", { fill: "#C21B7A"});639            this.layerAttr("seg_b3", { fill: null});640         }641         else if (this.getPort("Port_b1").getValue() && !this.getPort("Port_b2").getValue() && !this.getPort("Port_b4").getValue() && this.getPort("Port_b8").getValue()) {642            this.layerAttr("seg_b0", { fill: "#C21B7A"});643            this.layerAttr("seg_b1", { fill: "#C21B7A"});644            this.layerAttr("seg_b2", { fill: "#C21B7A"});645            this.layerAttr("seg_b5", { fill: "#C21B7A"});646            this.layerAttr("seg_b6", { fill: "#C21B7A"});647            this.layerAttr("seg_b3", { fill: null});648            this.layerAttr("seg_b4", { fill: null});649         }650         else if (!this.getPort("Port_b1").getValue() && !this.getPort("Port_b2").getValue() && !this.getPort("Port_b4").getValue() && this.getPort("Port_b8").getValue()) {651            this.layerAttr("seg_b0", { fill: "#C21B7A"});652            this.layerAttr("seg_b1", { fill: "#C21B7A"});653            this.layerAttr("seg_b3", { fill: "#C21B7A"});654            this.layerAttr("seg_b4", { fill: "#C21B7A"});655            this.layerAttr("seg_b2", { fill: "#C21B7A"});656            this.layerAttr("seg_b5", { fill: "#C21B7A"});657            this.layerAttr("seg_b6", { fill: "#C21B7A"});658         }659         else if (this.getPort("Port_b1").getValue() && this.getPort("Port_b2").getValue() && this.getPort("Port_b4").getValue() && !this.getPort("Port_b8").getValue()) {660            this.layerAttr("seg_b0", { fill: "#C21B7A"});661            this.layerAttr("seg_b1", { fill: "#C21B7A"});662            this.layerAttr("seg_b3", { fill: null});663            this.layerAttr("seg_b4", { fill: null});664            this.layerAttr("seg_b2", { fill: "#C21B7A"});665            this.layerAttr("seg_b5", { fill: null});666            this.layerAttr("seg_b6", { fill: null});667         }668         else if (!this.getPort("Port_b1").getValue() && this.getPort("Port_b2").getValue() && this.getPort("Port_b4").getValue() && !this.getPort("Port_b8").getValue()) {669            this.layerAttr("seg_b0", { fill: "#C21B7A"});670            this.layerAttr("seg_b1", { fill: null});671            this.layerAttr("seg_b3", { fill: "#C21B7A"});672            this.layerAttr("seg_b4", { fill: "#C21B7A"});673            this.layerAttr("seg_b2", { fill: "#C21B7A"});674            this.layerAttr("seg_b5", { fill: "#C21B7A"});675            this.layerAttr("seg_b6", { fill: "#C21B7A"});676         }677         else if (this.getPort("Port_b1").getValue() && !this.getPort("Port_b2").getValue() && this.getPort("Port_b4").getValue() && !this.getPort("Port_b8").getValue()) {678            this.layerAttr("seg_b0", { fill: "#C21B7A"});679            this.layerAttr("seg_b1", { fill: null});680            this.layerAttr("seg_b3", { fill: "#C21B7A"});681            this.layerAttr("seg_b4", { fill: null});682            this.layerAttr("seg_b2", { fill: "#C21B7A"});683            this.layerAttr("seg_b5", { fill: "#C21B7A"});684            this.layerAttr("seg_b6", { fill: "#C21B7A"});685         }686         else if (!this.getPort("Port_b1").getValue() && !this.getPort("Port_b2").getValue() && this.getPort("Port_b4").getValue() && !this.getPort("Port_b8").getValue()) {687            this.layerAttr("seg_b0", { fill: null});688            this.layerAttr("seg_b1", { fill: "#C21B7A"});689            this.layerAttr("seg_b3", { fill: null});690            this.layerAttr("seg_b4", { fill: null});691            this.layerAttr("seg_b2", { fill: "#C21B7A"});692            this.layerAttr("seg_b5", { fill: "#C21B7A"});693            this.layerAttr("seg_b6", { fill: "#C21B7A"});694         }695         else if (this.getPort("Port_b1").getValue() && this.getPort("Port_b2").getValue() && !this.getPort("Port_b4").getValue() && !this.getPort("Port_b8").getValue()) {696            this.layerAttr("seg_b0", { fill: "#C21B7A"});697            this.layerAttr("seg_b1", { fill: "#C21B7A"});698            this.layerAttr("seg_b3", { fill: "#C21B7A"});699            this.layerAttr("seg_b4", { fill: null});700            this.layerAttr("seg_b2", { fill: "#C21B7A"});701            this.layerAttr("seg_b5", { fill: null});702            this.layerAttr("seg_b6", { fill: "#C21B7A"});703         }704         else if (!this.getPort("Port_b1").getValue() && this.getPort("Port_b2").getValue() && !this.getPort("Port_b4").getValue() && !this.getPort("Port_b8").getValue()) {705            this.layerAttr("seg_b0", { fill: "#C21B7A"});706            this.layerAttr("seg_b1", { fill: "#C21B7A"});707            this.layerAttr("seg_b3", { fill: "#C21B7A"});708            this.layerAttr("seg_b4", { fill: "#C21B7A"});709            this.layerAttr("seg_b2", { fill: null});710            this.layerAttr("seg_b5", { fill: null});711            this.layerAttr("seg_b6", { fill: "#C21B7A"});712         }713         else if (this.getPort("Port_b1").getValue() && !this.getPort("Port_b2").getValue() && !this.getPort("Port_b4").getValue() && !this.getPort("Port_b8").getValue()) {714            this.layerAttr("seg_b0", { fill: null});715            this.layerAttr("seg_b1", { fill: "#C21B7A"});716            this.layerAttr("seg_b3", { fill: null});717            this.layerAttr("seg_b4", { fill: null});718            this.layerAttr("seg_b2", { fill: "#C21B7A"});719            this.layerAttr("seg_b5", { fill: null});720            this.layerAttr("seg_b6", { fill: null});721         }722         else if (!this.getPort("Port_b1").getValue() && !this.getPort("Port_b2").getValue() && !this.getPort("Port_b4").getValue() && !this.getPort("Port_b8").getValue()) {723            this.layerAttr("seg_b0", { fill: "#C21B7A"});724            this.layerAttr("seg_b1", { fill: "#C21B7A"});725            this.layerAttr("seg_b3", { fill: "#C21B7A"});726            this.layerAttr("seg_b4", { fill: "#C21B7A"});727            this.layerAttr("seg_b2", { fill: "#C21B7A"});728            this.layerAttr("seg_b5", { fill: "#C21B7A"});729            this.layerAttr("seg_b6", { fill: null});730         }731         // For c732         if (this.getPort("Port_c1").getValue() && this.getPort("Port_c2").getValue() && this.getPort("Port_c4").getValue() && this.getPort("Port_c8").getValue()) {733            this.layerAttr("seg_c0", { fill: "#C21B7A"});734            this.layerAttr("seg_c1", { fill: null});735            this.layerAttr("seg_c2", { fill: null});736            this.layerAttr("seg_c3", { fill: null});737            this.layerAttr("seg_c4", { fill: "#C21B7A"});738            this.layerAttr("seg_c5", { fill: "#C21B7A"});739            this.layerAttr("seg_c6", { fill: "#C21B7A"});740         }741         else if (!this.getPort("Port_c1").getValue() && this.getPort("Port_c2").getValue() && this.getPort("Port_c4").getValue() && this.getPort("Port_c8").getValue()) {742            this.layerAttr("seg_c0", { fill: "#C21B7A"});743            this.layerAttr("seg_c1", { fill: null});744            this.layerAttr("seg_c2", { fill: null});745            this.layerAttr("seg_c4", { fill: "#C21B7A"});746            this.layerAttr("seg_c5", { fill: "#C21B7A"});747            this.layerAttr("seg_c6", { fill: "#C21B7A"});748            this.layerAttr("seg_c3", { fill: "#C21B7A"});749         }750         else if (this.getPort("Port_c1").getValue() && !this.getPort("Port_c2").getValue() && this.getPort("Port_c4").getValue() && this.getPort("Port_c8").getValue()) {751            this.layerAttr("seg_c1", { fill: "#C21B7A"});752            this.layerAttr("seg_c2", { fill: "#C21B7A"});753            this.layerAttr("seg_c4", { fill: "#C21B7A"});754            this.layerAttr("seg_c6", { fill: "#C21B7A"});755            this.layerAttr("seg_c3", { fill: "#C21B7A"});756            this.layerAttr("seg_c0", { fill: null});757            this.layerAttr("seg_c5", { fill: null});758         }759         else if (!this.getPort("Port_c1").getValue() && !this.getPort("Port_c2").getValue() && this.getPort("Port_c4").getValue() && this.getPort("Port_c8").getValue()) {760            this.layerAttr("seg_c0", { fill: "#C21B7A"});761            this.layerAttr("seg_c3", { fill: "#C21B7A"});762            this.layerAttr("seg_c4", { fill: "#C21B7A"});763            this.layerAttr("seg_c5", { fill: "#C21B7A"});764            this.layerAttr("seg_c1", { fill: null});765            this.layerAttr("seg_c2", { fill: null});766            this.layerAttr("seg_c6", { fill: null});767         }768         else if (this.getPort("Port_c1").getValue() && this.getPort("Port_c2").getValue() && !this.getPort("Port_c4").getValue() && this.getPort("Port_c8").getValue()) {769            this.layerAttr("seg_c2", { fill: "#C21B7A"});770            this.layerAttr("seg_c3", { fill: "#C21B7A"});771            this.layerAttr("seg_c4", { fill: "#C21B7A"});772            this.layerAttr("seg_c5", { fill: "#C21B7A"});773            this.layerAttr("seg_c6", { fill: "#C21B7A"});774            this.layerAttr("seg_c1", { fill: null});775            this.layerAttr("seg_c0", { fill: null});776         }777         else if (!this.getPort("Port_c1").getValue() && this.getPort("Port_c2").getValue() && !this.getPort("Port_c4").getValue() && this.getPort("Port_c8").getValue()) {778            this.layerAttr("seg_c0", { fill: "#C21B7A"});779            this.layerAttr("seg_c1", { fill: "#C21B7A"});780            this.layerAttr("seg_c2", { fill: "#C21B7A"});781            this.layerAttr("seg_c4", { fill: "#C21B7A"});782            this.layerAttr("seg_c5", { fill: "#C21B7A"});783            this.layerAttr("seg_c6", { fill: "#C21B7A"});784            this.layerAttr("seg_c3", { fill: null});785         }786         else if (this.getPort("Port_c1").getValue() && !this.getPort("Port_c2").getValue() && !this.getPort("Port_c4").getValue() && this.getPort("Port_c8").getValue()) {787            this.layerAttr("seg_c0", { fill: "#C21B7A"});788            this.layerAttr("seg_c1", { fill: "#C21B7A"});789            this.layerAttr("seg_c2", { fill: "#C21B7A"});790            this.layerAttr("seg_c5", { fill: "#C21B7A"});791            this.layerAttr("seg_c6", { fill: "#C21B7A"});792            this.layerAttr("seg_c3", { fill: null});793            this.layerAttr("seg_c4", { fill: null});794         }795         else if (!this.getPort("Port_c1").getValue() && !this.getPort("Port_c2").getValue() && !this.getPort("Port_c4").getValue() && this.getPort("Port_c8").getValue()) {796            this.layerAttr("seg_c0", { fill: "#C21B7A"});797            this.layerAttr("seg_c1", { fill: "#C21B7A"});798            this.layerAttr("seg_c3", { fill: "#C21B7A"});799            this.layerAttr("seg_c4", { fill: "#C21B7A"});800            this.layerAttr("seg_c2", { fill: "#C21B7A"});801            this.layerAttr("seg_c5", { fill: "#C21B7A"});802            this.layerAttr("seg_c6", { fill: "#C21B7A"});803         }804         else if (this.getPort("Port_c1").getValue() && this.getPort("Port_c2").getValue() && this.getPort("Port_c4").getValue() && !this.getPort("Port_c8").getValue()) {805            this.layerAttr("seg_c0", { fill: "#C21B7A"});806            this.layerAttr("seg_c1", { fill: "#C21B7A"});807            this.layerAttr("seg_c3", { fill: null});808            this.layerAttr("seg_c4", { fill: null});809            this.layerAttr("seg_c2", { fill: "#C21B7A"});810            this.layerAttr("seg_c5", { fill: null});811            this.layerAttr("seg_c6", { fill: null});812         }813         else if (!this.getPort("Port_c1").getValue() && this.getPort("Port_c2").getValue() && this.getPort("Port_c4").getValue() && !this.getPort("Port_c8").getValue()) {814            this.layerAttr("seg_c0", { fill: "#C21B7A"});815            this.layerAttr("seg_c1", { fill: null});816            this.layerAttr("seg_c3", { fill: "#C21B7A"});817            this.layerAttr("seg_c4", { fill: "#C21B7A"});818            this.layerAttr("seg_c2", { fill: "#C21B7A"});819            this.layerAttr("seg_c5", { fill: "#C21B7A"});820            this.layerAttr("seg_c6", { fill: "#C21B7A"});821         }822         else if (this.getPort("Port_c1").getValue() && !this.getPort("Port_c2").getValue() && this.getPort("Port_c4").getValue() && !this.getPort("Port_c8").getValue()) {823            this.layerAttr("seg_c0", { fill: "#C21B7A"});824            this.layerAttr("seg_c1", { fill: null});825            this.layerAttr("seg_c3", { fill: "#C21B7A"});826            this.layerAttr("seg_c4", { fill: null});827            this.layerAttr("seg_c2", { fill: "#C21B7A"});828            this.layerAttr("seg_c5", { fill: "#C21B7A"});829            this.layerAttr("seg_c6", { fill: "#C21B7A"});830         }831         else if (!this.getPort("Port_c1").getValue() && !this.getPort("Port_c2").getValue() && this.getPort("Port_c4").getValue() && !this.getPort("Port_c8").getValue()) {832            this.layerAttr("seg_c0", { fill: null});833            this.layerAttr("seg_c1", { fill: "#C21B7A"});834            this.layerAttr("seg_c3", { fill: null});835            this.layerAttr("seg_c4", { fill: null});836            this.layerAttr("seg_c2", { fill: "#C21B7A"});837            this.layerAttr("seg_c5", { fill: "#C21B7A"});838            this.layerAttr("seg_c6", { fill: "#C21B7A"});839         }840         else if (this.getPort("Port_c1").getValue() && this.getPort("Port_c2").getValue() && !this.getPort("Port_c4").getValue() && !this.getPort("Port_c8").getValue()) {841            this.layerAttr("seg_c0", { fill: "#C21B7A"});842            this.layerAttr("seg_c1", { fill: "#C21B7A"});843            this.layerAttr("seg_c3", { fill: "#C21B7A"});844            this.layerAttr("seg_c4", { fill: null});845            this.layerAttr("seg_c2", { fill: "#C21B7A"});846            this.layerAttr("seg_c5", { fill: null});847            this.layerAttr("seg_c6", { fill: "#C21B7A"});848         }849         else if (!this.getPort("Port_c1").getValue() && this.getPort("Port_c2").getValue() && !this.getPort("Port_c4").getValue() && !this.getPort("Port_c8").getValue()) {850            this.layerAttr("seg_c0", { fill: "#C21B7A"});851            this.layerAttr("seg_c1", { fill: "#C21B7A"});852            this.layerAttr("seg_c3", { fill: "#C21B7A"});853            this.layerAttr("seg_c4", { fill: "#C21B7A"});854            this.layerAttr("seg_c2", { fill: null});855            this.layerAttr("seg_c5", { fill: null});856            this.layerAttr("seg_c6", { fill: "#C21B7A"});857         }858         else if (this.getPort("Port_c1").getValue() && !this.getPort("Port_c2").getValue() && !this.getPort("Port_c4").getValue() && !this.getPort("Port_c8").getValue()) {859            this.layerAttr("seg_c0", { fill: null});860            this.layerAttr("seg_c1", { fill: "#C21B7A"});861            this.layerAttr("seg_c3", { fill: null});862            this.layerAttr("seg_c4", { fill: null});863            this.layerAttr("seg_c2", { fill: "#C21B7A"});864            this.layerAttr("seg_c5", { fill: null});865            this.layerAttr("seg_c6", { fill: null});866         }867         else if (!this.getPort("Port_c1").getValue() && !this.getPort("Port_c2").getValue() && !this.getPort("Port_c4").getValue() && !this.getPort("Port_c8").getValue()) {868            this.layerAttr("seg_c0", { fill: "#C21B7A"});869            this.layerAttr("seg_c1", { fill: "#C21B7A"});870            this.layerAttr("seg_c3", { fill: "#C21B7A"});871            this.layerAttr("seg_c4", { fill: "#C21B7A"});872            this.layerAttr("seg_c2", { fill: "#C21B7A"});873            this.layerAttr("seg_c5", { fill: "#C21B7A"});874            this.layerAttr("seg_c6", { fill: null});875         }876     },877 878 879     /**880      *  Called if the simulation mode is starting881      *  @required...tests.js
Source:tests.js  
...28      component.getProperty('Table').data = TABLE;29      component.getProperty('Constraints').data = {30        name: { equalTo: 'Chess' }31      };32      component.getPort('Success').onEmit(function(){33        done();34      });35      component.getPort('Error').onEmit(function(){36        done(component.getPort('Error').getProperty('Data').data);37      });38      new Graph("graph-1").addComponent(component);39      component.execute();40    } catch(e) { done(e); }41  })42  it('Save Component should execute without errors', function (done) {43    try {44      const Component = require('./src/save');45      const component = new Component();46      component.getProperty('APP_ID').data = APP_ID;47      component.getProperty('CLIENT_KEY').data = CLIENT_KEY;48      component.getProperty('Table').data = TABLE;49      component.getProperty('Documents').data = [{ name: 'Jonah Dillingham' }];50      component.getPort('Success').onEmit(function(){51        done();52      });53      component.getPort('Error').onEmit(function(){54        done(component.getPort('Error').getProperty('Data').data);55      });56      new Graph("graph-1").addComponent(component);57      component.execute();58    } catch(e) { done(e); }59  })60  it('Delete Component should execute without errors', function (done) {61    try {62      const Component = require('./src/delete');63      const component = new Component();64      component.getProperty('APP_ID').data = APP_ID;65      component.getProperty('CLIENT_KEY').data = CLIENT_KEY;66      component.getProperty('Table').data = TABLE;67      component.getProperty('Documents').data = ['TbzuxauD'];68      component.getPort('Success').onEmit(function(){69        done();70      });71      component.getPort('Error').onEmit(function(){72        done(component.getPort('Error').getProperty('Data').data);73      });74      new Graph("graph-1").addComponent(component);75      component.execute();76    } catch(e) { done(e); }77  })78  it('Component should have all required ports', function (done) {79    try {80      let component = new QueryComponent();81      component.getPort('Success');82      component.getPort('Error');83      component = new DeleteComponent();84      component.getPort('Success');85      component.getPort('Error');86      component = new SaveComponent();87      component.getPort('Success');88      component.getPort('Error');89      done();90    } catch(e) { done(new Error('Component missing required ports')); }91  })92})93if (!(appId && clientKey && table)) return94function query(constraints=null) {95  const d = Q.defer();96  try {97    const component = new QueryComponent();98    99    component.getProperty('APP_ID').data = appId;100    component.getProperty('CLIENT_KEY').data = clientKey;101    component.getProperty('Table').data = table;102    if (constraints)103      component.getProperty('Constraints').data = constraints;104    component.getPort('Success').onEmit(function() {105      d.resolve(component.getPort('Success').getProperty('Result').data);106    });107    component.getPort('Error').onEmit(function() {108      d.reject(new Error('Emit returned error'));109    });110    component.execute();111  } catch(e) { d.reject(e); }112  return d.promise;113}114function save(name) {115  const d = Q.defer();116  try {117    const component = new SaveComponent();118    119    component.getProperty('APP_ID').data = appId;120    component.getProperty('CLIENT_KEY').data = clientKey;121    component.getProperty('Table').data = table;122    component.getProperty('Documents').data = [{ 123        name: name124    }];125    component.getPort('Success').onEmit(function() {126      d.resolve(/* component.getPort('Success').getProperty('Result').data */);127    });128    component.getPort('Error').onEmit(function() {129      d.reject(new Error('Emit returned error'));130    });131    component.execute();132    133  } catch(e) { d.reject(e); }134  return d.promise;135}136function remove(id) {137  const d = Q.defer();138  try {139    const component = new DeleteComponent();140    141    component.getProperty('APP_ID').data = appId;142    component.getProperty('CLIENT_KEY').data = clientKey;143    component.getProperty('Table').data = table;144    component.getProperty('Documents').data = [id];145    component.getPort('Success').onEmit(function() {146      d.resolve(/* component.getPort('Success').getProperty('Result').data */);147    });148    component.getPort('Error').onEmit(function() {149      d.reject(new Error('Emit returned error'));150    });151    component.execute();152    153  } catch(e) { d.reject(e); }154  return d.promise;155}156describe(`API Tests157`, function () {158  it('QueryComponent should return documents', function (done) {159    query().then(160      function(res) { if (res instanceof Array) done(); },161      function(e) { done(e); }162    );...TextNodeWidget.js
Source:TextNodeWidget.js  
...19          <FlowPort20            engine={engine}21            node={node}22            name="flowIn"23            portStatus={portStatus[node.getPort('flowIn').options.id]}24          />25          <FlowPort26            engine={engine}27            node={node}28            name="flowOut"29            portStatus={portStatus[node.getPort('flowOut').options.id]}30          />31        </div>32        <div className="TextNode__contentPorts">33          <div className="TextNode__contentPorts__left">34            {/*          <TextPort35            port={node.getPort('incomingMsg')}36            node={node}37            engine={engine}38            name="incomingMsg"39            align="left"40            color="#7FFF6A"41            label="СообÑение"42            portStatus={portStatus[node.getPort('incomingMsg').options.id]}43          /> */}44            <TextPort45              port={node.getPort('comparisonText')}46              node={node}47              engine={engine}48              name="comparisonText"49              align="left"50              color="#EDEDED"51              label="ТекÑÑ Ð´Ð»Ñ ÑÑавнениÑ"52              portStatus={portStatus[node.getPort('comparisonText').options.id]}53            />54            <TextPort55              port={node.getPort('button')}56              node={node}57              engine={engine}58              name="button"59              align="left"60              color="#EDEDED"61              label="Ðнопки"62              portStatus={portStatus[node.getPort('button').options.id]}63            />64          </div>65          {/*        <div className="TextNode__contentPorts__right">66          <TextPort67            port={node.getPort('outgoingMsg')}68            node={node}69            engine={engine}70            name="outgoingMsg"71            align="right"72            color="#7FFF6A"73            label="СообÑение"74            portStatus={portStatus[node.getPort('outgoingMsg').options.id]}75          />76        </div> */}77        </div>78      </div>79    );80  }, [node.isSelected()]);81  return (82    <div className={classNames('TextNode', { 'TextNode--selected': node.isSelected() })}>83      <div className="TextNode__header">84        <div className="TextNode__type" />85        <div className="TextNode__title">{node.title}</div>86      </div>87      <div className="TextNode__flowPorts">88        <FlowPort89          engine={engine}90          node={node}91          name="flowIn"92          portStatus={portStatus[node.getPort('flowIn').options.id]}93        />94        <FlowPort95          engine={engine}96          node={node}97          name="flowOut"98          portStatus={portStatus[node.getPort('flowOut').options.id]}99        />100      </div>101      <div className="TextNode__contentPorts">102        <div className="TextNode__contentPorts__left">103          {/*          <TextPort104            port={node.getPort('incomingMsg')}105            node={node}106            engine={engine}107            name="incomingMsg"108            align="left"109            color="#7FFF6A"110            label="СообÑение"111            portStatus={portStatus[node.getPort('incomingMsg').options.id]}112          /> */}113          <TextPort114            port={node.getPort('comparisonText')}115            node={node}116            engine={engine}117            name="comparisonText"118            align="left"119            color="#EDEDED"120            label="ТекÑÑ Ð´Ð»Ñ ÑÑавнениÑ"121            portStatus={portStatus[node.getPort('comparisonText').options.id]}122          />123          <TextPort124            port={node.getPort('button')}125            node={node}126            engine={engine}127            name="button"128            align="left"129            color="#EDEDED"130            label="Ðнопки"131            portStatus={portStatus[node.getPort('button').options.id]}132          />133        </div>134        {/*        <div className="TextNode__contentPorts__right">135          <TextPort136            port={node.getPort('outgoingMsg')}137            node={node}138            engine={engine}139            name="outgoingMsg"140            align="right"141            color="#7FFF6A"142            label="СообÑение"143            portStatus={portStatus[node.getPort('outgoingMsg').options.id]}144          />145        </div> */}146      </div>147    </div>148  );149};150TextNodeWidget.propTypes = {151};152TextNodeWidget.defaultProps = {153  size: 50154};...delTradeService.js
Source:delTradeService.js  
1const TradeModel = require('../models/tradesModel');2const searchSecurity = require('../services/searchSecurityService');3const PortfolioModel = require('../models/portfolioModel');4const _ = require('lodash');5// service method to delete a trade6const deleteTrade = async function (portId, tradeId) {7    //get the portfolio8    var getPort = await PortfolioModel.findById( portId );9    console.log(tradeId)10    if (getPort) {11        //fetch the trade to be deleted12        var getTrade = await TradeModel.findOne({ _id: tradeId  })13        if (!getTrade) {14            return Promise.reject({ message: "Trade doesn't exist in TradesmModel" })15        }16        // search thr security in the portfolio17        var securityIndex = searchSecurity.searchSecurityNew(getPort, getTrade.securityId);18        if (getTrade.type == "BUY") {19            if (securityIndex != -1) {20                //portfolio needs to have a higher quantity as we need to subtract the requested quantity:21                if (getPort.portfolio[securityIndex].totalShares >= getTrade.quantity) {22                    23                    // update the avg price24                    getPort.portfolio[securityIndex].avgBuyPrice = ((getPort.portfolio[securityIndex].totalShares 25                        * getPort.portfolio[securityIndex].avgBuyPrice) -(getTrade.quantity* 100)) / (getPort.portfolio[securityIndex].totalShares - getTrade.quantity);26                    //subtract the requested quantity:27                    getPort.portfolio[securityIndex].totalShares =28                    getPort.portfolio[securityIndex].totalShares - getTrade.quantity;29                    //Now delete the trade:30                    var result = await TradeModel.deleteOne({31                        _id: getTrade._id32                    })33                   // Pull the requested trade34                    const temp= await PortfolioModel.findOneAndUpdate({"_id":getPort._id},{$pull:{trades:getTrade._id}})35                    console.log(temp,temp)36                         await getPort.save()37                    return result;38                }39                else {40                    return Promise.reject({ message: "Portfolio contains a lesser quantity of the security" })41                }42            }43            else {44                return Promise.reject({ message: "The requested security doesn't exist in the portfolio" })45            }46        }47        else if (getTrade.type == "SELL") {48         49            if (securityIndex != -1) {50                //add back the trade quantity sold by the trade previously51                getPort.portfolio[securityIndex].totalShares =52                getPort.portfolio[securityIndex].totalShares + getTrade.quantity;53                //Now delete the trade:54                var result = await TradeModel.deleteOne({55                    _id: getTrade._id56                })57            }58            else {59                //this security will not be present in the portfolio, so add it:60               61                const sample={62                    securityId: getTrade.securityId,63                    avgBuyPrice: 100,64                    totalShares: getTrade.quantity65                }66                67               await PortfolioModel.findOneAndUpdate({"_id":getPort._id},{$push:{portfolio:sample}})68            }69            //update the portfolio accordingly:70            const temp= await PortfolioModel.findOneAndUpdate({"_id":getPort._id},{$pull:{trades:getTrade._id}})71            await getPort.save()72            return result;73        }74    }75    else {76            return Promise.reject({ message: "unable to get portfolio data." })77    }78}...addTradeService.js
Source:addTradeService.js  
1const TradeModel = require('../models/tradesModel');2const searchSecurity = require('../services/searchSecurityService');3const PortfolioModel = require('../models/portfolioModel');4const _ = require('lodash');5// Service method to add a trade for a security in a portfolio6const addTrade= async function (portId, givenTrade) {7    var getPort = await PortfolioModel.findById(portId);8    if(!getPort)9        return Promise.reject({ message: "Portfolio not found"}) 10    const trades=new TradeModel({securityId: givenTrade.securityId,11            type: givenTrade.tradeType,12            quantity:givenTrade.tradeQuantity,13            price: givenTrade.tradeQuantity * 10014        });   15    var ticker = searchSecurity.searchSecurityNew(getPort,givenTrade.securityId); //check if the security for which the trade is placed exists in the portfolio16    console.log(ticker+"fsd");17         18        if (givenTrade.tradeType == "BUY") { //if the trade is a BUY trade19            20             if (ticker == -1)  {21                const sample={22                    "securityId": givenTrade.securityId,23                    "totalShares": givenTrade.tradeQuantity,24                    "avgBuyPrice": 10025                }26            try{27                //push the new trade in portofolio in respective user portId28               const temp= await PortfolioModel.findOneAndUpdate({"_id":getPort._id},{$push:{portfolio:sample}})29              30            }31            catch(err){32                return Promise.reject({ message: "Error in updating model"}) 33            }34            }35             else {36                 //calculate the average buy price37                 getPort.portfolio[ticker].avgBuyPrice = ((getPort.portfolio[ticker].totalShares * getPort.portfolio[ticker].avgBuyPrice) + 38                 (givenTrade.tradeQuantity* 100)) / (getPort.portfolio[ticker].totalShares + givenTrade.tradeQuantity);39                //update the security quantity in the portfolio:40                getPort.portfolio[ticker].totalShares = getPort.portfolio[ticker].totalShares + givenTrade.tradeQuantity;41              42         }43     44     45         }46         else{47             48            if (givenTrade.tradeType == "SELL") {49                if (ticker == -1)50                   return Promise.reject({ message: "The security  doesn't exist in the portfolio"});51            if (ticker != -1) {52                 //sell trade can be allowed only if the portfolio has greater quantity of shares than the no. of shares requested to be sold:53                if (getPort.portfolio[ticker].totalShares >= givenTrade.tradeQuantity) {54                    getPort.portfolio[ticker].totalShares = getPort.portfolio[ticker].totalShares - givenTrade.tradeQuantity;55                }56                else {57                    return Promise.reject( { message: "Not enough quantity to sell for "})}58            }59        }60    }    61     62    //update the portfolio accordingly:63    const tradeRes = await trades.save();64    getPort.trades.push([tradeRes._id ]);65    await getPort.save();66    return tradeRes;67};68module.exports = {69    addTrade..._index-test.js
Source:_index-test.js  
...32  describe('getPort', function() {33    it('default', function() {34      let result = debug({35      });36      expect(result.getPort()).to.equal(5859);37    });38    it('debug 1234', function() {39      let result = debug({40        'debug': 123441      });42      expect(result.getPort()).to.equal(1235);43    });44    it('debug true', function() {45      let result = debug({46        'debug': true47      });48      expect(result.getPort()).to.equal(5859);49    });50    it('debug-brk 32892', function() {51      let result = debug({52        'debug-brk': 3289253      });54      expect(result.getPort()).to.equal(32893);55    });56    it('debug-brk true', function() {57      let result = debug({58        'debug-brk': true59      });60      expect(result.getPort()).to.equal(5859);61    });62    it('inspect 9282', function() {63      let result = debug({64        'inspect': 928265      });66      expect(result.getPort()).to.equal(9283);67    });68    it('inspect true', function() {69      let result = debug({70        'inspect': true71      });72      expect(result.getPort()).to.equal(9230);73    });74  });75  describe('releasePort', function() {76    it('releases single port', function() {77      let result = debug({78      });79      let firstPort = result.getPort();80      result.releasePort(firstPort);81      let secondPort = result.getPort();82      expect(secondPort).to.equal(firstPort);83    });84    it('reclaims top port', function() {85      let result = debug({86      });87      result.getPort();88      let secondPort = result.getPort();89      result.releasePort(secondPort);90      let thirdPort = result.getPort();91      expect(thirdPort).to.equal(secondPort);92    });93    it('reclaims earlier port', function() {94      let result = debug({95      });96      let firstPort = result.getPort();97      result.getPort();98      result.releasePort(firstPort);99      let thirdPort = result.getPort();100      expect(thirdPort).to.equal(firstPort);101    });102  });...environment.test.js
Source:environment.test.js  
...34      delete process.env.PIVOTAL_TRACKER_API_KEY;35      expect(getPivotalTrackerApiKey()).to.eql(undefined);36    });37  });38  describe('.getPort()', () => {39    const {getPort} = environmentUtils;40    it('works as expected', () => {41      process.env.PORT = 12345;42      expect(getPort()).to.eql(12345);43      process.env.PORT = '54321';44      expect(getPort()).to.eql(54321);45      delete process.env.PORT;46      expect(getPort()).to.eql(3000);47    });48    it('throws an error if port is invalid', () => {49      process.env.PORT = 1;50      expect(() => getPort()).to.not.throw();51      process.env.PORT = 0;52      expect(() => getPort()).to.throw();53      process.env.PORT = -1;54      expect(() => getPort()).to.throw();55      process.env.PORT = 65535;56      expect(() => getPort()).to.not.throw();57      process.env.PORT = 65536;58      expect(() => getPort()).to.throw();59    });60  });...gulpfile.js
Source:gulpfile.js  
1var gulp = require('gulp');2var plugins = require( 'gulp-load-plugins' )();3var op = require('openport');4GLOBAL.params = {5    buildPath: 'build',6    sourcePath: 'source',7    port: 8080,8    livePort: 35729,9    defaultBrowser: 'chrome'10};11function getTask(task) {12    return require('./gulp-tasks/' + task)(gulp, plugins, params);13}14gulp.task('compress:images', getTask('images'));15gulp.task('compile:javascript', getTask('javascript'));16gulp.task('compile:sass', getTask('sass'));17gulp.task('compile:jade', getTask('jade'));18gulp.task('getLivePort', ['getPort'], getTask('getLivePort'));19gulp.task('getPort', getTask('getPort'));20gulp.task('watch',['getPort', 'getLivePort', 'init', 'connect'], getTask('watch'));21gulp.task('openBrowser', ['getPort', 'getLivePort', 'init', 'connect', 'watch'], getTask('openBrowser'));22gulp.task('connect',['getPort', 'getLivePort'], getTask('connect'));23gulp.task('init',['getPort', 'getLivePort'], function(){24    gulp.start('compile:sass');25    gulp.start('compile:jade');26    gulp.start('compile:javascript');27    gulp.start('compress:images');28});29gulp.task('run', function(){30  op.find({31          startingPort: params.port,32          endingPort: 900033      },34      function(err, port) {35          if (err) {36              console.log(err);37              return;38          }39          params.port = port;40          gulp.start('run:init')41      }42  );43});44gulp.task('run:init', [45    'getPort',46    'getLivePort',47    'init',48    'connect',49    'watch',50    'openBrowser'51]);52gulp.task('build', [53    'init'54]);55/*56  Display Help57*/...Using AI Code Generation
1const wdio = require('webdriverio');2const path = require('path');3const opts = {4  capabilities: {5    app: path.resolve(__dirname, 'TestApp.app.zip'),6  },7};8const client = wdio.remote(opts);9client.init().then(() => {10  client.setImplicitTimeout(5000);11    .getPort()12    .then((port) => {13      console.log('Port is ' + port);14    })15    .catch((err) => {16      console.log('Error occurred while getting port ' + err);17    });18});19getLogTypes()20const wdio = require('webdriverio');21const path = require('path');22const opts = {23  capabilities: {24    app: path.resolve(__dirname, 'TestApp.app.zip'),25  },26};27const client = wdio.remote(opts);28client.init().then(() => {29  client.setImplicitTimeout(5000);30    .getLogTypes()31    .then((logTypes) => {32      console.log('Log Types are ' + logTypes);33    })34    .catch((err) => {35      console.log('Error occurred while getting log types ' + err);36    });37});Using AI Code Generation
1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4const { getPort } = require('portfinder');5chai.use(chaiAsPromised);6const expect = chai.expect;7const driver = wd.promiseChainRemote('localhost', 4723);8const caps = {9};10describe('sample test', () => {11  before(async () => {12    await driver.init(caps);13  });14  it('should get port', async () => {15    const port = await getPort();16    console.log(port);17  });18  after(async () => {19    await driver.quit();20  });21});Using AI Code Generation
1const {getPort} = require('appium-xcuitest-driver');2const port = getPort();3console.log(port);4{5  "dependencies": {6  }7}Using AI Code Generation
1const wd = require('wd');2const { getPort } = require('wd/build/lib/utils');3const driver = wd.promiseChainRemote('localhost', getPort(4723));4driver.init({5}).then(() => {6    console.log('App launched');7});8const wd = require('wd');9const { getPort } = require('wd/build/lib/utils');10const driver = wd.promiseChainRemote('localhost', getPort(4723));11driver.init({12}).then(() => {13    console.log('App launched');14});15const wd = require('wd');16const { getPort } = require('wd/build/lib/utils');17const driver = wd.promiseChainRemote('localhost', getPort(4723));18driver.init({19}).then(() => {20    console.log('App launched');21});22const wd = require('wd');23const { getPort } = require('wd/build/lib/utils');24const driver = wd.promiseChainRemote('localhost', getPort(4723));25driver.init({Using AI Code Generation
1const wd = require('wd');2const { AppiumDriver, AppiumServer } = require('appium-xcuitest-driver');3async function main() {4    const appiumServer = new AppiumServer({5    });6    await appiumServer.start();7    const driver = new AppiumDriver({8        desiredCapabilities: {9        }10    });11    await driver.init();12    await driver.implicitWait(10000);13    let port = await driver.getPort();14    console.log(port);15    await driver.quit();16    await appiumServer.stop();17}18main();Using AI Code Generation
1var xcuitest = require('appium-xcuitest-driver');2var driver = new xcuitest();3driver.getPort();4driver.getDevice();5driver.getPlatformVersion();6var getPort = function() {7  return this.opts.port;8}9var getDevice = function() {10  return this.opts.deviceName;11}12var getPlatformVersion = function() {13  return this.opts.platformVersion;14}15module.exports = {16}17var wd = require('wd');18var XCUITestDriver = require('./test.js');19var desiredCaps = {20}21var driver = wd.promiseChainRemote('localhost', desiredCaps.port);22XCUITestDriver.attachToSession(driver, desiredCaps);23driver.init(desiredCaps).then(function() {24  console.log('Appium session created successfully');25  driver.getPort().then(function(port) {26    console.log('Appium server port is: ' + port);27  });28  driver.getDevice().then(function(device) {29    console.log('Device Name is: ' + device);30  });31  driver.getPlatformVersion().then(function(version) {32    console.log('Platform version is: ' + version);33  });34});Using AI Code Generation
1const { AppiumXCUITestDriver } = require('appium-xcuitest-driver');2const driver = new AppiumXCUITestDriver();3const port = driver.getPort();4const AppiumXCUITestDriver = require('appium-xcuitest-driver').AppiumXCUITestDriver;5const driver = new AppiumXCUITestDriver();6const port = driver.getPort();7const AppiumXCUITestDriver = require('appium-xcuitest-driver').default;8const driver = new AppiumXCUITestDriver();9const port = driver.getPort();10const { AppiumXCUITestDriver } = require('appium-xcuitest-driver');11const driver = new AppiumXCUITestDriver();12const port = driver.getPort();Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var driver = wd.promiseChainRemote();4var desiredCaps = {5};6driver.init(desiredCaps)7  .then(function () {8    return driver.getPort();9  })10  .then(function (port) {11    console.log("Port number: " + port);12    return driver.quit();13  })14  .catch(function (err) {15    console.log("Error: " + err);16  });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!!
