通过某个元素的length来判断当前的元素共有多少,但是因为dom节点的class和id会有雷同的情况 可以根据实际情况进行加减做判断
async initializeFolder() { browser.pause(5000) await this.favoriteIcon.waitForClickable() await this.favoriteIcon.click() browser.pause(6000) //let a = await ($$(`li`)).length //let count = await ($$(`li`)).length -8 let count = await ($$('.EmbersNav-item-label')).length -4 //let txtCount=await document.getElementsByClassName(".MuiCollapse-entered").getElementsByTagName("li").length; console.log(a) console.log(count) if(count > 1){ for(let i=count;i>0;i--){ await this.favoriteFolder.click() await this.deleteIcon.click() await this.deleteFolderButton.click() console.log('*******') } } }
标签:count,webdriver,elements,await,li,length,let,io,click From: https://www.cnblogs.com/chenxiaomeng/p/17046511.html