cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Gianni <>
Subject AJAX and web testing
Date Wed, 05 Apr 2006 10:49:10 GMT
Hi All,
we recently moved to ajax in our latest project. We use Selenium for web 
tests. After the move we had a lot of problems with Selenium. This is 
what happens :
- Selenium executes a SelectAndWait (or clickAndWait)
- It then waits for a page reload
- It detects a page reload using an onload on the test iframe.
- Obviously, ajax does not reload the page, so Selenium waits for ever.

The only relevant document i've found about this matter on the internet 
) uses the worse solution : pauses 500 ms after a click.

We currently modified selenium to achieve a different behaviour : the 
cocoon forms _handleBrowserUpdate and _continue are overridden at run 
time with two custom functions that triggers Selenium page reloaded 
event after a _handleBrowserUpdate unless a continue has been received.

This solution works correctly, but it's a hack. IMMO we should find a 
better solution for executing webtests on a cocoon ajax enabled site ... 
just some random thoughts :

- Support and document how to use Dojo AOP to wrap a method around 
cocoon ajax calls (I tried this one but didn't managed to make it work).
- Provide some "classic" javascript hooks inside the cocoon ajax code, 
so that implementing some jsavascript functions a web test suite can be 
notified when an ajax transaction is started and ended.
- If there is a way of doing this not touching the cocoon ajax code (i 
was thinking about instrumenting/intercepting the 
dojo.hostenv.getXmlhttpObject()) we should document it somewhere.

I've already opened a bug for this problem on Selenium Jira, and could 
probably submit a solution if we find a way to make it "dojo based" and 
not that cocoon specific as the one I used.


P.S. FYI this is the code I added to selenium-browserbot.js if anybody 
need it; it's an untidy solution, but works until we find a better one.

in selenium-browserbot.js, method BrowserBot.prototype.getCurrentPage = 
function(), added :

        if (this.frame.contentWindow.dojo) {
            var contentWindow = this.frame.contentWindow;
            var cocoonProto = 
            if (cocoonProto._oldHandleBrowserUpdate == undefined) {
                cocoonProto._oldHandleBrowserUpdate = 
                cocoonProto._oldContinue = cocoonProto._continue;
            var widget = 
            if (widget != null) {
       = this;
                widget._handleBrowserUpdate = function (request) {
           = false;
                widget._continue = function () {
           = true;

and soon after a new function :

BrowserBot.prototype._handleDojoBrowserUpdate = function() {
    if (!this.continued) this.recordPageLoad();

Simone Gianni

View raw message