Test Overview
This test case checks the login functionality of a website. It verifies that when a user enters valid credentials, they successfully log in and see a welcome message.
This test case checks the login functionality of a website. It verifies that when a user enters valid credentials, they successfully log in and see a welcome message.
def test_login_success(): # Step 1: Open login page driver.get('https://example.com/login') # Step 2: Enter username username_field = driver.find_element(By.ID, 'username') username_field.send_keys('validUser') # Step 3: Enter password password_field = driver.find_element(By.ID, 'password') password_field.send_keys('validPass123') # Step 4: Click login button login_button = driver.find_element(By.ID, 'loginBtn') login_button.click() # Step 5: Verify welcome message welcome_message = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, 'welcomeMsg')) ) assert welcome_message.text == 'Welcome, validUser!', 'Welcome message did not match expected text'
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Open the login page URL | Browser navigates to https://example.com/login showing the login form | — | PASS |
| 2 | Find username input field and enter 'validUser' | Username field is filled with 'validUser' | — | PASS |
| 3 | Find password input field and enter 'validPass123' | Password field is filled with 'validPass123' | — | PASS |
| 4 | Find and click the login button | Login button clicked, page starts loading user dashboard | — | PASS |
| 5 | Wait for welcome message element and verify its text | Welcome message 'Welcome, validUser!' is displayed on the dashboard | Check that welcome message text equals 'Welcome, validUser!' | PASS |
Steps: 1. Enter username 'user1'
2. Enter password 'pass123'
3. Click 'Submit'
Expected: User is logged in and dashboard appears
Actual: Error message 'Invalid credentials'
Steps: 1. Open app
2. Click 'Settings'
Expected: Settings page opens
Actual: Settings page opens
Steps: 1. Add item to cart
2. Proceed to checkout
Expected: Total price updates correctly
Actual: Total price remains unchanged
Pass the test and this pattern moves unknown