logo logo

Web UI Testing Made Easy with Python, Pytest and Selenium WebDriver

main post image

Have you ever discovered a bug in a web app? Yuck! Almost everyone has. Bugs look bad, interrupt the user’s experience, and cheapen the web app’s value. Severe bugs can incur serious business costs and tarnish the provider’s reputation. So, how can we prevent these bugs from reaching users? The best way to catch bugs is to test the web app. However, web UI testing can be difficult: it requires more effort than unit testing, and it has a bad rap for being flaky.

Never fear! This tutorial will make web UI testing easy. We will build a simple yet robust web UI test solution using Python, pytest, and Selenium WebDriver. We will learn strategies for good test design as well as patterns for good automation code. By the end of the tutorial, you’ll be a web test automation champ! Your Python test project can be the foundation for your own test cases, too.

Tutorial Chapters

  1. Set Your Test Automation Goals (Chapter 1)
  2. Create A Python Test Automation Project Using Pytest (Chapter 2)
  3. Installing Selenium WebDriver Using Python and Chrome (Chapter 3)
  4. Write Your First Web Test Using Selenium WebDriver, Python and Chrome (Chapter 4)
  5. Develop Page Object Selenium Tests Using Python (Chapter 5)
  6. How to Read Config Files in Python Selenium Tests (Chapter 6)
  7. Take Your Python Test Automation To The Next Level (Chapter 7)

Example Project

As part of this tutorial, we will create an example test project with a few basic tests for the DuckDuckGo search engine. All instructions and code will be provided in the chapters. I strongly recommend creating and building this example project on your own machine as you progress through the tutorial.

The example project requires basic Python programming skills. Make sure your machine has an up-to-date version of Python 3 installed (not Python 2). You can download the latest version from Python.org. The example code will be written in Python 3.7.3. Command line examples will use UNIX (but they will be similar for other operating systems). I also recommend a good Python IDE like PyCharm or Visual Studio Code.

The completed example project code is hosted in GitHub at https://github.com/testproject-io/python-webui-testing. Each chapter has a branch corresponding to the new example code covered by the chapter. The master branch holds the final version. If you get stuck, compare your code to the GitHub project’s code.

Start here!
Happy Learning 🎓 



About the author


Andy Knight is the “Automation Panda” – an engineer, consultant, and international speaker who loves all things software. He specializes in building robust test automation systems from the ground up. Read his tech blog at AutomationPanda.com, and follow him on Twitter at @AutomationPanda.

Join TestProject Community

Get full access to the world's first cloud-based, open source friendly testing community. Enjoy TestProject's end-to-end test automation Platform, Forum, Blog and Docs - All for FREE.

Join Us Now  


13 2 comments
  • Августовская лента: лучшее за месяц — Блоги экспертов September 2, 2019, 5:20 pm

    […] • Webdriver + Python + Pytest: подробное руководство для разработки автотестов. […]

  • Testing Internship Update,  Learning Python , Courses, 100 Days of Testing  Challenge – Clickworks January 20, 2020, 10:02 am

    […] Web ui testing with python  […]

Leave a Reply

popup image

Selenium for Teams

Sharing and distributing Selenium tests has never been so easy! With TestProject's FREE Selenium based platform, you can finally create awesome tests with the freedom to collaborate with your team effortlessly.
Sign Up Now right arrow