Any suggestions how to get around stale elements exceptions when it seems one shouldn't be raised? Fair enough with any of the many javascript libraries in use any updates may remove the respective DOM nodes and later FindElement from the disconnected node you can get a stale element.
The problem it seems, the tests in question i'm testing i know once displayed the content is static. Also the same code is working 100% with Firefox, but both the Chrome and Edge's WebDrivers (if not the same really close?) are giving unexpected "Stale Element Exceptions".
My code gets a node which is a parent for a given subtree holding information desired. For the parent node "Driver.FindElement()" is used but subsequent XPath queries are relative to the "parent" node.
For example given this DOM tree:
<node id='Closest node By ID'>
<span>
<div>text i want</div>
<div>ignore this</div>
<div>text to get</div>
</span>
<span>
<!-- same pattern ... -->
</span>
</node>
var parentNode = WebDriver.FindElement(ByID("ID"));
var txt1 = parentNode.FindElement(By.XPath("./span/div[1]");
var txt2 = parentNode.FindElement(By.XPath("./span/div[3]");
The problem is at some point performing the XPath quires will result in a 'stale element exception'.
I have working repro i'd be glad to share if someone could help look into this, getting into the WebDriver itself may be beyond me... Ping me will gladly provide a complete repro in C# details and whatever else may be needed.
Ah, and for vitals: Chrome && WebDriver are both matched up.
Google Chrome is up to date, actually checking was 92, updated to 93 re-ran and same behavior. Version 93.0.4577.63 (Official Build) (64-bit)
C# .Net framework 4.8 Win 10 "Version 21H1 (OS Build 19043.1202)"
Thanks in advance.