最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

网站源码admin22浏览0评论

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

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

我正在使用nightwatch isVisible命令来检查可见元素。这里的场景是,如果该元素可见,我想单击该元素并继续测试。如果该元素不可见,则我不想单击该元素,但仍想继续测试。因此,我无法将代码包装在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`
回答如下:

我认为您在错误的地方等待使用。也许您可以简单地编写如下代码。

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();
发布评论

评论列表(0)

  1. 暂无评论