Test Overview
This test opens a web browser and navigates to a specific URL. It verifies that the page title matches the expected title to confirm the correct page loaded.
This test opens a web browser and navigates to a specific URL. It verifies that the page title matches the expected title to confirm the correct page loaded.
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By import unittest class TestOpenURL(unittest.TestCase): def setUp(self): service = Service() self.driver = webdriver.Chrome(service=service) self.driver.implicitly_wait(10) def test_open_url_and_check_title(self): url = "https://example.com" expected_title = "Example Domain" self.driver.get(url) actual_title = self.driver.title self.assertEqual(actual_title, expected_title, f"Page title should be '{expected_title}'") def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and WebDriver Chrome instance is created | Chrome browser window opens, ready for commands | - | PASS |
| 2 | Browser navigates to 'https://example.com' using driver.get() | Browser loads the Example Domain page | - | PASS |
| 3 | Retrieve the page title using driver.title | Page title is 'Example Domain' | Check if actual title equals 'Example Domain' | PASS |
| 4 | Assert that the page title matches expected title | Title matches expected | assertEqual passes | PASS |
| 5 | Test ends and browser is closed with driver.quit() | Browser window closes | - | PASS |