Test Overview
This test explores a simple login page without a fixed script. It tries different inputs and checks if the login button behaves correctly, verifying the system handles inputs as expected.
This test explores a simple login page without a fixed script. It tries different inputs and checks if the login button behaves correctly, verifying the system handles inputs as expected.
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 TestLoginExploratory(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example.com/login') def test_login_button_enabled_with_input(self): driver = self.driver wait = WebDriverWait(driver, 10) # Find username and password fields username = wait.until(EC.presence_of_element_located((By.ID, 'username'))) password = driver.find_element(By.ID, 'password') login_button = driver.find_element(By.ID, 'login-btn') # Initially, login button should be disabled self.assertFalse(login_button.is_enabled()) # Enter username only username.send_keys('testuser') self.assertFalse(login_button.is_enabled()) # Enter password password.send_keys('password123') # Now login button should be enabled self.assertTrue(login_button.is_enabled()) # Clear username to test edge case username.clear() self.assertFalse(login_button.is_enabled()) 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 showing login form with username, password fields and disabled login button | - | PASS |
| 2 | Waits for username field to be present and finds password and login button elements | All elements are visible and interactable | - | PASS |
| 3 | Checks that login button is initially disabled | Login button is disabled | Assert login_button.is_enabled() is False | PASS |
| 4 | Enters 'testuser' in username field | Username field contains 'testuser', password empty, login button still disabled | Assert login_button.is_enabled() is False | PASS |
| 5 | Enters 'password123' in password field | Username and password fields filled, login button enabled | Assert login_button.is_enabled() is True | PASS |
| 6 | Clears username field | Username empty, password filled, login button disabled | Assert login_button.is_enabled() is False | PASS |
| 7 | Test ends and browser closes | Browser closed | - | PASS |