Built-in Fixtures
See the default fixtures that Playwright gives you for free.
What you'll learn
- Name the common built-in fixtures.
- Know what each fixture is for.
- Use them instead of manual setup.
Playwright AutomationlessonsJump to another lesson
Built-in Fixtures
See the default fixtures that Playwright gives you for free.
Big Picture
One small picture can make this idea easier to hold.
Built-in
- Ready to use.
- Less code in each test.
- Shared by the framework.
- Easy to read.
Manual setup
- You create every piece.
- More repeated code.
- More chances to leak state.
- Harder to maintain.
VerdictBuilt-in fixtures save time and keep tests simple.
How It Moves
Short steps make the flow easier to see.
Meet the fixture
See what helpers the framework gives you.
Pick the right one
Use page, context, browser, or request.
Use it in the test
Read or act through the fixture.
Keep it simple
Do not rebuild what already exists.
Step By Step
This is the same idea, stretched across time.
- 1
Open the test
Look at the fixture list in the function.
- 2
Choose the helper
Pick the one that fits the job.
- 3
Run the test
Use the fixture instead of manual setup.
- 4
Review the code
Check that the test stays short and clear.
One Small Model
Think of this like a tiny card you can keep in your pocket.
Fixture set
5 fieldsQuick Check
What is the page fixture for?
Map It
One more picture helps you see where this lesson matters most.
Fixture value map
Best
Use page for browser work
Good
Use request for API checks
Weak
Build your own page every time
Okay
Use browser for rare setup