UnhandledPromiseRejectionWarning:未处理的承诺拒绝(NodeJs、Webdriverio、Selenium)
UnhandledPromiseRejectionWarning: Unhandled promise rejection (NodeJs, Webdriverio, Selenium)
我试图在成功提交时验证给定网页的 header(文本)。
我的命令:
async confirmSuccessfulSubmission() {
return $("#contact_reply h1").getText().then((value) => {
//incorrect text should be:Thank You for your Message!
expect(value.to.equal("Thank You for your Message!2"));
});
}
异常:
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
正确的标题是:感谢您的留言!因此,如果标题是:感谢您的消息!2 测试应该失败(Chai 断言)。
有什么想法吗?
感谢您的帮助
async confirmSuccessfulSubmission() {
try{
let value = await $("#contact_reply h1").getText()
if(value)
return expect(value).to.equal("Thank You for your Message!2");
return null
} catch(e) {
console.log(e)
}
}
捕获异常,以便您可以看到那里出了什么问题
我试图在成功提交时验证给定网页的 header(文本)。
我的命令:
async confirmSuccessfulSubmission() {
return $("#contact_reply h1").getText().then((value) => {
//incorrect text should be:Thank You for your Message!
expect(value.to.equal("Thank You for your Message!2"));
});
}
异常:
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
正确的标题是:感谢您的留言!因此,如果标题是:感谢您的消息!2 测试应该失败(Chai 断言)。
有什么想法吗?
感谢您的帮助
async confirmSuccessfulSubmission() {
try{
let value = await $("#contact_reply h1").getText()
if(value)
return expect(value).to.equal("Thank You for your Message!2");
return null
} catch(e) {
console.log(e)
}
}
捕获异常,以便您可以看到那里出了什么问题