Test Overview
This acceptance test checks if the login feature works as expected for a user. It verifies that a user can successfully log in with valid credentials and reach the dashboard page.
This acceptance test checks if the login feature works as expected for a user. It verifies that a user can successfully log in with valid credentials and reach the dashboard page.
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 import unittest class TestLoginAcceptance(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example.com/login') def test_valid_login(self): driver = self.driver # Find username field and enter username username_field = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, 'username')) ) username_field.send_keys('validUser') # Find password field and enter password password_field = driver.find_element(By.ID, 'password') password_field.send_keys('validPass123') # Find and click login button login_button = driver.find_element(By.ID, 'login-btn') login_button.click() # Wait for dashboard page to load by checking dashboard header dashboard_header = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, 'dashboard-header')) ) # Assert dashboard header text is correct self.assertEqual(dashboard_header.text, 'Welcome to Your Dashboard') 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 window opens at 'https://example.com/login' page | — | PASS |
| 2 | Waits for username field to be present and enters 'validUser' | Login page shows username and password fields and login button | Username field is present and enabled | PASS |
| 3 | Finds password field and enters 'validPass123' | Password field is visible and ready for input | Password field is present and enabled | PASS |
| 4 | Finds and clicks the login button | Login button is clickable | Login button is present and clickable | PASS |
| 5 | Waits for dashboard header to appear after login | Dashboard page loads with header element | Dashboard header text equals 'Welcome to Your Dashboard' | PASS |
| 6 | Test ends and browser closes | Browser window closes | — | PASS |
acceptance testing in software development?Given the user is on the login page When the user enters valid credentials Then the user should see the dashboard
Given the user is on the homepage When the user clicks the 'Submit' button Then the form should be submitted
Pass the test and this pattern moves unknown