Automating Regression Testing with Selenium and Python in Visual Studio Code
Introduction
Regression testing is an essential part of any software development cycle.As your project grows time consuming and error-prone. That’s where automation comes in. In this blog, We will walk you through how we automated my web application’s regression testing using Selenium with Python, all inside Visual Studio Code.
We will also cover how we used Selenium IDE for quick script generation and how we tackled some tricky issues caused by modern UI frameworks like Material UI (MUI).
Why I Chose Selenium with Python for Automation Testing
When it comes to automation testing, there are plenty of frameworks and tools out there — Playwright, Cypress, Puppeteer, TestCafe, and of course, Selenium. After researching and testing a few of them, We decided to go with Selenium + Python for several compelling reasons. Let us walk you through why this combination was the most practical, efficient, and scalable choice for our regression testing needs.
- Python is beginner-friendly, readable, and fast to code.
- Selenium supports all major browsers and is well-documented.
- It integrates smoothly with Visual Studio Code (VS Code), my preferred IDE.
- Perfect for automating functional and regression tests on web apps.
Step 1: Installing Python
First things first, you need to have Python installed on your system. Python is the backbone of our testing scripts.
- Visit python.org and download the latest version of Python.
- Follow the installation prompts, ensuring that you check the box “Add Python to PATH” before clicking “Install Now.”

Step 2: Installing Selenium
Next, we need to install the Selenium package for Python. Selenium is the library that allows us to control web browsers through Python scripts.
- 1Open your command prompt or terminal.
- 2Run the following command to install Selenium:

This will install the Selenium package along with all its dependencies.
Writing the Automation Script
Step 3: Setting Up Visual Studio Code
We prefer using Visual Studio Code (VS Code) as our Integrated Development Environment (IDE). It provides great support for Python and makes automation scripts easy to write and debug.
- 1Download VS Code from here.
- 2Install the Python extension in VS Code to get syntax highlighting, auto-completion, and debugging support for Python.

Step 4: Writing the First Automation Script
Now that we have our environment set up, let’s write the first automation script. The objective here is to open a browser, navigate to the login page, and perform actions like entering credentials and clicking buttons.
We’ll also guide you on how to save and run the file.
Steps to Follow:
- 1Open Visual Studio Code.
- 2Create a new file named
test_login.py (You can name it anything, but this name is simple and descriptive.)
Here’s an example script:

In this script:
- We first initialize the WebDriver.
- Open the web page https://test.project.com/login/.
- Locate the username and password fields by their IDs, enter credentials, and submit the form.
- Finally, we close the browser after 10 seconds.
Step 5: Automating with Selenium IDE in Firefox
While the above script was written manually, We also used Selenium IDE for quick script generation.
- 1Selenium IDE is a browser extension that records your actions in the browser and generates scripts in various languages (including Python).
- 2Unfortunately, Selenium IDE only works in Firefox (Chrome no longer supports it), so I installed the extension in Firefox.

To use Selenium IDE:
- Install the Selenium IDE extension in Firefox from the Firefox Add-ons store.

- Record your interactions on the web page (e.g., logging in, navigating, filling out forms).

- Export the recorded script in Python format.

Once exported, We refined the script in VS Code, cleaning up unnecessary code and adding assertions to validate expected results.
Challenges Faced During Automation
1. UI Issues Due to Material UI (MUI)
One of the challenges we encountered while automating tests was dealing with dynamic selectors generated by Material UI (MUI). MUI, being a popular component library, generates dynamic class names and IDs, which makes it difficult to select elements consistently.
For example:

These dynamic classes made it hard to reliably select elements using traditional ID or class locators.
💡Solution: To overcome this, We switched to using XPath selectors. XPath is flexible enough to target elements based on their attributes, text, and position in the DOM.
For example:

By using XPath, We could locate elements more reliably even when their class names changed.
Conclusion
By using Selenium with Python, We were able to automate the regression testing of the web application effectively. The combination of Visual Studio Code, Selenium IDE, and Python provided us with a powerful, flexible, and efficient environment to automate web tests.
While there were some challenges, particularly with dynamic selectors and Material UI (MUI), these were solved using XPath, and the rest of the testing process went smoothly.
If you are considering using Selenium + Python for your test automation, We highly recommend it. It’s beginner-friendly, well-documented, and powerful enough to handle complex web applications.
Why Building the Right MVP Architecture No Longer Slows You Down
Just build a simple monolith for your MVP. You can fix the architecture later...
Read MoreAI-Assisted MVP Development (Vibe Coding)
Building a startup MVP used to be slow, expensive, and stressful especially if you weren’t technical....
Read MoreFrom SEO to AEO & GEO: Why QA Teams Will Own Search Visibility in the AI Era
Search is no longer just a list of links. It’s becoming a decision layer, A place where users expect an immediate, synthesized answer, a recommendation, or a next action...
Read MoreCommon Amazon EventBridge Pitfalls in Production (and How to Avoid Them)
Amazon EventBridge simplifies the implementation of event-driven architectures. Publish an event, configure a rule, attach a target-and the system appears to work seamlessly...
Read MoreBuilding Production-Ready RAG Microservices: A Complete Serverless Architecture Guide
Large Language Models like GPT-4 and Claude have a critical flaw for businesses: they don't know your proprietary data. They can't answer questions about your products...
Read MoreWhat is a Data Lake, Data Warehouse, and Data Lakehouse? - A Simple Beginner’s Guide
Data has become one of the most valuable assets for modern businesses. Every click, transaction, message, and app interaction generates information that companies want to store, analyze, and learn from....
Read MoreImplementing a Scalable AWS Landing Zone: A Practical Guide for DevOps Teams
An AWS Landing Zone is a well-architected, multi-account AWS environment designed to support scalability, security, compliance, and operational excellence from day one....
Read MoreUsing EventBridge for Async Communication in a Serverless Microservice Architecture
Microservices often begin with simple, synchronous communication: Service A calls Service B’s API and waits for a response...
Read MorePros and cons of using DynamoDB
Amazon DynamoDB has become one of the most popular NoSQL databases in the cloud, offering a fully managed, serverless experience....
Read More