Chapter 3: Handling Waits and Synchronization
By Shivam Singh, founder of TesterRank · Updated September 2026
This is the #1 interview question on waits. When both implicit wait (e.g. 10s) and explicit wait (e.g. 15s) are active, explicit wait calls findElement() during each poll. If the element is not found, implicit wait forces a 10-second pause before returning to explicit wait! A 15-second wait can freeze for over 200 seconds.
Presence only means the HTML tag exists in the DOM tree. It could have opacity: 0, display: none, or be disabled. If you call .click() after presence check, you get ElementNotInteractableException. Always use elementToBeClickable for click targets.
Never write new WebDriverWait(driver, Duration.ofSeconds(10)) scattered across 50 classes. Centralize timeouts in a TimeoutConfig class so timeout policies can be tuned across the entire test suite in one place.
Never "fix" a flaky test by adding Thread.sleep. It hides the problem on your machine and fails again on a slower CI server. A real fix waits for a real condition, so it is both faster when the app is fast and safe when the app is slow.
Do not wrap every action in try/catch and retry blindly. It makes tests pass while real bugs, like a button that truly never appears, go unnoticed.
Setting every wait to 60 seconds feels safe, but it makes failures painfully slow. When something is really broken, each step waits a full minute before failing, and a suite of 200 tests can take hours to report a simple bug. Pick a normal timeout (10–15 seconds) for most steps, and use a longer one only for steps you know are slow, such as file uploads or report generation.
Key Point: Never mix implicit and explicit waits, always use elementToBeClickable before clicks, and centralize timeout constants.