Selenium is a great tool for testing web application. It tests the client side by launching a web browser and executing functional tests. Developing a test is very easy; we need just to record the test one time by Selenium IDE (Firefox plug-in). The recorded test can be exported to a JUnit test.
But sometimes testing screens with Ajax components need some caution to wait for asynchronous communication and for DHTML to be changed.
The source code below can help testing a JQuery Autocomplete field using Selenium.
selenium.typeKeys("??locator??", "a"); int second = 0; while(!selenium.isElementPresent("//li[?num?]")) { if(second >= 10) break; Thread.sleep(1000); second++; }