We're using Selenium for smoke-testing a Java Spring MVC based website. We invoke it using JUnit and the Java Selenium client. Much of the time, our tests work fine, but we tend to get timeouts in selenium.waitForPageToLoad in apparently random places. (That is, run the test suite multiple times and the location and number of timeouts will vary greatly.)
Running it with the server in the foreground, I can watch the tests executing. When one of these timeouts occurs, the selenium.click that preceded the wait has occurred but the wait doesn't appear to notice. Right-clicking on the page and selecting Refresh appears to clear the blockage.
To me, this suggests there's a race condition occurring between the click and waitForPageToLoad. Others have related problems with waitForPageToLoad but don't appear to describe a race condition. Some have suggested problems with the preceding selenium.click call, but I'm not seeing that here. Has anyone else seen what I've observed?
I've seen a number of suggestions to not use waitForPageToLoad, but the work-arounds often suggest using waitForElementPresent or manually polling for element presence. With our application that would seem to require instrumenting the HTML with IDs that would only be used by the tests. Is there a non-intrusive work-around to this method?