Best practices for handling logins
Authentication should be configured as an individual test, containing just the login steps. Record it like a regular test. Make sure to logout from your application before starting to record the test. Otherwise you will be already authenticated 🙂
It is best practice to use an incognito window, to ensure that there are no previous logins active and the inputs are not pre-completed with data from the browser’s “remember me” functionality”.
Run it at least once to make sure it doesn’t fail. When creating test suites, set that authentication test separately as a pre-hook. It will run before each test, providing authentication for the following steps.
If you need to test with multiple accounts, simply create more authentication tests and choose the proper one for each new test suite down the line.