3

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 Jun 28 '11 at 18:41
  • Hey @Tarun I still need the answer of the first point...:) Thanks a lot again – smriti Jun 29 '11 at 9:41
3

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.waitForCondition(
        "selenium.browserbot.getCurrentWindow().jQuery.active == 0",
        timeout);

Cheers!

  • Only works if you are using jQuery, won't work for all AJAX sites. – Ardesco Jun 30 '11 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 Jun 30 '11 at 12:33
  • 1
    True. But you can easily attune it to something else. :) Glad it helped smriti! :) – Hannibal Jun 30 '11 at 12:33
1

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, privacy policy and cookie policy

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