Test Overview
This test uses a shared fixture from conftest.py to open a browser, navigate to a page, and verify the page title. It checks that the fixture correctly provides the WebDriver instance.
This test uses a shared fixture from conftest.py to open a browser, navigate to a page, and verify the page title. It checks that the fixture correctly provides the WebDriver instance.
import pytest from selenium.webdriver.common.by import By def test_open_google(browser): browser.get('https://www.google.com') title = browser.title assert 'Google' in title # conftest.py import pytest from selenium import webdriver @pytest.fixture def browser(): driver = webdriver.Chrome() yield driver driver.quit()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | PyTest starts and loads conftest.py to find fixtures | PyTest environment ready with browser fixture available | - | PASS |
| 2 | Test function test_open_google is called with browser fixture injected | Browser fixture creates Chrome WebDriver instance | - | PASS |
| 3 | Browser navigates to 'https://www.google.com' | Chrome browser opens Google homepage | - | PASS |
| 4 | Test retrieves page title from browser | Page title is 'Google' | Check if 'Google' is in page title | PASS |
| 5 | Test asserts that 'Google' is in the page title | Assertion passes because title contains 'Google' | assert 'Google' in title | PASS |
| 6 | Test completes, browser fixture quits the WebDriver | Chrome browser closes | - | PASS |