我编写了一个包含多个范围的测试用例。现在,如果文本不正确或错误值或等待时间,则其中一个测试用例可能会失败。如果发生这种情况,通常会显示失败。但我想处理这些错误,以便用户可以获得消息而不是错误。我尝试过以下方式。但它没有发现任何错误。它总是进入然后阻塞。我已经写了一条错误的消息,以便我可以抓住,但没有任何工作正常。
这是我的代码
修改后的代码
it('save button is clicked and Save notification is appeared', async () => {
await click.onto(ContentPage.saveEdit);
// I want to wait here
ContentPage.saveNotification.isPresent().then(async function() {
await expect(ContentPage.saveNotification.getText()).toContain('0030565002C0 Updated.')
}).catch(function (err) {
console.log(err)
});
});