How to use driver.waitForElementById method in Appium

Best JavaScript code snippet using appium

index.js

Source:index.js Github

copy

Full Screen

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

Full Screen

Full Screen

basic.e2e.js

Source:basic.e2e.js Github

copy

Full Screen

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

Full Screen

Full Screen

viettel-pay.js

Source:viettel-pay.js Github

copy

Full Screen

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

Full Screen

Full Screen

elements.js

Source:elements.js Github

copy

Full Screen

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

Full Screen

Full Screen

PageObjectApp.js

Source:PageObjectApp.js Github

copy

Full Screen

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

Full Screen

Full Screen

IOS.js

Source:IOS.js Github

copy

Full Screen

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

Full Screen

Full Screen

Android.js

Source:Android.js Github

copy

Full Screen

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

Full Screen

Full Screen

loginTest.js

Source:loginTest.js Github

copy

Full Screen

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

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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) connected

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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)

Full Screen

Using AI Code Generation

copy

Full Screen

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 can

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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

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