🚨 Common Java QA Errors
Common Java QA Errors: Java's stack trace is like a "crime-scene timeline" that shows where the error was born at the top and, line by line below, how you got there — like a doct
Java's stack trace is like a "crime-scene timeline" that shows where the error was born at the top and, line by line below, how you got there — like a doctor diagnosing an infection from the fever+cough+fatigue signature: whether it is a `NullPointerException` or a `ClassCastException`, the signature tells you the root cause. But if the error already says "something blew up," why read the stack trace line by line? Because most bugs hide not in the line the message points to but in a caller one level up that sent it bad data; without recognizing the signature you fix the wrong place. Python's traceback works similarly but shows the last call at the bottom; Java shows it at the top, and knowing this directional difference speeds up your reading. For a QA engineer this skill is critical: if you can read the correct signature in the log of a red CI test, you find the true root cause in minutes instead of fighting the wrong locator for hours, and you can tell whether it is flaky or a real bug.
1. NoSuchElementException
Micro Lab: Code practice
Replace the TODO line with the critical line from the expected solution. This is not a real runtime; the goal is to reinforce writing the correct structure in a controlled way.
Why Does WebDriverWait Wait for elementToBeClickable Instead of Just findElement()?
A raw `driver.findElement(By.id("loginBtn"))` throws `NoSuchElementException` immediately if the page has NOT finished loading yet.
new WebDriverWait(driver…
`new WebDriverWait(driver, Duration.ofSeconds(10))` sets up a "wait AT MOST 10 seconds" CONTRACT — it doesn't give up instantly, but it doesn't wait forever either.
`ExpectedConditions.elementToBeClickable(...)` checks not just that the element is in the DOM, but that it is VISIBLE and CLICKABLE — plain `findElement` guarantees none of this.
Once the condition is met…
Once the condition is met, `.click()` is CHAINED immediately — the moment the element is ready, the click happens without extra waiting code.
2. StaleElementReferenceException
Solution — Retry pattern
Why Does an Element Go "Stale" and How Does Retry Fix It?