</>

Technology

Selenium

Difficulty

Intermediate

Interview Question

How to schedule the test suite execution in Selenium?

Use CI tools like Jenkins, GitHub Actions, or Bamboo to schedule and trigger test suite execution automatically on a schedule or on code commits.

Answer

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.

Method 1 — Jenkins (most popular CI tool)
GROOVY
// 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:

CODE
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
Method 2 — GitHub Actions
YAML
# .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.

Method 4 — Maven with TestNG
Bash
# 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
Method 5 — Windows Task Scheduler
POWERSHELL
# 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:

ToolBest forScheduling
JenkinsOn-premise, matureCron syntax
GitHub ActionsGitHub reposYAML cron
BambooAtlassian stackBuilt-in UI
Windows SchedulerWindows-onlyTask 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.

Follow AutomateQA

Related Topics