I am testing some AngularJS code using Selenium. Angular updates the DOM in unpredictable order, sometimes completely async (via setTimeout
), so it is difficult to know when the DOM has been completely updated after an AJAX request (or if the AJAX request has finished or not). (Because of this, all solutions that purely hooks the AJAX requests but not Angular itself are unstable.)
I was fully prepared to find all the places in Angular I need to hook to detect the end of a rendering cycle and inject loads of JS to hook them, then it was suggested to me that I could add sleeps until the result is stable.
Personally, I really hate sleeping in tests. It feels hacky as hell and unnecessarily slows down the already slow Selenium tests. But in this case, sleeping is much simpler and more maintainable.
What are your opinions on this?