← Back to all posts

Executing Selenium tests with Python (pytest) using GitHub Actions

You can find the working project on GitHub.

First we’ll create some example tests. I’ll be using Selenium with Python (pytest), so for this example I’ll create two files — one called conftest.py and the second one called test_web01.py.

conftest.py in GitHub

conftest.py preview

Now let’s create the second file where the actual tests live.

test_web01.py in GitHub

test_web01.py preview

For running with GitHub Actions we have to create the following file structure in the repo:

.github/
└── workflows/
    └── test01.yaml

test01.yaml in GitHub

test01.yaml preview

Now go to the Actions tab on GitHub, select the workflow named test01, and click Run workflow.

Run workflow screenshot

You can configure this workflow to execute on different triggers by modifying:

on:
  workflow_dispatch:

With any of the available events.

Passing test in GitHub Actions

You can find the working project here.