Test Overview
This test opens a browser, goes to example.com, checks the page title, and closes the browser. It verifies the page loaded correctly by checking the title text.
This test opens a browser, goes to example.com, checks the page title, and closes the browser. It verifies the page loaded correctly by checking the title text.
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options import unittest class TestExampleDotCom(unittest.TestCase): def setUp(self): options = Options() options.add_argument('--headless') # Run browser in headless mode service = Service() self.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') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts - unittest framework initializes test case | No browser open yet | - | PASS |
| 2 | Browser opens in headless mode using ChromeDriver | Chrome browser running without UI | - | PASS |
| 3 | Navigates to 'https://example.com' | Browser loads example.com homepage | - | PASS |
| 4 | Reads page title | Page title is 'Example Domain' | Check if title equals 'Example Domain' | PASS |
| 5 | Assertion checks title equality | Title matches expected text | assertEqual(title, 'Example Domain') | PASS |
| 6 | Browser closes | No browser running | - | PASS |
| 7 | Test ends successfully | Test framework reports success | - | PASS |