Quick start on Selenium tests with Django and GitHub Actions deployment

Bevan Steele
Rock and Null
Published in
2 min readFeb 11, 2023
Photo by Minku Kang / Unsplash

Writing a combination of unit and integration/UI tests is ideal for any kind of project that contains both user-facing components and business logic.

Django has excellent support for both of these kinds of tests. Unit tests are more straightforward to write and deploy in a CI/CD pipeline. The challenge in most languages and platforms comes when you need to write Integration/UI tests. Most of the time these integration tests are slow to write, slow to execute, and many times unreliable and flaky when you run them in a CI/CD system. In Django, these tests are supported via the popular Selenium framework used for testing all kinds of web applications.

Django gives you a great headstart when writing integration tests by coupling together a local running server with your app and a local DB and Selenium WebDriver. In this post, I will quickly guide you through a simple Django test using Selenium and how to deploy it to GitHub Actions for running it every time there's a new PR or commit.

The test part

Selenium WebDriver offers a great API for interacting with a browser and "driving" it to perform clicks and interactions to test your web app.

You can write most of these tests manually, but if you are new to the space I would strongly recommend giving Selenium IDE a try. This is a browser extension to quickly start with Selenium WebDriver tests without writing a single line of code. As your tests and app become complex over time, you would most probably need to write code, but still, the tests created by Selenium IDE can be a great starting point (you export those tests and modify the code).

Continue reading this post in our official blog…

--

--