Test Overview
This test checks that a previously fixed bug does not appear again after new changes. It verifies that the login feature still works correctly after updates.
This test checks that a previously fixed bug does not appear again after new changes. It verifies that the login feature still works correctly after updates.
import unittest from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class TestLoginRegression(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example.com/login') def test_login_functionality(self): driver = self.driver # Wait for username field WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'username'))) username_input = driver.find_element(By.ID, 'username') password_input = driver.find_element(By.ID, 'password') login_button = driver.find_element(By.ID, 'login-btn') username_input.send_keys('testuser') password_input.send_keys('correctpassword') login_button.click() # Wait for dashboard to load WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'dashboard'))) dashboard = driver.find_element(By.ID, 'dashboard') self.assertTrue(dashboard.is_displayed(), 'Dashboard should be visible after login') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and opens Chrome browser | Browser opened at https://example.com/login page | - | PASS |
| 2 | Waits up to 10 seconds for username input field to appear | Login page loaded with username, password fields and login button visible | Username input field is present | PASS |
| 3 | Finds username, password inputs and login button elements | All login form elements located | - | PASS |
| 4 | Enters 'testuser' in username and 'correctpassword' in password fields | Login form filled with credentials | - | PASS |
| 5 | Clicks the login button | Login form submitted, waiting for dashboard page | - | PASS |
| 6 | Waits up to 10 seconds for dashboard element to appear | Dashboard page loaded with dashboard element visible | Dashboard element is present | PASS |
| 7 | Checks if dashboard element is displayed | Dashboard visible on screen | Assert dashboard.is_displayed() is True | PASS |
| 8 | Test ends and browser closes | Browser closed | - | PASS |