CI/CD with GitHub Actions: Run Selenium Tests Automatically

Selenium 15 min min read Updated: Nov 16, 2026 Intermediate
CI/CD with GitHub Actions: Run Selenium Tests Automatically
Intermediate Topic 2 of 3

What Is CI/CD?

Continuous Integration runs your tests automatically whenever code changes, so problems are found within minutes. GitHub provides this free for public repositories (and a free monthly quota for private ones) through GitHub Actions.

Basic Workflow

Create .github/workflows/selenium.yml:

yaml ame: Selenium Tests on: push: branches: [ main ] pull_request: workflow_dispatch: # run manually from the Actions tab jobs: test: runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" cache: pip - name: Install dependencies run: pip install -r requirements.txt - name: Run smoke tests run: pytest -m smoke --headless -n 2 --html=reports/report.html --self-contained-html env: TEST_ENV: demo APP_USER: ${{ secrets.APP_USER }} APP_PASSWORD: ${{ secrets.APP_PASSWORD }} - name: Upload report and screenshots if: always() uses: actions/upload-artifact@v4 with: name: test-report path: | reports/ screenshots/
Chrome on the runner: GitHub's ubuntu-latest runner already has Google Chrome installed and Selenium Manager finds the matching driver. If you need a different version use the browser-actions/setup-chrome action.

Secrets

Go to the repository Settings > Secrets and variables > Actions > New repository secret and add APP_USER and APP_PASSWORD. In the workflow they appear as ${{ secrets.NAME }} and are masked in logs.

Test on Several Browsers (Matrix)

yaml strategy: fail-fast: false matrix: browser: [chrome, firefox] steps: ... - name: Run tests run: pytest -m smoke --headless --browser=${{ matrix.browser }}

Scheduled Nightly Runs

yaml on: schedule: - cron: "30 20 * * *" # every day 20:30 UTC

Allure Report in CI

yaml - run: pytest --alluredir=allure-results - name: Build Allure report if: always() run: | npm install -g allure-commandline allure generate allure-results --clean -o allure-report - uses: actions/upload-artifact@v4 if: always() with: name: allure-report path: allure-report

Using the Selenium Grid Service in Docker

yaml services: selenium: image: selenium/standalone-chrome:latest ports: - 4444:4444 options: --shm-size=2g steps: ... - run: pytest --remote=http://localhost:4444

Add a Status Badge to the README

markdown ![Selenium Tests](https://github.com/<user>/<repo>/actions/workflows/selenium.yml/badge.svg)

Typical CI Problems

ProblemFix
Test passes locally, fails in CIWindow size, headless differences, slower machine: set --window-size, use explicit waits
Chrome crashesAdd --no-sandbox and --disable-dev-shm-usage for containers
Missing filesCheck .gitignore and test data paths (use Path(__file__))
Secrets empty on pull requests from forksGitHub does not share secrets with forks. Use public demo data for those

Conclusion

A GitHub Actions workflow installs your dependencies, runs pytest headless, uploads reports and can run on every push, on a schedule and on several browsers.

Quick Summary: .github/workflows/*.yml: checkout, setup-python, pip install, pytest --headless, upload-artifact.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators