Skip to main content

How do you handle authentication in automated tests without logging in through the UI every time?

  • authentication
  • session management
  • performance

Answer it first, then compare. Nothing here is saved or scored.

Model answer

Methods: (1) API-based auth, call the login endpoint directly, store the session token/cookie. (2) Playwright storageState, log in once, save browser state to a file, reuse across tests. (3) Mock auth, inject a valid JWT in test environment. (4) Service accounts with long-lived tokens for CI. Best practice: log in through UI in one dedicated auth test, use API/state reuse for all others. This saves minutes per test run.

What interviewers listen for

  • Test architecture instincts
    You can defend why your suite is shaped like a pyramid, a trophy, or a honeycomb.
  • Locator discipline
    You rank selector strategies by stability and explain when to break the rule.
  • Flaky test ownership
    You debug to a structural fix instead of retry-until-green.
  • Parallelisation literacy
    You know how your framework isolates state, fixtures, and database access across workers.

See all 35 automation questions

Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026