Playwright + Python · Lesson 15 of 37
Module 15: Browser, Context & Page
Your task
Implement count_open_pages(context):
Write it in the editor, then press Check answer (Ctrl + Enter).
with sync_playwright() as p:
browser = p.chromium.launch()
admin_context = browser.new_context()
admin_page = admin_context.new_page()
admin_page.goto("https://targetqa.com/admin")
customer_context = browser.new_context()
customer_page = customer_context.new_page()
customer_page.goto("https://targetqa.com/store")
browser.close()A single Browser instance can host dozens of isolated BrowserContexts. In this lesson, you will master context isolation, running multi-user scenarios with zero cookie leakage, and managing tabs. Let's master Contexts!
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.
Contexts spin up in ~15ms with virtually zero memory overhead, whereas launching a browser takes seconds and consumes high RAM.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___