Running browser tests from GitHub Actions with SeleniumBase
Tags: python, pytest, webdriver, testing
Published: 2020-04-22 07:29:03

---
title: Running browser tests from GitHub Actions with SeleniumBase
published: true
description: Learn about using GitHub Actions for running browser tests
tags: #Python #pytest #WebDriver #Testing
---
<img src="https://camo.githubusercontent.com/b8a228f0e7cfaab905bebb63a376ad853e382f586bd25dc232891cfecf75e139/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f696d672f6768612f6769746875625f776f726b666c6f77735f372e706e67" title="SeleniumBase">

The [SeleniumBase](https://github.com/seleniumbase/SeleniumBase) Python-WebDriver framework allows you easily automate Web UI tests quickly and reliably. Here's an example of [this test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py) running against a website to test the complete flow of logging in, searching for an item, adding the item to a shopping cart, and making a purchase:

<img src="https://camo.githubusercontent.com/8053469813a50e76cc63d3eeec1dffb9dc81f3d3a49711695638aec6b5907967/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f6769662f737761675f64656d6f5f332e676966" title="SeleniumBase"><br />
That test was run with ``pytest``, a Python unit-testing framework that can expand to do much more than unit-testing. The ``--demo`` command-line option was added to activate "Demo Mode", which slows down the test and lets you see what the test assertions are. (Run from [here](https://github.com/seleniumbase/SeleniumBase/tree/master/examples)).

```bash
pytest test_swag_labs.py --demo
```

Once you've created your tests, you can easily run them from GitHub Workflows. This tutorial will help you get started.

### Step 0. Create a fork of [SeleniumBase](https://github.com/seleniumbase/SeleniumBase) on GitHub to help you get started.

* **(You'll be using your own repo eventually.)**

![SeleniumBase GitHub Actions](https://camo.githubusercontent.com/d5136664c2619721eaa3ec148348ad6f1e1fa9b7823017924850d696e1fc5257/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f696d672f6768612f6769746875625f776f726b666c6f77735f322e706e67 "Create a fork of SeleniumBase")

----------

### Step 1. From the GitHub Actions tab, choose to set up a Python package Workflow.

![SeleniumBase GitHub Actions](https://camo.githubusercontent.com/5174b82cb0c5e76b55b717ea777ecea289357ef94afa40d075262da08d5784b1/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f696d672f6768612f6769746875625f776f726b666c6f77735f312e706e67 "GitHub Actions/Workflows")

----------

### Step 2. Add your workflow ``.yml`` script.

* **(If using a SeleniumBase fork, the script from https://github.com/seleniumbase/SeleniumBase/blob/master/.github/workflows/python-package.yml already exists to help guide you.)**

![SeleniumBase GitHub Actions](https://camo.githubusercontent.com/eee93db7a44e7fcaf36524152f2e7f79129662310084967e14f11a3f9ffa43e8/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f696d672f6768612f6769746875625f776f726b666c6f77735f392e706e67 "GitHub Actions/Workflows")

### Step 3. Commit your changes to GitHub.

![SeleniumBase GitHub Actions](https://camo.githubusercontent.com/d04fbee0b5d449b678fcd5e0bab936f51bee563ca797d82c0d7a15feb0eb10f4/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f696d672f6768612f6769746875625f776f726b666c6f77735f342e706e67 "GitHub Actions/Workflows")

----------

### Step 4. Your tests will now run on every pull request and on every commit to the ``master`` branch.

* **(See https://github.com/seleniumbase/SeleniumBase/actions for the SeleniumBase example.)**

![SeleniumBase GitHub Actions](https://camo.githubusercontent.com/9e0e793ea088c05a7e001bf789c7e5078d15e3d3af53e50df072250520024b88/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f696d672f6768612f6769746875625f776f726b666c6f77735f352e706e67 "GitHub Actions/Workflows")

* **(You can click inside each build for more details.)**

![SeleniumBase GitHub Actions](https://camo.githubusercontent.com/1d57d341ca7eefff452189094c65d57380ade9871613f91621660830f75eb2ba/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f696d672f6768612f6769746875625f776f726b666c6f77735f362e706e67 "GitHub Actions/Workflows")

* **(You can also see the specific steps being performed by each command.)**

![SeleniumBase GitHub Actions](https://camo.githubusercontent.com/b8a228f0e7cfaab905bebb63a376ad853e382f586bd25dc232891cfecf75e139/68747470733a2f2f73656c656e69756d626173652e696f2f63646e2f696d672f6768612f6769746875625f776f726b666c6f77735f372e706e67 "GitHub Actions/Workflows")

* **(You'll notice that web browsers such as Chrome and Firefox get installed for tests to use. SeleniumBase uses pytest for running tests while using Selenium WebDriver to interact with web browsers.)**

----------

### Step 5. Congratulations! You now know how to create and run browser tests with GitHub Workflows!

----------

### **Study [SeleniumBase](https://github.com/seleniumbase/SeleniumBase) to learn more!**