Test Overview
This test opens a web page, clicks a button, and verifies the result. It demonstrates how test results are reported in a Continuous Integration (CI) environment.
This test opens a web page, clicks a button, and verifies the result. It demonstrates how test results are reported in a Continuous Integration (CI) environment.
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 TestButtonClick(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.implicitly_wait(5) def test_button_click(self): self.driver.get('https://example.com/buttonpage') button = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.ID, 'click-me')) ) button.click() message = WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located((By.ID, 'message')) ) self.assertEqual(message.text, 'Button clicked!') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initializes and prepares to run tests | - | PASS |
| 2 | Browser opens Chrome | Chrome browser window opens, ready for navigation | - | PASS |
| 3 | Navigates to 'https://example.com/buttonpage' | Page loads with a button having ID 'click-me' | - | PASS |
| 4 | Waits until button with ID 'click-me' is clickable | Button is visible and enabled | Button is clickable | PASS |
| 5 | Clicks the button | Button click triggers message display | - | PASS |
| 6 | Waits until message with ID 'message' is visible | Message element appears with text 'Button clicked!' | Message is visible | PASS |
| 7 | Checks that message text equals 'Button clicked!' | Message text is exactly 'Button clicked!' | Assert message.text == 'Button clicked!' | PASS |
| 8 | Test ends and browser closes | Browser window closes, test runner collects results | - | PASS |
| 9 | Test report generated in CI environment | CI system shows test passed with details | Test status is PASS in report | PASS |