loading...
SeleniumBase

Running browser tests from GitHub Workflows with SeleniumBase

mintzworld profile image Michael Mintz ・2 min read

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

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


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


Step 2. Add your workflow .yml script.

Step 3. Commit your changes to GitHub.


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

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

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

  • (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!

Discussion

pic
Editor guide
Collapse
johnhiggs profile image
John Ahigian

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.