Built-in Fixtures

See the default fixtures that Playwright gives you for free.

Playwright Automation Module 3 Lesson 2
9 min read

What you'll learn

  • Name the common built-in fixtures.
  • Know what each fixture is for.
  • Use them instead of manual setup.

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.

2

Pick the right one

Use page, context, browser, or request.

3

Use it in the test

Read or act through the fixture.

4

Keep it simple

Do not rebuild what already exists.

Step By Step

This is the same idea, stretched across time.

  1. 1

    Open the test

    Look at the fixture list in the function.

  2. 2

    Choose the helper

    Pick the one that fits the job.

  3. 3

    Run the test

    Use the fixture instead of manual setup.

  4. 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 fields
browser:"One browser instance"
context:"Fresh session"
page:"One tab"
request:"API helper"
state:"Clean"
Each fixture gives the test one useful thing.

Quick Check

Question 1 of 10 correct

What is the page fixture for?

Map It

One more picture helps you see where this lesson matters most.

Fixture value map

Test effort
Easy

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

Hard
Manual workBuilt-in help
Setup style
Built-in fixtures keep tests short and repeatable.

Final Quiz

Question 1 of 30 correct

Which fixture gives you a browser tab?