Styrow.dev
Question 37 of 64

What is Stale Element Reference Exception?

Question

What is Stale Element Reference Exception?

Answer

This Exception occurs when driver is trying to perform action on the element which is no longer exists in DOM or not valid.

WebElement ele = driver.findElement(By.id(""sample""));

// Before clicking some thing happened and DOM has changed due to page refresh, or element is removed and re-added

ele.click();

Now at this point, the element which you’re trying to click is no longer valid then selenium throws StaleElementReferenceException