Handle Ajax with Selenium RC
Posted: December 15th, 2009 | Author: Anuradha Uduwage | Filed under: Java Ruled, Selenium | Tags: Java, Selenium | 4 Comments »Lately I have been adding improvements to the framework that I have build using selenium rc, JUnit, Java, and Xpath. While adding more functions I wanted to add a method to handle ajax. The idea was to wait until all the ajax action complete in a page. Selenium api has a waitForCondition method. Method accept a script, and time out.
public void waitForCondition(java.lang.String script,
java.lang.String timeout)
Our application uses Prototype ajax library. so I used waitForCondition() from selenium api, and implement the following method.
public void waitForAjax() {
super.waitForCondition("selenium.browserbot.getCurrentWindow().Ajax.activeRequestCount == 0;",
SeleniumDefaultProperties.getResourceAsStream("default.pageload.timeout"));
}
I have added
.properties file to handle all the server settings and timings related to our test automation framework. In above method timing is invoked from that properties file.


yeah , that made so much sense! why didnt i see that!
Sometime you don’t see what is close to…
Great! Thanks!
Thanks for reading the blog and I am glad this post helped you…