Suppose I initiate a transition from one page to another (A -> B). I
then select element X and test it. Suppose element X exists on both A
and B.
Intermittently, X is selected from A before the page transition
happens and not tested until after going to B, raising a
StaleElementReferenceException. It's easy to check for this condition:
try:
visit_B()
element = driver.find_element_by_id('X') # Whoops, we're still on A
element.click()
except StaleElementReferenceException:
element = driver.find_element_by_id('X') # Now we're on B
element.click()
But I'd rather
element = driver.find_element_by_id('X') # Get the elment on A
visit_B()
WebDriverWait(element, 2).until(lamba element: is_stale(element)
element = driver.find_element_by_id('X') # Get element on B
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.