Test Overview
This test simulates a simple web login automation to verify that the login button works and the user is redirected to the dashboard page. It checks if automation can successfully perform a login action and validate the result.
This test simulates a simple web login automation to verify that the login button works and the user is redirected to the dashboard page. It checks if automation can successfully perform a login action and validate the result.
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 TestLoginAutomation(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example.com/login') def test_login_button_redirects(self): driver = self.driver # Wait until login button is clickable login_button = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.ID, 'login-btn')) ) login_button.click() # Wait until dashboard page loads by checking URL WebDriverWait(driver, 10).until( EC.url_contains('/dashboard') ) self.assertIn('/dashboard', driver.current_url) def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and Chrome browser opens | Browser window opened at https://example.com/login | - | PASS |
| 2 | Wait until login button with ID 'login-btn' is clickable | Login page fully loaded with login button visible and enabled | Login button is clickable | PASS |
| 3 | Click the login button | Browser navigates to new page after click | - | PASS |
| 4 | Wait until URL contains '/dashboard' indicating page load | Dashboard page loaded with URL containing '/dashboard' | Current URL contains '/dashboard' | PASS |
| 5 | Assert that current URL contains '/dashboard' | Dashboard page visible | assertIn('/dashboard', driver.current_url) | PASS |
| 6 | Close browser and end test | Browser closed | - | PASS |