cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: AJAX and web testing
Date Wed, 05 Apr 2006 16:25:52 GMT
Simone Gianni wrote:
> 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 (
> http://www-128.ibm.com/developerworks/java/library/wa-selenium-ajax/index.html
> ) 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.

You can do it using Dojo's nice AOP features to intercept the method
that handles the browser update sent by Cocoon:

  <script>
      dojo.addOnLoad(function() {
          dojo.require("cocoon.ajax.BUHandler");
          dojo.event.connect(cocoon.ajax.BUHandler.prototype,
"processResponse", function() {
              alert("Page has been updated!")
          })
      });
  </script>


Sylvain

-- 
Sylvain Wallez
http://bluxte.net
Apache Software Foundation Member


Mime
View raw message