一旦满足"夜表可见"条件,就无法继续测试



我正在使用nightwatchisVisible命令来检查元素是否可见。这里的场景是,如果元素可见,我想单击该元素并继续测试。如果元素不可见,我不想单击该元素,但我仍然想继续测试。因此,我无法将代码包装在else块中。

这里的问题是,一旦条件满足,测试就不会继续。我相信它不可能从那种情况中走出来。请在下面找到我的代码并提供您的建议。

`       
const result = await  this.myAccountTest.isVisible('@btnremove');
console.log('isVisible result', result);
if(await result.value==true)
{
await this.myAccountTest.remove();
await this.myAccountTest.clickConfirm();
}
// rest of the code to continue
await this.myaccountTest.create();
//more code`

我认为您在错误的地方使用了wait。也许您可以简单地按照以下方式进行编码。

const result = await this.myAccountTest.isVisible('@btnremove');
console.log('isVisible result', result);
if (result.value) {
this.myAccountTest.remove();
this.myAccountTest.clickConfirm();
}
// rest of the code to continue
await this.myaccountTest.create();

最新更新