Test Overview
This test opens a web page, retrieves its title and URL, and verifies they match expected values.
This test opens a web page, retrieves its title and URL, and verifies they match expected values.
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By import unittest class TestPageTitleAndURL(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome(service=Service()) def test_title_and_url(self): driver = self.driver driver.get('https://example.com') title = driver.title url = driver.current_url self.assertEqual(title, 'Example Domain') self.assertEqual(url, 'https://example.com/') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and Chrome browser opens | Chrome browser window is open, ready for commands | - | PASS |
| 2 | Browser navigates to 'https://example.com' | Browser displays the Example Domain homepage | - | PASS |
| 3 | Retrieve page title using driver.title | Title retrieved: 'Example Domain' | Check if title equals 'Example Domain' | PASS |
| 4 | Retrieve current URL using driver.current_url | URL retrieved: 'https://example.com/' | Check if URL equals 'https://example.com/' | PASS |
| 5 | Assertions for title and URL pass | Test confirms title and URL match expected values | Both assertions are true | PASS |
| 6 | Browser closes and test ends | Browser window closed, resources released | - | PASS |