
The alternative offered with the driver is to tell the selenium server to pause until a javascript expression evaluates to true, which there is a function for already. The question is how to do this with jQuery, which wasn’t very easily answered at first since the majority of knowledge regarding this problem seems to deal with pages using prototype. As for jQuery, the solution seems to be to use the following piece of javascript:
jQuery.active
…which will report 0 when no ajax requests are active. Calling it the context of your test might look like this:
$selenium.wait_for_condition('selenium.browserbot.getCurrentWindow().jQuery.active == 0', $max_selenium_timeout)
This ended up being a much simpler solution that I had assumed it would be >.>
2 Comments
Thank you!
I used this for waitForCondition with ASP.NET
Javascript:
function isInAsyncPostBack() {
instance = Sys.WebForms.PageRequestManager.getInstance();
return instance.get_isInAsyncPostBack();
}
C#
selenium.WaitForCondition(“!selenium.browserbot.getCurrentWindow().isInAsyncPostBack()”, “1000″);
It wasn’t working for me, jQuery or any other custom properties were not found, with the help of #selenium and this post http://crschmidt.net/blog/348/selenium-ide-getcurrentwindow-problems/ it fixed the problem.