SoftwareTestPilot

Debug a failing Selenium test

  • Selenium
  • intermediate
  • 6 min
  • 2 questions

Selenium failures often look random but follow a few patterns. Read the code and the error, then pick the cause and the fix.

Skills practised: Explicit waits, Exception reading, Root-cause analysis

Worked example

NoSuchElementException right after a click that loads data usually means the script looked before the element existed. An explicit wait fixes it; Thread.sleep only hides it.

Question 1

This fails with StaleElementReferenceException on the second loop. Why?

List<WebElement> rows = driver.findElements(By.css(".row"));
for (WebElement r : rows) {
  r.findElement(By.css(".delete")).click(); // table re-renders
}
This fails with StaleElementReferenceException on the second loop. Why?

Question 2

Best fix for waiting until a spinner disappears?

Best fix for waiting until a spinner disappears?
0/2 answered

Keep learning