Please brief me about the Ajax testing with selenium RC. As in Ajax element does not reflect on the view-source, but using firebug we can see the changes in HTML source code.

There are two methods associated with it..

  1. The method waitForCondition (java.lang.String script, java.lang.String timeout), to provide script we have to create a java script by own or it should be the same Ajax script/java script present on the web page.

Please correct me if i am wrong on below point:

  1. The method waitForElementPresent(Locator), we check the Element in the firebug and check the same in this method is self waitForElementPresent(Locator).

Let me know if anything else I am missing testing Ajax application.

  • Well if you answered your question and have got it right too :)
    – Tarun
    Commented Jun 28, 2011 at 18:41
  • Hey @Tarun I still need the answer of the first point...:) Thanks a lot again
    – smriti
    Commented Jun 29, 2011 at 9:41

2 Answers 2


I already gave an example on a similar question which can be used to wait for Ajax and javascripts to finish.

Here it is:

        "selenium.browserbot.getCurrentWindow().jQuery.active == 0",


  • Only works if you are using jQuery, won't work for all AJAX sites.
    – Ardesco
    Commented Jun 30, 2011 at 11:08
  • Thanks a lot Hannibal and Ardesco for this great help. I got this form one article agilesoftwaretesting.com/?p=111 JQuery: “jQuery.active” Prototype: “Ajax.activeRequestCount” Dojo: “dojo.io.XMLHTTPTransport.inFlight.length” So if there is Ajax call we can use second option. Please correct me if I am missing something …. Thanks in Advance
    – smriti
    Commented Jun 30, 2011 at 12:33
  • 1
    True. But you can easily attune it to something else. :) Glad it helped smriti! :)
    – Hannibal
    Commented Jun 30, 2011 at 12:33

You could you wait for condition like this -

selenium.waitForCondition("selenium.isElementPresent(\"element locator\")", "waitPeriod")

Hence you need to write the wait condition and here in I have used one of the Selenium API it self

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.