Test Overview
This test checks a login button click on a webpage that requires a special workaround for Firefox browser due to a known click issue. It verifies the login success message appears after clicking.
This test checks a login button click on a webpage that requires a special workaround for Firefox browser due to a known click issue. It verifies the login success message appears after clicking.
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 TestLoginButton(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() # Using Firefox to demonstrate workaround self.driver.get('https://example.com/login') def test_login_button_click(self): driver = self.driver wait = WebDriverWait(driver, 10) login_button = wait.until(EC.presence_of_element_located((By.ID, 'login-btn'))) # Workaround for Firefox: use JavaScript click instead of Selenium click if 'firefox' in driver.capabilities['browserName'].lower(): driver.execute_script('arguments[0].click();', login_button) else: login_button.click() success_message = wait.until(EC.visibility_of_element_located((By.ID, 'success-msg'))) self.assertEqual(success_message.text, 'Login successful') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and Firefox browser opens | Firefox browser window is open and ready | - | PASS |
| 2 | Navigates to https://example.com/login | Login page is loaded with login button visible | - | PASS |
| 3 | Finds login button by ID 'login-btn' | Login button element is located on the page | Element presence verified | PASS |
| 4 | Checks browser type and applies Firefox workaround: clicks login button using JavaScript | Login button is clicked successfully despite Firefox click issue | - | PASS |
| 5 | Waits for success message with ID 'success-msg' to appear | Success message 'Login successful' is visible on page | Assert success message text equals 'Login successful' | PASS |
| 6 | Test ends and browser closes | Firefox browser window is closed | - | PASS |