stale element reference exception in selenium how to handle it code example

Example 1: 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.

Example 2: 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