How to test AJAX websites using Selenium
This article will show you how to test AJAX web applications using Selenium. If you have used Selenium before, you are familiar with the wait_for_page_to_load (waitForPageToLoad) call which waits until a page finishes loading before continuing. If you have tried using this for an AJAX-enabled website, you will notice that your Selenium scripts just whizzes by that call. A quick and easy way to fix this is by using the wait_for_condition (waitForCondition) call that will wait until all pending AJAX requests have completed before continuing with the rest of the test script. Simple add this call immediately after your action that spawns an AJAX request:
selenium.wait_for_condition "selenium.browserbot.getCurrentWindow().Ajax.activeRequestCount == 0", 60000
For example:
selenium.load "http://heatware.net/"
selenium.click "link_that_makes_ajax_call"
selenium.wait_for_condition "selenium.browserbot.getCurrentWindow().Ajax.activeRequestCount == 0", 60000