Manuals / Selenium WebDriver / Chapter 9

D · Delivery · intermediate · Week 7–8 · Chapter 9 of 12

Selenium in CI

Headless Chrome in GitHub Actions. Cache dependencies, upload screenshots on failure, smoke on PR, full suite nightly.

Path progress
69%

Step 1 of 3

GitHub Actions workflow

setup-java or setup-python, install browsers, run pytest/testng, upload reports.

GitHub Actions workflowDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →GitHub Actions wordrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

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.

Was this step clear?
Chapter learning outcomes
  • Headless Chrome in CI
  • Artifact upload
  • Service containers
  • Retry strategy

Clear these before you leave

Side quest

Fix CI flake

If CI fails but local passes, fix wait or headless viewport — document in FLAKES.md.