How to use sleep method in Appium

Best JavaScript code snippet using appium

configurationManagement.spec.js

Source:configurationManagement.spec.js Github

copy

Full Screen

...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();...

Full Screen

Full Screen

doTask_Mianfei.js

Source:doTask_Mianfei.js Github

copy

Full Screen

...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    }...

Full Screen

Full Screen

SleepAddScreen.js

Source:SleepAddScreen.js Github

copy

Full Screen

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  },...

Full Screen

Full Screen

intro.js

Source:intro.js Github

copy

Full Screen

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;...

Full Screen

Full Screen

day4.js

Source:day4.js Github

copy

Full Screen

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));...

Full Screen

Full Screen

Graph.js

Source:Graph.js Github

copy

Full Screen

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}...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

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  ...

Full Screen

Full Screen

MainContainer.js

Source:MainContainer.js Github

copy

Full Screen

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}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.sleep(2000);2driver.findElement(By.id("com.android.calculator2:id/digit_5")).click();3driver.findElement(By.id("com.android.calculator2:id/op_add")).click();4driver.findElement(By.id("com.android.calculator2:id/digit_6")).click();5driver.findElement(By.id("com.android.calculator2:id/eq")).click();6Thread.sleep(2000);7driver.findElement(By.id("com.android.calculator2:id/digit_5")).click();8driver.findElement(By.id("com.android.calculator2:id/op_add")).click();9driver.findElement(By.id("com.android.calculator2:id/digit_6")).click();10driver.findElement(By.id("com.android.calculator2:id/eq")).click();11WebDriverWait wait = new WebDriverWait(driver, 10);12wait.until(ExpectedConditions.presenceOfElementLocated(By.id("com.android.calculator2:id/digit_5"))).click();13driver.findElement(By.id("com.android.calculator2:id/op_add")).click();14driver.findElement(By.id("com.android.calculator2:id/digit_6")).click();15driver.findElement(By.id("com.android.calculator2:id/eq")).click();16Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)17.withTimeout(30, TimeUnit.SECONDS)18.pollingEvery(5, TimeUnit.SECONDS)19.ignoring(NoSuchElementException.class);20WebElement element = wait.until(new Function<WebDriver, WebElement>() {21public WebElement apply(WebDriver driver) {22return driver.findElement(By.id("com.android.calculator2:id/digit_5"));23}24});25element.click();26driver.findElement(By.id("com.android.calculator2:id/op_add")).click();27driver.findElement(By.id("com.android.calculator2:id/digit_6")).click();28driver.findElement(By.id("com.android.calculator2:id/eq")).click();29driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);30driver.findElement(By.id("com.android.calculator2:id/digit_5")).click();31driver.findElement(By.id("com.android.calculator2:id/op_add")).click();32driver.findElement(By.id("com.android.calculator2:id/digit_6")).click();33driver.findElement(By.id("com.android.calculator2:id/eq")).click();34driver.manage().timeouts().setScriptTimeout

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.sleep(10000);2driver.sleep(10000);3driver.pause(10000);4browser.sleep(10000);5Thread.sleep(10000);6driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);7driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));8driver.manage().timeouts().implicitlyWait(Duration.of(10, SECONDS));9driver.manage().timeouts().implicitlyWait(10, SECONDS);10driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);11driver.manage().timeouts().implicitlyWait(10, TimeUnit.MILLISECONDS);12driver.manage().timeouts().implicitlyWait(10, TimeUnit.MICROSECONDS);13driver.manage().timeouts().implicitlyWait(10, TimeUnit.NANOSECONDS);14driver.manage().timeouts().implicitlyWait(10, TimeUnit.DAYS);15driver.manage().timeouts().implicitlyWait(10, TimeUnit.HOURS);16driver.manage().timeouts().implicitlyWait(10, TimeUnit.MINUTES);17driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);18driver.manage().timeouts().implicitlyWait(10, TimeUnit.MILLISECONDS);19driver.manage().timeouts().implicitlyWait(10, TimeUnit.MICROSECONDS);20driver.manage().timeouts().implicitlyWait(10, TimeUnit.NANOSECONDS);21driver.manage().timeouts().implicitlyWait(10, TimeUnit.DAYS);

Full Screen

Using AI Code Generation

copy

Full Screen

1import sleep from 'wdio-sleep';2describe('Test suite', () => {3    it('Test case', () => {4        sleep(5000);5    });6});

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful