Playwright + Python · Lesson 11 of 37
Module 11: Python for Automation
Your task
Implement get_env_url(env_name: str) -> str:
Write it in the editor, then press Check answer (Ctrl + Enter).
from enum import Enum
class Environment(str, Enum):
DEV = "https://dev.targetqa.com"
STAGING = "https://staging.targetqa.com"
PROD = "https://targetqa.com"
class BrowserType(str, Enum):
CHROME = "chrome"
FIREFOX = "firefox"
EDGE = "edge"
class TestConfig:
DEFAULT_TIMEOUT: int = 30
DEFAULT_ENV: Environment = Environment.STAGINGWelcome to Phase 2! In this module, we connect Python directly to test automation architecture. You will learn to build reusable helper functions, type-safe enums for browsers and environments, and structured configuration handlers. Let's design maintainable automation code!
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.
Inheriting from both str and Enum allows the enum to be compared directly with strings and easily serialized into JSON configurations.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___