DEV Community

Michael Mintz for SeleniumBase

Posted on • Updated on

Running browser tests from GitHub Actions with SeleniumBase

The SeleniumBase Python-WebDriver framework allows you easily automate Web UI tests quickly and reliably. Here's an example of this test 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:



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).

pytest test_swag_labs.py --demo
Enter fullscreen mode Exit fullscreen mode

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 on GitHub to help you get started.

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

SeleniumBase GitHub Actions


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

SeleniumBase GitHub Actions


Step 2. Add your workflow .yml script.

SeleniumBase GitHub Actions

Step 3. Commit your changes to GitHub.

SeleniumBase GitHub Actions


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

SeleniumBase GitHub Actions

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

SeleniumBase GitHub Actions

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

SeleniumBase GitHub Actions

  • (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 to learn more!

Top comments (1)

Collapse
 
johnhiggs profile image
John Ahigian • Edited

awesome article one of the best i've encountered so far for getting webdriver up and running in github actions with newer js related setup. So many other github action add ons that don't even really work without setting up env and configurations for webdriver to work.