这是一种情况。
if (await browser.wait(ExpectedConditions.presenceOf(this.collapsedContinent), 500)) {
await this.helper.click(this.expandCountry);
await this.helper.click(this.chkcountry);
} else {
await this.helper.click(this.chkcountry);
}
我期望expect返回true或false,然后执行后续操作。看起来我好像做错了什么。
我知道expect返回一个promise,但是有没有什么方法可以让expect返回一个true或false,然后从那里开始呢?
我可以使用其他方法,只要它检查元素的存在。我使用的是异步等待,所以我不需要doThis.then(doThat);
我完全想避免使用.then()
发布于 2019-07-17 21:33:31
或者,如果您确实需要在检查之前等待一段时间,browser.wait不会返回true/false,但您可以使用.then来实现:
if (await browser.wait(ExpectedConditions.presenceOf(this.collapsedContinent), 500).then(()=> true, err=> false)) {
await this.helper.click(this.expandCountry);
await this.helper.click(this.chkcountry);
} else {
await this.helper.click(this.chkcountry);
}
https://stackoverflow.com/questions/57064059
复制相似问题