Test Overview
This test uses a fixture to open a browser before the test and close it after. It verifies that the page title is correct after navigating to the website.
This test uses a fixture to open a browser before the test and close it after. It verifies that the page title is correct after navigating to the website.
import pytest from selenium import webdriver from selenium.webdriver.common.by import By @pytest.fixture def browser(): driver = webdriver.Chrome() yield driver driver.quit() def test_page_title(browser): browser.get('https://example.com') assert browser.title == 'Example Domain'
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Pytest fixture 'browser' starts: opens Chrome browser | Chrome browser window opens, ready for commands | - | PASS |
| 2 | Test navigates browser to 'https://example.com' | Browser loads the Example Domain webpage | - | PASS |
| 3 | Test checks that page title equals 'Example Domain' | Page title is 'Example Domain' | assert browser.title == 'Example Domain' | PASS |
| 4 | Test ends, fixture 'browser' teardown runs: closes browser | Chrome browser window closes | - | PASS |