Test Overview
This test opens a browser using Selenium WebDriver with ChromeDriver, navigates to a simple page, and verifies the page title to confirm the setup works correctly.
This test opens a browser using Selenium WebDriver with ChromeDriver, navigates to a simple page, and verifies the page title to confirm the setup works correctly.
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By import unittest class TestWebDriverSetup(unittest.TestCase): def setUp(self): service = Service(executable_path='chromedriver') self.driver = webdriver.Chrome(service=service) def test_open_google(self): self.driver.get('https://www.google.com') title = self.driver.title self.assertEqual(title, 'Google') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and setUp method runs | ChromeDriver executable is located and Chrome browser instance is launched | - | PASS |
| 2 | Browser navigates to 'https://www.google.com' | Browser window shows Google homepage | - | PASS |
| 3 | Test retrieves page title | Page title is 'Google' | Assert page title equals 'Google' | PASS |
| 4 | tearDown method runs and browser closes | Browser window is closed, WebDriver session ends | - | PASS |