I've encountered some failing tests that we suspect are caused by network drops. To address this problem, I have modified my login method to retry after an error is detected. I would also like to have the number of retry attempts displayed in the console. Is this approach the best solution?
login(email: string, password: string) {
let count = 0
if (!this.errorDisplayed()) {
this.setEmail(email)
this.setPassword(password)
return this.clickSignIn()
} while (this.errorDisplayed() && count < 5) {
browser.refresh()
count ++
}
console.log(`The login process encountered errors and was retried ${count} times`)
}
I have also experimented with the following:
login(email: string, password: string) {
this.setEmail(email)
this.setPassword(password)
this.clickSignIn()
let count = 0
this.errorDisplayed().then(result => {
if (!result) {
console.log(`No errors were encountered`)
} while (result && count < 5) {
browser.refresh()
count ++
}
})
console.log(`The login process encountered errors and was retried ${count} times`)
}