RE: Selenium fluentWait is resulting in a StaleElementReferenceException


I have a scenario as outlined in the screenshot below:

RE: Selenium fluentWait is resulting in a StaleElementReferenceException

So, I’ve built some code which will allow me to click on the bar charts on the left….each time I do it will display a relational bar chart on the right. If the bar chart is particularly big on the left it might take a while for the relational bar chart on the right to show. To counter this, I build a fluentWait method, as below:

public static void fluentWaitOnRelationalBarChartSelector(InternetExplorerDriver driver)


WebElement relationalBarSelect = (new WebDriverWait(driver, 20))



However, not always, but sometimes, I am getting an error in the console as below: “Exception in thread “main” org.openqa.selenium.StaleElementReferenceException: Element is no longer valid (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 33 milliseconds”

What I’m not sure on is why this timeout is occurring after 33 milliseconds when I have applied a wait of 20 seconds? Is there a way of me being able to cater for this StaleElementReferenceException?

Any help would be appreciated.

tilston1001 Train Asked on December 18, 2014 in Selenium WebDriver.
Add Comment
2 Answers

Thanks Rajesh, I’ll try that

Train Answered on December 18, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.