Selenium fluentWait is resulting in a StaleElementReferenceException


I have a scenario as outlined in the screenshot below:

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.

Train Asked on December 18, 2014 in Selenium WebDriver.
Add Comment
  • 2 Answer(s)
    Best answer

    StaleElementReferenceException usually occurs if the reference is lost.

    So as i understand when you click on the bar on left, the page might gets refreshed and hence the reference too.

    May be you can try to relocate the element using the same selector before click event (

    Supporter Answered on December 18, 2014.

    Thanks Rajesh for helping Us

    on December 19, 2014.
    Add Comment

    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.