Scheduling Test Suite Execution
Selenium tests can be scheduled and automated using CI/CD tools — they trigger test execution on a schedule, on code commits, or on demand.
// Jenkinsfile — Schedule nightly regression at midnight
pipeline {
agent any
triggers {
cron(''0 0 * * *'') // Every day at midnight
}
stages {
stage(''Run Selenium Tests'') {
steps {
sh ''mvn clean test -DsuiteXmlFile=testng.xml''
}
}
}
post {
always {
publishHTML([
reportDir: ''test-output'',
reportFiles: ''index.html'',
reportName: ''TestNG Report''
])
}
}
}
Jenkins cron schedule examples:
0 0 * * * → Every day at midnight
0 8 * * 1-5 → Every weekday at 8 AM
*/30 * * * * → Every 30 minutes
0 20 * * 5 → Every Friday at 8 PM
# .github/workflows/selenium-tests.yml
name: Selenium Test Suite
on:
schedule:
- cron: ''0 1 * * *'' # Daily at 1 AM UTC
push:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: ''11''
- name: Run Selenium Tests
run: mvn clean test
Method 3 — Bamboo Bamboo supports scheduling build plans via the UI — set "Build Triggers" to schedule at specific times.
# Run suite directly via Maven (schedule this in any scheduler)
mvn clean test -DsuiteXmlFile=regression.xml
# With specific browser
mvn test -Dbrowser=chrome -DsuiteXmlFile=testng.xml
# Create scheduled task on Windows
schtasks /create /tn "SeleniumNightlyRun" /tr "mvn -f C:\project\pom.xml test" /sc daily /st 23:00
CI/CD integration best practices:
- ✓Trigger on every pull request — smoke tests only (fast)
- ✓Trigger nightly — full regression suite
- ✓Trigger on release tags — E2E tests
- ✓Send results to Slack/email on failure
Tool comparison:
| Tool | Best for | Scheduling |
|---|---|---|
| Jenkins | On-premise, mature | Cron syntax |
| GitHub Actions | GitHub repos | YAML cron |
| Bamboo | Atlassian stack | Built-in UI |
| Windows Scheduler | Windows-only | Task UI |
Key answer: We can schedule the test suite execution using CI tools like Hudson (Jenkins) and Bamboo. Alternatively, we can use the Windows Task Scheduler to launch test execution at specified times.
