Sane AJAX Testing in Selenium

Selenium is great for Web 1.0 applications, which involve a page load after each significant user action. Selenium knows to block until the page is done loading, and so the page load provides an implicit “wait until crap is done” barrier to keep your test from getting ahead of the browser.

But that goes away in AJAX applications–no page load. There are a variety of ways to compensate, most of which are what I call pre-assertion waiting–before asserting “did X happen” poll for a little bit to ensure “X” is there. E.g.: