Test Overview
This test opens a webpage with radio buttons, selects a specific radio button, and verifies that it is selected correctly.
This test opens a webpage with radio buttons, selects a specific radio button, and verifies that it is selected correctly.
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 RadioButtonTest(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://example.com/radio-buttons') def test_select_radio_button(self): driver = self.driver wait = WebDriverWait(driver, 10) # Wait until radio button is clickable radio_button = wait.until(EC.element_to_be_clickable((By.ID, 'option2'))) radio_button.click() # Verify the radio button is selected self.assertTrue(radio_button.is_selected(), 'Radio button option2 should be selected') 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 is open, ready to load URL | - | PASS |
| 2 | Navigates to 'https://example.com/radio-buttons' | Page with radio buttons loads fully | - | PASS |
| 3 | Waits until radio button with ID 'option2' is clickable | Radio button 'option2' is visible and interactable | - | PASS |
| 4 | Clicks on radio button with ID 'option2' | Radio button 'option2' is selected | - | PASS |
| 5 | Checks if radio button 'option2' is selected | Radio button 'option2' remains selected | Assert radio_button.is_selected() is True | PASS |
| 6 | Test ends and browser closes | Browser window closed | - | PASS |