How to Write Test Cases For a Login Page (Sample Scenarios)

Sample Test Cases for a Login Page (Includes ALL important functional and non-functional test cases for login page)

Whenever you will be asked to write the test cases for the ‘Form with some controls’, you need to follow the list of rules for writing test cases as mentioned below:

  • Write a test case on each form object.
  • Written test cases should be a combination of both negative and positive test cases.
  • Also, test cases should always be a combination of functional, performance, UI, usability, and compatibility test cases.

Test cases for login page

When you will be asked in the interview to write the test cases for a login page, firstly you need to think about, how many maximum controls can be available on a login page?

Because you don’t have a login page in front of you and neither you have requirements document for this login page. But the login page is such a common thing of which we can easily imagine the controls.

There can be a username, password, ‘Sign In’ button, Cancel Button, and Forgot Password link. There can be one more control which is a checkbox named ‘Remember me’ to remember the login details on a particular machine.

Test Cases – Login Page

Following is the possible list of functional and non-functional test cases for a login page:

Functional Test Cases:

Sr. No.Functional Test CasesType- Negative/ Positive Test Case
1Verify if a user will be able to login with a valid username and valid password.Positive
2Verify if a user cannot login with a valid username and an invalid password.Negative
3Verify the login page for both, when the field is blank and Submit button is clicked.Negative
4Verify the ‘Forgot Password’ functionality.Positive
5Verify the messages for invalid login.Positive
6Verify the ‘Remember Me’ functionality.Positive
7Verify if the data in password field is either visible as asterisk or bullet signs.Positive
8Verify if a user is able to login with a new password only after he/she has changed the password.Positive
9Verify if the login page allows to log in simultaneously with different credentials in a different browser.Positive
10Verify if the ‘Enter’ key of the keyboard is working correctly on the login page.Positive
Other Test Cases
11Verify the time taken to log in with a valid username and password.Performance & Positive Testing
12Verify if the font, text color, and color coding of the Login page is as per the standard.UI Testing & Positive Testing
13Verify if there is a ‘Cancel’ button available to erase the entered text.Usability Testing
14Verify the login page and all its controls in different browsersBrowser Compatibility & Positive Testing.

Non-functional Security Test Cases:

Sr. No.Security test casesType- Negative/ Positive Test Case
1Verify if a user cannot enter the characters more than the specified range in each field (Username and Password).Negative
2Verify if a user cannot enter the characters more than the specified range in each field (Username and Password).Positive
3Verify the login page by pressing ‘Back button’ of the browser. It should not allow you to enter into the system once you log out.Negative
4Verify the timeout functionality of the login session.Positive
5Verify if a user should not be allowed to log in with different credentials from the same browser at the same time.Negative
6Verify if a user should be able to login with the same credentials in different browsers at the same time.Positive
7Verify the Login page against SQL injection attack.Negative
8Verify the implementation of SSL certificate.Positive

We can take an Example of Gmail Login page. Here is the image of it.

Gmail login screen

Test Cases for Gmail Login page

SignUp Gmail screen

Sr. No.Test Scenarios
1Enter the valid email address & click next. Verify if the user gets an option to enter the password.
2Don’t enter an email address or phone number & just click the Next button. Verify if the user will get the correct message or if the blank field will get highlighted.
3Enter the invalid email address & click the Next button. Verify if the user will get the correct message.
4Enter an invalid phone number & click the Next button. Verify if the user will get the correct message.
5Verify if a user can log in with a valid email address and password.
6 Verify if a user can log in with a valid phone number and password.
7Verify if a user cannot log in with a valid phone number and an invalid password.
8Verify if a user cannot log in with a valid email address and a wrong password.
9Verify the ‘Forgot email’ functionality.
10Verify the ‘Forgot password’ functionality.

Test Scenarios for the Sign-up page

#1) Verify the messages for each mandatory field.

#2) Verify if the user cannot proceed without filling all the mandatory fields.

#3) Verify the age of the user when the DOB is selected.

#4) Verify if the numbers and special characters are not allowed in the First and Last name.

#5) Verify if a user can sign-up successfully with all the mandatory details.

#6) Verify if a user can log in with the valid details.

#7) Verify if the Password and Confirm Password fields are accepting similar strings only.

#8) Verify if the Password field will prompt you for the weak passwords.

#9) Verify if duplicate email address will not get assigned.

#10) Verify that hints are provided for each field on the form, for the ease of use.

Test Scenarios for the Login page of Mobile Application

Mobile Login screen

[image source]

#1) Verify if a user can log in with a valid username and password.

#2) Verify if a user cannot log in with an invalid username or password. Check permutation and combinations of this.

#3) Verify the ‘Keep me Sign In’ option. If this check box is selected, then the user should not get logged out even after exiting the app.

#4) Verify if this check box is not selected by default.

#5) If the user has signed up with Facebook or social media, verify that the user can log in with those credentials or not.

#6) Verify the Forgot password functionality.

#7) Verify if the login page fits the mobile screen. The user should not have to scroll the screen.

Conclusion

While writing test cases for login or sign-up page write the test cases for all the fields. There should be a combination of both positive and negative test cases. Try to cover the performance, security, and functional scenarios.

The login page is the page with fewer controls, so even though it is looking simple for testing, it should not be considered as an easy task.

Also many a time it is the first impression of an application, so it should be perfect for user interface and usability.

Hope you would have got a complete idea of how to write test cases for the Login page.