how to fix stale element reference exception in selenium webdriver code example

Example: stale element exception

There are two reasons for Stale element reference:
The element has been deleted entirely.
The element is no longer attached to the DOM.

We face this stale element reference exception when the element we are 
interacting is destroyed and then recreated again. When this happens 
the reference of the element in the DOM becomes stale. So, we are not able to
get the reference to the element.

Tags:

Misc Example