I am running a test using WebdriverIO and precisely on this line:
await browser.waitForVisible('#tx-sent li', 15000)
Every now and then, I get a Promise rejection error:
Error: Promise was rejected with the following reason: java.net.SocketException: Connection reset by peer (connect failed)
Is there a way to catch this promise rejection so that it doesn't cause the entire test to fail? In other words I want to catch this Promise rejection and resolve it.
You can use try/catch
try {
await browser.waitForVisible('#tx-sent li', 15000);
} catch(e) {
console.log(e);
}
You can use try and catch to handle errors in promises. do something like this
try {
await browser.waitForVisible('#tx-sent li', 15000)
} catch(error) {
// thro or log erro as per you need
//throw error;
console.log(error);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.