Best JavaScript code snippet using appium
index.js
Source:index.js  
...49        .then(function(){50            return driver.startActivity({appPackage: 'com.zhiliaoapp.musically.go',appActivity: 'com.ss.android.ugc.aweme.splash.SplashActivity'})51            // return true;52        })53        .then(function (){return driver.waitForElementById('com.zhiliaoapp.musically.go:id/agr', asserters.isDisplayed && asserters.isEnabled, 5000);54        })55        .then(function (searchElement) {56            searchElement.click();57        })58        .then(function (){59            //profiles=await client.$('//*[contains(@resource-id, "com.zhiliaoapp.musically.go:id/akz")]')60            //await profiles.click()61            console.log('mlkmlk')62            //driver.execute("mobile: shell", {'command':'am start','args': ["-a", "android.intent.action.VIEW","-d","'https://www.tiktok.com/@elmonsifio' com.zhiliaoapp.musically"]});63            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/x8', asserters.isDisplayed && asserters.isEnabled, 1000);64        })65        .then(function (searchInput) {66            searchInput.click();67        })68        .then(function (){69            //profiles=await client.$('//*[contains(@resource-id, "com.zhiliaoapp.musically.go:id/akz")]')70            //await profiles.click()71            console.log('mlkmlk')72            //driver.execute("mobile: shell", {'command':'am start','args': ["-a", "android.intent.action.VIEW","-d","'https://www.tiktok.com/@elmonsifio' com.zhiliaoapp.musically"]});73            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/x8', asserters.isDisplayed && asserters.isEnabled, 1000);74        })75        .then(function (searchInput) {76            searchInput.sendKeys(accounts[ff].follower);77        })78        .then(async function (){79        return driver.waitForElementById('com.zhiliaoapp.musically.go:id/bcw',1000);80        // let isDisplayed = await element.isDisplayed();81        //  console.log(driver.waitForElementByXPath('//*[(@text, "'+account[ff].follower+' T")]', asserters.isDisplayed && asserters.isEnabled, 5000).inspect() );82        // return driver.waitForElementByXPath('//*[(@text, "'+account[ff].follower+' T")]', asserters.isDisplayed && asserters.isEnabled, 5000).isDisplayed() || driver.waitForElementByXPath('//*[(@text, "'+account[ff].follower+'")]', asserters.isDisplayed && asserters.isEnabled, 30000).isDisplayed() ;83    })84.then(function(searchBtn){85        searchBtn.click();86    })87        .then(async function (){88        //  return driver.waitForElementById('com.zhiliaoapp.musically.go:id/bjh',5000);89        // let isDisplayed = await element.isDisplayed();90        //  console.log(driver.waitForElementByXPath('//*[(@text, "'+account[ff].follower+' T")]', asserters.isDisplayed && asserters.isEnabled, 5000).inspect() );91        return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.RelativeLayout/android.widget.LinearLayout', asserters.isDisplayed && asserters.isEnabled, 3000) ;92    })93.then(function (firstResult) {94        console.log('mlkmlks')95        return firstResult.click();96    })97    /*.then(function (){98     return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.RelativeLayout', asserters.isDisplayed && asserters.isEnabled, 5000);99     })100     .then(function (userTab) {101     return userTab.click();102     })103     .then(function (){104     return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.RelativeLayout', asserters.isDisplayed && asserters.isEnabled, 5000);105     })106     .then(function (userTab1) {107     console.log('lkjl')108     return userTab1.click();109     })*/110        .then(async function (){111                 return driver.waitForElementByXPath('//android.widget.TextView[@text="Abonnés"]', 3000)112        })113        .then(async (follower)=>{114                return follower.click();115        })116        .then(function (){117        return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.HorizontalScrollView/android.widget.LinearLayout/androidx.appcompat.app.a.b[2]/android.widget.TextView', 10000);118        })119        .then(function(){120            j=1;121            i=1122            ii=0;123            setTimeout(async function run() {124                if(j<200) {125                  followBtn=await  driver.elementsByXPath('//android.widget.TextView[contains(@text, "S\'abonner")]')126                        .then(_p.filterDisplayed)127                    inival=followBtn.length128                    if(followBtn.length>ii){129                      //  if(inival)130                        console.log('iiiih'+ j)131                        followBtn.map((val,idx)=>{132                            delay(500*idx).then(function() {133                            return val.click();134                        });135                        j++136                        ii=idx+1;137                        })138                    }139                   else{140                        i=2;141                        ii=0;142                        action = new wd.TouchAction(driver)143                            action.press({x: 450, y:1300 }).wait(500).moveTo({x:450, y: 410}).release().perform();144                    //  driver.setImplicitWaitTimeout(5000);145                }146                    setTimeout(run,1000);147                }148                else{149                    ff++;150                    return setTimeout(function(){signOut()},5000)151                }152            }, 5000);153        }).catch(function(e){154            console.log('--------------------------')155            follow1()156        })157        .done();158}159function randomNumber(min, max) {160    return Math.floor(Math.random() * (max - min) + min);161}162follow=()=>{163    driver.init(desiredCaps)164        .then(function(){165            return driver.startActivity({appPackage: 'com.zhiliaoapp.musically.go',appActivity: 'com.ss.android.ugc.aweme.splash.SplashActivity'})166           // return true;167        })168        .then(function (){return driver.waitForElementById('com.zhiliaoapp.musically.go:id/akw', asserters.isDisplayed && asserters.isEnabled, 5000);169        })170        .then(function (searchElement) {171            searchElement.click();172        })173        .then(function (){174            //profiles=await client.$('//*[contains(@resource-id, "com.zhiliaoapp.musically.go:id/akz")]')175            //await profiles.click()176            console.log('mlkmlk')177            //driver.execute("mobile: shell", {'command':'am start','args': ["-a", "android.intent.action.VIEW","-d","'https://www.tiktok.com/@elmonsifio' com.zhiliaoapp.musically"]});178            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/z9', asserters.isDisplayed && asserters.isEnabled, 3000);179        })180        .then(function (searchInput) {181            searchInput.click();182        })183        .then(function (){184            //profiles=await client.$('//*[contains(@resource-id, "com.zhiliaoapp.musically.go:id/akz")]')185            //await profiles.click()186            console.log('mlkmlk')187            //driver.execute("mobile: shell", {'command':'am start','args': ["-a", "android.intent.action.VIEW","-d","'https://www.tiktok.com/@elmonsifio' com.zhiliaoapp.musically"]});188            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/z9', asserters.isDisplayed && asserters.isEnabled, 3000);189        })190        .then(function (searchInput) {191            searchInput.sendKeys(accounts[ff].follower);192        })193        .then(async function (){194        return driver.waitForElementById('com.zhiliaoapp.musically.go:id/bjh',5000);195        // let isDisplayed = await element.isDisplayed();196        //  console.log(driver.waitForElementByXPath('//*[(@text, "'+account[ff].follower+' T")]', asserters.isDisplayed && asserters.isEnabled, 5000).inspect() );197       // return driver.waitForElementByXPath('//*[(@text, "'+account[ff].follower+' T")]', asserters.isDisplayed && asserters.isEnabled, 5000).isDisplayed() || driver.waitForElementByXPath('//*[(@text, "'+account[ff].follower+'")]', asserters.isDisplayed && asserters.isEnabled, 30000).isDisplayed() ;198        })199        .then(function(searchBtn){200        searchBtn.click();201         })202        .then(async function (){203          //  return driver.waitForElementById('com.zhiliaoapp.musically.go:id/bjh',5000);204           // let isDisplayed = await element.isDisplayed();205            //  console.log(driver.waitForElementByXPath('//*[(@text, "'+account[ff].follower+' T")]', asserters.isDisplayed && asserters.isEnabled, 5000).inspect() );206            return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.RelativeLayout/android.widget.LinearLayout', asserters.isDisplayed && asserters.isEnabled, 10000) ;207        })208        .then(function (firstResult) {209            console.log('mlkmlks')210            return firstResult.click();211        })212        /*.then(function (){213            return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.RelativeLayout', asserters.isDisplayed && asserters.isEnabled, 5000);214        })215        .then(function (userTab) {216            return userTab.click();217        })218        .then(function (){219            return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.RelativeLayout', asserters.isDisplayed && asserters.isEnabled, 5000);220        })221        .then(function (userTab1) {222            console.log('lkjl')223            return userTab1.click();224        })*/225        .then(function (){226            return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.TextView[1]', asserters.isDisplayed && asserters.isEnabled, 10000);227        })228        .then(async function (follower) {229            console.log('followers')230            return await follower.click();231        })232        .then(function (){233            return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.RelativeLayout[1]/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.TextView', asserters.isDisplayed && asserters.isEnabled, 5000);234        })235        .then(function(){236            j=1;237            i=1238            setTimeout(async function run() {239                if(j<160) {240                    driver.elementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.RelativeLayout["+i+"]/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.TextView", asserters.isDisplayed && asserters.isEnabled, 3000)241                        .then(function(followText){242                            return followText.text()243                        })244                        .then(function(tex){245                            console.log('text')246                            console.log(tex)247                            aaa=tex248                            console.log(aaa)249                            if(tex=='S\'abonner'){250                                console.log(true);251                                driver.elementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.RelativeLayout["+i+"]/android.widget.RelativeLayout", asserters.isDisplayed && asserters.isEnabled, 3000)252                                    .then(async function(fff) {253                                    j++;254                                     fff.click();255                                })256                            }257                            i++;258                        }).catch(async()=>{259                        action = new wd.TouchAction(driver);260                    action.press({xx: 441, y: 1500});261                    action.wait(400);262                    action.moveTo({xx: 441, y: 1700})263                    action.wait(400);264                    action.moveTo({x: 430, y: 414});265                    action.release();266                    await action.perform();267                    i=2;268                  //  driver.setImplicitWaitTimeout(5000);269                })270                    setTimeout(run,2000);271                }272                else{273                    ff++;274                  return setTimeout(function(){signOut()},10000)275                }276            }, 3000);277        })278        .done();279}280nextProfile=()=>{281    console.log('lklsfjmqksdùaqpslù')282    connexion(follow,signOut)283}284connexion=async()=>{285    driver286        .init(desiredCaps)287        .then(function(){288            return driver.startActivity({appPackage: 'com.zhiliaoapp.musically.go',appActivity: 'com.ss.android.ugc.aweme.splash.SplashActivity'})289        })290        .then(function (){291            //profiles=await client.$('//*[contains(@resource-id, "com.zhiliaoapp.musically.go:id/akz")]')292            //await profiles.click()293            console.log('mlkmlk')294            //driver.execute("mobile: shell", {'command':'am start','args': ["-a", "android.intent.action.VIEW","-d","'https://www.tiktok.com/@elmonsifio' com.zhiliaoapp.musically"]});295            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/agu', asserters.isDisplayed && asserters.isEnabled, 4000);296        })297        .then(function (searchElement) {298            console.log('succes')299            return searchElement.click();300        })301        .then(async function(){302            try {303                elm= await driver.waitForElementById('com.zhiliaoapp.musically.go:id/jv', asserters.isDisplayed && asserters.isEnabled, 4000)304            }catch(e){305console.log('lkjmlzqkdqldùmql')306                throw 'need_signout'307            }308            return elm;309        })310        .then(function(connexionBtn){311            return connexionBtn.click()312        })313        .then(function(){314            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/a2q', asserters.isDisplayed && asserters.isEnabled, 2000)315        })316        .then(async function(){317        action = new wd.TouchAction(driver);318        action.press({xx: 441, y: 1800});319        action.wait(300);320        action.moveTo({x: 430, y: 414});321        action.release();322        await action.perform();323        })324        .then(async function(){325                action = new wd.TouchAction(driver);326                action.press({xx: 441, y: 1800});327                action.wait(300);328                action.moveTo({x: 430, y: 414});329                action.release();330                await action.perform();331            })332        .then(function () {333            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/e3', asserters.isDisplayed && asserters.isEnabled, 2000);334        })335        .then(function (addExistingAccount) {336            return addExistingAccount.click();337        })338        .then(function () {339            return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.FrameLayout/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[1]/android.widget.TextView', asserters.isDisplayed && asserters.isEnabled, 2000);340        })341        .then(function (connectAccount) {342            return connectAccount.click();343        })344        .then(function () {345            return driver.waitForElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.HorizontalScrollView/android.widget.LinearLayout/androidx.appcompat.app.a.b[2]/android.widget.TextView', asserters.isDisplayed && asserters.isEnabled, 2000);346        })347        .then(function (emailTab) {348            return emailTab.click();349        })350        .then(function () {351            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/a5x', asserters.isDisplayed && asserters.isEnabled, 2000);352        })353        .then(function (user) {354            return user.click()355        })356        .then(function () {357            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/a5x', asserters.isDisplayed && asserters.isEnabled, 2000);358        })359        .then(function (user) {360            console.log('sensing key')361            console.log(accounts[k].name)362            return user.sendKeys(accounts[k].name)363        })364        .then(function () {365            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/x6', asserters.isDisplayed && asserters.isEnabled, 2000);366        })367        .then(function (passInput) {368            return passInput.click();369        })370        .then(function () {371            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/x6', asserters.isDisplayed && asserters.isEnabled, 2000);372        })373        .then(function (passInput) {374            return passInput.sendKeys(accounts[k].pass);375        })376        .then(function () {377            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/aff', asserters.isDisplayed && asserters.isEnabled, 2000);378        })379        .then(function (connexionBtn) {380            return connexionBtn.click();381        })382         .then(function () {383         return driver.waitForElementById('com.zhiliaoapp.musically.go:id/a1x', asserters.isDisplayed && asserters.isEnabled, 2000);384         })385        .then(function() { return  setTimeout(follow1,5000)})386        .catch(function(e){387            console.log('--------------------------')388            if(e=='need_signout'){389                signOutLaunchFollow();390            }else{391                console.log(accounts)392                console.log(k)393                console.log(accounts[k])394                connexion()395            }396        })397        .done();398}399signOutLaunchFollow=()=>{400    driver401        .init(desiredCaps)402        .then(function(){403            //  return true;404            return driver.startActivity({appPackage: 'com.zhiliaoapp.musically.go',appActivity: 'com.ss.android.ugc.aweme.splash.SplashActivity'})405        })406        .then(function (){407            //profiles=await client.$('//*[contains(@resource-id, "com.zhiliaoapp.musically.go:id/akz")]')408            //await profiles.click()409            console.log('mlkmlk')410            //driver.execute("mobile: shell", {'command':'am start','args': ["-a", "android.intent.action.VIEW","-d","'https://www.tiktok.com/@elmonsifio' com.zhiliaoapp.musically"]});411            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/agu', asserters.isDisplayed && asserters.isEnabled, 3000);412        })413        .then(function (searchElement) {414            console.log('succes')415            return searchElement.click();416        })417        .then(function(){418            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/ai9', asserters.isDisplayed && asserters.isEnabled, 3000)419        })420        .then(function(menuBtn){421            return menuBtn.click()422        })423        .then(function(){424            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/b85', asserters.isDisplayed && asserters.isEnabled, 3000);425        })426        .then(async function(){427        action = await new wd.TouchAction(driver);428        return action.press({xx: 441, y: 1726}).wait(1000).moveTo({x: 430, y: 414}).release().perform();429    })430.then(function () {431        return driver.waitForElementById('com.zhiliaoapp.musically.go:id/ag6', asserters.isDisplayed && asserters.isEnabled, 3000);432    })433        .then(function (disconnectBtn) {434            return disconnectBtn.click();435        })436        .then(function () {437            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/apr', asserters.isDisplayed && asserters.isEnabled, 5000);438        })439        .then(function (validateSignOut) {440            return validateSignOut.click();441        })442        /*443         .then(function () {444         return driver.elementsByClassName('android.widget.TextView');445         })446         .then(function (search_results) {447         assert(search_results.length > 0);448         })*/449        .then(function() {  driver.quit(); return setTimeout(connexion,4000) })450        .catch(function(e){451            console.log('-----------signout---------------')452            signOutLaunchFollow()453        })454        .done();455}456signOut=()=>{457    driver458        .init(desiredCaps)459        .then(function(){460            //  return true;461            return driver.startActivity({appPackage: 'com.zhiliaoapp.musically.go',appActivity: 'com.ss.android.ugc.aweme.splash.SplashActivity'})462        })463        .then(function (){464            //profiles=await client.$('//*[contains(@resource-id, "com.zhiliaoapp.musically.go:id/akz")]')465            //await profiles.click()466            console.log('mlkmlk')467            //driver.execute("mobile: shell", {'command':'am start','args': ["-a", "android.intent.action.VIEW","-d","'https://www.tiktok.com/@elmonsifio' com.zhiliaoapp.musically"]});468            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/agu', asserters.isDisplayed && asserters.isEnabled, 3000);469        })470        .then(function (searchElement) {471            console.log('succes')472            return searchElement.click();473        })474        .then(function(){475            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/ai9', asserters.isDisplayed && asserters.isEnabled, 3000)476        })477        .then(function(menuBtn){478            return menuBtn.click()479        })480        .then(function(){481            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/b85', asserters.isDisplayed && asserters.isEnabled, 3000);482        })483        .then(async function(){484        action = await new wd.TouchAction(driver);485        return action.press({xx: 441, y: 1726}).wait(1000).moveTo({x: 430, y: 414}).release().perform();486    })487.then(function () {488        return driver.waitForElementById('com.zhiliaoapp.musically.go:id/ag6', asserters.isDisplayed && asserters.isEnabled, 3000);489    })490        .then(function (disconnectBtn) {491            return disconnectBtn.click();492        })493        .then(function () {494            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/apr', asserters.isDisplayed && asserters.isEnabled, 5000);495        })496        .then(function (validateSignOut) {497            return validateSignOut.click();498        })499        .then(function (){500        k++501        })502        /*503         .then(function () {504         return driver.elementsByClassName('android.widget.TextView');505         })506         .then(function (search_results) {507         assert(search_results.length > 0);508         })*/509        .then(function() {  driver.quit(); return setTimeout(main,5000) })510        .catch(function(e){511            console.log('-----------signout---------------')512            signOut()513        })514        .done();515}516autoDM=()=>{517    j=1;518    i=2519    driver520        .init(desiredCaps)521        .then(function(){522            //  return true;523            // return driver.startActivity({appPackage: 'com.zhiliaoapp.musically.go',appActivity: 'com.ss.android.ugc.aweme.splash.SplashActivity'})524            setTimeout(async function run() {525                if(j<160) {526                    profileName='';527                    driver.elementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/dmt.viewpager.DmtViewPager.d/android.widget.TabHost/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[1]/android.view.ViewGroup/android.widget.FrameLayout/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup["+i+"]", asserters.isDisplayed && asserters.isEnabled, 2000)528                        .then(function(newfollower){529                            return newfollower.click()530                        })531                        .then(function(){532                            return driver.waitForElementById('com.zhiliaoapp.musically.go:id/b3s',6000);533                        })534                        .then(function(messageBtn){535                            return messageBtn.click()536                        })537                        .then(async function(){538                        return driver.waitForElementById("com.zhiliaoapp.musically.go:id/amx",8000);539                    })540                .then(function (el2) {541                        return el2.click();542                    })543                        .then(function(){544                            return driver.elementById('com.zhiliaoapp.musically.go:id/bdl',6000);545                        })546                        .then(function(title){547                            return title.text()548                        })549                        .then(function(txt){550                            return profileName=txt551                        })552                        .then(async function(){553                        return driver.waitForElementById("com.zhiliaoapp.musically.go:id/amx",8000);554                    })555                .then(async function(el2){556                        return el2.sendKeys("hello "+profileName+", check my bio for live");557                    })558                .then(async function(){559                        return driver.waitForElementById("com.zhiliaoapp.musically.go:id/b3p",10000);560                    })561                .then(async function(send){562                        send.click();563                    })564                .then(async function(){565                        return driver.waitForElementByXPath("//android.widget.LinearLayout[@content-desc=\"Retour\"]/android.widget.ImageView",5000);566                    })567                .then(async function(back){568                        back.click();569                        i++;570                    })571                .then(async function(){572                        return driver.waitForElementById("com.zhiliaoapp.musically.go:id/hq",5000);573                    })574                .then(async function(backFromProfile){575                        backFromProfile.click();576                        i++;577                    }).catch(async(err)=>{578                        console.log(err)579                    action = new wd.TouchAction(driver);580                    action.press({xx: 441, y: 1726});581                    action.wait(600);582                    action.moveTo({x: 430, y: 414});583                    action.release();584                    await action.perform();585                    i=2;586                    //  driver.setImplicitWaitTimeout(5000);...basic.e2e.js
Source:basic.e2e.js  
...10  });11  afterEach(async () => driver.resetApp());12  afterAll(async () => driver.quit());13  it('check Search', async () => {                                                                   // ÐоиÑк14    expect(await driver.waitForElementById('openSearchInputID'));15    // console.log("ÐоиÑк еÑÑÑ")16    await driver.elementByAccessibilityId('openSearchInputID').click();17    // console.log("ÐоиÑк оÑкÑÑÑ")18    expect(await driver.waitForElementById('searchInput_TitleID'));19    // console.log("СÑÑока ввода еÑÑÑ")20    expect(await driver.waitForElementById('searchFocus_mainID'));21    // console.log("ÐÐ¾ÐºÐ¾Ð²Ð°Ñ Ð»Ñпа еÑÑÑ")22    expect(await driver.waitForElementById('search_closeID'));23    // console.log("ÐакÑÑÑие поиÑка еÑÑÑ")24    await driver.elementByAccessibilityId('searchInput_TitleID').type("CHF/JPY");25    expect(await driver.waitForElementById("CHF/JPYID"))26    // console.log("ÐÐ»ÐµÐ¼ÐµÐ½Ñ Ð½Ð°Ð¹Ð´ÐµÐ½")27    let element = await driver.elementByAccessibilityId("CHF/JPYFullNameID");28    let text = await element.text();29    // console.log(text);30    expect(text).toEqual('CHF/JPY');31    // console.log("ТекÑÑ ÑооÑвеÑÑÑвÑеÑ")32    await driver.elementByAccessibilityId('search_closeID').click();33  });34  it('check Autorization', async () => {                                                         //ÐойÑи в авÑоÑизаÑии35    expect(await driver.waitForElementById('ButtonMenuID'));36    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")37    await driver.elementByAccessibilityId('ButtonMenuID').click();38    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")39    expect(await driver.waitForElementById('LogInMenuID'));40    // console.log("ÐойÑи еÑÑÑ!")41    await driver.elementByAccessibilityId('LogInMenuID').click();42    // console.log("ÐойÑи оÑкÑÑÑо")43    expect(await driver.waitForElementById('LoginAuthorizationID'));44    // console.log("Ðоле логин еÑÑÑ!")45    expect(await driver.waitForElementById('PasswordInputAuthorizationID'));46    // console.log("Ðоле паÑÐ¾Ð»Ñ ÐµÑÑÑ!")47    await driver.elementByAccessibilityId('LoginAuthorizationID').type("testviktoriya@gmail.com");48    // console.log("Ðогин введÑн")49    await driver.elementByAccessibilityId('PasswordInputAuthorizationID').type("123qwe");50    // console.log("ÐаÑÐ¾Ð»Ñ Ð²Ð²ÐµÐ´Ñн")51    expect(await driver.waitForElementById('BtnShowPassAuthorizationID'));52    // console.log("СкÑÑÑÑ Ð¿Ð°ÑÐ¾Ð»Ñ ÐÑÑÑ")53    await driver.elementByAccessibilityId('BtnShowPassAuthorizationID').click();54    // console.log("ÐаÑÐ¾Ð»Ñ ÑкÑÑÑ!")55    await driver.elementByAccessibilityId('BtnShowPassAuthorizationID').click();56    // console.log("ÐаÑÐ¾Ð»Ñ Ð¿Ð¾ÐºÐ°Ð·Ð°Ð½")57    expect(await driver.waitForElementById('BtnLoginAuthorizationID'));58    // console.log('Ðнопка "ÐойÑи" еÑÑÑ')59    await driver.elementByAccessibilityId('BtnLoginAuthorizationID').click();60    // console.log("ÐвÑоÑизиÑовано")61    await driver.sleep(3000) // ÐоÑÑÑлÑ62    expect(await driver.waitForElementById('ButtonMenuID'));63    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")64    expect(await driver.waitForElementById('openSearchInputID'));65    // console.log("ÐоиÑк еÑÑÑ")66    expect(await driver.waitForElementById('TabTitleID'));67    // console.log("Ðаголовок еÑÑÑ")68    // ÐÑовеÑка popup69    let element = await driver.elementByAccessibilityId("TabTitleID");70    let text = await element.text();71    // console.log(text);72    expect(text).toEqual('ÐалÑÑÑ');73    // console.log("ТекÑÑ ÑооÑвеÑÑÑвÑеÑ")74  });75  it('check Autorization', async () => {                                                 //ÐÑÑ
од из авÑоÑизиÑованого полÑзоваÑелÑ76    expect(await driver.waitForElementById('ButtonMenuID'));77    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")78    await driver.elementByAccessibilityId('ButtonMenuID').click();79    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")80    expect(await driver.waitForElementById('LogInMenuID'));81    // console.log("ÐойÑи еÑÑÑ!")82    await driver.elementByAccessibilityId('LogInMenuID').click();83    // console.log("ÐойÑи оÑкÑÑÑо")84    expect(await driver.waitForElementById('LoginAuthorizationID'));85    // console.log("Ðоле логин еÑÑÑ!")86    expect(await driver.waitForElementById('PasswordInputAuthorizationID'));87    // console.log("Ðоле паÑÐ¾Ð»Ñ ÐµÑÑÑ!")88    await driver.elementByAccessibilityId('LoginAuthorizationID').type("testviktoriya@gmail.com");89    // console.log("Ðогин введÑн")90    await driver.elementByAccessibilityId('PasswordInputAuthorizationID').type("123qwe");91    // console.log("ÐаÑÐ¾Ð»Ñ Ð²Ð²ÐµÐ´Ñн")92    expect(await driver.waitForElementById('BtnShowPassAuthorizationID'));93    // console.log("СкÑÑÑÑ Ð¿Ð°ÑÐ¾Ð»Ñ ÐÑÑÑ")94    await driver.elementByAccessibilityId('BtnShowPassAuthorizationID').click();95    // console.log("ÐаÑÐ¾Ð»Ñ ÑкÑÑÑ!")96    await driver.elementByAccessibilityId('BtnShowPassAuthorizationID').click();97    // console.log("ÐаÑÐ¾Ð»Ñ Ð¿Ð¾ÐºÐ°Ð·Ð°Ð½")98    expect(await driver.waitForElementById('BtnLoginAuthorizationID'));99    // console.log('Ðнопка "ÐойÑи" еÑÑÑ')100    await driver.elementByAccessibilityId('BtnLoginAuthorizationID').click();101    // console.log("ÐвÑоÑизиÑовано")102    await driver.sleep(3000) // ÐоÑÑÑлÑ103    expect(await driver.waitForElementById('ButtonMenuID'));104    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")105    expect(await driver.waitForElementById('openSearchInputID'));106    // console.log("ÐоиÑк еÑÑÑ")107    expect(await driver.waitForElementById('TabTitleID'));108    // console.log("Ðаголовок еÑÑÑ")109    expect(await driver.waitForElementById('ButtonMenuID'));110    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")111    await driver.elementByAccessibilityId('ButtonMenuID').click();112    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")113    expect(await driver.waitForElementById('BtnExitMenuID'));114    // console.log("ÐÑÑ
од еÑÑÑ!")115    await driver.elementByAccessibilityId('BtnExitMenuID').click();116    // console.log("ÐÑÑ
од нажаÑо")117    expect(await driver.waitForElementById('BtnRegistrationPopupID'));118    // console.log("Ðнопка 'ÐÐ' еÑÑÑ!")119    await driver.elementByAccessibilityId('BtnRegistrationPopupID').click();120    // console.log("ÐÑйдено")121  });122  it('check Invalid data', async () => {                                                             // ÐÑовеÑка оÑибки окна ÐвÑоÑизаÑии123    expect(await driver.waitForElementById('ButtonMenuID'));124    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")125    await driver.elementByAccessibilityId('ButtonMenuID').click();126    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")127    expect(await driver.waitForElementById('BtnEnMenuID'));         // ÐеÑеклÑÑение на английÑкий128    // console.log("ÐеÑеклÑÑение на английÑкий ÑзÑк еÑÑÑ")129    await driver.elementByAccessibilityId('BtnEnMenuID').click();130    // console.log("ÐÑиложение на английÑком")131    expect(await driver.waitForElementById('LogInMenuID'));132    // console.log("ÐойÑи еÑÑÑ!")133    await driver.elementByAccessibilityId('LogInMenuID').click();134    // console.log("ÐойÑи оÑкÑÑÑо")135    expect(await driver.waitForElementById('LoginAuthorizationID'));136    // console.log("Ðоле логин еÑÑÑ!")137    expect(await driver.waitForElementById('PasswordInputAuthorizationID'));138    // console.log("Ðоле паÑÐ¾Ð»Ñ ÐµÑÑÑ!")139    await driver.elementByAccessibilityId('LoginAuthorizationID').type("testviktoriya@gmail.com");140    // console.log("Ðогин введÑн")141    await driver.elementByAccessibilityId('PasswordInputAuthorizationID').type("123qwerty");142    // console.log("ÐаÑÐ¾Ð»Ñ Ð²Ð²ÐµÐ´Ñн")143    expect(await driver.waitForElementById('BtnShowPassAuthorizationID'));144    // console.log("СкÑÑÑÑ Ð¿Ð°ÑÐ¾Ð»Ñ ÐÑÑÑ")145    await driver.elementByAccessibilityId('BtnShowPassAuthorizationID').click();146    // console.log("ÐаÑÐ¾Ð»Ñ ÑкÑÑÑ!")147    await driver.elementByAccessibilityId('BtnShowPassAuthorizationID').click();148    // console.log("ÐаÑÐ¾Ð»Ñ Ð¿Ð¾ÐºÐ°Ð·Ð°Ð½")149    expect(await driver.waitForElementById('BtnLoginAuthorizationID'));150    // console.log('Ðнопка "ÐойÑи" еÑÑÑ')151    await driver.elementByAccessibilityId('BtnLoginAuthorizationID').click();152    expect(await driver.waitForElementById('AuthorizationBtnId'));153    // console.log('ÐÑибка валидаÑÐ¸Ñ Ð¿Ð¾ÐºÐ°Ð·Ð°Ð½Ð°')154    // ÐÑовеÑка popup155    let element = await driver.elementByAccessibilityId("AuthorizationTextId");156    let text = await element.text();157    // console.log(text);158    expect(text).toEqual('Incorrect email address or password.');159    // console.log("ТекÑÑ ÑооÑвеÑÑÑвÑеÑ")160    await driver.elementByAccessibilityId('AuthorizationBtnId').click();161    // console.log("ÐÑибка ÑкÑÑÑа")162  });163  it('check Validation Autorization', async () => {                                  //  ÐÑовеÑка валидаÑии авÑоÑизаÑии164    expect(await driver.waitForElementById('ButtonMenuID'));165    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")166    await driver.elementByAccessibilityId('ButtonMenuID').click();167    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")168    expect(await driver.waitForElementById('BtnEnMenuID'));         // ÐеÑеклÑÑение на английÑкий169    // console.log("ÐеÑеклÑÑение на английÑкий ÑзÑк еÑÑÑ")170    await driver.elementByAccessibilityId('BtnEnMenuID').click();171    // console.log("ÐÑиложение на английÑком")172    expect(await driver.waitForElementById('LogInMenuID'));173    // console.log("ÐойÑи еÑÑÑ!")174    await driver.elementByAccessibilityId('LogInMenuID').click();175    // console.log("ÐойÑи оÑкÑÑÑо")176    expect(await driver.waitForElementById('LoginAuthorizationID'));177    // console.log("Ðоле логин еÑÑÑ!")178    expect(await driver.waitForElementById('PasswordInputAuthorizationID'));179    // console.log("Ðоле паÑÐ¾Ð»Ñ ÐµÑÑÑ!")180    await driver.elementByAccessibilityId('LoginAuthorizationID').type("123");181    // console.log("Ðогин введÑн")182    await driver.elementByAccessibilityId('PasswordInputAuthorizationID').type("123");183    // console.log("ÐаÑÐ¾Ð»Ñ Ð²Ð²ÐµÐ´Ñн")184    expect(await driver.waitForElementById('LoginErrorAuthorizationID'));185    // console.log("ÐÑибка логина еÑÑÑ")186    await driver.elementByAccessibilityId('BtnShowPassAuthorizationID').click();187    expect(await driver.waitForElementById('PasswordInputAuthorizationID'));188    // console.log("ÐÑибка паÑÐ¾Ð»Ñ ÐµÑÑÑ")189    await driver.elementByAccessibilityId('LoginAuthorizationID').click();190    let LogInError = await driver.elementByAccessibilityId("LoginErrorAuthorizationID");    // ÐÑовеÑка popup191    let textLogIn = await LogInError.text();192    // console.log(textLogIn);193    expect(textLogIn).toEqual('Email-entry error');194    // console.log("ТекÑÑ ÑооÑвеÑÑÑвÑеÑ")    195    let PasswordError = await driver.elementByAccessibilityId("PasswordErrorAuthorizationID");  //ÐÑовека popup196    let textPassword = await PasswordError.text();197    // console.log(textPassword);198    expect(textPassword).toEqual('Password failed');199    // console.log("ТекÑÑ ÑооÑвеÑÑÑвÑеÑ")200    // console.log("ÐалидаÑÐ¸Ñ ÑабоÑаеÑ")201  });202  it('check Registration', async () => {                                           // РегиÑÑÑаÑÐ¸Ñ Ñ ÑÑÑеÑÑвÑÑÑей поÑÑой         203    await driver.sleep(5000)204    expect(await driver.waitForElementById('ButtonMenuID'));205    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")206    await driver.elementByAccessibilityId('ButtonMenuID').click();207    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")208    expect(await driver.waitForElementById('LogInMenuID'));209    // console.log("ÐойÑи еÑÑÑ!")210    expect(await driver.waitForElementById('BtnEnMenuID'));         // ÐеÑеклÑÑение на английÑкий211    // console.log("ÐеÑеклÑÑение на английÑкий ÑзÑк еÑÑÑ")212    await driver.elementByAccessibilityId('BtnEnMenuID').click();213    // console.log("ÐÑиложение на английÑком")214    await driver.elementByAccessibilityId('LogInMenuID').click();215    // console.log("ÐойÑи оÑкÑÑÑо")216    expect(await driver.waitForElementById('BtnRegistrationAuthorizationID'));217    // console.log("ÐаÑегеÑÑÑиÑоваÑÑÑÑ ÐµÑÑÑ!")218    await driver.elementByAccessibilityId('BtnRegistrationAuthorizationID').click();219    // console.log("ÐолÑзоваÑÐµÐ»Ñ Ð² Ð¼ÐµÐ½Ñ ÑегиÑÑÑаÑии")220    expect(await driver.waitForElementById('InputFirstNameRegistrationID'));   //ÐмÑ221    // console.log("СÑÑока ÐÐ¼Ñ ÐµÑÑÑ")222    expect(await driver.waitForElementById('InputLastNameRegistrationID'));   // ФамилиÑ223    // console.log("СÑÑока Ð¤Ð°Ð¼Ð¸Ð»Ð¸Ñ ÐµÑÑÑ")224    expect(await driver.waitForElementById('InputEmailRegistrationID'));     // ÐоÑÑа225    // console.log("СÑÑока E-mail еÑÑÑ")226    expect(await driver.waitForElementById('BtnCountryListRegistrationID'));  // СÑÑана227    // console.log("СÑÑÐ°Ð½Ñ  еÑÑÑ")228    expect(await driver.waitForElementById('InputPhoneRegistrationID'));    // ТелеÑон229    // console.log("Ðвод ÑелеÑона еÑÑÑ")230    await driver.elementByAccessibilityId('BtnCountryListRegistrationID').click();231    // console.log("Ð Ð¼ÐµÐ½Ñ Ð²ÑбоÑа ÑÑÑанÑ")232    await driver.sleep(3000) //коÑÑÑлÑ233    await driver.elementByAccessibilityId('SearchInputCountryID').click();234    await driver.elementByAccessibilityId('SearchInputCountryID').type("russ");235    expect(await driver.waitForElementById('RUID'));236    await driver.elementByAccessibilityId('RUID').click();237    // console.log("РоÑÑÐ¸Ñ ÐµÑÑÑ")238    await driver.sleep(3000) //коÑÑÑлÑ239    // console.log(" ÐÑÐ±Ð¾Ñ ÑÑÑÐ°Ð½Ñ = РоÑÑиÑ")240    await driver.elementByAccessibilityId('InputFirstNameRegistrationID').type("Barak");241    await driver.elementByAccessibilityId('InputLastNameRegistrationID').type("O'Bama");242    await driver.elementByAccessibilityId('InputEmailRegistrationID').type("test-rn-qfx@gmail.com");243    driver.hideKeyboard();244    await driver.elementByAccessibilityId('InputPhoneRegistrationID').type("14881488");245    driver.hideKeyboard();246    // console.log("ÐаÑегеÑÑÑиÑовано еÑÑÑ")247    expect(await driver.waitForElementById('BtnCheckBoxRegistrationID'));248    await driver.elementByAccessibilityId('BtnCheckBoxRegistrationID').click();249    expect(await driver.waitForElementById('BtnRegistrationInRegistrationID'));250    // console.log("Ðнопка ÐаÑегеÑÑÑиÑоваÑÑÑÑ ÐµÑÑÑ")251    await driver.elementByAccessibilityId('BtnRegistrationInRegistrationID').click();252    let RegPopup = await driver.elementByAccessibilityId("RegistrationTextId");     // РегиÑÑÑаÑÐ¸Ñ Ñ Ð¾Ð´Ð½Ð¾Ð¹ и Ñой же поÑÑой бÑÐ´ÐµÑ Ð²ÑдаваÑÑ Ð¾ÑибкÑ253    let textPopup = await RegPopup.text();254    // console.log(textPopup);255    expect(textPopup).toEqual('Unfortunately, the account with this email already exists.');256    // console.log("ТекÑÑ ÑооÑвеÑÑÑÑеÑ")257    expect(await driver.waitForElementById('RegistrationBtnId'));258    // console.log("Popup о Ñом ÑÑо ÑÐ°ÐºÐ°Ñ Ð¿Ð¾ÑÑа Ñже еÑÑÑ Ð¿Ð¾ÑвилÑÑ")259    await driver.elementByAccessibilityId('RegistrationBtnId').click()260  });261  it('check Registration ÐÑÑÑÑе полÑ', async () => {                                                 // ÐалидаÑÐ¸Ñ ÑегиÑÑÑаÑии262    expect(await driver.waitForElementById('ButtonMenuID'));263    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")264    await driver.elementByAccessibilityId('ButtonMenuID').click();265    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")266    expect(await driver.waitForElementById('BtnEnMenuID'));267    // console.log("ÐеÑеклÑÑение на английÑкий ÑзÑк еÑÑÑ")268    await driver.elementByAccessibilityId('BtnEnMenuID').click();269    // console.log("ÐÑиложение на английÑком")270    expect(await driver.waitForElementById('LogInMenuID'));271    // console.log("ÐойÑи еÑÑÑ!")272    await driver.elementByAccessibilityId('LogInMenuID').click();273    // console.log("ÐойÑи оÑкÑÑÑо")274    expect(await driver.waitForElementById('BtnRegistrationAuthorizationID'));275    // console.log("ÐаÑегеÑÑÑиÑоваÑÑÑÑ ÐµÑÑÑ!")276    await driver.elementByAccessibilityId('BtnRegistrationAuthorizationID').click();277    // console.log("ÐолÑзоваÑÐµÐ»Ñ Ð² Ð¼ÐµÐ½Ñ ÑегиÑÑÑаÑии")278    expect(await driver.waitForElementById('InputFirstNameRegistrationID'));   //ÐмÑ279    // console.log("СÑÑока ÐÐ¼Ñ ÐµÑÑÑ")280    expect(await driver.waitForElementById('InputLastNameRegistrationID'));   // ФамилиÑ281    // console.log("СÑÑока Ð¤Ð°Ð¼Ð¸Ð»Ð¸Ñ ÐµÑÑÑ")282    expect(await driver.waitForElementById('InputEmailRegistrationID'));     // ÐоÑÑа283    // console.log("СÑÑока E-mail еÑÑÑ")284    expect(await driver.waitForElementById('BtnCountryListRegistrationID'));  // СÑÑана285    // console.log("СÑÑÐ°Ð½Ñ  еÑÑÑ")286    expect(await driver.waitForElementById('InputPhoneRegistrationID'));    // ТелеÑон287    await driver.elementByAccessibilityId('InputFirstNameRegistrationID').type("$");288    await driver.elementByAccessibilityId('InputLastNameRegistrationID').type("$");289    await driver.elementByAccessibilityId('InputEmailRegistrationID').type("barak_obama$prisident.cherniy");290    driver.hideKeyboard();291    await driver.elementByAccessibilityId('InputPhoneRegistrationID').type(";");292    driver.hideKeyboard();293    await driver.elementByAccessibilityId('BtnRegistrationInRegistrationID').click();294    expect(await driver.waitForElementById('FirstNameErrorRegostrationID'))295    expect(await driver.waitForElementById('LastNameErrorRegostrationID'))296    expect(await driver.waitForElementById('EmailErrorRegostrationID'))297    expect(await driver.waitForElementById('PasswordErrorRegistrationID'))298    // console.log("ÐÑе оÑибки поÑвилиÑÑ")299    let FirstNameError = await driver.elementByAccessibilityId("FirstNameErrorRegostrationID"); // ÐÑовеÑка оÑибки в Ðоле "ÐмÑ"300    let textFirstName = await FirstNameError.text();301    // console.log(textFirstName);302    expect(textFirstName).toEqual('Name-entry error');303    // console.log("ÐалидаÑÐ¸Ñ Ð¿Ð¾Ð»Ñ 'ÐмÑ' еÑÑÑ")304    let LastNameError = await driver.elementByAccessibilityId("LastNameErrorRegostrationID"); // ÐÑовеÑка оÑибки в Ðоле "ФамилиÑ"305    let textLastName = await LastNameError.text();306    // console.log(textLastName);307    expect(textLastName).toEqual('Last name-entry error');308    // console.log("ÐалидаÑÐ¸Ñ Ð¿Ð¾Ð»Ñ 'ФамилиÑ' еÑÑÑ")309    let emailError = await driver.elementByAccessibilityId("EmailErrorRegostrationID"); // ÐÑовеÑка оÑибки в Ðоле "ÐоÑÑа"310    let textEmail = await emailError.text();311    // console.log(textEmail);312    expect(textEmail).toEqual('Email-entry error');313    // console.log("ÐалидаÑÐ¸Ñ Ð¿Ð¾Ð»Ñ 'Email' еÑÑÑ")314    let TelError = await driver.elementByAccessibilityId("PasswordErrorRegistrationID");           // ÐÑовеÑка оÑибки в Ðоле "ÐаÑолÑ"315    let textTel = await TelError.text();316    // console.log(textTel);317    expect(textTel).toEqual('Invalid phone number');318    // console.log("ÐалидаÑÐ¸Ñ Ð¿Ð¾Ð»Ñ 'ТелеÑона' еÑÑÑ")319  });320  it('check Password recovery', async () => {                                                   // ÐоÑÑÑановлеине паÑолÑ321    expect(await driver.waitForElementById('ButtonMenuID'));322    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")323    await driver.elementByAccessibilityId('ButtonMenuID').click();324    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")325    expect(await driver.waitForElementById('BtnEnMenuID'));   // ÐеÑеклÑÑение на английÑкий326    // console.log("ÐеÑеклÑÑение на английÑкий ÑзÑк еÑÑÑ")327    await driver.elementByAccessibilityId('BtnEnMenuID').click();328    // console.log("ÐÑиложение на английÑком")329    expect(await driver.waitForElementById('LogInMenuID'));330    // console.log("ÐойÑи еÑÑÑ!")331    await driver.elementByAccessibilityId('LogInMenuID').click();332    // console.log("ÐойÑи оÑкÑÑÑо")333    expect(await driver.waitForElementById('ForgotPasswordAuthorizationID'));334    // console.log("ÐабÑли паÑÐ¾Ð»Ñ ÐµÑÑÑ!")335    await driver.elementByAccessibilityId('ForgotPasswordAuthorizationID').click();336    // console.log("Ðкно воÑÑÑÐ½Ð°Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ Ð¾ÑкÑÑÑо")337    expect(await driver.waitForElementById('ForgotPasswordInputID'));338    // console.log("СÑÑока ввода поÑÑÑ ÐµÑÑÑ!")339    await driver.elementByAccessibilityId('ForgotPasswordInputID').type("testviktoriya@gmail.com");340    driver.hideKeyboard();341    await driver.elementByAccessibilityId('ForgotPasswordSubmitID').click();342    await driver.elementByAccessibilityId('ForgotPasswordSubmitID').click();343    expect(await driver.waitForElementById('BtnForgotPasswordPopUpID'));344    // console.log("Popup поÑвилÑÑ")345    let RecPopup = await driver.elementByAccessibilityId("TextRecoveryPopupID");     // ÐÑовеÑка popup 346    let textPopup = await RecPopup.text();  347    // console.log(textPopup);348    expect(textPopup).toEqual("Instructions\n\r for password recovery have been sent to the user's email");349    // console.log("ТекÑÑ ÑооÑвеÑÑÑÑеÑ")350    await driver.elementByAccessibilityId('BtnForgotPasswordPopUpID').click()351    expect(await driver.waitForElementById('LoginAuthorizationID'));  // ÐеÑекидÑвание на поле авÑоÑизаÑии352    // console.log("Ðоле логин еÑÑÑ!")353    expect(await driver.waitForElementById('PasswordInputAuthorizationID'));354    // console.log("Ðоле паÑÐ¾Ð»Ñ ÐµÑÑÑ!")355    // console.log("ÐоÑÑÑановление паÑÐ¾Ð»Ñ ÑÑабоÑало ÑÑпеÑно")356  });357  it('check Password recovery non valid', async () => {                                                   // Ðевалидное воÑÑÑановлеин паÑолÑ358    expect(await driver.waitForElementById('ButtonMenuID'));359    // console.log("ÐÐµÐ½Ñ ÐµÑÑÑ!")360    await driver.elementByAccessibilityId('ButtonMenuID').click();361    // console.log("ÐÐµÐ½Ñ Ð¾ÑкÑÑÑо")362    expect(await driver.waitForElementById('BtnEnMenuID'));363    // console.log("ÐеÑеклÑÑение на английÑкий ÑзÑк еÑÑÑ")364    await driver.elementByAccessibilityId('BtnEnMenuID').click();365    // console.log("ÐÑиложение на английÑком")366    expect(await driver.waitForElementById('LogInMenuID'));367    // console.log("ÐойÑи еÑÑÑ!")368    await driver.elementByAccessibilityId('LogInMenuID').click();369    // console.log("ÐойÑи оÑкÑÑÑо")370    expect(await driver.waitForElementById('ForgotPasswordAuthorizationID'));371    // console.log("ÐабÑли паÑÐ¾Ð»Ñ ÐµÑÑÑ!")372    await driver.elementByAccessibilityId('ForgotPasswordAuthorizationID').click();373    // console.log("Ðкно воÑÑÑÐ½Ð°Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ Ð¾ÑкÑÑÑо")374    expect(await driver.waitForElementById('ForgotPasswordInputID'));375    // console.log("СÑÑока ввода поÑÑÑ ÐµÑÑÑ!")376    await driver.elementByAccessibilityId('ForgotPasswordInputID').type("nevalidnii@gmail.com");377    driver.hideKeyboard();378    await driver.elementByAccessibilityId('ForgotPasswordSubmitID').click();379    await driver.elementByAccessibilityId('ForgotPasswordSubmitID').click();380    expect(await driver.waitForElementById('ForgotPasswordBtnId'));381    // console.log("Popup поÑвилÑÑ")382    let element = await driver.elementByAccessibilityId("ForgotPasswordTextId"); // ÐÑовеÑка popup383    let textError = await element.text();384    // console.log(textError);385    expect(textError).toEqual('Incorrect email address.');386    // console.log("ÐÑибка ÑооÑвеÑÑÑвÑеÑ")387    await driver.elementByAccessibilityId('ForgotPasswordBtnId').click();388  });389  it('check Minimize all open charts', async () => {                                                   // СвеÑнÑÑÑ Ð²Ñе окна390    expect(await driver.waitForElementById('AUD/CADID'));391    expect(await driver.waitForElementById('AUD/CHFID'));392    expect(await driver.waitForElementById('AUD/JPYID'));393    expect(await driver.waitForElementById('AUD/NZDID'));394    expect(await driver.waitForElementById('AUD/USDID'));395    await driver.elementByAccessibilityId('AUD/CADID').click();396    await driver.elementByAccessibilityId('AUD/CHFID').click();397    await driver.elementByAccessibilityId('AUD/JPYID').click();398    // console.log("ÐÑкÑÑÑÑ ÑÑейки")399    await driver.elementByAccessibilityId('ButtonMenuID').click();400    // console.log("РменÑ")401    await driver.elementByAccessibilityId('BtnTurnAll').click();402    // console.log("СкÑÑÑÑ ÑÑейки")403    driver.back();404    expect(await driver.waitForElementById('AUD/CADID'));405    expect(await driver.waitForElementById('AUD/CHFID'));406    expect(await driver.waitForElementById('AUD/JPYID'));407    expect(await driver.waitForElementById('AUD/NZDID'));408    expect(await driver.waitForElementById('AUD/USDID'));409  });...viettel-pay.js
Source:viettel-pay.js  
...17  const id_btn_start = 'com.bplus.vtpay:id/btn_start';18  const id_btn_accept = 'com.bplus.vtpay:id/accept';19  const check_btn_start = await driver.hasElementById(id_btn_start);20  if (check_btn_start) {21    const btn_start = await driver.waitForElementById(id_btn_start, 5000);22    await btn_start.click();23    const accept = await driver.waitForElementById(id_btn_accept, 5000);24    await accept.click();25  }26}27// Kiá»m tra có thông báo hiá»n lên không28async function checkNotification() {29  const id_md_button_default_positive =30    'com.bplus.vtpay:id/md_buttonDefaultPositive';31  await driver.sleep(2000);32  const check_md_button_default_positive = await driver.hasElementById(33    id_md_button_default_positive34  );35  if (check_md_button_default_positive) {36    const md_button_default_positive = await driver.waitForElementById(37      id_md_button_default_positive,38      500039    );40    await md_button_default_positive.click();41  }42}43// ÄÄng nháºp vào và viettelpay44async function login() {45  await checkPolicy();46  const id_input_phone_number = 'com.bplus.vtpay:id/edt_phone_number';47  const input_phone_number = await driver.waitForElementById(48    id_input_phone_number,49    3000050  );51  await input_phone_number.sendKeys(phoneNumber);52  const id_input_password = 'com.bplus.vtpay:id/edt_password';53  const input_password = await driver.waitForElementById(id_input_password);54  await input_password.sendKeys(passLogin);55  await driver.sleep(3000);56  // sai máºt khẩu57  const xpath_md_content = '';58  const id_md_content = 'com.bplus.vtpay:id/md_content';59  const check_md_content = await driver.elementByIdIfExists(id_md_content);60  if (check_md_content) {61    const get_notice = await check_md_content.getAttribute('text');62    if (get_notice.includes('sai máºt khẩu')) {63      await checkNotification();64      return get_notice;65    }66  }67  // tài khoản không tá»n tại68  const id_content = 'com.bplus.vtpay:id/content';69  const check_content = await driver.elementByIdIfExists(id_content);70  if (check_content) {71    const get_notice = await check_content.getAttribute('text');72    if (check_content.includes('chưa ÄÄng dá»ch vụ')) {73      const id_cancel_btn = 'com.bplus.vtpay:id/cancel_btn';74      await driver.waitForElementById(id_cancel_btn, 5000).click();75      return get_notice;76    }77  }78  await checkNotification();79  return 'success';80}81async function logout() {82  const id_profile = 'com.bplus.vtpay:id/menu_title_5';83  const profile = await driver.waitForElementById(id_profile, 5000);84  await profile.click();85  const xpath_logout = '//android.widget.TextView[contains(@text,"ÄÄng xuất")]';86  const logout = await driver.waitForElementByXPath(xpath_logout, 5000);87  await logout.click();88  await checkNotification();89  const id_login_register = 'com.bplus.vtpay:id/login_register';90  const login_register = await driver.waitForElementById(91    id_login_register,92    500093  );94  await login_register.click();95  return 'logout success';96}97// Kiá»m tra sá» dư trong vÃ98async function getBalance() {99  let get_balance = '';100  const money = await driver.waitForElementById(101    'com.bplus.vtpay:id/login_register',102    5000103  );104  get_balance = await money.getAttribute('text');105  if (get_balance === '******') {106    const view_money = await driver.waitForElementById(107      'com.bplus.vtpay:id/view_money',108      5000109    );110    await view_money.click();111  }112  await driver.sleep(2000);113  get_balance = await money.getAttribute('text');114  return get_balance;115}116async function checkBTN(xpath_btn, id_btn) {117  await driver.sleep(2000);118  const check_btn = await driver.hasElementById(id_btn);119  if (check_btn) {120    const element_btn = await driver.waitForElementById(id_btn, 5000);121    element_btn.click();122  }123}124// Nạp tiá»n125async function recharge(data) {126  const xpath_choose_recharge =127    '//android.widget.TextView[contains(@text,"Nạp ÄT")]';128  const choose_recharge = await driver.waitForElementByXPath(129    xpath_choose_recharge,130    5000131  );132  await choose_recharge.click();133  // Äiá»u lá»134  await checkBTN(135    '//android.widget.Button[contains(@text,"TÃI Äà HIá»U")]',136    'com.bplus.vtpay:id/btn_understend'137  );138  // Quyá»n kết ná»i tá»i danh bạ139  await checkBTN(140    '//android.widget.Button[contains(@text,"ALLOW")]',141    'com.android.packageinstaller:id/permission_allow_button'142  );143  const id_edt_phone = 'com.bplus.vtpay:id/edt_phone';144  const input_edt_phone = await driver.waitForElementById(id_edt_phone, 5000);145  await input_edt_phone.sendKeys(data.receiver);146  const id_edt_amount = 'com.bplus.vtpay:id/edt_amount';147  const input_edt_amount = await driver.waitForElementById(id_edt_amount);148  await input_edt_amount.sendKeys(data.amount);149  const id_tv_send = 'com.bplus.vtpay:id/tv_send';150  const btn_tv_send = await driver.waitForElementById(id_tv_send);151  await btn_tv_send.click();152  const id_btn_confirm = 'com.bplus.vtpay:id/btn_confirm';153  const btn_confirm = await driver.waitForElementById(id_btn_confirm, 5000);154  await btn_confirm.click();155  const arr_password = passLogin.split('');156  for (let i of arr_password) {157    const btn_number = await driver.waitForElementById(158      `com.bplus.vtpay:id/btn_${i}`,159      5000160    );161    await btn_number.click();162  }163  await driver.sleep(3000);164  const id_content = 'com.bplus.vtpay:id/content';165  const check_content = await driver.elementByIdIfExists(id_content);166  if (check_content) {167    const get_notice = await check_content.getAttribute('text');168    if (check_content.includes('phiên làm viá»c')) {169      const id_confirm_btn = 'com.bplus.vtpay:id/confirm_btn';170      await driver.waitForElementById(id_confirm_btn, 5000).click();171      return get_notice;172    }173  }174  // sai máºt khẩu175  const id_md_content = 'com.bplus.vtpay:id/md_content';176  const check_md_content = await driver.elementByIdIfExists(id_md_content);177  if (check_md_content) {178    const get_notice = await check_md_content.getAttribute('text');179    if (get_notice.includes('sai máºt khẩu')) {180      await checkNotification();181      return get_notice;182    }183  }184  return 'success';185}186async function goBackHome() {187  const id_btn_go_home = 'com.bplus.vtpay:id/btn_go_home';188  const btn_back_home = await driver.waitForElementById(id_btn_go_home, 5000);189  await btn_back_home.click();190}191// Lấy OTP192async function getOTP(otp) {193  // const id_tv_resend = 'com.bplus.vtpay:id/tv_resend';194  // const tv_resend = await driver.elementByIdIfExists(id_tv_resend);195  // console.log('tv_resend', tv_resend);196  // if (tv_resend) {197  //   await tv_resend.click();198  //   return 'Get OTP Again';199  // }200  const input_otp = await driver.waitForElementById(201    'com.bplus.vtpay:id/edt_name',202    5000203  );204  await input_otp.sendKeys(otp);205  const btn_confirm = await driver.waitForElementById(206    'com.bplus.vtpay:id/btn_continue',207    5000208  );209  await btn_confirm.click();210  await goBackHome();211  await checkNotification();212  return 'Get OTP Success';213}214// API ÄÄng nháºp215app.get('/login', async (req, res) => {216  try {217    console.log('login');218    const result = await login();219    res.send({ status: 'success', message: 'ÄÄng nháºp thành công' });...elements.js
Source:elements.js  
...6const elementByIdAndClickAndTest = async (id, waitForElementId, testLabel, back) => {7  id = `${testIDResourceID}${id}`8  const driver = getDriver()9  logTestInfo(logKeyStart, id, testLabel)10  await driver.waitForElementById(id, 10000)11  const element = await driver.elementById(id)12  await element.click()13  await driver.waitForElementById(waitForElementId, 10000)14  if (back) await driver.back()15  logTestInfo(logKeyEnd, id, testLabel)16}17const elementByIdClick = async (id, testLabel, back) => {18  id = `${testIDResourceID}${id}`19  const driver = getDriver()20  logTestInfo(logKeyStart, id, testLabel)21  await driver.waitForElementById(id, 10000)22  const element = await driver.elementById(id)23  await element.click()24  if (back) await driver.back()25  logTestInfo(logKeyEnd, id, testLabel)26}27const elementCheckIfPresent = async (id, testLabel) => {28  id = `${testIDResourceID}${id}`29  const driver = getDriver()30  logTestInfo(logKeyStart, id, testLabel)31  // elementById throws an error if it cannot find a matching element32  await driver.elementById(id)33  logTestInfo(logKeyEnd, id, testLabel)34}35const elementCheckIfNotPresent = async (id, testLabel) => {36  id = `${testIDResourceID}${id}`37  const driver = getDriver()38  logTestInfo(logKeyStart, id, testLabel)39  let shouldPass = false40  try {41    // elementById throws an error if it cannot find a matching element42    await driver.elementById(id)43  } catch (error) {44    // If the element was not found, then this check has passed.45    shouldPass = true46  }47  if (!shouldPass) {48    throw new Error(`Element found when it should not be present: ${id}`)49  }50  logTestInfo(logKeyEnd, id, testLabel)51}52const elementWaitFor = async (id, testLabel) => {53  id = `${testIDResourceID}${id}`54  const driver = getDriver()55  logTestInfo(logKeyStart, id, testLabel)56  await driver.waitForElementById(id, 10000)57  logTestInfo(logKeyEnd, id, testLabel)58}59const elementByIdToggle = async (id, testLabel) => {60  id = `${testIDResourceID}${id}`61  const driver = getDriver()62  logTestInfo(logKeyStart, id, testLabel)63  await driver.waitForElementById(id, 10000)64  const element = await driver.elementById(id)65  await element.click()66  await driver.sleep(1000)67  await element.click()68  logTestInfo(logKeyEnd, id, testLabel)69}70const elementByIdHasText = async (id, text, testLabel) => {71  if (!testLabel) {72    testLabel = id + ', "' + text + '" '73  }74  const label = `${testLabel}: text check`75  id = `${testIDResourceID}${id}`76  const driver = getDriver()77  logTestInfo(logKeyStart, id, label)78  await driver.waitForElementById(id, 10000)79  const element = await driver.elementById(id)80  const actualText = await element.text()81  if (text !== actualText) {82    throw new Error(`83      Error: Text not found.84      Expected: ${text}85      Actual: ${actualText}86    `)87  }88  logTestInfo(logKeyEnd, id, label)89}90const elementByIdGetText = async (id, testLabel) => {91  if (!testLabel) {92    testLabel = id + ', "' 93  }94  const label = `${testLabel}: text check`95  id = `${testIDResourceID}${id}`96  const driver = getDriver()97  logTestInfo(logKeyStart, id, label)98  await driver.waitForElementById(id, 10000)99  const element = await driver.elementById(id)100  const actualText = await element.text()101  logTestInfo(logKeyEnd, id, label)102  return actualText103}104module.exports = {105  elementByIdAndClickAndTest,106  elementByIdClick,107  elementCheckIfNotPresent,108  elementCheckIfPresent,109  elementWaitFor,110  elementByIdToggle,111  elementByIdHasText,112  elementByIdGetText,...PageObjectApp.js
Source:PageObjectApp.js  
...6  clickByAccessibilityId(ele) {7    return driver.waitForElementByAccessibilityId(ele, 20000, `${ele} is not clickable`).elementByAccessibilityId(ele).click();8  }9  clickById(ele) {10    return driver.waitForElementById(ele, 20000, `${ele} is not clickable`).elementById(ele).click();11  }12  clickByXPath(ele) {13    return driver.waitForElementByXPath(ele, 20000, `${ele} is not clickable`).elementByXPath(ele).click();14  }15  // * Element displayed16  elementDisplayedById(ele) {17    return driver.waitForElementById(ele, 20000, `${ele} is not displayed`).elementById(ele).isDisplayed();18  }19  elementDisplayedByAccessibilityId(ele) {20    return driver.waitForElementByAccessibilityId(ele, 20000, `${ele} is not displayed`).elementByAccessibilityId(ele).isDisplayed();21  }22  elementDisplayedByXPath(ele) {23    return driver.waitForElementByXPath(ele, 20000, `${ele} is not displayed`).elementByXPath(ele).isDisplayed();24  }25  // Move to down26  moveTo(ele, dir) {27    return driver.moveToElement(ele, dir);28  }29  moveToExecuteUP() {30    return driver.execute('mobile: scroll', { direction: 'up' });31  }32  moveToExecuteDown() {33    return driver.execute('mobile: scroll', { direction: 'down' });34  }35  // Get attribute36  getAttributeByXPath(ele, att) {37    return driver.waitForElementByXPath(ele, 10000).elementByXPath(ele).getAttribute(att);38  }39  getAttributeById(ele, att) {40    return driver.waitForElementById(ele, 20000).elementById(ele).getAttribute(att);41  }42  getAttributeByAccessibilityId(ele, att) {43    return driver.waitForElementByAccessibilityId(ele, 20000).elementByAccessibilityId(ele).getAttribute(att);44  }45  // Fill text46  fillTextByAccessibilityId(ele, text) {47    return driver.waitForElementByAccessibilityId(ele, 20000).elementByAccessibilityId(ele).click().clean(ele).sendKeys(text).hideKeyboardTouch();48  }49  fillTextById(ele, text) {50    return driver.waitForElementById(ele, 40000).elementById(ele).click().clean(ele).sendKeys(text).hideKeyboardTouch();51  }52  async fillTextByXPath(ele, text) {53    await driver.waitForElementByXPath(ele, 10000).elementByXPath(ele).click().clean(ele).sendKeys(text);54    return driver.hideKeyboardTouch();55  }56  //Element Exist57  exist(ele, css) {58    return driver.elementExist(ele, css);59  }60  //Get elements61  getElementsByXPath(ele) {62    return driver.elementsByXPath(ele);63  }64  getElementsById(ele) {...IOS.js
Source:IOS.js  
...20async function iOStest(){21try {22driver.init(desired_capabilities)23.then(function(){24    return driver.waitForElementById('color',10000)25})26.then(function(color){27    return color.click();28})29.then(function(){30    return driver.waitForElementById('Text',10000)31})32.then(function(text){33    text.click()34    return driver.waitForElementById('toast',10000)35})36.then(function(toast){37    toast.click()38    return driver.waitForElementById('notification',10000)39})40.then(function(notification){41    notification.click()42    return driver.waitForElementById('geoLocation',10000)43})44.then(function(geoLocation){45    return geoLocation.click()46})47.then(async function(){48    return driver.waitForElementById('Back',10000)49})50.then(function(Back){51    Back.click()52    return driver.waitForElementById('speedTest',10000)53})54.then(async function(speedTest){55    speedTest.click()56    return driver.waitForElementById('Back',10000)57})58.then(function(back){59    back.click()60    return driver.waitForElementById('Browser',10000)61})62.then(function(Browser){63    Browser.click()64    return driver.waitForElementById('url',10000)65})66.then(function(url){67    url.type("https://www.lambdatest.com")68    return driver.waitForElementById('find',10000)69})70.then(function(find){71    find.click()72    driver.quit()73})74}75catch (e) {76    driver.quit()77}78}...Android.js
Source:Android.js  
...18async function Androidtest(){19try {20driver.init(desired_capabilities)21.then(function(){22    return driver.waitForElementById('color',10000)23})24.then(function(colorButton){25    return colorButton.click();26})27.then(function(){28    return driver.waitForElementById('Text',10000)29})30.then(function(text){31    text.click()32    return driver.waitForElementById('toast',10000)33})34.then(function(toast){35    toast.click()36    return driver.waitForElementById('notification',10000)37})38.then(function(notification){39    notification.click()40    return driver.waitForElementById('geoLocation',10000)41})42.then(function(geoLocation){43    geoLocation.click()44    return driver.waitForElementById('buttonPage',10000)45})46.then(function(Home){47    Home.click()48    return driver.waitForElementById('speedTest',10000)49})50.then(function(speedTest){51    speedTest.click()52    return driver.waitForElementById('webview',10000)53})54.then(function(Browser){55    Browser.click()56    return driver.waitForElementById('url',10000)57})58.then(function(url){59    url.type("https://www.lambdatest.com")60    return driver.waitForElementById('find',10000)61})62.then(function(find){63    find.click()64    driver.quit()65})66}67catch (e) {68    driver.quit()69}70}...loginTest.js
Source:loginTest.js  
1import assert from 'assert';2export async function execute(driver, asserters, capabilities){3    await driver.init({...capabilities, name: 'Login test'});4    const emailfield = await driver.waitForElementById('emailLoginTextField', asserters.isDisplayed, 10000, 100);5    await emailfield.sendKeys('tester@gmail.com');6    const passwordfield = await driver.waitForElementById('passwordLoginTextField', asserters.isDisplayed, 10000, 100);7    await passwordfield.sendKeys('test');8    const loginButton = await driver.waitForElementById('confirmLoginButton', asserters.isDisplayed, 10000, 100);9    await driver.tapElement(loginButton);10    assert(true);11    driver.quit();...Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var chai = require('chai');4var chaiAsPromised = require('chai-as-promised');5var should = chai.should();6var expect = chai.expect;7chai.use(chaiAsPromised);8var browser = wd.promiseChainRemote("localhost", 4723);9var desired = {10};11browser.init(desired).then(function () {12    browser.waitForElementById("com.example.test:id/button", 10000).click();13    browser.waitForElementById("com.example.test:id/textView", 10000).text().should.eventually.equal("Hello World!");14    browser.quit();15});16[debug] [ADB] 1 device(s) connected17[debug] [ADB] 1 device(s) connected18[debug] [ADB] 1 device(s) connectedUsing AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3    .withCapabilities(webdriver.Capabilities.chrome())4    .build();5driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');6driver.findElement(webdriver.By.name('btnG')).click();7driver.wait(function() {8  return driver.getTitle().then(function(title) {9    return title === 'webdriver - Google Search';10  });11}, 1000);12driver.quit();13var webdriver = require('selenium-webdriver');14var driver = new webdriver.Builder()15    .withCapabilities(webdriver.Capabilities.chrome())16    .build();17driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');18driver.findElement(webdriver.By.name('btnG')).click();19driver.wait(function() {20  return driver.getTitle().then(function(title) {21    return title === 'webdriver - Google Search';22  });23}, 1000);24driver.quit();25var webdriver = require('selenium-webdriver');26var driver = new webdriver.Builder()27    .withCapabilities(webdriver.Capabilities.chrome())28    .build();29driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');30driver.findElement(webdriver.By.name('btnG')).click();31driver.wait(function() {32  return driver.getTitle().then(function(title) {33    return title === 'webdriver - Google Search';34  });35}, 1000);36driver.quit();37var webdriver = require('selenium-webdriver');38var driver = new webdriver.Builder()39    .withCapabilities(webdriver.Capabilities.chrome())40    .build();41driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');42driver.findElement(webdriver.By.name('btnG')).click();43driver.wait(function() {44  return driver.getTitle().then(function(title) {45    return title === 'webdriver - Google Search';46  });47}, 1000);48driver.quit();49var webdriver = require('selenium-webdriver');50var driver = new webdriver.Builder()Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.chrome()).build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6  return driver.getTitle().then(function(title) {7    return title === 'webdriver - Google Search';8  });9}, 1000);10driver.quit();Using AI Code Generation
1var driver = new webdriver.Builder()2   .withCapabilities({3   })4   .build();5driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');6driver.findElement(webdriver.By.name('btnG')).click();7driver.wait(function() {8  return driver.getTitle().then(function(title) {9    return title === 'webdriver - Google Search';10  });11}, 1000);12driver.quit();13info: Welcome to Appium v1.3.7 (REV 7a8d0c2e2b2a1e9e1d8a1f0a0f7c6aa5d7e8e3d3)Using AI Code Generation
1var driver = new webdriver.Builder()2   .forBrowser('chrome')3   .build();4driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');5driver.findElement(webdriver.By.name('btnG')).click();6driver.wait(function() {7   return driver.getTitle().then(function(title) {8     return title === 'webdriver - Google Search';9   });10}, 1000);11driver.quit();12driver.wait() method canUsing AI Code Generation
1var wd = require('wd'),2    assert = require('assert'),3    _ = require('underscore'),4    serverConfigs = require('./appium-servers');5var desired = {6};7var driver = wd.promiseChainRemote('localhost', 4723);8  .init(desired)9  .then(function () {10    return driver.waitForElementById('io.appium.android.apis:id/animation', 10000);11  })12  .then(function (el) {13    return el.click();14  })15  .fin(function() { driver.quit(); })16  .done();17driver.waitForElementByXPath(xpath, timeout, cb)18var wd = require('wd'),19    assert = require('assert'),20    _ = require('underscore'),21    serverConfigs = require('./appium-sUsing AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3    .withCapabilities({4    })5    .build();6driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');7driver.findElement(webdriver.By.name('btnG')).click();8driver.wait(function() {9  return driver.getTitle().then(function(title) {10    return title === 'webdriver - Google Search';11  });12}, 1000);13driver.quit();14var webdriver = require('selenium-webdriver');15var driver = new webdriver.Builder()16    .withCapabilities({17    })18    .build();19driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');20driver.findElement(webdriver.By.name('btnG')).click();21driver.wait(function() {22}, 1000);23driver.quit();Using AI Code Generation
1driver.waitForElementById('elementId', 2000, 1000, function(err, element) {2    if (err) {3        console.log(err);4    } else {5        console.log(element);6    }7});8driver.quit();9driver.waitForElementById('elementId', 2000, 1000, function(err, element) {10    if (err) {11        console.log(err);12    } else {13        console.log(element);14    }15});16driver.waitForElementById('elementId', 2000, 1000, function(err, element) {17    if (err) {18        console.log(err);19    } else {20        console.log(element);21    }22});23driver.waitForElementById('elementId', 2000, 1000, function(err, element) {24    if (err) {25        console.log(err);26    } else {27        console.log(element);28    }29});30driver.waitForElementById('elementId', 2000, 1000, function(err, element) {31    if (err) {32        console.log(err);33    } else {34        console.log(element);35    }36});37driver.waitForElementById('elementId', 2000, 1000, function(err, element) {38    if (err) {39        console.log(err);40    } else {41        console.log(element);42    }43});44driver.waitForElementById('elementId', 2000, 1000, function(err, element) {45    if (err) {46        console.log(err);47    } else {48        console.log(element);49    }50});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!!
