I ran into this weird situation.
I am first at page 1, which has an element with id of "abc", I use "abc" to find webElement and get its text value
I click on a link in page 1, it takes me to page 2
In page 2, there is also an element with id of "abc", when i try to use "abc" to find element and get its text value, webdriver gives me a "stale element exception, element not attached to DOM etc"
I google to get to this page, http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp. It explains that "is that page that the element was part of has been refreshed, or the user has navigated away to another page... the driver has no way to determine that the replacements are actually what's expected"
So how to solve this kind of question? In theory, there is no way for webdriver to know that these elements are in two different pages.
It's worth to notice that if i insert a hard coded delay (a thread sleep etc) in between the page switch, the stale issue will not appear.
Thanks,