36. Centralized Configuration, pytest.ini & Device Emulation

Configuration in pytest.ini

[pytest]
addopts = --base-url https://staging.targetqa.com --headed=false --tracing retain-on-failure
testpaths = tests

Mobile Device Emulation

def 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")

Task

  • Implement make_viewport_config(width=1920, height=1080):
  • 1. Return {"viewport": {"width": width, "height": height}}
πŸ’‘Common doubts
Did you like the problem?
Lesson 36 of 37
Python
Loading code editor…
Next