“Wait… this was working yesterday!”
That’s exactly what I said when a perfectly working feature suddenly broke after a small code change on our test automation dashboard.
We were prepping for a sprint release, and I had just updated a locator in the login page module. Nothing major. But a teammate’s bug fix in the user profile area unexpectedly broke the checkout flow. That’s when I knew — it was time to run regression testing.
If you’ve ever been in a situation where a tiny update causes a ripple effect across your application, you know how important regression testing is.
So, in this article, I’m going to walk you through how I used Selenium WebDriver to perform regression testing, step by step — with examples, code, and a human explanation (no jargon overload, I promise).
What is Regression Testing?
Let’s break it down real quick.
Regression testing is the process of re-running existing test cases after changes are made to the code. The goal is simple: make sure the new code didn’t mess up the old stuff.
In my case, we had:
- A new login update.
- A bug fix in user profiles,
- And a checkout flow that suddenly failed.
Without regression testing, these issues would’ve made it to production. Not good.
Why Selenium?
We already had Selenium WebDriver set up as our main test automation tool. It’s reliable, flexible, and integrates well with tools like TestNG and Maven — perfect for running regression tests quickly.
Whether you’re using Java, Python, or any other language with Selenium, the concept stays the same.
Step-by-Step: How I Did Regression Testing with Selenium WebDriver
Let’s walk through the exact steps I followed.
Step 1: Setup the Environment
Since I work in Java, here’s what I used:
- Java 11
- Maven for dependency management
- TestNG as the test framework
- ChromeDriver for browser automation
- IntelliJ as the IDE
My Maven pom.xml
had this for Selenium:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.18.0</version>
</dependency>
Step 2: Created a Base Class for Reuse
This base class handled setup and teardown.
public class BaseTest {
WebDriver driver;
@BeforeClass
public void launchBrowser() {
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
driver = new ChromeDriver();
driver.get("https://yourwebsite.com");
driver.manage().window().maximize();
}
@AfterClass
public void closeBrowser() {
driver.quit();
}
}
Step 3: Identified Regression Test Cases
From experience, I knew which areas were likely to break:
- Login flow
- Checkout process
- Profile update
So I wrote test classes like this one for login:
public class LoginTest extends BaseTest {
@Test
public void verifyUserCanLogin() {
driver.findElement(By.id("username")).sendKeys("demoUser");
driver.findElement(By.id("password")).sendKeys("demoPass");
driver.findElement(By.id("loginBtn")).click();
String welcomeMsg = driver.findElement(By.id("welcomeText")).getText();
Assert.assertEquals(welcomeMsg, "Welcome, demoUser!");
}
}
Step 4: Grouped the Tests as a Regression Suite
I created a testng.xml
file to run everything together:
<suite name="Regression Suite">
<test name="RegressionTests">
<classes>
<class name="LoginTest"/>
<class name="CheckoutTest"/>
<class name="ProfileUpdateTest"/>
</classes>
</test>
</suite>
Running this suite gave me quick feedback on what was still working and what wasn’t.
Step 5: Integrated with Jenkins for CI
After validating locally, I pushed the test suite to our Jenkins pipeline. This way, every code push triggered the full regression test run.
If anything failed, the team was alerted immediately. No more surprises before release.
Best Practices for Regression Testing with Selenium
- Always keep your critical flows in your regression suite
- Use Page Object Model to keep code clean
- Don’t try to automate everything — just what’s stable and repetitive
- Integrate with CI/CD early — saves time, saves releases
- Add clear logs and screenshots for easier debugging
Final Thoughts on Using Selenium for Regression Testing
If you’re working on any live project — even a small one — regression testing is your safety net. And using Selenium WebDriver makes the job easier, faster, and more reliable.
This real-world experience taught me to never assume small code changes are harmless. Automating regression with Selenium gives you peace of mind — and your clients will thank you for the stability.
Want to Learn More?
If you’re looking to sharpen your skills in Selenium with Java, explore our full training program at:
👉 QA Online Training – Selenium with Java
👉 QA Online Training – Selenium with Python
👉 Free Selenium Tutorial with Java
👉 Free Selenium Tutorial with Python
Hands-on. Real-world projects. And guidance from industry pros.