Skip to main content

Framework Configuration

TAFLEX PY uses a highly robust, type-safe configuration system powered by Pydantic. Configuration is managed entirely through environment variables, typically loaded from a .env file at the root of the project.

By using Pydantic, the framework validates that all provided variables are of the correct type (e.g., URLs are valid, booleans are properly parsed, required fields are present) before any tests are executed, preventing late-stage failures.

Example Configuration File

Here is the comprehensive .env template generated by the setup script:

# ==============================================================================
# TAFLEX PY - Environment Configuration
# ==============================================================================

# ------------------------------------------------------------------------------
# Core Execution Settings
# ------------------------------------------------------------------------------
# The primary mode of execution.
# Supported values: web, api, mobile
EXECUTION_MODE=web

# Global timeout for requests, element waiting, etc. (in milliseconds)
# Default: 30000
TIMEOUT=30000

# ------------------------------------------------------------------------------
# Web Automation Settings (Playwright)
# ------------------------------------------------------------------------------
# The browser engine to use.
# Supported values: chromium, firefox, webkit
BROWSER=chromium

# Whether to run the browser in headless mode (no UI).
# Supported values: true, false
HEADLESS=true

# The base URL for web navigation.
BASE_URL=https://the-internet.herokuapp.com

# ------------------------------------------------------------------------------
# API Automation Settings
# ------------------------------------------------------------------------------
# The base URL for API requests.
API_BASE_URL=https://jsonplaceholder.typicode.com

# The underlying HTTP client to use for API testing.
# Supported values: playwright (hybrid flows), httpx (high-speed specialized)
API_PROVIDER=httpx

# ------------------------------------------------------------------------------
# Cloud Grid Settings (BrowserStack / SauceLabs)
# ------------------------------------------------------------------------------
# Target execution platform.
# Supported values: local, browserstack, saucelabs
CLOUD_PLATFORM=local

# Cloud provider credentials. (Uncomment and populate if using cloud grid)
# CLOUD_USER=your_username
# CLOUD_KEY=your_access_key

# Specific environment requirements for cloud execution.
# BROWSER_VERSION=latest
# OS=Windows
# OS_VERSION=11

# ------------------------------------------------------------------------------
# Reporting & Integration Settings
# ------------------------------------------------------------------------------
# Comma-separated list of active reporters.
# Example: html, allure, reportportal, xray
REPORTERS=html,allure

# Directory to output Allure results.
ALLURE_RESULTS_DIR=allure-results

# --- EPAM ReportPortal Integration ---
# RP_ENDPOINT=https://rp.yourcompany.com/api/v1
# RP_API_KEY=your_secret_api_key
# RP_PROJECT=taflex-automation
# RP_LAUNCH=nightly_build
# RP_DESCRIPTION=Regression Suite
# RP_ATTRIBUTES=env:dev;team:qa

# --- Jira Xray Integration ---
XRAY_ENABLED=false
# XRAY_CLIENT_ID=your_xray_client_id
# XRAY_CLIENT_SECRET=your_xray_client_secret
# XRAY_PROJECT_KEY=PROJ
# XRAY_TEST_PLAN_KEY=PROJ-100
# XRAY_TEST_EXEC_KEY=PROJ-101
# XRAY_ENVIRONMENT=staging

# ------------------------------------------------------------------------------
# Pact Contract Testing Settings
# ------------------------------------------------------------------------------
PACT_ENABLED=false
PACT_CONSUMER=taflex-consumer
PACT_PROVIDER=taflex-provider
# PACT_BROKER_URL=https://your-pact-broker.com
# PACT_BROKER_TOKEN=your_broker_token
# PACT_LOG_LEVEL=info # debug, info, warn, error

How to Access Configuration

You can safely retrieve these configuration values anywhere in your tests or framework utilities by importing the config_manager singleton.

from src.config.config_manager import config_manager

def test_config_usage():
# Safely retrieve values (automatically typed by Pydantic)
mode = config_manager.get('execution_mode')
timeout = config_manager.get('timeout')

# Values fallback to defaults or return None if optional and omitted
print(f"Running in {mode} mode with a timeout of {timeout}ms")