I need a playwright test for a login flow that behaves like this:
Sign In
which triggers a post request to Server 2 url /login
/login
url with a html response./signin-saml
./signin-saml
is executed and Server 1 returns 302 with location to Server 1 url /Account/ExternalLoginCallback
./Account/ExternalLoginCallback
must load correctly including some fields.I have tried different ways to get a 100% reliable test without luck so far. The test fails at different navigation points, saying that the navigation didn't happen.
I have tried, for example, 3 await waitForUrl statements in a row playing with the timeouts and waitUntil arguments, and also a waitForTimeout using a long enough time followed by a waitForUrl(/Account/ExternalLoginCallback
). I haven't tried anything with waitForNavigation since it appears as deprecated in the current version of playwright that I'm using.
I need a way to test the described scenario with a reliable test. What is the best way to do that?
Thank you in advance
Closing as I could find a solution. Based on the answer of this question, I changed the await waitForUrl(...) statements for an await Promise.all(...) passing all the awaits as arguments and also, added a delay to the click event before the navigation to make sure the navigations didn't occur before waiting for them.