Playwright + Python · Lesson 26 of 37
Module 26: Fixtures
Your task
Implement a custom fixture create_user_fixture():
Write it in the editor, then press Check answer (Ctrl + Enter).
import pytest
from pages.login_page import LoginPage
# Built-in page fixture gives an isolated page for every test:
def test_login_flow(page):
page.goto("https://targetqa.com/login")
# Custom Page Object fixture:
@pytest.fixture
def login_page(page):
login = LoginPage(page)
login.goto("/login")
return login
def test_admin_login(login_page):
login_page.login("admin@targetqa.com", "SecretPass")pytest fixtures are the backbone of test configuration in Python. In this lesson, you will master built-in fixtures like page and context provided by pytest-playwright, and create your own custom Page Object fixtures. Let's master fixtures!
Part of the Playwright + Python course (Playwright with Python). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
Yes! pytest-playwright creates a fresh, isolated BrowserContext for every test function, ensuring total isolation.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___