Sometimes when I execute code like this:
webDriver.findElement(By.xpath("//*[@class='classname']")).click();
I get this exception: org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM I know I could do a retry, but does anyone know why this happens and how I can prevent it?