D · DeliveryIntermediate60 min read
9. Selenium in CI
Selenium WebDriver · 48 pages source format
Headless Chrome in GitHub Actions. Cache dependencies, upload screenshots on failure, smoke on PR, full suite nightly.
What you'll learn
- Headless Chrome in CI
- Artifact upload
- Service containers
- Retry strategy
GitHub Actions workflow
setup-java or setup-python, install browsers, run pytest/testng, upload reports.
name: Selenium Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: pip install -r requirements.txt
- run: pytest -m smoke --headless
- uses: actions/upload-artifact@v4
if: failure()
with:
name: selenium-screenshots
path: screenshots/Do this now
Green workflow on push. Headless Chrome.
Clear?
Screenshot on failure
Hook pytest runtest_makereport or TestNG listener to capture driver screenshot on fail.
Do this now
Trigger failure in CI. Confirm screenshot artifact downloadable.
Clear?
Smoke on PR, full nightly
PR: 5 min smoke. schedule: cron full regression. Standard enterprise pattern.
Do this now
Add workflow_dispatch or cron job stub for nightly. Document in CI.md.
Clear?