Handle Ajax with Selenium RC

Posted: December 15th, 2009 | Author: Anuradha Uduwage | Filed under: Java Ruled, Selenium | Tags: , | 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.


4 Comments on “Handle Ajax with Selenium RC”

  1. 1 Nivashini said at 9:17 pm on March 16th, 2010:

    yeah , that made so much sense! why didnt i see that!

  2. 2 Anuradha Uduwage said at 9:50 pm on March 17th, 2010:

    Sometime you don’t see what is close to…

  3. 3 Ekaterina said at 2:03 am on April 15th, 2010:

    Great! Thanks!

  4. 4 Anuradha Uduwage said at 10:21 pm on May 5th, 2010:

    Thanks for reading the blog and I am glad this post helped you…


Leave a Reply

  • or, connect with
Get Adobe Flash playerPlugin by wpburn.com wordpress themes