Skip to content
QA Knowledge Hub

Test cases for a login page

Updated 2026-11-12 · 6 min read

A login page looks simple and hides a lot of cases. Below are 40 grouped by type, with expected results, a CSV you can open in Excel or Google Sheets, and a way to answer the interview question in two minutes.

This assumes a page with an email or username field, a password field, a "Sign in" button, a "Forgot password" link and optionally "Remember me". Adjust for your product: if it has OTP or social login, add those cases.

How to answer this in an interview

Do not start listing. Say: "I would group the tests: functional, negative, boundary, UI, security, performance and compatibility. Let me give the important ones from each." Then give three or four from each group, and finish with "and I would ask what the lockout rule and password policy are, because they change the expected results." That last sentence shows you test requirements as well as screens.

Functional

IDCategoryTest caseExpected result
L01FunctionalLog in with a valid username and valid passwordUser reaches the dashboard and sees their own name
L02FunctionalPress Enter in the password field instead of clicking the buttonForm submits and login succeeds
L03FunctionalLog in with a valid email typed in a different case ([email protected])Behaves as documented; email matching is normally case-insensitive
L04FunctionalLog in with leading or trailing spaces around the emailSpaces are trimmed and login succeeds, or a clear message is shown
L05FunctionalTick "Remember me", close the browser, reopen the siteUser remains signed in for the documented period
L06FunctionalLeave "Remember me" unticked, close the browser, reopenUser is signed out
L07FunctionalClick "Forgot password"Reset page opens
L08FunctionalLog in, then log out, then press the browser Back buttonProtected pages are not shown; user is sent to login
L09FunctionalOpen the login page while already signed inUser is redirected to the dashboard (or sees a sign-out option)
L10FunctionalLog in after a password change with the old passwordLogin fails with the standard error message

Negative

IDCategoryTest caseExpected result
L11NegativeValid username, wrong passwordGeneric error such as "Email or password is incorrect"
L12NegativeUnregistered username, any passwordThe same generic error; it must not reveal that the account does not exist
L13NegativeBoth fields emptyInline messages for both required fields; no request is sent
L14NegativeUsername filled, password emptyMessage on the password field
L15NegativeInvalid email format (asha@, asha.example.com)Format error shown before submitting
L16NegativeWrong password repeated past the lockout limit (for example 5 times)Account is locked or throttled with a message, per the requirement
L17NegativeTry the correct password after the lockout startsStill blocked until the lockout ends or is reset
L18NegativeLog in with a deactivated or unverified accountClear message about the account state
L19NegativeSubmit the form twice quickly (double click)One request is processed; no duplicate session or error
L20NegativeSubmit while the network is offlineFriendly error; fields keep their values (except the password if designed so)

Boundary

IDCategoryTest caseExpected result
L21BoundaryPassword of exactly the minimum allowed lengthAccepted if correct
L22BoundaryPassword one character shorter than the minimumRejected
L23BoundaryPassword of the maximum allowed length, and one longerMaximum works; longer is rejected or truncated as documented
L24BoundaryEmail of 254 characters, and 255254 handled; 255 rejected cleanly (no server error)
L25BoundaryPassword containing spaces, unicode and emojiTreated as normal characters; login works with the same password

UI and usability

IDCategoryTest caseExpected result
L26UIPassword field masks input; the show/hide icon toggles itWorks, and the icon has an accessible label
L27UITab order moves email, password, remember me, sign in, forgot passwordLogical order; focus is visible
L28UIError messages are readable and appear next to the fieldYes; colour is not the only signal
L29UIOpen on a 360px wide phone, and rotateNo horizontal scroll; the keyboard does not hide the button
L30UIBrowser password manager offers to save and autofillFields use correct autocomplete attributes

Security

IDCategoryTest caseExpected result
L31SecurityEnter ' OR '1'='1 in the usernameNo login; handled as normal text with the standard error
L32SecurityEnter <script>alert(1)</script> in the fields and see if it is echoed backNever executed; any echo is encoded
L33SecurityCheck the page is served over HTTPS and the form posts over HTTPSYes, with no mixed content
L34SecurityInspect the request: is the password in the URL or in plain text logs?Sent in the request body only, over HTTPS
L35SecurityAfter login, check the session cookie flagsHttpOnly and Secure set; a new session id is issued on login
L36SecurityLog in on two browsers, then change the passwordOther sessions end if the requirement says so
L37SecurityReplay the login request many times from a scriptRate limiting or captcha appears

Performance and compatibility

IDCategoryTest caseExpected result
L38PerformanceTime a login under normal loadWithin the agreed limit (for example under 2 seconds)
L39CompatibilityRepeat L01 on the latest Chrome, Firefox, Safari and EdgeSame result on all
L40CompatibilityRepeat L01 on Android Chrome and iOS SafariSame result on both

Automating these

Start with L01, L11, L13 and L16 as the smoke set. You can try them on the practice playground login page, which has stable element IDs for exactly this.

Downloads

Quick answers

How many test cases should I write for a login page in an interview?

You are not expected to list forty. Name the categories (functional, negative, boundary, UI, security, performance, compatibility) and give two or three strong examples from each. Structure matters more than count.

What are the most important test cases for login?

Valid login, invalid password, invalid username, empty fields, account lockout after repeated failures, password masking, session handling after logout, and protection against SQL injection in the inputs.

Want a project you can show in interviews?

The portfolio project kit walks you through testing a deliberately buggy app with Selenium or Playwright and API tests, then explaining it. The app itself is free.