Manuals / Playwright with Python / Chapter 9
Part 1 · Foundations · beginner · ~50 min · Chapter 9 of 61
4. First Script
Launching a browser (headless vs headed) from playwright.sync_api import sync_playwright with sync_playwright() as p: browser = p.chromium.launch(headless=False) # headed — visible window headless=True (the default) runs with no visible window — faster and what CI environments require. headless=False opens an actual visible browser window — invaluable while you're first writing a test and want to
Step 1 of 5
Launching a browser (headless vs headed)
browser = p.chromium.launch(headless=False) # headed — visible window headless=True (the default) runs with no visible window — faster and what CI environments require. headless=False opens an actual visible browser window — invaluable while you're first writing a test and want to watch what's happening. A common workflow: write and debug with headless=False, then flip to True (or just remove the argument) once the test is stable and you're ready to commit it.
Try it
Run / study this snippet
from playwright.sync_api import sync_playwrightChapter learning outcomes
- Launching a browser (headless vs headed)
- Navigating to a URL
- Closing browser/context properly
Clear these before you leave
Side quest
4. First Script deliverable
Apply one idea from “Launching a browser (headless vs headed)” in a small script or note.