Automation Learn

08 Debugging

It is 9:00 AM. You open your laptop, coffee in hand. You check the nightly Jenkins build.

Status: FAILED.

Your heart sinks slightly. This is the moment where many testers panic. They stare at the red screen and think, “I broke it.” But you are not just a tester anymore; you are a Code Archaeologist.

Maintenance is the “dark matter” of automation. Writing the test takes 1 hour; maintaining it over a year takes 10. If you cannot debug quickly, your automation suite becomes a burden, not an asset.

In this module, we are going to learn how to fix things fast. We are going to stop guessing and start diagnosing. We will turn that red “FAILED” status into a green “PASSED” before your coffee gets cold.


8.1 Root Cause Analysis: The Triage Tent

When a test fails, it is a cry for help. But who is screaming? Is the application broken? Is your test code wrong? Or is the server just having a bad day?

Distinguishing between these three is the most critical skill in automation.

8.1.1 The “Blame Game”: App vs. Auto vs. Env

Imagine you are a doctor. A patient walks in with a headache.

  1. Application Bug (The Disease): The patient actually has the flu. The software is broken. The button doesn’t click. The calculation is wrong. Action: Log a bug for the developer.
  2. Automation Bug (The Faulty Thermometer): The patient is fine, but your thermometer is broken and says they have a fever of 105°F. Your logic is flawed. You used the wrong selector. You expected “User” but the app says “user” (lowercase). Action: Fix your code.
  3. Environment Issue (The Hospital is on Fire): The patient is fine, the thermometer is fine, but the lights just went out in the hospital. The database is down. The network is slow. The API is returning 503 errors. Action: Ping the DevOps team.

How to tell the difference?

8.1.2 Analyzing Stack Traces Efficiently (Reading the DNA)

We touched on this in Reporting, but now we go deeper. The Stack Trace is the crime scene map.


8.2 Debugging Tools: The Surgical Instruments

Stop using System.out.println("Here 1");. Stop it. You are better than that. Using print statements to debug is like trying to find a needle in a haystack by burning down the haystack. We have laser-precision tools for this.

8.2.1 IDE Breakpoints and “Evaluate Expression” (Freezing Time)

This is your superpower.

8.2.2 Browser DevTools: Under the Hood

Sometimes the IDE can’t see the problem because it’s happening in the browser’s brain, not Java’s.


8.3 Handling Flakiness: The Ghost in the Machine

A “Flaky Test” is a test that passes sometimes and fails sometimes, without any code changes. It is the enemy of trust. If your tests are flaky, developers will stop listening to you. They will say, “Oh, just run it again, it’s probably nothing.” We must kill flakiness.

8.3.1 Strategies for Retrying (The Band-Aid)

Sometimes, the internet hiccups. A packet gets lost. It happens.

8.3.2 Stabilizing Environment Timing (The Cure)

90% of flakiness comes from Timing.

Summary: From Panic to Precision

By the end of this module, you will stop fearing the red “FAILED” text. You will see it as a puzzle.

  1. You will use Root Cause Analysis to triage the problem instantly.
  2. You will use Debuggers to perform surgery on running code.
  3. You will eliminate Flakiness by synchronizing your robot with the speed of the application.

A broken test is not a failure of the tester. It is an opportunity to fix a hole in the net. Go fix it.

← Back to Modules