Use YAML files in config/ to separate environment variables, browser choices, and credentials.
Example config.yaml content:
environment: staging
browser: chrome
base_url: https://staging.example.com
Example credentials.yaml content:
username: testuser
password: securepass123
Load these configs in tests or driver factory to customize test runs.
Jenkinsfile uses parameters to select environment and browser dynamically:
pipeline {
agent any
parameters {
choice(name: 'ENV', choices: ['staging', 'production'], description: 'Select environment')
choice(name: 'BROWSER', choices: ['chrome', 'firefox'], description: 'Select browser')
}
stages {
stage('Run Tests') {
steps {
sh 'pytest --env=${ENV} --browser=${BROWSER} --html=reports/latest_report.html'
}
}
}
post {
always {
publishHTML(target: [
reportDir: 'reports',
reportFiles: 'latest_report.html',
reportName: 'Test Report'
])
}
}
}