Playwright + Python · Lesson 36 of 37
Module 36: Playwright Configuration
Your task
Implement make_viewport_config(width=1920, height=1080):
Write it in the editor, then press Check answer (Ctrl + Enter).
pytest.ini[pytest]
addopts = --base-url https://staging.targetqa.com --headed=false --tracing retain-on-failure
testpaths = testsdef test_mobile_layout(playwright):
iphone = playwright.devices["iPhone 14"]
browser = playwright.chromium.launch()
context = browser.new_context(**iphone)
page = context.new_page()
page.goto("https://targetqa.com")Configuring test parameters in a centralized file keeps your test suites clean and portable. In this lesson, you will configure Base URLs, viewports, mobile device emulation, and default timeouts in Python. Let's configure our framework!
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! When using device emulation or setting has_touch=True in new_context, Playwright accurately simulates touch and mobile tap events.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___