HOWTO: Add global ajax event handlers with jQuery

Май 30, 2011

Task: add global state for selenium tests to wait for when ui is very ajax based.


//javascript

var _Busy = false;

function setBusy(flag) {
    _Busy = flag;
}

function isBusy() {
    return _Busy;
}

$(document).ajaxStart(function () {
    setBusy(true);
});

$(document).ajaxStop(function () {
    setBusy(false);
});

//C# - selenium wrapper

public void WaitForUiReady()
{
    _selenium.WaitForCondition("selenium.browserbot.getUserWindow().isBusy() == false", PageLoadTimeOut);
}

posted in FYI by dmitko

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org