Retrying login logic

I have a problem where CAS fails at random times and I need to retry login process. I’m using autoLogin plugin and basically I tried following ways to retry the process but with no luck:

  1. login: (I) => I.retry().login()
  2. retryFailedStep plugin (I guess this failed because I wasn’t running it on step but on Before()), even trying to set when function but with no results
  3. I tried I.waitInUrl('/dashboard').then(() => {}, () => this.login()) to recursively re-try it but it closes page and fails and doesn’t go into loop

Frankly, I’m out of ideas and could use some fresh input here.

Thank you in advance.