While utilizing Backbone.js, our team has encountered difficulties during the execution of WebDriver tests. Specifically, we are facing the following error:
org.openqa.selenium.StaleElementReferenceException: Error Message => 'Element does not exist in cache'
Our current understanding suggests that this issue arises when attempting to locate an element and performing an action on it (such as click()
). The identified element becomes 'stale', indicating a potential re-render or modification.
Various solutions have been proposed, but we are hesitant to implement them due to concerns:
- The use of
Thread.Sleep(...)
, which introduces explicit sleeps into the code, is not preferred - Adopting a retry strategy, involving loops or try-catch blocks for the
StaleElementReferenceException
, is seen as a less optimal solution with potential fragility - Some individuals utilize
WebDriverWait
by waiting for a JavaScript function's return value to be true. While examples like
in Angular exist, a corresponding method for Backbone is not readily apparent.notifyWhenNoOutstandingRequests(callback)
We are seeking a clean resolution that avoids direct sleeping or repetitive looping. Do you have any suggestions?