Skip to content
RED SAGSkills
mediumAutomation Test Engineer interview question

How do you handle authentication in a large UI test suite without making every test log in through the UI?

What the interviewer wants to hear

  • Test the login UI itself in a few dedicated tests
  • Log in once via API or setup step and reuse session state
  • Separate state per role or user
  • Handle token expiry and parallel workers
  • Keep credentials in secrets

Model answer

I test the login page itself thoroughly in a few dedicated tests, including wrong passwords and MFA. Every other test should not pay for it. In Playwright I use a setup project that logs in once per role, through the API where possible, and saves storage state files with the cookies and local storage. Tests then start already signed in as admin, viewer or customer by choosing the right file. In Selenium I do the same by calling the auth API and injecting the session cookie. When tests change account data, I give each parallel worker its own account so they do not interfere. I make sure tokens are refreshed if a run is long, and all credentials come from the CI secret store. This often cuts minutes from the suite while keeping real authentication in the loop.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Automation Test Engineer questions