Test Automation

Selenium WebDriver
TestNG
POM

(See test case examples below)

Test Cases for Login Page:

  1. Valid User Login:

    • Verify that a user can successfully log in with a valid username and password.

    • Ensure the user is redirected to the appropriate landing page after a successful login.

  2. Invalid User Login:

    • Test login with an invalid username and a valid password.

    • Test login with a valid username and an invalid password.

    • Verify that appropriate error messages are displayed for invalid login attempts.

  3. Empty Fields:

    • Test login without entering any username or password and ensure it's not allowed.

    • Verify that error messages are displayed for both empty fields.

  4. Password Masking:

    • Ensure that the password field masks characters (e.g., asterisks or dots) for security purposes.

  5. Case Sensitivity:

    • Test the case sensitivity of the username and password fields (e.g., ensure that "User" and "user" are treated as different inputs).

  6. Remember Me:

    • Test the "Remember Me" checkbox to ensure it remembers the user's login across sessions.

  7. Session Timeout:

    • Test the session timeout functionality by leaving the page idle for an extended period and verifying that the user is automatically logged out.

  8. Forgot Password:

    • Test the "Forgot Password" link and ensure that users can reset their passwords via email.

  9. Account Lockout:

    • Test account lockout functionality after a specified number of failed login attempts.

    • Verify that locked-out users receive an email notification and can unlock their accounts.

  10. Security and Validation:

    • Test for security vulnerabilities, such as SQL injection and cross-site scripting (XSS) attacks.

    • Ensure that input fields are properly validated to prevent malicious input.

  11. Password Strength:

    • Verify that the system enforces password strength rules (e.g., minimum length, special characters, numbers, etc.).

  12. Browser Compatibility:

    • Test the login page on different web browsers (e.g., Chrome, Firefox, Safari, Edge) to ensure compatibility.

  13. Mobile Responsiveness:

    • Test the login page on various mobile devices (e.g., smartphones, tablets) to ensure responsive design.

  14. Localization:

    • Test the login page with different languages and character sets to ensure text and error messages are displayed correctly.

  15. Performance:

    • Test the login page's performance under load to ensure it can handle concurrent login attempts without issues.

  16. Accessibility:

    • Verify that the login page is accessible to users with disabilities by testing it with screen readers and keyboard navigation.

  17. Cross-browser and Cross-platform Testing:

    • Test the login page on different operating systems (e.g., Windows, macOS, Linux) to ensure compatibility.

  18. Browser Developer Tools Testing:

    • Test the login page using browser developer tools to inspect network requests, check for console errors, and debug issues.

  19. User Experience (UX) Testing:

    • Evaluate the overall user experience of the login page, including user-friendly error messages and clear instructions.

  20. Edge Cases:

    • Test edge cases such as very long usernames or passwords to ensure the system handles them gracefully.

Sample Java Below

package com.codility.selenium;

import
org.openqa.selenium.By;
import
org.openqa.selenium.Keys;
import
org.openqa.selenium.WebElement;
import
org.openqa.selenium.interactions.Actions;

import
org.junit.Test;
import static
org.junit.Assert.assertTrue;
import static
org.junit.Assert.assertEquals;

import
java.util.ArrayList;
import
java.util.Arrays;
import
java.util.List;

import
org.testng.Assert;

public class
AppTest extends BaseTest {


private final String validEmail = "login@codility.com";
private final
String wrongEmail = "unknown@codility.com";
private final
String incompleteEmail = "unknownlogin";

// get password from properties file, or git hub key.
private final String password = "password";




public void
useWebElements(String login, String pass) {

WebElement emailInputField = webDriver.findElement(By.id(
"email-input"));
WebElement password = webDriver.findElement(By.id("password-input"));
WebElement loginBtn = webDriver.findElement(By.id("login-button"));

emailInputField.sendKeys(validEmail);



}

public WebElement loginInputField() {

return webDriver.findElement(By.id("email-input"));
}

public WebElement passwordInputField() {

return webDriver.findElement(By.id("password-input"));
}

public WebElement loginBtn() {

return webDriver.findElement(By.id("login-button"));
}





@Test (priority =
0)
public void assertFieldsAreDisplayed(){

Assert.assertTrue(loginInputField.isDisplayed())
;
Assert.assertTrue(passwordInputField.isDisplayed());
Assert.assertTrue(loginBtn.isDisplayed());

}


@Test (priority=
1)
public void credentialsValid(){

loginWithProvidedCredentials(validEmail
,password);

Assert.assertTrue(loginSuccessful());

}

@Test(priority=
2)
public void credentialsWrong(){
loginWithProvidedCredentials(wrongEmail
,password);

Assert.assertTrue(wrongCredentialsYouShallNotPassArrDisplayed());

}

@Test(priority=
3)
public void checkIfEmailValidationWorking() {
loginWithProvidedCredentials(incompleteEmail
,password);
Assert.assertTrue(enterValidEmailDisplayed());

}

@Test(priority =
4)
public void checkEmptyCredentials() {

String textWithinLoginField = loginInputField().getText()
;
String textWithinPasswordField = passwordInputField().getText();


Assert.assertEquals(textWithinLoginField, "");
Assert.assertEquals(textWithinPasswordField, "")


}




public void loginWithProvidedCredentials(String email, String pass) {
loginInputField.sendKeys(validEmail)
;
passwordInputField.sendKeys(password);
loginBtn.click();
}


public boolean loginSuccessful() {
WebElement welcomeToCodility = webDriver.findElement(By.
class("success"));
return
welcomeToCodility.isDisplayed();
}

public boolean wrongCredentialsYouShallNotPassArrDisplayed(){
WebElement youShallNotPassArrr = webDriver.findElement(By.
class("error"));
return
youShallNotPassArrr.isDisplayed();
}

public boolean enterValidEmailDisplayed(){
WebElement enterValidEmailMessage = webDriver.findElement(By.
class("validation"));
return
enterValidEmailMessage.isDisplayed();

}



/*
========= TEST CASES ======

0) Assert if id's are found
1) Check if given valid credentials work
2) Check if given wrong credentials work
3) Check if email validation is working
4) check if fields are empty





*/


// POM, LoginPage.java
// @FindBy (id ="email-input")
// final private WebElement emailInputField;

// @FindBy (id="password-input")
// final private WebElement passwordInputField;

// @FindBy(id = "login-button")
// final private WebElement loginBtn;




}