Test Overview
This test opens a web page, checks the page title, and generates a test report showing the test result.
This test opens a web page, checks the page title, and generates a test report showing the test result.
import unittest from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options class TestPageTitle(unittest.TestCase): @classmethod def setUpClass(cls): options = Options() options.add_argument('--headless') cls.driver = webdriver.Chrome(service=Service(), options=options) def test_title(self): self.driver.get('https://example.com') title = self.driver.title self.assertEqual(title, 'Example Domain') @classmethod def tearDownClass(cls): cls.driver.quit() if __name__ == '__main__': unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts: unittest framework initializes test suite | Test runner ready, ChromeDriver configured with headless option | - | PASS |
| 2 | Browser opens: Chrome browser starts in headless mode | Chrome browser running without UI | - | PASS |
| 3 | Navigates: Browser navigates to 'https://example.com' | Page 'Example Domain' loaded | - | PASS |
| 4 | Finds element: Selenium reads the page title | Page title is 'Example Domain' | Check if page title equals 'Example Domain' | PASS |
| 5 | Assertion checks: unittest asserts title equality | Assertion passes as titles match | assertEqual('Example Domain', 'Example Domain') | PASS |
| 6 | Browser closes: ChromeDriver quits | Browser closed, resources freed | - | PASS |
| 7 | Test report generated by unittest TextTestRunner | Test report shows test passed with details | - | PASS |