I have a web application to test with Selenium. There is a lot of JavaScript running on page load.
This JavaScript code is not so well written but I can't change anything.
So waiting for an element to appear in the DOM with findElement()
method is not an option.
I want to create a generic function in Java to wait for a page to load, a possible solution would be:
document.body.innerHTML
in a string variable body
.body
variable to the previous version of body
. if they are the same then set increment a counter notChangedCount
otherwise set notChangedCount
to zero.notChangedCount >= 10
then exit the loop otherwise loop to the first step.Do you think it's a valid solution?