Practice login form automation on a free, interactive demo page โ fill fields, submit, and assert success and error states with Selenium, Cypress, or Playwright.
Practice UI Automation for Secure Banking
Email: user@premiumbank.com
Password: Bank@123
Use these credentials to practice automating the login process.Explore common test scenarios for login functionality to enhance your automation practice.
This login form is a classic first automation exercise. Practice filling inputs, submitting, and asserting the success and error states โ all handled entirely in your browser, nothing is sent anywhere.
The same scenario written for two popular frameworks. These use the stable id and data-testid locators documented in the cheat sheet below.
import { test, expect } from '@playwright/test';
const URL = 'https://www.qapractice.com/practice-login-form';
test('valid credentials log the user in', async ({ page }) => {
await page.goto(URL);
await page.getByTestId('login-email').fill('user@premiumbank.com');
await page.getByTestId('login-password').fill('Bank@123');
await page.getByTestId('login-submit').click();
// Auto-retrying assertion waits for the success banner to appear
await expect(page.getByTestId('login-success'))
.toContainText('Login Successful');
});
test('invalid credentials show an error', async ({ page }) => {
await page.goto(URL);
await page.getByTestId('login-email').fill('wrong@example.com');
await page.getByTestId('login-password').fill('nope');
await page.getByTestId('login-submit').click();
await expect(page.getByTestId('login-error'))
.toContainText('Invalid');
});
test('submitting empty fields is rejected', async ({ page }) => {
await page.goto(URL);
await page.getByTestId('login-submit').click();
await expect(page.getByTestId('login-error'))
.toContainText('required');
});import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
public class LoginTest {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
driver.get("https://www.qapractice.com/practice-login-form");
// Valid login
driver.findElement(By.id("login-email")).sendKeys("user@premiumbank.com");
driver.findElement(By.id("login-password")).sendKeys("Bank@123");
driver.findElement(By.id("login-submit")).click();
String message = wait.until(ExpectedConditions.visibilityOfElementLocated(
By.cssSelector("[data-testid='login-success']"))).getText();
assert message.contains("Login Successful") : "Expected success message";
driver.quit();
}
}Every interactive element on this page exposes a stable id and/or data-testid so your scripts don't depend on brittle positions or styling.
| Element | id | data-testid | Playwright locator | Selenium locator |
|---|---|---|---|---|
| Email input | login-email | login-email | getByTestId('login-email') | By.id("login-email") |
| Password input | login-password | login-password | getByTestId('login-password') | By.id("login-password") |
| Remember-me checkbox | login-remember | login-remember | getByTestId('login-remember') | By.id("login-remember") |
| Forgot-password link | login-forgot-password | login-forgot-password | getByRole('link', { name: 'Forgot password?' }) | By.linkText("Forgot password?") |
| Sign-in button | login-submit | login-submit | getByTestId('login-submit') | By.id("login-submit") |
| Register link | login-register | login-register | getByRole('link', { name: 'Register now' }) | By.linkText("Register now") |
| Success message | โ | login-success | getByTestId('login-success') | By.cssSelector("[data-testid='login-success']") |
| Error message | โ | login-error | getByTestId('login-error') | By.cssSelector("[data-testid='login-error']") |
Use these as a checklist to build your automation suite. Download them as a Markdown file to keep alongside your test project.
| ID | Scenario | Steps | Expected Result |
|---|---|---|---|
| TC01 | Valid login |
| A success message "Login Successful! Welcome to Premium Banking." is shown. |
| TC02 | Both fields empty |
| Error "Email and Password are required" is shown. |
| TC03 | Missing password |
| Error "Password is required" is shown. |
| TC04 | Missing email |
| Error "Email is required" is shown. |
| TC05 | Invalid credentials |
| Error "Invalid email id and password" is shown; no success message. |
| TC06 | Password is masked |
| The characters are obscured (input type="password"). |
| TC07 | Forgot-password navigation |
| The browser navigates to /forget-password. |
| TC08 | Register navigation |
| The browser navigates to /register. |