Best JavaScript code snippet using appium-android-driver
configurationManagement.spec.js
Source:configurationManagement.spec.js
...19 it('url: http://127.0.0.1:8811', async function(){20 await driver.url(_(`http://127.0.0.1:8811`));21 });22 it('waitBody: ', async function(){23 await driver.sleep(500).wait('body', 30000).html().then(function(code){24 isPageError(code).should.be.false;25 });26 });27 it('click: #username, 89, 41, 0', async function(){28 await driver.sleep(300).wait('#username', 30000)29 .sleep(300).mouseMove(89, 41).click(0);30 });31 it('sendKeys: nacos', async function(){32 await driver.sendKeys('nacos');33 });34 it('click: #password, 53, 34, 0', async function(){35 await driver.sleep(300).wait('#password', 30000)36 .sleep(300).mouseMove(53, 34).click(0);37 });38 it('sendKeys: nacos', async function(){39 await driver.sendKeys('nacos');40 });41 it('click: æ交 ( //button[text()="æ交"], 321, 30, 0 )', async function(){42 await driver.sleep(300).wait('//button[text()="æ交"]', 30000)43 .sleep(300).mouseMove(321, 30).click(0);44 });45 it('click: div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"], 178, 9, 0', async function(){46 await driver.sleep(300).wait('div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"]', 30000)47 .sleep(300).mouseMove(178, 9).click(0);48 });49 it('sendKeys: test_test', async function(){50 await driver.sendKeys('test_test');51 });52 it('click: æ¥è¯¢ ( //button[text()="æ¥è¯¢"], 3, 9, 0 )', async function(){53 await driver.sleep(300).wait('//button[text()="æ¥è¯¢"]', 30000)54 .sleep(300).mouseMove(3, 9).click(0);55 });56 it('click: #viewFramework-product-body i.next-icon-add, 15, 27, 0', async function(){57 await driver.sleep(300).wait('#viewFramework-product-body i.next-icon-add', 30000)58 .sleep(300).mouseMove(15, 27).click(0);59 });60 it('click: Data ID: ( #dataId, 154, 20, 0 )', async function(){61 await driver.sleep(300).wait('#dataId', 30000)62 .sleep(300).mouseMove(154, 20).click(0);63 });64 it('sendKeys: test_test', async function(){65 await driver.sendKeys('test_test');66 });67 it('dblClick: Group: ( #group, 89, 11, 0 )', async function(){68 await driver.sleep(300).wait('#group', 30000)69 .sleep(300).mouseMove(89, 11).click(0).click(0);70 });71 it('click: #viewFramework-product-body i.next-icon-delete-filling, 11, 7, 0', async function(){72 await driver.sleep(300).wait('#viewFramework-product-body i.next-icon-delete-filling', 30000)73 .sleep(300).mouseMove(11, 7).click(0);74 });75 it('sendKeys: test', async function(){76 await driver.sendKeys('test');77 });78 it('click: æ´å¤é«çº§é项 ( //a[text()="æ´å¤é«çº§é项"], 61, 3, 0 )', async function(){79 await driver.sleep(300).wait('//a[text()="æ´å¤é«çº§é项"]', 30000)80 .sleep(300).mouseMove(61, 3).click(0);81 });82 it('click: span.next-select-trigger-search > input[role="combobox"]:nth-child(1), 66, 8, 0', async function(){83 await driver.sleep(300).wait('span.next-select-trigger-search > input[role="combobox"]:nth-child(1)', 30000)84 .sleep(300).mouseMove(66, 8).click(0);85 });86 it('click: span.next-select-trigger-search > input[role="combobox"]:nth-child(1), 71, 16, 0', async function(){87 await driver.sleep(300).wait('span.next-select-trigger-search > input[role="combobox"]:nth-child(1)', 30000)88 .sleep(300).mouseMove(71, 16).click(0);89 });90 it('click: å½å±åºç¨: ( #appName, 50, 19, 0 )', async function(){91 await driver.sleep(300).wait('#appName', 30000)92 .sleep(300).mouseMove(50, 19).click(0);93 });94 it('click: æ¶èµ· ( //a[text()="æ¶èµ·"], 16, 5, 0 )', async function(){95 await driver.sleep(300).wait('//a[text()="æ¶èµ·"]', 30000)96 .sleep(300).mouseMove(16, 5).click(0);97 });98 it('click: #desc, 77, 40, 0', async function(){99 await driver.sleep(300).wait('#desc', 30000)100 .sleep(300).mouseMove(77, 40).click(0);101 });102 it('sendKeys: test', async function(){103 await driver.sendKeys('test');104 });105 it('scrollElementTo: #viewFramework-product-body, 0, 49', async function(){106 await driver.sleep(300).wait('#viewFramework-product-body', 30000)107 .sleep(300).scrollElementTo(0, 49);108 });109 it('click: #container div.view-line, 60, 15, 0', async function(){110 await driver.sleep(300).wait('#container div.view-line', 30000)111 .sleep(300).mouseMove(60, 15).click(0);112 });113 it('sendKeys: test', async function(){114 await driver.sendKeys('test');115 });116 it('scrollElementTo: #viewFramework-product-body, 0, 155', async function(){117 await driver.sleep(300).wait('#viewFramework-product-body', 30000)118 .sleep(300).scrollElementTo(0, 155);119 });120 it('click: åå¸ ( //button[text()="åå¸"], 39, 9, 0 )', async function(){121 await driver.sleep(300).wait('//button[text()="åå¸"]', 30000)122 .sleep(300).mouseMove(39, 9).click(0);123 });124 it('à click: ç¡®å® ( //button[text()="ç¡®å®"], 13, 9, 0 )', async function(){125 await driver.sleep(300).wait('//button[text()="ç¡®å®"]', 30000)126 .sleep(300).mouseMove(13, 9).click(0);127 });128 it('click: è¿å ( //button[text()="è¿å"], 39, 18, 0 )', async function(){129 await driver.sleep(300).wait('//button[text()="è¿å"]', 30000)130 .sleep(300).mouseMove(39, 18).click(0);131 });132 it('scrollElementTo: #viewFramework-product-body, 0, 0', async function(){133 await driver.sleep(300).wait('#viewFramework-product-body', 30000)134 .sleep(300).scrollElementTo(0, 0);135 });136 it('click: 详æ
( //a[text()="详æ
"], 12, 7, 0 )', async function(){137 await driver.sleep(300).wait('//a[text()="详æ
"]', 30000)138 .sleep(300).mouseMove(12, 7).click(0);139 });140 it('scrollElementTo: #viewFramework-product-body, 0, 22', async function(){141 await driver.sleep(300).wait('#viewFramework-product-body', 30000)142 .sleep(300).scrollElementTo(0, 22);143 });144 it('click: test ( #content, 225, 35, 0 )', async function(){145 await driver.sleep(300).wait('#content', 30000)146 .sleep(300).mouseMove(225, 35).click(0);147 });148 it('click: #backarrow, 13, 10, 0', async function(){149 await driver.sleep(300).wait('#backarrow', 30000)150 .sleep(300).mouseMove(13, 10).click(0);151 });152 it('scrollElementTo: #viewFramework-product-body, 0, 0', async function(){153 await driver.sleep(300).wait('#viewFramework-product-body', 30000)154 .sleep(300).scrollElementTo(0, 0);155 });156 it('click: 示ä¾ä»£ç ( //a[text()="示ä¾ä»£ç "], 29, 6, 0 )', async function(){157 await driver.sleep(300).wait('//a[text()="示ä¾ä»£ç "]', 30000)158 .sleep(300).mouseMove(29, 6).click(0);159 });160 it('click: Spring Boot ( li[role="tab"]:nth-child(2) > div.next-tabs-tab-inner, 63, 22, 0 )', async function(){161 await driver.sleep(300).wait('li[role="tab"]:nth-child(2) > div.next-tabs-tab-inner', 30000)162 .sleep(300).mouseMove(63, 22).click(0);163 });164 it('click: i.next-icon-close, 9, 10, 0', async function(){165 await driver.sleep(300).wait('i.next-icon-close', 30000)166 .sleep(300).mouseMove(9, 10).click(0);167 });168 it('click: ç¼è¾ ( //a[text()="ç¼è¾"], 14, 6, 0 )', async function(){169 await driver.sleep(300).wait('//a[text()="ç¼è¾"]', 30000)170 .sleep(300).mouseMove(14, 6).click(0);171 });172 it('scrollElementTo: #viewFramework-product-body, 0, 134', async function(){173 await driver.sleep(300).wait('#viewFramework-product-body', 30000)174 .sleep(300).scrollElementTo(0, 134);175 });176 it('click: label:nth-child(2) > span.next-radio > input[type="radio"][role="radio"].next-radio-input, 7, 1, 0', async function(){177 await driver.sleep(300).wait('label:nth-child(2) > span.next-radio > input[type="radio"][role="radio"].next-radio-input', 30000)178 .sleep(300).mouseMove(7, 1).click(0);179 });180 it('click: label:nth-child(1) > span.next-radio > input[type="radio"][role="radio"].next-radio-input, 8, 8, 0', async function(){181 await driver.sleep(300).wait('label:nth-child(1) > span.next-radio > input[type="radio"][role="radio"].next-radio-input', 30000)182 .sleep(300).mouseMove(8, 8).click(0);183 });184 it('click: test ( #container div.view-line, 47, 11, 0 )', async function(){185 await driver.sleep(300).wait('#container div.view-line', 30000)186 .sleep(300).mouseMove(47, 11).click(0);187 });188 it('sendKeys: _test', async function(){189 await driver.sendKeys('_test');190 });191 it('click: test ( #desc, 76, 25, 0 )', async function(){192 await driver.sleep(300).wait('#desc', 30000)193 .sleep(300).mouseMove(76, 25).click(0);194 });195 it('sendKeys: _test', async function(){196 await driver.sendKeys('_test');197 });198 it('click: åå¸ ( //button[text()="åå¸"], 41, 15, 0 )', async function(){199 await driver.sleep(300).wait('//button[text()="åå¸"]', 30000)200 .sleep(300).mouseMove(41, 15).click(0);201 });202 it('click: 确认åå¸ ( //button[text()="确认åå¸"], 61, 16, 0 )', async function(){203 await driver.sleep(300).wait('//button[text()="确认åå¸"]', 30000)204 .sleep(300).mouseMove(61, 16).click(0);205 });206 it('click: ç¡®å® ( //button[text()="ç¡®å®"], 31, 15, 0 )', async function(){207 await driver.sleep(300).wait('//button[text()="ç¡®å®"]', 30000)208 .sleep(300).mouseMove(31, 15).click(0);209 });210 it('click: è¿å ( //button[text()="è¿å"], 25, 6, 0 )', async function(){211 await driver.sleep(300).wait('//button[text()="è¿å"]', 30000)212 .sleep(300).mouseMove(25, 6).click(0);213 });214 it('scrollElementTo: #viewFramework-product-body, 0, 0', async function(){215 await driver.sleep(300).wait('#viewFramework-product-body', 30000)216 .sleep(300).scrollElementTo(0, 0);217 });218 it('click: æ´å¤ ( #viewFramework-product-body span:nth-child(9), 19, 12, 0 )', async function(){219 await driver.sleep(300).wait('#viewFramework-product-body span:nth-child(9)', 30000)220 .sleep(300).mouseMove(19, 12).click(0);221 });222 it('click: åå²çæ¬ ( //span[text()="åå²çæ¬"], 0, 3, 0 )', async function(){223 await driver.sleep(300).wait('//span[text()="åå²çæ¬"]', 30000)224 .sleep(300).mouseMove(0, 3).click(0);225 });226 it('click: é
ç½®å表 ( //div[text()="é
ç½®å表"], 120, 36, 0 )', async function(){227 await driver.sleep(300).wait('//div[text()="é
ç½®å表"]', 30000)228 .sleep(300).mouseMove(120, 36).click(0);229 });230 it('click: æ´å¤ ( #viewFramework-product-body tr.first > td[type="body"][role="gridcell"].last > div.next-table-cell-wrapper > div > span:nth-child(9), 10, 8, 0 )', async function(){231 await driver.sleep(300).wait('#viewFramework-product-body tr.first > td[type="body"][role="gridcell"].last > div.next-table-cell-wrapper > div > span:nth-child(9)', 30000)232 .sleep(300).mouseMove(10, 8).click(0);233 });234 it('click: div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"], 163, 21, 0', async function(){235 await driver.sleep(300).wait('div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"]', 30000)236 .sleep(300).mouseMove(163, 21).click(0);237 });238 it('click: span.next-input > input[role="combobox"], 31, 19, 0', async function(){239 await driver.sleep(300).wait('span.next-input > input[role="combobox"]', 30000)240 .sleep(300).mouseMove(31, 19).click(0);241 });242 it('sendKeys: test', async function(){243 await driver.sendKeys('test');244 });245 it('click: æ¥è¯¢ ( //button[text()="æ¥è¯¢"], 8, 25, 0 )', async function(){246 await driver.sleep(300).wait('//button[text()="æ¥è¯¢"]', 30000)247 .sleep(300).mouseMove(8, 25).click(0);248 });249 it('click: div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"], 91, 18, 0', async function(){250 await driver.sleep(300).wait('div:nth-child(1) > div.next-form-item-control > span.next-medium > input[type="text"]', 30000)251 .sleep(300).mouseMove(91, 18).click(0);252 });253 it('sendKeys: test_test', async function(){254 await driver.sendKeys('test_test');255 });256 it('click: æ¥è¯¢ ( //button[text()="æ¥è¯¢"], 17, 17, 0 )', async function(){257 await driver.sleep(300).wait('//button[text()="æ¥è¯¢"]', 30000)258 .sleep(300).mouseMove(17, 17).click(0);259 });260 it('click: å é¤ ( //a[text()="å é¤"], 7, 8, 0 )', async function(){261 await driver.sleep(300).wait('//a[text()="å é¤"]', 30000)262 .sleep(300).mouseMove(7, 8).click(0);263 });264 it('click: 确认 ( //button[text()="确认"], 21, 15, 0 )', async function(){265 await driver.sleep(300).wait('//button[text()="确认"]', 30000)266 .sleep(300).mouseMove(21, 15).click(0);267 });268 it('click: ç¡®å® ( //button[text()="ç¡®å®"], 25, 14, 0 )', async function(){269 await driver.sleep(300).wait('//button[text()="ç¡®å®"]', 30000)270 .sleep(300).mouseMove(25, 14).click(0);271 });272 function _(str){273 if(typeof str === 'string'){274 return str.replace(/\{\{(.+?)\}\}/g, function(all, key){275 return testVars[key] || '';276 });277 }278 else{279 return str;280 }281 }282};283if(module.parent && /mocha\.js/.test(module.parent.id)){284 runThisSpec();...
doTask_Mianfei.js
Source:doTask_Mianfei.js
...32 if (index > (MAXN_Tasks_Mianfei - 1)) {33 //第7个å¼å§è¦æ»å¨34 for (let i = 0; i < n; i++) {35 swipeToPoint(startx, starty, startx, starty - rollDist, 200 * 1);36 sleep(500);37 }38 buttonY = FirstPt_Tasks_Mianfei.y + Gap_Tasks_Mianfei * (MAXN_Tasks_Mianfei - 1);39 }40 //æ ¹æ®å
·ä½ä»»å¡å»å41 const ttl = table["title"];42 const btt = table["buttonText"];43 if ((ttl.substr(0, 5) === "éç²¾é好ç©" && btt === "å»éé") || (ttl.substr(0, 5) === "éç²¾éåå" && btt === "å»éé")) {44 //æ¶éï¼å¿«ï¼15s45 clickPoint(buttonX, buttonY);46 sleep(17000);47 while (true) {48 if (has(text('æµè§å®æï¼ç°å¨ä¸åç«å³å¾1ä¸è¥æï¼'))) {49 while (true) {50 if (has(text("æµè§ç²¾é好货").clz("android.view.View"))) {51 let node = text("æµè§ç²¾é好货").clz("android.view.View").getOneNodeInfo(3000);52 let sbls = node.parent().allChildren();53 sbls[0].child(0).clickCenter();54 sleep(3000);55 } else {56 break;57 }58 }59 break;60 }61 sleep(1000);62 }63 } else if (((ttl.indexOf("çè§é¢") > -1) && btt === "å»æµè§")) {64 //è¿åº¦æ¡ï¼å è½½ææ
¢ï¼30s65 clickPoint(buttonX, buttonY);66 sleep(35000);67 while (true) {68 if (has(text('ä»»å¡å·²ç»å
¨é¨å®æå¦').clz('android.view.View'))) {69 click(id("com.taobao.taobao:id/tbvideo_back").clz("android.widget.ImageView"));70 sleep(4000);71 break;72 } else if (!has(text("æ»å¨æµè§å¾è¥æ").clz("android.view.View"))) {73 //å¡äºï¼æ²¡è¿åº¦æ¡74 while (true) {75 if (has(id("com.taobao.taobao:id/tbvideo_back").clz("android.widget.ImageView"))) {76 click(id("com.taobao.taobao:id/tbvideo_back").clz("android.widget.ImageView"));77 } else {78 break;79 }80 sleep(4000);81 }82 break;83 }84 sleep(2000);85 }86 } else if (((ttl.indexOf("ç´æ") > -1) && btt === "å»æµè§") || (ttl.match("^è§ç.+") && btt === "å»æµè§")) {87 //è¿åº¦æ¡ï¼å è½½æ
¢ï¼15s88 clickPoint(buttonX, buttonY);89 sleep(25000);90 while (true) {91 if (has(text('ä»»å¡å·²ç»å
¨é¨å®æå¦').clz('android.view.View'))) {92 while (true) {93 if (has(id("com.taobao.taobao:id/taolive_close_new_layout").clz("android.widget.LinearLayout"))) {94 let node = id("com.taobao.taobao:id/taolive_close_new_layout").clz("android.widget.LinearLayout").getOneNodeInfo(3000);95 node.child(2).clickCenter();96 } else {97 break;98 }99 sleep(4000);100 }101 break;102 } else if (!has(text("æ»å¨æµè§å¾è¥æ").clz("android.view.View"))) {103 //å¡äºï¼æ²¡è¿åº¦æ¡104 while (true) {105 if (has(id("com.taobao.taobao:id/taolive_close_new_layout").clz("android.widget.LinearLayout"))) {106 let node = id("com.taobao.taobao:id/taolive_close_new_layout").clz("android.widget.LinearLayout").getOneNodeInfo(3000);107 node.child(2).clickCenter();108 } else {109 break;110 }111 sleep(4000);112 }113 break;114 }115 sleep(2000);116 }117 } else if ((ttl.match("^æµè§.+åº") && btt === "å»æµè§") || (ttl.substr(0, 3) === "éä¸é" && btt === "å»æµè§") || (ttl.substr(0, 7) === "éç½çº¢æ°æ½®åç" && btt === "å»æµè§") || (ttl.match("^é.+ä¼åº") && btt === "å»æµè§") || (ttl.match("^æµè§ä¼å.+") && btt === "å»æµè§")) {118 //è¿åº¦æ¡ï¼å è½½ä¸è¬ï¼15s119 clickPoint(buttonX, buttonY);120 sleep(20000);121 while (true) {122 if (has(text('ä»»å¡å·²ç»å
¨é¨å®æå¦').clz('android.view.View'))) {123 while (true) {124 if (has(text("è¿å").clz("android.widget.Button"))) {125 click(text("è¿å").clz("android.widget.Button"));126 } else {127 break;128 }129 sleep(3000);130 }131 break;132 } else if (!has(text("æ»å¨æµè§å¾è¥æ").clz("android.view.View"))) {133 //å¡äºï¼æ²¡è¿åº¦æ¡134 while (true) {135 if (has(text("è¿å").clz("android.widget.Button"))) {136 click(text("è¿å").clz("android.widget.Button"));137 } else {138 break;139 }140 sleep(3000);141 }142 break;143 }144 sleep(2000);145 }146 } else if (((ttl.substr(0, 8) === "éé¢å¸ä¸å¿æ¢ç¥å¸") && btt === "å»æµè§")) {147 //è¿åº¦æ¡ï¼å è½½ä¸è¬ï¼15s148 clickPoint(buttonX, buttonY);149 sleep(20000);150 while (true) {151 if (has(text('ä»»å¡å·²ç»å
¨é¨å®æå¦').clz('android.view.View'))) {152 while (true) {153 if (has(desc("è¿å").clz("android.widget.FrameLayout"))) {154 click(desc("è¿å").clz("android.widget.FrameLayout"));155 } else {156 break;157 }158 sleep(3000);159 }160 break;161 } else if (!has(text("æ»å¨æµè§å¾è¥æ").clz("android.view.View"))) {162 //å¡äºï¼æ²¡è¿åº¦æ¡163 while (true) {164 if (has(desc("è¿å").clz("android.widget.FrameLayout"))) {165 click(desc("è¿å").clz("android.widget.FrameLayout"));166 } else {167 break;168 }169 sleep(3000);170 }171 break;172 }173 sleep(2000);174 }175 } else if ((ttl.substr(0, 9) === "æµè§è·éæ¶åç礼å
" && btt === "å»æµè§")) {176 //è¿åº¦æ¡ï¼å è½½ä¸è¬ï¼15s177 clickPoint(buttonX, buttonY);178 sleep(20000);179 while (true) {180 if (has(text('ä»»å¡å·²ç»å
¨é¨å®æå¦').clz('android.view.View'))) {181 while (true) {182 if (has(desc("转å°ä¸ä¸å±çº§").clz("android.widget.ImageButton"))) {183 click(desc("转å°ä¸ä¸å±çº§").clz("android.widget.ImageButton"));184 } else {185 break;186 }187 sleep(3000);188 }189 break;190 } else if (!has(text("æ»å¨æµè§å¾è¥æ").clz("android.view.View"))) {191 //å¡äºï¼æ²¡è¿åº¦æ¡192 while (true) {193 if (has(desc("转å°ä¸ä¸å±çº§").clz("android.widget.ImageButton"))) {194 click(desc("转å°ä¸ä¸å±çº§").clz("android.widget.ImageButton"));195 } else {196 break;197 }198 sleep(3000);199 }200 break;201 }202 sleep(2000);203 }204 } else if (ttl.substr(0, 7) === "æµè§è¶
æ ä¹°ç款" && btt === "å»æµè§") {205 //è¿åº¦æ¡ï¼å è½½è¾å¿«ï¼15s206 clickPoint(buttonX, buttonY);207 sleep(17000);208 while (true) {209 if (has(text('ä»»å¡å·²ç»å
¨é¨å®æå¦').clz('android.view.View'))) {210 while (true) {211 if (has(text("æ£åä½ä»· 好货éç¼ä¹°").clz("android.view.View"))) {212 let node = text("æ£åä½ä»· 好货éç¼ä¹°").clz("android.view.View").getOneNodeInfo(3000);213 let sbls = node.parent().previousSiblings();214 sbls[0].clickCenter();215 } else {216 break;217 }218 sleep(3000);219 }220 break;221 } else if (!has(text("æ»å¨æµè§å¾è¥æ").clz("android.view.View"))) {222 //å¡äºï¼æ²¡è¿åº¦æ¡223 while (true) {224 if (has(text("æ£åä½ä»· 好货éç¼ä¹°").clz("android.view.View"))) {225 let node = text("æ£åä½ä»· 好货éç¼ä¹°").clz("android.view.View").getOneNodeInfo(3000);226 let sbls = node.parent().previousSiblings();227 sbls[0].clickCenter();228 } else {229 break;230 }231 sleep(3000);232 }233 break;234 }235 sleep(2000);236 }237 } else if ((ttl.substr(0, 8) === "é¢400è¥æ礼å
" && btt === "å»é¢å") || (ttl.substr(0, 6) === "é¢è¥æå°æ示" && btt === "ç¥éäº")) {238 //é¢å239 clickPoint(buttonX, buttonY);240 sleep(3000);241 } else if (ttl.substr(0, 9) === "æµè§éå¸å°éå¾è¥æ" && btt === "å»æµè§") {242 //è¿åº¦æ¡ï¼å è½½ä¸è¬ï¼15s243 clickPoint(buttonX, buttonY);244 sleep(20000);245 while (true) {246 if (has(text('ä»»å¡å·²ç»å
¨é¨å®æå¦').clz('android.view.View'))) {247 while (true) {248 if (has(text("è¿å").clz("android.widget.Button"))) {249 click(text("è¿å").clz("android.widget.Button"));250 } else {251 break;252 }253 sleep(3000);254 }255 break;256 } else if (!has(text("æ»å¨æµè§å¾è¥æ").clz("android.view.View"))) {257 //å¡äºï¼æ²¡è¿åº¦æ¡258 while (true) {259 if (has(text("è¿å").clz("android.widget.Button"))) {260 click(text("è¿å").clz("android.widget.Button"));261 } else {262 break;263 }264 sleep(3000);265 }266 break;267 }268 sleep(2000);269 }270 } else if (ttl.substr(0, 8) === "å»æ·å®äººçæ¿å¥è£
" && btt === "å»éé") {271 //æ½å¿æ¿ç¤¼çå¾300è¥æ272 clickPoint(buttonX, buttonY);273 sleep(5000);274 while (true) {275 if (isInTaobaorenshengMain()) {276 sleep(2000);277 break;278 }279 sleep(2000);280 }281 let pcxylh = findFreeChouXinYuanLiHe();282 if (pcxylh) {283 clickPoint(pcxylh.x, pcxylh.y);284 sleep(4000);285 back();286 sleep(5000);287 } else {288 //x6æ½ä¸æ¬¡ï¼ä¸åäºï¼éåº289 back();290 sleep(5000);291 }292 while (true) {293 if (has(text('æ·å®äººç').clz('android.webkit.WebView'))) {294 let zjtc = findExitInTBRS();295 if (zjtc) {296 clickPoint(zjtc.x, zjtc.y);297 sleep(3000);298 break;299 }300 }301 sleep(2000);302 }303 HasFreeChouXinYuanLiHe = false;304 } else if (ttl.substr(0, 9) === "ééæ¯ä»å®èèååº") {305 clickPoint(buttonX, buttonY);306 sleep(10000);307 IsStartZhifubaoExcp = true;308 sleep(5000);309 doZhifubaoBaBaNongChang();310 logd("æ¯ä»å®ä»»å¡å
¨é¨å®æ~");311 //è¿åæ·å®312 logd("åå¤è¿åæ·å®...");313 back();314 sleep(8000);315 while (true) {316 if (getRunningPkg() === "com.eg.android.AlipayGphone") {317 back();318 } else if (getRunningPkg() === "com.taobao.taobao") {319 sleep(2000);320 returnJifeiliao_Mianfei();321 sleep(1000);322 break;323 } else {324 openMyTaobao();325 sleep(6000);326 gotoMianfeilingshuiguoSinceClickBaba();327 sleep(2000);328 logd("æ¯ä»å®è¿åæ·å®ï¼éäºæ¯ä»å®ï¼éå¼æ·å®ï¼è¿å
¥å
è´¹é¢æ°´æ主页é¢");329 clickPoint(xy_Jifeiliao_Mianfei.x, xy_Jifeiliao_Mianfei.y);330 sleep(2000);331 break;332 }333 sleep(4000);334 }335 } else if ((ttl.match("^æµè§.+") && btt === "å»æµè§")) {336 //æåå¤ææ¯ä¸æ¯æµè§**337 //è¿åº¦æ¡ï¼å è½½ä¸è¬ï¼15s338 clickPoint(buttonX, buttonY);339 sleep(20000);340 while (true) {341 if (has(text('ä»»å¡å·²ç»å
¨é¨å®æå¦').clz('android.view.View'))) {342 while (true) {343 if (has(text("è¿å").clz("android.widget.Button"))) {344 click(text("è¿å").clz("android.widget.Button"));345 } else {346 break;347 }348 sleep(3000);349 }350 break;351 } else if (!has(text("æ»å¨æµè§å¾è¥æ").clz("android.view.View"))) {352 //å¡äºï¼æ²¡è¿åº¦æ¡353 while (true) {354 if (has(text("è¿å").clz("android.widget.Button"))) {355 click(text("è¿å").clz("android.widget.Button"));356 } else {357 break;358 }359 sleep(3000);360 }361 break;362 }363 sleep(2000);364 }365 } else {366 logd("æ·å®æªç¥ä»»å¡ï¼", ttl);367 UnknowTasks_Mianfei.push(ttl);368 }369 //å¤æè¿åç页é¢ï¼å¹¶åå°éè¥æ370 returnJifeiliao_Mianfei();371 if (index > (MAXN_Tasks_Mianfei - 1)) {372 //第7个å¼å§è¦æ»åå»373 for (let i = 0; i < n; i++) {374 swipeToPoint(startx, starty, startx, starty + 2 * rollDist, 200);375 sleep(500);376 }377 }...
SleepAddScreen.js
Source:SleepAddScreen.js
1import React, { Component } from "react";2import {3 StyleSheet,4 Text,5 View,6 TouchableOpacity,7 Dimensions,8 Switch,9 ScrollView,10 Image11} from "react-native";12import textStyles from "./../../common/TextStyles";13import ThemeStyle from "../../styles/ThemeStyle";14import Header from "./../../components/Header";15import { Transition } from "react-navigation-fluid-transitions";16import LinearGradient from "react-native-linear-gradient";17import CustomButton from "./../../components/Button";18import { withStore } from "../../utils/StoreUtils";19import { setSleepData } from "../../actions/RecordActions";20import { asyncStorageConstants, getScreens } from "../../constants";21import { recordScreenEvent, screenNames } from "../../utils/AnalyticsUtils";22import DateTimePicker from "react-native-modal-datetime-picker";23import moment from "moment";24import Icon from "../../common/icons";25import Card from "../../components/Card";26import * as Animatable from "react-native-animatable";27import { addSleepEntry, deleteSleepEntries, getSleepEntries } from "../../actions/NutritionixActions"28import { showMessage } from "react-native-flash-message";29import { setTopSafeAreaView } from "../../actions/AppActions";30const { width, height } = Dimensions.get("window");31class SleepAddScreen extends Component {32 constructor(props) {33 super(props);34 this.defaultSleepTime = moment();35 this.defaultSleepTime.hours(36 props.isEdit && props.editEntry.bedTime37 ? moment(props.editEntry.bedTime).get("hours")38 : 2239 );40 this.defaultSleepTime.minutes(41 props.isEdit && props.editEntry.bedTime42 ? moment(props.editEntry.bedTime).get("minutes")43 : 1544 );45 this.defaultWakeTime = moment();46 this.defaultWakeTime.hours(47 props.isEdit && props.editEntry.wakeTime48 ? moment(props.editEntry.wakeTime).get("hours")49 : 650 );51 this.defaultWakeTime.minutes(52 props.isEdit && props.editEntry.wakeTime53 ? moment(props.editEntry.wakeTime).get("minutes")54 : 1555 );56 this.state = {57 currentDate: props.isEdit ? moment(props.editEntry.dateTime) : moment(),58 sleepTime: this.defaultSleepTime,59 wakeTime: this.defaultWakeTime,60 switch: props.isEdit ? props.editEntry.medication : false,61 duration: this.calculateDuration(62 this.defaultSleepTime,63 this.defaultWakeTime64 ),65 duration_min: this.calculateDurationMin(66 this.defaultSleepTime,67 this.defaultWakeTime68 )69 };70 }71 72 componentDidMount() {73 this.props.setTopSafeAreaView(ThemeStyle.backgroundColor);74 recordScreenEvent(screenNames.medication);75 }76 componentWillUnmount() {77 this.props.setTopSafeAreaView(ThemeStyle.gradientStart);78 }79 calculateDuration(sleepTime, wakeTime) {80 let hours = wakeTime.diff(sleepTime, "hours", true);81 if (hours < 0) {82 hours = 24 + hours;83 }84 const durationHours = Math.floor(hours);85 const minutes = hours - durationHours;86 let durationMins = Math.floor(minutes * 60);87 if (durationMins < 10) {88 durationMins = "0" + durationMins;89 }90 return durationHours + ":" + durationMins;91 }92 calculateDurationMin(sleepTime, wakeTime) {93 let hours = wakeTime.diff(sleepTime, "hours", true);94 if (hours < 0) {95 hours = 24 + hours;96 }97 const durationHours = Math.floor(hours);98 const minutes = hours - durationHours;99 const durationMins = Math.floor(minutes * 60);100 return durationHours * 60 + durationMins;101 }102 onClickAddSleep = () => {103 var params = {104 bed_time: this.state.sleepTime.toISOString(),105 wake_time: this.state.wakeTime.toISOString(),106 duration: this.state.duration,107 duration_min: this.state.duration_min108 }109 let dateTime = this.state.currentDate.format("YYYY-MM-DD");110 this.props.addSleepEntry(params, dateTime, onAdded => {111 console.log("Success to upload sleep", onAdded)112 showMessage({113 message:'Sleep have been saved sucessfully.',114 type: "success"115 });116 this.props.navigation.goBack(null);117 })118 }119 render() {120 return (121 <View style={[ThemeStyle.pageContainer, { paddingHorizontal: 20 }]}>122 <Header123 title="Sleep"124 goBack={() => {125 this.props.navigation.goBack(null);126 }}127 />128 <Animatable.View animation="fadeInUp">129 <LinearGradient130 style={{ marginTop: 12, borderRadius: 10 }}131 start={{ x: 0.8, y: 0.2 }}132 end={{ x: 0.2, y: 1 }}133 colors={ThemeStyle.gradientColor}134 >135 <View style={{ flexDirection: "row" }}>136 <TouchableOpacity137 style={{ flex: 1, padding: 24, alignItems: "center" }}138 onPress={() => {139 this.setState({140 isDatePickerVisible: true,141 dateType: "sleep"142 });143 }}144 >145 <Image146 source={require("../../assets/images/redesign/Night-icon.png")}147 style={{ height: 72, marginVertical: 16 }}148 resizeMode="contain"149 />150 <Text151 style={[152 textStyles.GeneralTextBold,153 { textAlign: "center", color: "#333" }154 ]}155 >156 Slept at157 </Text>158 <Text159 style={[160 textStyles.SubHeaderBold,161 { textAlign: "center", color: "#fff" }162 ]}163 >164 {this.state.sleepTime.format("hh : mm A")}165 </Text>166 </TouchableOpacity>167 <TouchableOpacity168 style={{ flex: 1, padding: 24, alignItems: "center" }}169 onPress={() => {170 this.setState({171 isDatePickerVisible: true,172 dateType: "wake"173 });174 }}175 >176 <Image177 source={require("../../assets/images/redesign/Day-graphic.png")}178 style={{ height: 72, marginVertical: 16 }}179 resizeMode="contain"180 />181 <Text182 style={[183 textStyles.GeneralTextBold,184 { textAlign: "center", color: "#333" }185 ]}186 >187 Wokeup at188 </Text>189 <Text190 style={[191 textStyles.SubHeaderBold,192 { textAlign: "center", color: "#fff" }193 ]}194 >195 {this.state.wakeTime.format("hh : mm A")}196 </Text>197 </TouchableOpacity>198 </View>199 </LinearGradient>200 </Animatable.View>201 <Animatable.View202 animation="fadeInUp"203 style={{204 borderRadius: 10,205 ...ThemeStyle.shadow(),206 backgroundColor: "#fff",207 borderWidth: 2,208 marginTop: 16,209 borderColor: ThemeStyle.mainColor,210 flexDirection: "row",211 padding: 16,212 alignItems: "center"213 }}214 >215 <Image216 source={require("../../assets/images/redesign/Sleep_Duration-graphic.png")}217 style={{ height: 72 }}218 resizeMode="contain"219 />220 <View style={{ flexDirection: "column", marginLeft: 24 }}>221 <Text style={[textStyles.GeneralTextBold]}>{"Sleep Duration"}</Text>222 <Text223 style={[224 textStyles.SubHeaderBold,225 { color: ThemeStyle.mainColor }226 ]}227 >228 {this.state.duration}229 </Text>230 </View>231 </Animatable.View>232 <DateTimePicker233 isVisible={this.state.isDatePickerVisible}234 date={235 this.state.dateType === "sleep"236 ? new Date(this.state.sleepTime.toISOString())237 : new Date(this.state.wakeTime.toISOString())238 }239 mode="time"240 onCancel={() => {241 this.setState({242 isDatePickerVisible: false243 });244 }}245 onConfirm={date => {246 console.log(date);247 const selectedDate = moment(date);248 if (this.state.dateType === "sleep") {249 this.setState({250 isDatePickerVisible: false,251 sleepTime: selectedDate,252 duration: this.calculateDuration(253 selectedDate,254 this.state.wakeTime255 ),256 duration_min: this.calculateDurationMin(257 selectedDate,258 this.state.wakeTime259 )260 });261 }262 if (this.state.dateType === "wake") {263 this.setState({264 isDatePickerVisible: false,265 wakeTime: selectedDate,266 duration: this.calculateDuration(267 this.state.sleepTime,268 selectedDate269 ),270 duration_min: this.calculateDurationMin(271 this.state.sleepTime, 272 selectedDate273 )274 });275 }276 }}277 />278 <CustomButton279 style={{280 position: "absolute",281 bottom: 0,282 marginBottom: 50,283 alignSelf: "center"284 }}285 name={"Log Sleep"}286 onPress={this.onClickAddSleep}287 />288 </View>289 );290 }291}292export default withStore(293 SleepAddScreen,294 state => ({295 isEdit: state.record.isEdit,296 editEntry: state.record.editEntry297 }),298 dispatch => ({299 setTopSafeAreaView: color => dispatch(setTopSafeAreaView(color)),300 setSleepData: data => dispatch(setSleepData(data)),301 addSleepEntry: (query, date, data) =>302 dispatch(addSleepEntry(query, date, data)),303 deleteSleepEntries: (entryId, data) =>304 dispatch(deleteSleepEntries(entryId, data)),305 getSleepEntries: (date, fetchListData) =>306 dispatch(getSleepEntries(date, fetchListData)),307 })308);309var styles = StyleSheet.create({310 inputBox: {311 height: 300,312 borderColor: "#fff",313 borderWidth: 1,314 paddingHorizontal: 24,315 marginVertical: 24,316 fontSize: 16,317 textAlignVertical: "top",318 color: "#000",319 backgroundColor: "#fff"320 },...
intro.js
Source:intro.js
2const chalk = require("chalk");3const figures = require('figures');4const dt = new DynamicTerminal();5const lines = [];6async function sleep(milliseconds) {7 return new Promise(resolve => setTimeout(resolve, milliseconds));8}9(async () => {10 try {11 process.stdout.write('\033c'); // Clear the screen12 dt.start({ repaintOnResize: true });13 for (let i=0; i<=6; i++)14 lines.push({ text: '', indent: '' });15 lines[0].indent = 10;16 openingBanner(lines[0]);17 await sleep(1000);18 lines[1].indent = 15;19 typeWriter(lines[1], 'Hi');20 await sleep(1000);21 lines[2].indent = 0;22 await typeWriter(lines[2], 'Right now I\'m using Dynamic Terminal', 20);23 await sleep(1000);24 await clearLines(lines, 20);25 lines[2].indent = 5;26 await typeWriter(lines[2], "It lets you create dynamic terminal output.", 21);27 await sleep(500);28 lines[3].indent = 3;29 typeWriter(lines[3], "Each line is represented as an object like so:", 20);30 await sleep(500);31 lines[4] = { text: '', indent: 6 };32 await typeWriter(lines[4], "{ text: \"Running task...\", indent: 2 }", 22);33 lines[4].text = `{ ${chalk.red('text')}: ${chalk.green("\"Running task...\"")}, ${chalk.red('indent')}: ${chalk.green('2')} }`;34 update();35 await sleep(2000);36 await clearLines(lines, 20);37 lines[4].force = false;38 lines.forEach(v => v.indent = 2);39 typeWriter(lines[0], 'Full control over each line. An optimized Change', 5);40 await sleep(100);41 typeWriter(lines[1], 'algorithm compares the previous and new render,', 5);42 await sleep(100);43 typeWriter(lines[2], 'making sure that ONLY differences are updated, and', 5);44 await sleep(100);45 typeWriter(lines[3], "not the whole screen.", 5)46 await sleep(2000);47 typeWriter(lines[5], "All the work is offloaded to a separate thread.", 5);48 await sleep(100);49 typeWriter(lines[6], 'Any action returns an ES2015 Promise. Never slow', 5);50 await sleep(100);51 lines[7] = { text: '', indent: 2 };52 typeWriter(lines[7], 'down your main thread with useless console logic.', 5);53 await sleep(2000);54 lines[8] = { text: chalk.cyan(">> That's why it's so fast. <<"), indent: 9 };55 update();56 await sleep(4000);57 for (let i=0; i<=8; i++) {58 lines[i].text = '';59 update();60 await sleep(200);61 }62 typeWriter(lines[0], "Easily display different running tasks\nand update them as things go wrong!");63 lines[1] = { text: DynamicTerminal.SPINNER + " Looking for your password...", indent: 4 };64 lines[2] = { text: DynamicTerminal.SPINNER + " Stealing your SSH keys...", indent: 4 };65 lines[3] = { text: chalk.green(DynamicTerminal.TICK) + " I didn't even need to do anything", indent: 4 };66 update();67 lines[4].indent = 4;68 await progressBar(lines[4]).catch((err) => { dt.stop(); setTimeout( () => console.error(err), 2000); });69 lines[1] = { text: chalk.red(DynamicTerminal.CROSS) + " Damn. I didn't find any!", indent: 4 };70 update();71 await sleep(1000);72 lines[2] = { text: DynamicTerminal.SPINNER + " Noticed how I'm still spinning?", indent: 4 };73 update();74 await sleep(2000);75 lines.forEach(v => v.text = '');76 lines[0].text = "And did I mention...";77 update();78 await sleep(400);79 lines[2] = `ANSI ${chalk.red('colour codes')} are supported?`;80 update();81 await sleep(400);82 lines[2] = `ANSI ${chalk.green('colour codes')} are supported?`;83 update();84 await sleep(400);85 lines[2] = `ANSI ${chalk.cyan('colour codes')} are supported?`;86 update();87 await sleep(400);88 lines[2] = `ANSI ${chalk.blue('colour codes')} are supported?`;89 update();90 await sleep(400);91 lines[2] = `ANSI ${chalk.yellow('colour codes')} are supported?`;92 update();93 await sleep(400);94 await dt.update([{ text: `${chalk.green(figures.tick)} I'm done showing off.`, indent: 2 }, { text: "Let's see what you can do!", indent: 4 }]);95 await sleep(500);96 await dt.stop();97 await sleep(500);98 dt.destroy();99 } catch (err) {100 dt.stop();101 console.error('Error in demo:');102 console.error(err);103 dt.destroy();104 process.exit();105 }106})();107function update() {108 dt.update(lines);109}110function typeWriter(line, text, interval = 20) {111 let cursor = 0;...
day4.js
Source:day4.js
1const fs = require('fs');2const path = require('path');3const ENTRY_REGEX = /^\[\d{4}\-(\d{2}\-\d{2})\s(\d{2}:\d{2})\]\s(?:Guard.*#)?(\d{1,})?.*(falls|wakes|begins).*/;4function sortEntries(entries) {5 entries.sort((a, b) => {6 const [,date1, time1] = a.match(ENTRY_REGEX);7 const [,date2, time2] = b.match(ENTRY_REGEX);8 if (date1 + time1 < date2 + time2) { return -1; }9 else if (date1 + time1 > date2 + time2) { return 1; }10 else { return 0; }11 });12}13function getTimeSlept(start, end) {14 return parseInt(end.replace(':', ''), 10) - parseInt(start.replace(':', ''), 10);15}16function updateMinuteMap(map, start, end) {17 start = parseInt(start.replace(':', ''), 10);18 end = parseInt(end.replace(':', ''), 10);19 for (; start <= end; start++) {20 map[start.toString()] = map[start.toString()] || 0;21 map[start.toString()] += 1;22 if (map[start.toString()] % 100 === 60) {23 start += 100;24 start -= 60;25 }26 }27}28function guardSleeptimes(entries) {29 const sleepMap = {};30 let currentGuard = null;31 let sleepStart = null;32 for (const e of entries) {33 const [,date, time, guard, action] = e.match(ENTRY_REGEX);34 if (action === 'begins') {35 currentGuard = guard;36 } else if (action === 'falls') {37 sleepStart = time;38 } else if (action === 'wakes') {39 sleepMap[currentGuard] = sleepMap[currentGuard] || { sleepTime: 0, minuteMap: {}};40 // Total time slept41 sleepMap[currentGuard].sleepTime += getTimeSlept(sleepStart, time);42 // Mark the minutes asleep43 updateMinuteMap(sleepMap[currentGuard].minuteMap, sleepStart, time);44 } else {45 throw new Error(`Invalid entry: ${action}`);46 }47 }48 return sleepMap;49}50function part1(input) {51 const entries = input52 .trim()53 .split('\n');54 55 sortEntries(entries);56 const sleepMap = guardSleeptimes(entries);57 let maxSleepTime = null;58 let target = {};59 for (const [guard, { sleepTime }] of Object.entries(sleepMap)) {60 if (maxSleepTime === null || sleepTime > maxSleepTime) {61 maxSleepTime = sleepTime;62 target = {63 guard, sleepTime64 }65 }66 }67 let maxMinuteSleepTime = null;68 for (const [minute, sleepTime] of Object.entries(sleepMap[target.guard].minuteMap)) {69 if (maxMinuteSleepTime === null || sleepTime > maxMinuteSleepTime) {70 maxMinuteSleepTime = sleepTime;71 target.minute = minute;72 }73 }74 return target.guard * target.minute;75}76function part2(input) {77 const entries = input78 .trim()79 .split('\n');80 81 sortEntries(entries);82 const sleepMap = guardSleeptimes(entries);83 let allGuardsmaxMinuteSleepTime = null;84 let target = {};85 for (const guard of Object.keys(sleepMap)) {86 for (const [minute, sleepTime] of Object.entries(sleepMap[guard].minuteMap)) {87 if (allGuardsmaxMinuteSleepTime === null || sleepTime > allGuardsmaxMinuteSleepTime) {88 allGuardsmaxMinuteSleepTime = sleepTime;89 target.guard = guard;90 target.minute = minute;91 }92 }93 94 }95 return target.guard * target.minute;96}97const input = fs.readFileSync(path.resolve(__dirname, './input.txt'), 'utf8');98console.log('day4 part1:', part1(input));...
Graph.js
Source:Graph.js
1import React from 'react'2import { Line } from "react-chartjs-2";3const Graph = (props) => {4 const sleep = props.sleepData5//dates being sorted to display in timeline properly6 sleep.sort((a,b)=>{7 8 const bdate = b.date.split('-')9 const adate = a.date.split('-')10 console.log(adate)11 return adate[0] - bdate[0] || adate[1] - bdate[1] || adate[2] - bdate[2];12 })13//getting just sleep dates14 const sleepEntryDate = sleep.map((sleep) => (15 // console.log("mapped", sleep)16 sleep.date17 ))18//getting just score19 const sleepEntryScore = sleep.map((sleep) => (20 // console.log("mapped", sleep)21 sleep.score 22))23//optimized the overall sleep score... will break down the optimization by category later, running out of time24const sleepEntryScoreOptimized = sleep.map((sleep) => (25 // console.log("mapped", sleep)26 27 sleep.score + ( sleep.score * 20 / 100)28))29 // const verifyNotNull = (sleep) => {30 // const notNull = []31 // for(let obj in array){32 // if(Object.values(obj) !== null){33 34 // notNull.push(obj.score)35 36 // }37 38 // }39 // return notNull40 // }41 // const notNull = verifyNotNull(sleep)42 //console.log(verifyNotNull)43 44 console.log("sleep entries", sleepEntryScore)45//graph data below sorry guys running out of time we can talk about this if it's unclear46 const data = {47 labels: sleepEntryDate,48 datasets: [49 {50 label: "Current Sleep",51 data: sleepEntryScore,52 fill: true,53 backgroundColor: "rgba(75,192,192,0.2)",54 borderColor: "rgba(75,192,192,1)"55 },56 {57 label: "Optimized Sleep",58 data: sleepEntryScoreOptimized,59 fill: false,60 borderColor: "#742774"61 }62 ]63 };64 return (65 <div className="">66 <Line className="graph" data={data}/>67 </div>68 )69}...
index.js
Source:index.js
1const getSleepHours = day => {2 // const getSleepHours.toLowerCase();3 if (day === 'monday') {4 return 8;5 } else if(day === 'monday') {6 return 8;7 } else if(day === 'tuesday') {8 return 4;9 } else if(day === 'wednesday') {10 return 8;11 } else if(day === 'thursday') {12 return 5;13 } else if(day === 'friday') {14 return 8;15 } else if(day === 'saturday') {16 return 3;17 } else if (day === 'sunday') {18 return 8;19 }20 else {21 return 'What day?';22 }23 };24 25 const getActualSleepHours = () => {26 return 27 getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday'); 28 };29 30 console.log(getSleepHours('monday'));31 32 const getIdealSleepHours = () => {33 let idealHours = 8;34 return idealHours * 7; 35 };36 37 console.log(getIdealSleepHours());38 39 const calculateSleepDebt = () => {40 const actualSleepHours = getActualSleepHours();41 const idealSleepHours = getIdealSleepHours();42 43 if (actualSleepHours === idealSleepHours) {44 return console.log('You got the perfect amount of sleep');45 } else if(actualSleepHours > idealSleepHours) {46 return console.log('You got' + (idealSleepHours - actualSleepHours) + 'more hours sleep than was needed');47 } else if(actualSleepHours < idealSleepHours) {48 return console.log('You should get some more rest because you only got' + (idealSleepHours - actualSleepHours));49 } else {50 console.log('something went wrong :(')51 }52 };53 ...
MainContainer.js
Source:MainContainer.js
1import React from 'react'2import SleepForm from './SleepForm'3import SleepEntry from './SleepEntry'4import Graph from './Graph'5 const MainContainer = (props) => {6 // console.log("MainContainer", props.sleepData)7 const sleep = props.sleepData8 9 sleep.sort((a,b)=>{10 11 const bdate = b.date.split('-')12 const adate = a.date.split('-')13 console.log(adate)14 return bdate[0] - adate[0] || bdate[1] - adate[1] || bdate[2] - adate[2];15 })16 // console.log("MainContainer state", sleep)17 // console.log("user stuff", props.userData)18 const sleepEntries = sleep.map((sleep) => (19 // console.log("mapped", sleep)20 <SleepEntry key={sleep.sleepid} sleep={sleep} entryDate={sleep.date} />21 22 ))23 24 return (25 <div className="containerG">26 27 <SleepForm userData={props.userData} />28 <div className="graphContainer">29 <Graph sleepData={props.sleepData}/>30 </div>31 <div className="entries">32 {sleepEntries}33 </div>34 {/* <SleepEntry key={sleep.sleepid} sleep={sleep} entryDate={sleep.date} /> */}35 {/* <SleepEntry key={sleep.sleepid} sleep={sleep} entryDate={sleep.date} /> */}36 </div>37 )38}...
Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var serverConfig = {4};5var desiredCaps = {6};7var driver = wd.promiseChainRemote(serverConfig);8 .init(desiredCaps)9 .click()10 .sleep(5000)11 .click()12 .quit();13from appium import webdriver14import time15desired_caps = {16}17time.sleep(5)18driver.quit()
Using AI Code Generation
1driver.sleep(5000);2driver.sleep(5000);3driver.sleep(5000);4driver.sleep(5000);5driver.sleep(5000);6driver.sleep(5000);7driver.sleep(5000);8driver.sleep(5000);9driver.sleep(5000);10driver.sleep(5000);11driver.sleep(5000);12driver.sleep(5000);13driver.sleep(5000);14driver.sleep(5000);15driver.sleep(5000);16driver.sleep(5000);17driver.sleep(5000);18driver.sleep(5000);19driver.sleep(5000);20driver.sleep(5000);21driver.sleep(5000);22driver.sleep(5000);23driver.sleep(5000);24driver.sleep(5000);25driver.sleep(5000);26driver.sleep(5000);27driver.sleep(5000);28driver.sleep(5000);
Using AI Code Generation
1driver.sleep(5000);2driver.sleep(5000);3driver.sleep(5000);4driver.sleep(5000);5driver.sleep(5000);6driver.sleep(5000);7driver.sleep(5000);8driver.sleep(5000);9driver.sleep(5000);10driver.sleep(5000);11driver.sleep(5000);12driver.sleep(5000);13driver.sleep(5000);14driver.sleep(5000);15driver.sleep(5000);16driver.sleep(5000);17driver.sleep(5000);18driver.sleep(5000);19driver.sleep(5000);20driver.sleep(5000);21driver.sleep(5000);22driver.sleep(5000);23driver.sleep(5000);24driver.sleep(5000);25driver.sleep(5000);26driver.sleep(5000);27driver.sleep(5000);28driver.sleep(5000);29driver.sleep(5000);30driver.sleep(5000);31driver.sleep(5000);
Using AI Code Generation
1driver.sleep(5000);2Thread.sleep(5000);3Thread.sleep(5000);4ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);5executor.execute(()->{6 try {7 Thread.sleep(5000);8 } catch (InterruptedException e) {9 e.printStackTrace();10 }11});12executor.shutdown();
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!!